|
27 | 27 | #define LED_ON LOW
|
28 | 28 |
|
29 | 29 | #ifndef LED_BUILTIN
|
30 |
| - #define LED_BUILTIN 25 |
| 30 | + #define LED_BUILTIN 25 |
31 | 31 | #endif
|
32 | 32 |
|
33 | 33 | #ifndef LED_BLUE_PIN
|
@@ -63,7 +63,7 @@ NRF52_Slow_PWM ISR_PWM;
|
63 | 63 |
|
64 | 64 | void TimerHandler()
|
65 | 65 | {
|
66 |
| - ISR_PWM.run(); |
| 66 | + ISR_PWM.run(); |
67 | 67 | }
|
68 | 68 |
|
69 | 69 | //////////////////////////////////////////////////////
|
@@ -93,29 +93,29 @@ void TimerHandler()
|
93 | 93 | // You can assign pins here. Be carefull to select good pin to use or crash, e.g pin 6-11
|
94 | 94 | uint32_t PWM_Pin[] =
|
95 | 95 | {
|
96 |
| - LED_BUILTIN, LED_BLUE_PIN, LED_GREEN_PIN, PIN_D0, PIN_D1, PIN_D2, PIN_D3, PIN_D4, |
97 |
| - PIN_D5, PIN_D6, PIN_D7, PIN_D8, PIN_D9, PIN_D10, PIN_D11, PIN_D12 |
| 96 | + LED_BUILTIN, LED_BLUE_PIN, LED_GREEN_PIN, PIN_D0, PIN_D1, PIN_D2, PIN_D3, PIN_D4, |
| 97 | + PIN_D5, PIN_D6, PIN_D7, PIN_D8, PIN_D9, PIN_D10, PIN_D11, PIN_D12 |
98 | 98 | };
|
99 | 99 |
|
100 | 100 | // You can assign any interval for any timer here, in microseconds
|
101 | 101 | uint32_t PWM_Period[] =
|
102 | 102 | {
|
103 |
| - 1000000L, 500000L, 333333L, 250000L, 200000L, 166667L, 142857L, 125000L, |
104 |
| - 111111L, 100000L, 66667L, 50000L, 40000L, 33333L, 25000L, 20000L |
| 103 | + 1000000L, 500000L, 333333L, 250000L, 200000L, 166667L, 142857L, 125000L, |
| 104 | + 111111L, 100000L, 66667L, 50000L, 40000L, 33333L, 25000L, 20000L |
105 | 105 | };
|
106 | 106 |
|
107 | 107 | // You can assign any interval for any timer here, in Hz
|
108 | 108 | float PWM_Freq[] =
|
109 | 109 | {
|
110 |
| - 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, |
111 |
| - 9.0f, 10.0f, 15.0f, 20.0f, 25.0f, 30.0f, 40.0f, 50.0f |
| 110 | + 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, |
| 111 | + 9.0f, 10.0f, 15.0f, 20.0f, 25.0f, 30.0f, 40.0f, 50.0f |
112 | 112 | };
|
113 | 113 |
|
114 | 114 | // You can assign any interval for any timer here, in milliseconds
|
115 | 115 | float PWM_DutyCycle[] =
|
116 | 116 | {
|
117 |
| - 5.0, 10.0, 20.0, 30.0, 40.0, 45.0, 50.0, 55.0, |
118 |
| - 60.0, 65.0, 70.0, 75.0, 80.0, 85.0, 90.0, 95.0 |
| 117 | + 5.0, 10.0, 20.0, 30.0, 40.0, 45.0, 50.0, 55.0, |
| 118 | + 60.0, 65.0, 70.0, 75.0, 80.0, 85.0, 90.0, 95.0 |
119 | 119 | };
|
120 | 120 |
|
121 | 121 | typedef void (*irqCallback) ();
|
@@ -190,59 +190,60 @@ void doingSomething15()
|
190 | 190 |
|
191 | 191 | irqCallback irqCallbackStartFunc[] =
|
192 | 192 | {
|
193 |
| - doingSomething0, doingSomething1, doingSomething2, doingSomething3, |
194 |
| - doingSomething4, doingSomething5, doingSomething6, doingSomething7, |
195 |
| - doingSomething8, doingSomething9, doingSomething10, doingSomething11, |
196 |
| - doingSomething12, doingSomething13, doingSomething14, doingSomething15 |
| 193 | + doingSomething0, doingSomething1, doingSomething2, doingSomething3, |
| 194 | + doingSomething4, doingSomething5, doingSomething6, doingSomething7, |
| 195 | + doingSomething8, doingSomething9, doingSomething10, doingSomething11, |
| 196 | + doingSomething12, doingSomething13, doingSomething14, doingSomething15 |
197 | 197 | };
|
198 | 198 |
|
199 | 199 | ////////////////////////////////////////////////
|
200 | 200 |
|
201 | 201 | void setup()
|
202 | 202 | {
|
203 |
| - Serial.begin(115200); |
| 203 | + Serial.begin(115200); |
204 | 204 |
|
205 |
| - while (!Serial && millis() < 5000); |
| 205 | + while (!Serial && millis() < 5000); |
206 | 206 |
|
207 |
| - delay(2000); |
| 207 | + delay(2000); |
208 | 208 |
|
209 |
| - Serial.print(F("\nStarting ISR_16_PWMs_Array on ")); Serial.println(BOARD_NAME); |
210 |
| - Serial.println(NRF52_SLOW_PWM_VERSION); |
| 209 | + Serial.print(F("\nStarting ISR_16_PWMs_Array on ")); |
| 210 | + Serial.println(BOARD_NAME); |
| 211 | + Serial.println(NRF52_SLOW_PWM_VERSION); |
211 | 212 |
|
212 |
| - // Interval in microsecs |
213 |
| - if (ITimer.attachInterruptInterval(HW_TIMER_INTERVAL_US, TimerHandler)) |
214 |
| - { |
215 |
| - startMicros = micros(); |
216 |
| - Serial.print(F("Starting ITimer OK, micros() = ")); |
217 |
| - Serial.println(startMicros); |
218 |
| - } |
219 |
| - else |
220 |
| - Serial.println(F("Can't set ITimer. Select another freq. or timer")); |
| 213 | + // Interval in microsecs |
| 214 | + if (ITimer.attachInterruptInterval(HW_TIMER_INTERVAL_US, TimerHandler)) |
| 215 | + { |
| 216 | + startMicros = micros(); |
| 217 | + Serial.print(F("Starting ITimer OK, micros() = ")); |
| 218 | + Serial.println(startMicros); |
| 219 | + } |
| 220 | + else |
| 221 | + Serial.println(F("Can't set ITimer. Select another freq. or timer")); |
221 | 222 |
|
222 | 223 | #if 1
|
223 | 224 |
|
224 |
| - // Just to demonstrate, don't use too many ISR Timers if not absolutely necessary |
225 |
| - // You can use up to 16 timer for each ISR_PWM |
226 |
| - for (uint16_t i = 0; i < NUMBER_ISR_PWMS; i++) |
227 |
| - { |
228 |
| - //void setPWM(uint32_t pin, float frequency, float dutycycle |
229 |
| - // , timer_callback_p StartCallback = nullptr, timer_callback_p StopCallback = nullptr) |
| 225 | + // Just to demonstrate, don't use too many ISR Timers if not absolutely necessary |
| 226 | + // You can use up to 16 timer for each ISR_PWM |
| 227 | + for (uint16_t i = 0; i < NUMBER_ISR_PWMS; i++) |
| 228 | + { |
| 229 | + //void setPWM(uint32_t pin, float frequency, float dutycycle |
| 230 | + // , timer_callback_p StartCallback = nullptr, timer_callback_p StopCallback = nullptr) |
230 | 231 |
|
231 | 232 | #if USING_PWM_FREQUENCY
|
232 | 233 |
|
233 |
| - // You can use this with PWM_Freq in Hz |
234 |
| - ISR_PWM.setPWM(PWM_Pin[i], PWM_Freq[i], PWM_DutyCycle[i], irqCallbackStartFunc[i]); |
| 234 | + // You can use this with PWM_Freq in Hz |
| 235 | + ISR_PWM.setPWM(PWM_Pin[i], PWM_Freq[i], PWM_DutyCycle[i], irqCallbackStartFunc[i]); |
235 | 236 |
|
236 | 237 | #else
|
237 | 238 | #if USING_MICROS_RESOLUTION
|
238 |
| - // Or using period in microsecs resolution |
239 |
| - ISR_PWM.setPWM_Period(PWM_Pin[i], PWM_Period[i], PWM_DutyCycle[i], irqCallbackStartFunc[i]); |
| 239 | + // Or using period in microsecs resolution |
| 240 | + ISR_PWM.setPWM_Period(PWM_Pin[i], PWM_Period[i], PWM_DutyCycle[i], irqCallbackStartFunc[i]); |
240 | 241 | #else
|
241 |
| - // Or using period in millisecs resolution |
242 |
| - ISR_PWM.setPWM_Period(PWM_Pin[i], PWM_Period[i] / 1000, PWM_DutyCycle[i], irqCallbackStartFunc[i]); |
| 242 | + // Or using period in millisecs resolution |
| 243 | + ISR_PWM.setPWM_Period(PWM_Pin[i], PWM_Period[i] / 1000, PWM_DutyCycle[i], irqCallbackStartFunc[i]); |
243 | 244 | #endif
|
244 | 245 | #endif
|
245 |
| - } |
| 246 | + } |
246 | 247 |
|
247 | 248 | #endif
|
248 | 249 | }
|
|
0 commit comments