@@ -46,7 +46,7 @@ static NRF_PWM_Type * const _PWMInstance = NRF_PWM2;
4646static HardwarePWM * const _HwPWM = HwPWMx[2 ];
4747
4848// Defined a struct, to simplify validation testing ... also provides context when debugging
49- class TONE_PWM_CONFIG {
49+ class TonePwmConfig {
5050 private:
5151 const nrf_pwm_clk_t clock_frequency = NRF_PWM_CLK_125kHz;
5252 const nrf_pwm_mode_t pwm_mode = NRF_PWM_MODE_UP;
@@ -75,7 +75,7 @@ class TONE_PWM_CONFIG {
7575 bool ApplyConfigurationAndStartPlayback (uint32_t pin);
7676 uint64_t CalculateExpectedPulseCount (void );
7777};
78- TONE_PWM_CONFIG _pwm_config;
78+ TonePwmConfig _pwm_config;
7979
8080inline static bool _is_pwm_enabled (NRF_PWM_Type const * pwm_instance) {
8181 bool isEnabled =
@@ -227,8 +227,8 @@ void noTone(uint8_t pin)
227227 _pwm_config.StopPlayback (true ); // release ownership of PWM peripheral
228228}
229229
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)) {
232232 LOG_LV1 (" TON" , " unable to allocate PWM2 to Tone" );
233233 return false ;
234234 }
@@ -265,7 +265,7 @@ bool TONE_PWM_CONFIG::EnsurePwmPeripheralOwnership(void) {
265265// COUNT += (start at SEQ0) ? (SEQ0.CNT * (SEQ0.REFRESH+1) : 0;
266266// COUNT += 1; // final SEQ1 emits single pulse
267267//
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) {
269269
270270 if (_bits_used (pulse_count_x) > 37 ) {
271271 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
339339 this ->is_initialized = true ;
340340 return true ;
341341}
342- bool TONE_PWM_CONFIG ::ApplyConfiguration (uint32_t pin) {
342+ bool TonePwmConfig ::ApplyConfiguration (uint32_t pin) {
343343 if (!this ->is_initialized ) {
344344 return false ;
345345 }
@@ -363,8 +363,8 @@ bool TONE_PWM_CONFIG::ApplyConfiguration(uint32_t pin) {
363363
364364 nrf_pwm_pins_set (_PWMInstance, pins); // must set pins before enabling
365365 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);
368368 nrf_pwm_shorts_set (_PWMInstance, this ->shorts );
369369 nrf_pwm_int_set (_PWMInstance, 0 );
370370
@@ -394,7 +394,7 @@ bool TONE_PWM_CONFIG::ApplyConfiguration(uint32_t pin) {
394394 nrf_pwm_event_clear (_PWMInstance, NRF_PWM_EVENT_LOOPSDONE);
395395 return true ;
396396}
397- bool TONE_PWM_CONFIG ::StartPlayback (void ) {
397+ bool TonePwmConfig ::StartPlayback (void ) {
398398 if (!this ->is_initialized ) {
399399 LOG_LV1 (" TON" , " Cannot start playback without first initializing" );
400400 return false ;
@@ -406,11 +406,11 @@ bool TONE_PWM_CONFIG::StartPlayback(void) {
406406 nrf_pwm_task_trigger (_PWMInstance, this ->task_to_start );
407407 return true ;
408408}
409- bool TONE_PWM_CONFIG ::StopPlayback (bool releaseOwnership) {
409+ bool TonePwmConfig ::StopPlayback (bool releaseOwnership) {
410410
411411 bool notInIsr = !isInISR ();
412412
413- if (!_HwPWM->isOwner (TONE_PWM_CONFIG ::toneToken)) {
413+ if (!_HwPWM->isOwner (TonePwmConfig ::toneToken)) {
414414 if (notInIsr) {
415415 LOG_LV2 (" TON" , " Attempt to set noTone when not the owner of the PWM peripheral. Ignoring call...." );
416416 }
@@ -424,7 +424,7 @@ bool TONE_PWM_CONFIG::StopPlayback(bool releaseOwnership) {
424424 }
425425
426426 if (releaseOwnership) {
427- _HwPWM->releaseOwnership (TONE_PWM_CONFIG ::toneToken);
427+ _HwPWM->releaseOwnership (TonePwmConfig ::toneToken);
428428 }
429429 return true ;
430430}
0 commit comments