@@ -277,26 +277,21 @@ bool TONE_PWM_CONFIG::InitializeFromPulseCountAndTimePeriod(uint64_t pulse_count
277277 this ->duty_with_polarity = 0x8000U | (time_period / 2U );
278278
279279 if (this ->pulse_count == 0 ) {
280- LOG_LV3 (" TON" , " Infinite duration requested\n " );
281-
282280 this ->seq0_refresh = 0xFFFFFFU ; // 24-bit maximum value
283281 this ->seq1_refresh = 0xFFFFFFU ; // 24-bit maximum value
284282 this ->loop_count = 0xFFFFU ; // 16-bit maximum value
285283 this ->task_to_start = NRF_PWM_TASK_SEQSTART0;
286284 this ->shorts = NRF_PWM_SHORT_LOOPSDONE_SEQSTART0_MASK;
287285 }
288286 else if (this ->pulse_count == 1 ) {
289- LOG_LV3 (" TON" , " Edge case: exactly one pulse\n " );
290- // yes, this is an edge case
287+ // yes, this is an edge case; e.g., frequency == 100, duration == 100 causes this
291288 this ->seq0_refresh = 0 ;
292289 this ->seq1_refresh = 0 ;
293290 this ->loop_count = 1 ;
294291 this ->task_to_start = NRF_PWM_TASK_SEQSTART1;
295292 this ->shorts = NRF_PWM_SHORT_LOOPSDONE_STOP_MASK;
296293 }
297294 else {
298- LOG_LV3 (" TON" , " Non-infinite duration of at least two pulses requested\n " );
299-
300295 // This is the interesting section.
301296 //
302297 // To ensure refresh value stays within 24 bits, the maximum number of bits
@@ -318,37 +313,27 @@ bool TONE_PWM_CONFIG::InitializeFromPulseCountAndTimePeriod(uint64_t pulse_count
318313
319314 // NOTE: Due to final SEQ1 outputting exactly one pulse, may need one additional bit for loop count
320315 // ... but that will still be within the 16 bits available, because top of range is 13 bits.
321- LOG_LV3 (" TON" , " Using %d bits for refresh, and %d bits for loop_count\n " , bits_for_refresh, bits_for_loop_count);
322316
323317 // now determine how many PWM pulses should occur per loop (when both SEQ0 and SEQ1 are played)
324318 uint32_t total_refresh_count = 1 << bits_for_refresh; // range is [2 .. 2^24]
325319 uint32_t full_loops = (this ->pulse_count - 1 ) / total_refresh_count; // == loopCount - 1
326320
327- LOG_LV3 (" TON" , " total_refresh_count is 0x%" PRIx32 " (%" PRIu32 " )\n " , total_refresh_count, total_refresh_count);
328- LOG_LV3 (" TON" , " full_loops is 0x%" PRIx32 " (%" PRIu32 " )\n " , full_loops, full_loops);
329-
330321 // if (pulses - 1) % total_refresh_count == 0, then start at SEQ1 and split refresh evenly
331322 // else, start at SEQ0, and set SEQ0 to extra pulses needed...
332323 uint32_t extraPulsesNeededIfStartingAtSequence1 = (this ->pulse_count - 1 ) % total_refresh_count;
333324 uint32_t seq0_count;
334325
335326 if (extraPulsesNeededIfStartingAtSequence1 == 0 ) {
336- LOG_LV3 (" TON" , " Pulse count (minus one) is exact multiple of total_refresh_count -- starting at SEQ1\n " );
337327 seq0_count = total_refresh_count / 2 ; // range is [1 .. 2^23]
338328 this ->task_to_start = NRF_PWM_TASK_SEQSTART1;
339329 }
340330 else {
341- LOG_LV3 (" TON" , " Pulse count (minus one) requires extra %" PRIu32 " pulses ... setting SEQ0 to that value\n " , extraPulsesNeededIfStartingAtSequence1);
342331 seq0_count = extraPulsesNeededIfStartingAtSequence1;
343332 this ->task_to_start = NRF_PWM_TASK_SEQSTART0;
344333 }
345334 this ->loop_count = full_loops + 1 ;
346335 this ->seq0_refresh = seq0_count - 1 ;
347336 this ->seq1_refresh = (total_refresh_count - seq0_count) - 1 ;
348-
349- LOG_LV3 (" TON" , " seq0_count is %" PRIu32 " , so refresh will be set to %" PRIu32 " \n " , seq0_count, this ->seq0_refresh );
350- LOG_LV3 (" TON" , " seq1_count is %" PRIu32 " , so refresh will be set to %" PRIu32 " \n " , (total_refresh_count - seq0_count), this ->seq1_refresh );
351-
352337 this ->shorts = NRF_PWM_SHORT_LOOPSDONE_STOP_MASK;
353338 }
354339 this ->is_initialized = true ;
0 commit comments