]> sigrok.org Git - sigrok-firmware-fx2lafw.git/blob - fx2lib/include/delay.h
Add Hantek PSO2020 firmware support
[sigrok-firmware-fx2lafw.git] / fx2lib / include / delay.h
1 // Copyright (C) 2009 Ubixum, Inc. 
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, see <http://www.gnu.org/licenses/>.
15
16 /*! \file 
17  *  Functions for causing delays.
18  * */
19
20
21 #ifndef DELAY_H
22 #define DELAY_H
23
24 #include "fx2types.h"
25
26 /**
27  * 0-65536 millis
28  **/
29 void delay(WORD millis);
30
31 /**
32  * See TRM 15-14,15-15
33  * some registers (r/w) require syncdelay after
34  *
35  * up to the programmer to determine which sync is needed.
36  * for standard 48mhz clock w/ 48mhz IFCONFIG 3 nops is sufficient.
37  *
38  * slower clock and faster ifclock require more delay
39  *
40  * min delay = roof ( 1.5 x (ifclock/clkout + 1) )
41  *
42  * Minimum IFCLOCK is 5mhz but you have to use an
43  * external clock source to go below 30mhz
44  * 
45  * IFCLKSRC 1 = internal, 0=external
46  * 3048mhz 0 = 30mhz, 1 = 48mzh
47  *
48  * Figure your own sync delay out if IFCLKSRC=0.
49  **/
50
51 #define NOP __asm nop __endasm
52
53 /**
54  * SYNCDELAY2 can work for the following clock speeds
55  *
56  * ifclk/clk
57  * \li 48/12
58  *
59  * ceil(1.5 * (20.8 / 83.3 + 1)) = 2
60  *
61  * \see NOP
62  *
63  **/
64 #define SYNCDELAY2 NOP; NOP
65
66 /**
67  * SYNCDELAY3 can work for the following clock speeds
68  *
69  * ifcfg/clk
70  * \li 48/24
71  * \li 48/48
72  * \li 30/12
73  * \li 30/24
74  *
75  * \see NOP
76  **/
77 #define SYNCDELAY3 NOP; NOP; NOP
78
79 /**
80  * SYNCDELAY4 should be used for the following speeds
81  *
82  * ifcfg/clk
83  * \li 30/48
84  *
85  * \see NOP
86  **/
87 #define SYNCDELAY4 NOP; NOP; NOP; NOP
88
89 #endif
90