remove a bash-ism from a Makefile
[fx2lib.git] / include / delay.h
blob893ca67b8be3940e2f4fc6ba22a08d51c55c0aec
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.
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
17 /*! \file
18 * Functions for causing delays.
19 * */
22 #ifndef DELAY_H
23 #define DELAY_H
25 #include "fx2types.h"
27 /**
28 * 0-65536 millis
29 **/
30 void delay(WORD millis);
32 /**
33 * See TRM 15-14,15-15
34 * some registers (r/w) require syncdelay after
36 * up to the programmer to determine which sync is needed.
37 * for standard 48mhz clock w/ 48mhz IFCONFIG 3 nops is sufficient.
39 * slower clock and faster ifclock require more delay
41 * min delay = roof ( 1.5 x (ifclock/clkout + 1) )
43 * Minimum IFCLOCK is 5mhz but you have to use an
44 * external clock source to go below 30mhz
46 * IFCLKSRC 1 = internal, 0=external
47 * 3048mhz 0 = 30mhz, 1 = 48mzh
49 * Figure your own sync delay out if IFCLKSRC=0.
50 **/
52 #define NOP __asm nop __endasm
54 /**
55 * SYNCDELAY2 can work for the following clock speeds
57 * ifclk/clk
58 * \li 48/12
60 * ceil(1.5 * (20.8 / 83.3 + 1)) = 2
62 * \see NOP
64 **/
65 #define SYNCDELAY2 NOP; NOP
67 /**
68 * SYNCDELAY3 can work for the following clock speeds
70 * ifcfg/clk
71 * \li 48/24
72 * \li 48/48
73 * \li 30/12
74 * \li 30/24
76 * \see NOP
77 **/
78 #define SYNCDELAY3 NOP; NOP; NOP
80 /**
81 * SYNCDELAY4 should be used for the following speeds
83 * ifcfg/clk
84 * \li 30/48
86 * \see NOP
87 **/
88 #define SYNCDELAY4 NOP; NOP; NOP; NOP
90 /**
91 * All the SYNCDELAYs you could possibly want for other speeds
93 * \see NOP
94 **/
95 #define SYNCDELAY5 NOP; NOP; NOP; NOP; NOP
96 #define SYNCDELAY6 NOP; NOP; NOP; NOP; NOP; NOP
97 #define SYNCDELAY7 NOP; NOP; NOP; NOP; NOP; NOP; NOP
98 #define SYNCDELAY8 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP
99 #define SYNCDELAY9 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP
100 #define SYNCDELAY10 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP
101 #define SYNCDELAY11 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP
102 #define SYNCDELAY12 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP
103 #define SYNCDELAY13 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP
104 #define SYNCDELAY14 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP
105 #define SYNCDELAY15 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP
106 #define SYNCDELAY16 NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP; NOP
108 #endif