@@ -170,23 +170,23 @@ void tone(uint8_t pin, unsigned int frequency, unsigned long duration)
170
170
{
171
171
// limit frequency to reasonable audible range
172
172
if ((frequency < 20 ) | (frequency > 25000 )) {
173
- LOG_LV1 (" TON " , " frequency outside range [20..25000] -- ignoring" );
173
+ LOG_LV1 (" Tone " , " frequency outside range [20..25000] -- ignoring" );
174
174
return ;
175
175
}
176
176
uint64_t pulse_count = _calculate_pulse_count (frequency, duration);
177
177
uint16_t time_period = _calculate_time_period (frequency);
178
178
if (!_pwm_config.ensurePwmPeripheralOwnership ()) {
179
- LOG_LV1 (" TON " , " Unable to acquire PWM peripheral" );
179
+ LOG_LV1 (" Tone " , " Unable to acquire PWM peripheral" );
180
180
} else if (!_pwm_config.stopPlayback ()) {
181
- LOG_LV1 (" TON " , " Unable to stop playback" );
181
+ LOG_LV1 (" Tone " , " Unable to stop playback" );
182
182
} else if (!_pwm_config.initializeFromPulseCountAndTimePeriod (pulse_count, time_period)) {
183
- LOG_LV1 (" TON " , " Failed calculating configuration" );
183
+ LOG_LV1 (" Tone " , " Failed calculating configuration" );
184
184
} else if (!_pwm_config.applyConfiguration (pin)) {
185
- LOG_LV1 (" TON " , " Failed applying configuration" );
185
+ LOG_LV1 (" Tone " , " Failed applying configuration" );
186
186
} else if (!_pwm_config.startPlayback ()) {
187
- LOG_LV1 (" TON " , " Failed attempting to start PWM peripheral" );
187
+ LOG_LV1 (" Tone " , " Failed attempting to start PWM peripheral" );
188
188
} else {
189
- // LOG_LV2("TON ", "Started playback of tone at frequency %d duration %ld", frequency, duration);
189
+ // LOG_LV2("Tone ", "Started playback of tone at frequency %d duration %ld", frequency, duration);
190
190
}
191
191
return ;
192
192
}
@@ -199,7 +199,7 @@ void noTone(uint8_t pin)
199
199
200
200
bool TonePwmConfig::ensurePwmPeripheralOwnership (void ) {
201
201
if (!_HwPWM->isOwner (TonePwmConfig::toneToken) && !_HwPWM->takeOwnership (TonePwmConfig::toneToken)) {
202
- LOG_LV1 (" TON " , " unable to allocate PWM2 to Tone" );
202
+ LOG_LV1 (" Tone " , " unable to allocate PWM2 to Tone" );
203
203
return false ;
204
204
}
205
205
return true ;
@@ -238,7 +238,7 @@ bool TonePwmConfig::ensurePwmPeripheralOwnership(void) {
238
238
bool TonePwmConfig::initializeFromPulseCountAndTimePeriod (uint64_t pulse_count_x, uint16_t time_period) {
239
239
240
240
if (_bits_used (pulse_count_x) > 37 ) {
241
- LOG_LV1 (" TON " , " pulse count is limited to 37 bit long value" );
241
+ LOG_LV1 (" Tone " , " pulse count is limited to 37 bit long value" );
242
242
return false ;
243
243
}
244
244
@@ -332,14 +332,8 @@ bool TonePwmConfig::applyConfiguration(uint32_t pin) {
332
332
nrf_pwm_shorts_set (_PWMInstance, this ->shorts );
333
333
nrf_pwm_int_set (_PWMInstance, 0 );
334
334
335
- // static sequence value ... This is the value actually used
336
- // during playback ... do NOT modify without semaphore *and*
337
- // having ensured playback has stopped!
338
- static uint16_t seq_values; // static value
339
- seq_values = this ->duty_with_polarity ;
340
-
341
- nrf_pwm_seq_ptr_set (_PWMInstance, 0 , &seq_values);
342
- nrf_pwm_seq_ptr_set (_PWMInstance, 1 , &seq_values);
335
+ nrf_pwm_seq_ptr_set (_PWMInstance, 0 , &this ->duty_with_polarity );
336
+ nrf_pwm_seq_ptr_set (_PWMInstance, 1 , &this ->duty_with_polarity );
343
337
nrf_pwm_seq_cnt_set (_PWMInstance, 0 , 1 );
344
338
nrf_pwm_seq_cnt_set (_PWMInstance, 1 , 1 );
345
339
@@ -361,7 +355,7 @@ bool TonePwmConfig::applyConfiguration(uint32_t pin) {
361
355
362
356
bool TonePwmConfig::startPlayback (void ) {
363
357
if (!this ->ensurePwmPeripheralOwnership ()) {
364
- LOG_LV1 (" TON " , " PWM peripheral not available for playback" );
358
+ LOG_LV1 (" Tone " , " PWM peripheral not available for playback" );
365
359
return false ;
366
360
}
367
361
nrf_pwm_task_trigger (_PWMInstance, this ->task_to_start );
@@ -371,7 +365,7 @@ bool TonePwmConfig::startPlayback(void) {
371
365
bool TonePwmConfig::stopPlayback (bool releaseOwnership) {
372
366
373
367
if (!_HwPWM->isOwner (TonePwmConfig::toneToken)) {
374
- LOG_LV2 (" TON " , " Attempt to set noTone when not the owner of the PWM peripheral. Ignoring call...." );
368
+ LOG_LV2 (" Tone " , " Attempt to set noTone when not the owner of the PWM peripheral. Ignoring call...." );
375
369
return false ;
376
370
}
377
371
// ensure stopped and then disable
0 commit comments