Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Commit 2c86fbf

Browse files
authored
v1.2.2 to add support to Seeeduino nRF52
### Releases v1.2.2 1. Add support to Seeeduino nRF52840-based boards such as **Seeed_XIAO_NRF52840 and Seeed_XIAO_NRF52840_SENSE**, etc. using Seeeduino `nRF52` core 2. Add astyle using `allman` style. Restyle the library 3. Update all examples 4. Update `Packages' Patches` to add Seeeduino `nRF52` core
1 parent f20e8b3 commit 2c86fbf

File tree

6 files changed

+398
-392
lines changed

6 files changed

+398
-392
lines changed

examples/ISR_16_PWMs_Array/ISR_16_PWMs_Array.ino

+42-41
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#define LED_ON LOW
2828

2929
#ifndef LED_BUILTIN
30-
#define LED_BUILTIN 25
30+
#define LED_BUILTIN 25
3131
#endif
3232

3333
#ifndef LED_BLUE_PIN
@@ -63,7 +63,7 @@ NRF52_Slow_PWM ISR_PWM;
6363

6464
void TimerHandler()
6565
{
66-
ISR_PWM.run();
66+
ISR_PWM.run();
6767
}
6868

6969
//////////////////////////////////////////////////////
@@ -93,29 +93,29 @@ void TimerHandler()
9393
// You can assign pins here. Be carefull to select good pin to use or crash, e.g pin 6-11
9494
uint32_t PWM_Pin[] =
9595
{
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
9898
};
9999

100100
// You can assign any interval for any timer here, in microseconds
101101
uint32_t PWM_Period[] =
102102
{
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
105105
};
106106

107107
// You can assign any interval for any timer here, in Hz
108108
float PWM_Freq[] =
109109
{
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
112112
};
113113

114114
// You can assign any interval for any timer here, in milliseconds
115115
float PWM_DutyCycle[] =
116116
{
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
119119
};
120120

121121
typedef void (*irqCallback) ();
@@ -190,59 +190,60 @@ void doingSomething15()
190190

191191
irqCallback irqCallbackStartFunc[] =
192192
{
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
197197
};
198198

199199
////////////////////////////////////////////////
200200

201201
void setup()
202202
{
203-
Serial.begin(115200);
203+
Serial.begin(115200);
204204

205-
while (!Serial && millis() < 5000);
205+
while (!Serial && millis() < 5000);
206206

207-
delay(2000);
207+
delay(2000);
208208

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);
211212

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"));
221222

222223
#if 1
223224

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)
230231

231232
#if USING_PWM_FREQUENCY
232233

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]);
235236

236237
#else
237238
#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]);
240241
#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]);
243244
#endif
244245
#endif
245-
}
246+
}
246247

247248
#endif
248249
}

0 commit comments

Comments
 (0)