rotaryrgb  2.1.0.0
rotaryrgb_delays.h
Go to the documentation of this file.
1 
16 #ifndef ROTARYRGB_DELAYS_H
17 #define ROTARYRGB_DELAYS_H
18 
19 // Delay adjustment for specific systems.
20 // Adjusted specifically for NECTO v6.0.2 and mikroSDK v2.10.2.
21 #ifdef __MIKROC_AI__
22  #ifdef STM32F407ZG
23  /*< Adjusted for STM32F407ZG */
24  #define DELAY_TOH Delay_Cyc( 3 ); // ~280ns
25  #define DELAY_TOL Delay_Cyc( 7 ); // ~790ns
26  #define DELAY_T1H Delay_Cyc( 12 ); // ~820ns
27  #define DELAY_T1L Delay_Cyc( 8 ); // ~840ns
28  #elif MK64FN1M0VDC12
29  /*< Adjusted for MK64FN1M0VDC12 */
30  #define DELAY_TOH Delay_Cyc( 2 ); // ~300ns
31  #define DELAY_TOL Delay_Cyc( 4 ); // ~780ns
32  #define DELAY_T1H Delay_Cyc( 7 ); // ~790ns
33  #define DELAY_T1L Delay_Cyc( 3 ); // ~810ns
34  #elif TM4C129XNCZAD
35  /*< Adjusted for TM4C129XNCZAD */
36  #define DELAY_TOH // ~360ns
37  #define DELAY_TOL asm nop; // ~820ns
38  #define DELAY_T1H Delay_Cyc( 4 ); // ~850ns
39  #define DELAY_T1L // ~940ns
40  #elif PIC32MX795F512L
41  /*< Adjusted for PIC32MX795F512L */
42  #define DELAY_TOH // ~250ns
43  #define DELAY_TOL // ~710ns
44  #define DELAY_T1H Delay_Cyc( 4 ); // ~840ns
45  #define DELAY_T1L // ~890ns
46  #else
47  #error "Logic delays are not defined for the selected MCU"
48  #endif
49 #elif __clang__
50  #ifdef STM32F407ZG
51  /*< Adjusted for STM32F407ZG */
52  #define DELAY_TOH Delay_Cyc( 2 ); // ~370ns
53  #define DELAY_TOL Delay_Cyc( 4 ); // ~740ns
54  #define DELAY_T1H Delay_Cyc( 10 ); // ~740ns
55  #define DELAY_T1L Delay_Cyc( 4 ); // ~750ns
56  #elif MK64
57  /*< Adjusted for MK64FN1M0VDC12 */
58  #define DELAY_TOH Delay_Cyc( 2 ); // ~400ns
59  #define DELAY_TOL Delay_Cyc( 2 ); // ~770ns
60  #define DELAY_T1H Delay_Cyc( 12 ); // ~740ns
61  #define DELAY_T1L Delay_Cyc( 2 ); // ~800ns
62  #elif TM4C129
63  /*< Adjusted for TM4C129XNCZAD */
64  #define DELAY_TOH \
65  asm("nop"); \
66  asm("nop"); \
67  asm("nop"); \
68  asm("nop"); \
69  asm("nop"); \
70  asm("nop"); \
71  asm("nop"); \
72  asm("nop"); \
73  asm("nop"); \
74  asm("nop"); \
75  asm("nop"); \
76  asm("nop"); // ~280ns
77  #define DELAY_TOL \
78  asm("nop"); \
79  asm("nop"); \
80  asm("nop"); \
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"); // ~820ns
90  #define DELAY_T1H Delay_Cyc( 6 ); // ~780ns
91  #define DELAY_T1L \
92  asm("nop"); \
93  asm("nop"); \
94  asm("nop"); \
95  asm("nop"); \
96  asm("nop"); \
97  asm("nop"); \
98  asm("nop"); \
99  asm("nop"); // ~790ns
100  #elif GD32VF103VBT6
101  /*< Adjusted for GD32VF103VBT6 */
102  #define DELAY_TOH \
103  asm("nop"); \
104  asm("nop"); \
105  asm("nop"); \
106  asm("nop"); \
107  asm("nop"); \
108  asm("nop"); \
109  asm("nop"); \
110  asm("nop"); \
111  asm("nop"); \
112  asm("nop"); \
113  asm("nop"); \
114  asm("nop"); \
115  asm("nop"); \
116  asm("nop"); \
117  asm("nop"); \
118  asm("nop"); // ~300ns
119  #define DELAY_TOL \
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"); \
135  asm("nop"); // ~680ns
136  #define DELAY_T1H Delay_Cyc( 2 ); // ~680ns
137  #define DELAY_T1L \
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"); // ~740ns
154  #else
155  #error "Logic delays are not defined for the selected MCU"
156  #endif
157 #elif __GNUC__
158  #ifdef STM32F407ZG
159  /*< Adjusted for STM32F407ZG */
160  #define DELAY_TOH \
161  asm("nop"); \
162  asm("nop"); \
163  asm("nop"); \
164  asm("nop"); \
165  asm("nop"); \
166  asm("nop"); \
167  asm("nop"); \
168  asm("nop"); \
169  asm("nop"); \
170  asm("nop"); \
171  asm("nop"); \
172  asm("nop"); \
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"); // ~260ns
185  #define DELAY_TOL Delay_Cyc( 2 ); // ~740ns
186  #define DELAY_T1H Delay_Cyc( 7 ); // ~710ns
187  #define DELAY_T1L Delay_Cyc( 2 ); // ~740ns
188  #elif MK64
189  /*< Adjusted for MK64FN1M0VDC12 */
190  #define DELAY_TOH Delay_Cyc( 2 ); // ~390ns
191  #define DELAY_TOL Delay_Cyc( 2 ); // ~720ns
192  #define DELAY_T1H Delay_Cyc( 10 ); // ~680ns
193  #define DELAY_T1L Delay_Cyc( 4 ); // ~780ns
194  #elif TM4C129
195  /*< Adjusted for TM4C129XNCZAD */
196  #define DELAY_TOH // ~470ns
197  #define DELAY_TOL // ~980ns
198  #define DELAY_T1H Delay_Cyc( 2 ); // ~1000ns
199  #define DELAY_T1L // ~990ns
200  #elif GD32VF103VBT6
201  /*< Adjusted for GD32VF103VBT6 */
202  #define DELAY_TOH \
203  asm("nop"); \
204  asm("nop"); \
205  asm("nop"); \
206  asm("nop"); \
207  asm("nop"); \
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"); // ~270ns
219  #define DELAY_TOL Delay_Cyc( 2 ); // ~850ns
220  #define DELAY_T1H Delay_Cyc( 4 ); // ~770ns
221  #define DELAY_T1L Delay_Cyc( 2 ); // ~820ns
222  #else
223  #error "Logic delays are not defined for the selected MCU"
224  #endif
225 #else
226  #error "Logic delays are not defined for the selected toolchain"
227 #endif
228 
229 #endif // _ROTARYRGB_H_