c4x4rgb 2.0.0.0
c4x4rgb_delays.h
Go to the documentation of this file.
1
16#ifndef C4X4RGB_DELAYS_H
17#define C4X4RGB_DELAYS_H
18
19// Delay adjustment for specific systems.
20// Adjusted specifically for NECTO v6.1.0 and mikroSDK v2.11.0.
21#ifdef __MIKROC_AI__
22 #ifdef STM32F407ZG
23 /*< Adjusted for STM32F407ZG */
24 #define DELAY_TOH Delay_Cyc( 3 ); // ~290ns
25 #define DELAY_TOL Delay_Cyc( 5 ); // ~730ns
26 #define DELAY_T1H Delay_Cyc( 9 ); // ~640ns
27 #define DELAY_T1L Delay_Cyc( 2 ); // ~550ns
28 #elif MK64FN1M0VDC12
29 /*< Adjusted for MK64FN1M0VDC12 */
30 #define DELAY_TOH Delay_Cyc( 2 ); // ~300ns
31 #define DELAY_TOL Delay_Cyc( 3 ); // ~870ns
32 #define DELAY_T1H Delay_Cyc( 7 ); // ~720ns
33 #define DELAY_T1L Delay_Cyc( 2 ); // ~700ns
34 #elif TM4C129XNCZAD
35 /*< Adjusted for TM4C129XNCZAD */
36 #define DELAY_TOH // ~420ns
37 #define DELAY_TOL // ~1000ns
38 #define DELAY_T1H Delay_Cyc( 2 ); // ~690ns
39 #define DELAY_T1L // ~1000ns
40 #elif PIC32MX795F512L
41 /*< Adjusted for PIC32MX795F512L */
42 #define DELAY_TOH \
43 asm nop; \
44 asm nop; \
45 asm nop; \
46 asm nop; \
47 asm nop; \
48 asm nop; \
49 asm nop; \
50 asm nop; // ~350ns
51 #define DELAY_TOL // ~880ns
52 #define DELAY_T1H Delay_Cyc( 3 ); // ~700ns
53 #define DELAY_T1L // ~1000ns
54 #else
55 #error "Logic delays are not defined for the selected MCU"
56 #endif
57#elif __clang__
58 #ifdef STM32F407ZG
59 /*< Adjusted for STM32F407ZG */
60 #define DELAY_TOH Delay_Cyc( 2 ); // ~370ns
61 #define DELAY_TOL Delay_Cyc( 4 ); // ~790ns
62 #define DELAY_T1H Delay_Cyc( 9 ); // ~700ns
63 #define DELAY_T1L Delay_Cyc( 2 ); // ~690ns
64 #elif MK64
65 /*< Adjusted for MK64FN1M0VDC12 */
66 #define DELAY_TOH Delay_Cyc( 2 ); // ~370ns
67 #define DELAY_TOL Delay_Cyc( 3 ); // ~780ns
68 #define DELAY_T1H Delay_Cyc( 12 ); // ~700ns
69 #define DELAY_T1L \
70 asm("nop"); \
71 asm("nop"); \
72 asm("nop"); \
73 asm("nop"); \
74 asm("nop"); \
75 asm("nop"); \
76 asm("nop"); \
77 asm("nop"); // ~610ns
78 #elif TM4C129
79 /*< Adjusted for TM4C129XNCZAD */
80 #define DELAY_TOH \
81 asm("nop"); \
82 asm("nop"); \
83 asm("nop"); \
84 asm("nop"); \
85 asm("nop"); \
86 asm("nop"); \
87 asm("nop"); \
88 asm("nop"); \
89 asm("nop"); \
90 asm("nop"); \
91 asm("nop"); \
92 asm("nop"); \
93 asm("nop"); \
94 asm("nop"); \
95 asm("nop"); \
96 asm("nop"); \
97 asm("nop"); \
98 asm("nop"); \
99 asm("nop"); \
100 asm("nop"); \
101 asm("nop"); \
102 asm("nop"); \
103 asm("nop"); \
104 asm("nop"); // ~380ns
105 #define DELAY_TOL \
106 asm("nop"); \
107 asm("nop"); \
108 asm("nop"); \
109 asm("nop"); // ~750ns
110 #define DELAY_T1H Delay_Cyc( 4 ); // ~690ns
111 #define DELAY_T1L // ~750ns
112 #elif GD32VF103VBT6
113 /*< Adjusted for GD32VF103VBT6 */
114 #define DELAY_TOH \
115 asm("nop"); \
116 asm("nop"); \
117 asm("nop"); \
118 asm("nop"); \
119 asm("nop"); \
120 asm("nop"); \
121 asm("nop"); \
122 asm("nop"); \
123 asm("nop"); \
124 asm("nop"); \
125 asm("nop"); \
126 asm("nop"); \
127 asm("nop"); \
128 asm("nop"); \
129 asm("nop"); \
130 asm("nop"); \
131 asm("nop"); \
132 asm("nop"); \
133 asm("nop"); \
134 asm("nop"); // ~350ns
135 #define DELAY_TOL \
136 asm("nop"); \
137 asm("nop"); \
138 asm("nop"); \
139 asm("nop"); \
140 asm("nop"); \
141 asm("nop"); \
142 asm("nop"); \
143 asm("nop"); \
144 asm("nop"); \
145 asm("nop"); \
146 asm("nop"); \
147 asm("nop"); \
148 asm("nop"); \
149 asm("nop"); \
150 asm("nop"); \
151 asm("nop"); \
152 asm("nop"); \
153 asm("nop"); \
154 asm("nop"); \
155 asm("nop"); \
156 asm("nop"); \
157 asm("nop"); \
158 asm("nop"); \
159 asm("nop"); // ~780ns
160 #define DELAY_T1H Delay_Cyc( 2 ); // ~690ns
161 #define DELAY_T1L \
162 asm("nop"); \
163 asm("nop"); \
164 asm("nop"); \
165 asm("nop"); // ~620ns
166 #else
167 #error "Logic delays are not defined for the selected MCU"
168 #endif
169#elif __GNUC__
170 #ifdef STM32F407ZG
171 /*< Adjusted for STM32F407ZG */
172 #define DELAY_TOH \
173 asm("nop"); \
174 asm("nop"); \
175 asm("nop"); \
176 asm("nop"); \
177 asm("nop"); \
178 asm("nop"); \
179 asm("nop"); \
180 asm("nop"); \
181 asm("nop"); \
182 asm("nop"); \
183 asm("nop"); \
184 asm("nop"); \
185 asm("nop"); \
186 asm("nop"); \
187 asm("nop"); \
188 asm("nop"); \
189 asm("nop"); \
190 asm("nop"); \
191 asm("nop"); \
192 asm("nop"); \
193 asm("nop"); \
194 asm("nop"); \
195 asm("nop"); \
196 asm("nop"); \
197 asm("nop"); \
198 asm("nop"); \
199 asm("nop"); \
200 asm("nop"); \
201 asm("nop"); \
202 asm("nop"); \
203 asm("nop"); \
204 asm("nop"); // ~310ns
205 #define DELAY_TOL Delay_Cyc( 2 ); // ~760ns
206 #define DELAY_T1H Delay_Cyc( 7 ); // ~710ns
207 #define DELAY_T1L \
208 asm("nop"); \
209 asm("nop"); \
210 asm("nop"); \
211 asm("nop"); \
212 asm("nop"); \
213 asm("nop"); \
214 asm("nop"); \
215 asm("nop"); \
216 asm("nop"); \
217 asm("nop"); \
218 asm("nop"); \
219 asm("nop"); \
220 asm("nop"); \
221 asm("nop"); \
222 asm("nop"); \
223 asm("nop"); \
224 asm("nop"); \
225 asm("nop"); \
226 asm("nop"); \
227 asm("nop"); \
228 asm("nop"); \
229 asm("nop"); \
230 asm("nop"); \
231 asm("nop"); \
232 asm("nop"); \
233 asm("nop"); \
234 asm("nop"); \
235 asm("nop"); \
236 asm("nop"); \
237 asm("nop"); \
238 asm("nop"); \
239 asm("nop"); // ~600ns
240 #elif MK64
241 /*< Adjusted for MK64FN1M0VDC12 */
242 #define DELAY_TOH Delay_Cyc( 2 ); // ~390ns
243 #define DELAY_TOL Delay_Cyc( 3 ); // ~780ns
244 #define DELAY_T1H Delay_Cyc( 11 ); // ~690ns
245 #define DELAY_T1L \
246 asm("nop"); \
247 asm("nop"); \
248 asm("nop"); \
249 asm("nop"); \
250 asm("nop"); \
251 asm("nop"); \
252 asm("nop"); \
253 asm("nop"); \
254 asm("nop"); \
255 asm("nop"); \
256 asm("nop"); \
257 asm("nop"); \
258 asm("nop"); \
259 asm("nop"); \
260 asm("nop"); \
261 asm("nop"); // ~610ns
262 #elif TM4C129
263 /*< Adjusted for TM4C129XNCZAD */
264 #define DELAY_TOH // ~450ns
265 #define DELAY_TOL // ~960ns
266 #define DELAY_T1H \
267 asm("nop"); \
268 asm("nop"); \
269 asm("nop"); \
270 asm("nop"); \
271 asm("nop"); \
272 asm("nop"); \
273 asm("nop"); \
274 asm("nop"); \
275 asm("nop"); \
276 asm("nop"); \
277 asm("nop"); \
278 asm("nop"); \
279 asm("nop"); \
280 asm("nop"); \
281 asm("nop"); \
282 asm("nop"); \
283 asm("nop"); \
284 asm("nop"); \
285 asm("nop"); \
286 asm("nop"); \
287 asm("nop"); \
288 asm("nop"); \
289 asm("nop"); \
290 asm("nop"); \
291 asm("nop"); \
292 asm("nop"); \
293 asm("nop"); \
294 asm("nop"); \
295 asm("nop"); \
296 asm("nop"); \
297 asm("nop"); \
298 asm("nop"); // ~720ns
299 #define DELAY_T1L // ~1020ns
300 #elif GD32VF103VBT6
301 /*< Adjusted for GD32VF103VBT6 */
302 #define DELAY_TOH \
303 asm("nop"); \
304 asm("nop"); \
305 asm("nop"); \
306 asm("nop"); \
307 asm("nop"); \
308 asm("nop"); \
309 asm("nop"); \
310 asm("nop"); \
311 asm("nop"); \
312 asm("nop"); \
313 asm("nop"); \
314 asm("nop"); \
315 asm("nop"); \
316 asm("nop"); \
317 asm("nop"); \
318 asm("nop"); \
319 asm("nop"); \
320 asm("nop"); \
321 asm("nop"); \
322 asm("nop"); \
323 asm("nop"); \
324 asm("nop"); \
325 asm("nop"); \
326 asm("nop"); // ~350ns
327 #define DELAY_TOL Delay_Cyc( 2 ); // ~860ns
328 #define DELAY_T1H Delay_Cyc( 4 ); // ~760ns
329 #define DELAY_T1L \
330 asm("nop"); \
331 asm("nop"); \
332 asm("nop"); \
333 asm("nop"); \
334 asm("nop"); \
335 asm("nop"); \
336 asm("nop"); \
337 asm("nop"); \
338 asm("nop"); \
339 asm("nop"); \
340 asm("nop"); \
341 asm("nop"); // ~600ns
342 #else
343 #error "Logic delays are not defined for the selected MCU"
344 #endif
345#else
346 #error "Logic delays are not defined for the selected toolchain"
347#endif
348
349#endif // C4X4RGB_DELAYS_H