@@ -46,7 +46,7 @@ static NRF_PWM_Type * const _PWMInstance = NRF_PWM2;
46
46
static HardwarePWM * const _HwPWM = HwPWMx[2 ];
47
47
48
48
// Defined a struct, to simplify validation testing ... also provides context when debugging
49
- class TONE_PWM_CONFIG {
49
+ class TonePwmConfig {
50
50
private:
51
51
const nrf_pwm_clk_t clock_frequency = NRF_PWM_CLK_125kHz;
52
52
const nrf_pwm_mode_t pwm_mode = NRF_PWM_MODE_UP;
@@ -75,7 +75,7 @@ class TONE_PWM_CONFIG {
75
75
bool ApplyConfigurationAndStartPlayback (uint32_t pin);
76
76
uint64_t CalculateExpectedPulseCount (void );
77
77
};
78
- TONE_PWM_CONFIG _pwm_config;
78
+ TonePwmConfig _pwm_config;
79
79
80
80
inline static bool _is_pwm_enabled (NRF_PWM_Type const * pwm_instance) {
81
81
bool isEnabled =
@@ -227,8 +227,8 @@ void noTone(uint8_t pin)
227
227
_pwm_config.StopPlayback (true ); // release ownership of PWM peripheral
228
228
}
229
229
230
- bool TONE_PWM_CONFIG ::EnsurePwmPeripheralOwnership (void ) {
231
- if (!_HwPWM->isOwner (TONE_PWM_CONFIG ::toneToken) && !_HwPWM->takeOwnership (TONE_PWM_CONFIG ::toneToken)) {
230
+ bool TonePwmConfig ::EnsurePwmPeripheralOwnership (void ) {
231
+ if (!_HwPWM->isOwner (TonePwmConfig ::toneToken) && !_HwPWM->takeOwnership (TonePwmConfig ::toneToken)) {
232
232
LOG_LV1 (" TON" , " unable to allocate PWM2 to Tone" );
233
233
return false ;
234
234
}
@@ -265,7 +265,7 @@ bool TONE_PWM_CONFIG::EnsurePwmPeripheralOwnership(void) {
265
265
// COUNT += (start at SEQ0) ? (SEQ0.CNT * (SEQ0.REFRESH+1) : 0;
266
266
// COUNT += 1; // final SEQ1 emits single pulse
267
267
//
268
- bool TONE_PWM_CONFIG ::InitializeFromPulseCountAndTimePeriod (uint64_t pulse_count_x, uint16_t time_period) {
268
+ bool TonePwmConfig ::InitializeFromPulseCountAndTimePeriod (uint64_t pulse_count_x, uint16_t time_period) {
269
269
270
270
if (_bits_used (pulse_count_x) > 37 ) {
271
271
LOG_LV1 (" TON" , " pulse count is limited to 37 bit long value" );
@@ -339,7 +339,7 @@ bool TONE_PWM_CONFIG::InitializeFromPulseCountAndTimePeriod(uint64_t pulse_count
339
339
this ->is_initialized = true ;
340
340
return true ;
341
341
}
342
- bool TONE_PWM_CONFIG ::ApplyConfiguration (uint32_t pin) {
342
+ bool TonePwmConfig ::ApplyConfiguration (uint32_t pin) {
343
343
if (!this ->is_initialized ) {
344
344
return false ;
345
345
}
@@ -363,8 +363,8 @@ bool TONE_PWM_CONFIG::ApplyConfiguration(uint32_t pin) {
363
363
364
364
nrf_pwm_pins_set (_PWMInstance, pins); // must set pins before enabling
365
365
nrf_pwm_enable (_PWMInstance);
366
- nrf_pwm_configure (_PWMInstance, TONE_PWM_CONFIG ::clock_frequency, TONE_PWM_CONFIG ::pwm_mode, this ->time_period );
367
- nrf_pwm_decoder_set (_PWMInstance, TONE_PWM_CONFIG ::load_mode, TONE_PWM_CONFIG ::step_mode);
366
+ nrf_pwm_configure (_PWMInstance, TonePwmConfig ::clock_frequency, TonePwmConfig ::pwm_mode, this ->time_period );
367
+ nrf_pwm_decoder_set (_PWMInstance, TonePwmConfig ::load_mode, TonePwmConfig ::step_mode);
368
368
nrf_pwm_shorts_set (_PWMInstance, this ->shorts );
369
369
nrf_pwm_int_set (_PWMInstance, 0 );
370
370
@@ -394,7 +394,7 @@ bool TONE_PWM_CONFIG::ApplyConfiguration(uint32_t pin) {
394
394
nrf_pwm_event_clear (_PWMInstance, NRF_PWM_EVENT_LOOPSDONE);
395
395
return true ;
396
396
}
397
- bool TONE_PWM_CONFIG ::StartPlayback (void ) {
397
+ bool TonePwmConfig ::StartPlayback (void ) {
398
398
if (!this ->is_initialized ) {
399
399
LOG_LV1 (" TON" , " Cannot start playback without first initializing" );
400
400
return false ;
@@ -406,11 +406,11 @@ bool TONE_PWM_CONFIG::StartPlayback(void) {
406
406
nrf_pwm_task_trigger (_PWMInstance, this ->task_to_start );
407
407
return true ;
408
408
}
409
- bool TONE_PWM_CONFIG ::StopPlayback (bool releaseOwnership) {
409
+ bool TonePwmConfig ::StopPlayback (bool releaseOwnership) {
410
410
411
411
bool notInIsr = !isInISR ();
412
412
413
- if (!_HwPWM->isOwner (TONE_PWM_CONFIG ::toneToken)) {
413
+ if (!_HwPWM->isOwner (TonePwmConfig ::toneToken)) {
414
414
if (notInIsr) {
415
415
LOG_LV2 (" TON" , " Attempt to set noTone when not the owner of the PWM peripheral. Ignoring call...." );
416
416
}
@@ -424,7 +424,7 @@ bool TONE_PWM_CONFIG::StopPlayback(bool releaseOwnership) {
424
424
}
425
425
426
426
if (releaseOwnership) {
427
- _HwPWM->releaseOwnership (TONE_PWM_CONFIG ::toneToken);
427
+ _HwPWM->releaseOwnership (TonePwmConfig ::toneToken);
428
428
}
429
429
return true ;
430
430
}
0 commit comments