@@ -67,13 +67,11 @@ class TonePwmConfig {
6767 boolean is_initialized; // < defaults to uninitialized
6868
6969 public:
70- bool EnsurePwmPeripheralOwnership (void );
71- bool InitializeFromPulseCountAndTimePeriod (uint64_t pulse_count, uint16_t time_period);
72- bool ApplyConfiguration (uint32_t pin);
73- bool StartPlayback (void );
74- bool StopPlayback (bool releaseOwnership = false );
75- bool ApplyConfigurationAndStartPlayback (uint32_t pin);
76- uint64_t CalculateExpectedPulseCount (void );
70+ bool ensurePwmPeripheralOwnership (void );
71+ bool initializeFromPulseCountAndTimePeriod (uint64_t pulse_count, uint16_t time_period);
72+ bool applyConfiguration (uint32_t pin);
73+ bool startPlayback (void );
74+ bool stopPlayback (bool releaseOwnership = false );
7775};
7876TonePwmConfig _pwm_config;
7977
@@ -205,15 +203,15 @@ void tone(uint8_t pin, unsigned int frequency, unsigned long duration)
205203 uint64_t pulse_count = _calculate_pulse_count (frequency, duration);
206204 uint16_t time_period = _calculate_time_period (frequency);
207205
208- if (!_pwm_config.EnsurePwmPeripheralOwnership ()) {
206+ if (!_pwm_config.ensurePwmPeripheralOwnership ()) {
209207 LOG_LV1 (" TON" , " Unable to acquire PWM peripheral" );
210- } else if (!_pwm_config.StopPlayback ()) {
208+ } else if (!_pwm_config.stopPlayback ()) {
211209 LOG_LV1 (" TON" , " Unable to stop playback" );
212- } else if (!_pwm_config.InitializeFromPulseCountAndTimePeriod (pulse_count, time_period)) {
210+ } else if (!_pwm_config.initializeFromPulseCountAndTimePeriod (pulse_count, time_period)) {
213211 LOG_LV1 (" TON" , " Failed calculating configuration" );
214- } else if (!_pwm_config.ApplyConfiguration (pin)) {
212+ } else if (!_pwm_config.applyConfiguration (pin)) {
215213 LOG_LV1 (" TON" , " Failed applying configuration" );
216- } else if (!_pwm_config.StartPlayback ()) {
214+ } else if (!_pwm_config.startPlayback ()) {
217215 LOG_LV1 (" TON" , " Failed attempting to start PWM peripheral" );
218216 } else {
219217 // LOG_LV2("TON", "Started playback of tone at frequency %d duration %ld", frequency, duration);
@@ -224,10 +222,10 @@ void tone(uint8_t pin, unsigned int frequency, unsigned long duration)
224222void noTone (uint8_t pin)
225223{
226224 ( void )pin; // avoid unreferenced parameter compiler warning
227- _pwm_config.StopPlayback (true ); // release ownership of PWM peripheral
225+ _pwm_config.stopPlayback (true ); // release ownership of PWM peripheral
228226}
229227
230- bool TonePwmConfig::EnsurePwmPeripheralOwnership (void ) {
228+ bool TonePwmConfig::ensurePwmPeripheralOwnership (void ) {
231229 if (!_HwPWM->isOwner (TonePwmConfig::toneToken) && !_HwPWM->takeOwnership (TonePwmConfig::toneToken)) {
232230 LOG_LV1 (" TON" , " unable to allocate PWM2 to Tone" );
233231 return false ;
@@ -265,7 +263,7 @@ bool TonePwmConfig::EnsurePwmPeripheralOwnership(void) {
265263// COUNT += (start at SEQ0) ? (SEQ0.CNT * (SEQ0.REFRESH+1) : 0;
266264// COUNT += 1; // final SEQ1 emits single pulse
267265//
268- bool TonePwmConfig::InitializeFromPulseCountAndTimePeriod (uint64_t pulse_count_x, uint16_t time_period) {
266+ bool TonePwmConfig::initializeFromPulseCountAndTimePeriod (uint64_t pulse_count_x, uint16_t time_period) {
269267
270268 if (_bits_used (pulse_count_x) > 37 ) {
271269 LOG_LV1 (" TON" , " pulse count is limited to 37 bit long value" );
@@ -339,17 +337,17 @@ bool TonePwmConfig::InitializeFromPulseCountAndTimePeriod(uint64_t pulse_count_x
339337 this ->is_initialized = true ;
340338 return true ;
341339}
342- bool TonePwmConfig::ApplyConfiguration (uint32_t pin) {
340+ bool TonePwmConfig::applyConfiguration (uint32_t pin) {
343341 if (!this ->is_initialized ) {
344342 return false ;
345343 }
346344 if (pin >= PINS_COUNT) {
347345 return false ;
348346 }
349- if (!this ->EnsurePwmPeripheralOwnership ()) {
347+ if (!this ->ensurePwmPeripheralOwnership ()) {
350348 return false ;
351349 }
352- this ->StopPlayback (false );
350+ this ->stopPlayback (false );
353351
354352 this ->arduino_pin = pin;
355353 this ->nrf_pin = g_ADigitalPinMap[pin];
@@ -394,19 +392,19 @@ bool TonePwmConfig::ApplyConfiguration(uint32_t pin) {
394392 nrf_pwm_event_clear (_PWMInstance, NRF_PWM_EVENT_LOOPSDONE);
395393 return true ;
396394}
397- bool TonePwmConfig::StartPlayback (void ) {
395+ bool TonePwmConfig::startPlayback (void ) {
398396 if (!this ->is_initialized ) {
399397 LOG_LV1 (" TON" , " Cannot start playback without first initializing" );
400398 return false ;
401399 }
402- if (!this ->EnsurePwmPeripheralOwnership ()) {
400+ if (!this ->ensurePwmPeripheralOwnership ()) {
403401 LOG_LV1 (" TON" , " PWM peripheral not available for playback" );
404402 return false ;
405403 }
406404 nrf_pwm_task_trigger (_PWMInstance, this ->task_to_start );
407405 return true ;
408406}
409- bool TonePwmConfig::StopPlayback (bool releaseOwnership) {
407+ bool TonePwmConfig::stopPlayback (bool releaseOwnership) {
410408
411409 bool notInIsr = !isInISR ();
412410
0 commit comments