]> sigrok.org Git - sigrok-firmware-fx2lafw.git/blob - fx2lib/include/delay.h
Import fx2lib into fx2lafw directly.
[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, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
16
17 /*! \file 
18  *  Functions for causing delays.
19  * */
20
21
22 #ifndef DELAY_H
23 #define DELAY_H
24
25 #include "fx2types.h"
26
27 /**
28  * 0-65536 millis
29  **/
30 void delay(WORD millis);
31
32 /**
33  * See TRM 15-14,15-15
34  * some registers (r/w) require syncdelay after
35  *
36  * up to the programmer to determine which sync is needed.
37  * for standard 48mhz clock w/ 48mhz IFCONFIG 3 nops is sufficient.
38  *
39  * slower clock and faster ifclock require more delay
40  *
41  * min delay = roof ( 1.5 x (ifclock/clkout + 1) )
42  *
43  * Minimum IFCLOCK is 5mhz but you have to use an
44  * external clock source to go below 30mhz
45  * 
46  * IFCLKSRC 1 = internal, 0=external
47  * 3048mhz 0 = 30mhz, 1 = 48mzh
48  *
49  * Figure your own sync delay out if IFCLKSRC=0.
50  **/
51
52 #define NOP __asm nop __endasm
53
54 /**
55  * SYNCDELAY2 can work for the following clock speeds
56  *
57  * ifclk/clk
58  * \li 48/12
59  *
60  * ceil(1.5 * (20.8 / 83.3 + 1)) = 2
61  *
62  * \see NOP
63  *
64  **/
65 #define SYNCDELAY2 NOP; NOP
66
67 /**
68  * SYNCDELAY3 can work for the following clock speeds
69  *
70  * ifcfg/clk
71  * \li 48/24
72  * \li 48/48
73  * \li 30/12
74  * \li 30/24
75  *
76  * \see NOP
77  **/
78 #define SYNCDELAY3 NOP; NOP; NOP
79
80 /**
81  * SYNCDELAY4 should be used for the following speeds
82  *
83  * ifcfg/clk
84  * \li 30/48
85  *
86  * \see NOP
87  **/
88 #define SYNCDELAY4 NOP; NOP; NOP; NOP
89
90 #endif
91