diff --git a/cores/nRF5/HardwarePWM.cpp b/cores/nRF5/HardwarePWM.cpp index 30622044..e29f538a 100644 --- a/cores/nRF5/HardwarePWM.cpp +++ b/cores/nRF5/HardwarePWM.cpp @@ -110,21 +110,12 @@ bool HardwarePWM::takeOwnership(uintptr_t token) } } if (this->_owner_token != 0) { - if (notInIsr) { - LOG_LV3("HwPWM", "failing to acquire ownership because already owned by other token"); - } return false; } if (this->usedChannelCount() != 0) { - if (notInIsr) { - LOG_LV3("HwPWM", "failing to acquire ownership because at least one channel connected"); - } return false; } if (this->enabled()) { - if (notInIsr) { - LOG_LV3("HwPWM", "failing to acquire ownership because peripheral is already enabled"); - } return false; } // TODO: warn, but do not fail, if taking ownership with IRQs already enabled diff --git a/cores/nRF5/Tone.cpp b/cores/nRF5/Tone.cpp index 4aff6741..70e365ba 100644 --- a/cores/nRF5/Tone.cpp +++ b/cores/nRF5/Tone.cpp @@ -277,8 +277,6 @@ bool TONE_PWM_CONFIG::InitializeFromPulseCountAndTimePeriod(uint64_t pulse_count this->duty_with_polarity = 0x8000U | (time_period / 2U); if (this->pulse_count == 0) { - LOG_LV3("TON", "Infinite duration requested\n"); - this->seq0_refresh = 0xFFFFFFU; // 24-bit maximum value this->seq1_refresh = 0xFFFFFFU; // 24-bit maximum value this->loop_count = 0xFFFFU; // 16-bit maximum value @@ -286,8 +284,7 @@ bool TONE_PWM_CONFIG::InitializeFromPulseCountAndTimePeriod(uint64_t pulse_count this->shorts = NRF_PWM_SHORT_LOOPSDONE_SEQSTART0_MASK; } else if (this->pulse_count == 1) { - LOG_LV3("TON", "Edge case: exactly one pulse\n"); - // yes, this is an edge case + // yes, this is an edge case; e.g., frequency == 100, duration == 100 causes this this->seq0_refresh = 0; this->seq1_refresh = 0; this->loop_count = 1; @@ -295,8 +292,6 @@ bool TONE_PWM_CONFIG::InitializeFromPulseCountAndTimePeriod(uint64_t pulse_count this->shorts = NRF_PWM_SHORT_LOOPSDONE_STOP_MASK; } else { - LOG_LV3("TON", "Non-infinite duration of at least two pulses requested\n"); - // This is the interesting section. // // 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 // NOTE: Due to final SEQ1 outputting exactly one pulse, may need one additional bit for loop count // ... but that will still be within the 16 bits available, because top of range is 13 bits. - LOG_LV3("TON", "Using %d bits for refresh, and %d bits for loop_count\n", bits_for_refresh, bits_for_loop_count); // now determine how many PWM pulses should occur per loop (when both SEQ0 and SEQ1 are played) uint32_t total_refresh_count = 1 << bits_for_refresh; // range is [2 .. 2^24] uint32_t full_loops = (this->pulse_count - 1) / total_refresh_count; // == loopCount - 1 - LOG_LV3("TON", "total_refresh_count is 0x%" PRIx32 " (%" PRIu32 ")\n", total_refresh_count, total_refresh_count); - LOG_LV3("TON", "full_loops is 0x%" PRIx32 " (%" PRIu32 ")\n", full_loops, full_loops); - // if (pulses - 1) % total_refresh_count == 0, then start at SEQ1 and split refresh evenly // else, start at SEQ0, and set SEQ0 to extra pulses needed... uint32_t extraPulsesNeededIfStartingAtSequence1 = (this->pulse_count - 1) % total_refresh_count; uint32_t seq0_count; if (extraPulsesNeededIfStartingAtSequence1 == 0) { - LOG_LV3("TON", "Pulse count (minus one) is exact multiple of total_refresh_count -- starting at SEQ1\n"); seq0_count = total_refresh_count / 2; // range is [1 .. 2^23] this->task_to_start = NRF_PWM_TASK_SEQSTART1; } else { - LOG_LV3("TON", "Pulse count (minus one) requires extra %" PRIu32 " pulses ... setting SEQ0 to that value\n", extraPulsesNeededIfStartingAtSequence1); seq0_count = extraPulsesNeededIfStartingAtSequence1; this->task_to_start = NRF_PWM_TASK_SEQSTART0; } this->loop_count = full_loops + 1; this->seq0_refresh = seq0_count - 1; this->seq1_refresh = (total_refresh_count - seq0_count) - 1; - - LOG_LV3("TON", "seq0_count is %" PRIu32 ", so refresh will be set to %" PRIu32 "\n", seq0_count, this->seq0_refresh); - LOG_LV3("TON", "seq1_count is %" PRIu32 ", so refresh will be set to %" PRIu32 "\n", (total_refresh_count - seq0_count), this->seq1_refresh); - this->shorts = NRF_PWM_SHORT_LOOPSDONE_STOP_MASK; } this->is_initialized = true; diff --git a/cores/nRF5/common_func.h b/cores/nRF5/common_func.h index c6229b8a..ad42c626 100644 --- a/cores/nRF5/common_func.h +++ b/cores/nRF5/common_func.h @@ -172,14 +172,6 @@ const char* dbg_err_str(int32_t err_id); // TODO move to other place #define LOG_LV2_BUFFER(...) #endif -#if CFG_DEBUG >= 3 -#define LOG_LV3(...) ADALOG(__VA_ARGS__) -#define LOG_LV3_BUFFER(...) ADALOG_BUFFER(__VA_ARGS__) -#else -#define LOG_LV3(...) -#define LOG_LV3_BUFFER(...) -#endif - #if CFG_DEBUG #define PRINT_LOCATION() PRINTF("%s: %d:\n", __PRETTY_FUNCTION__, __LINE__) diff --git a/cores/nRF5/wiring_analog.cpp b/cores/nRF5/wiring_analog.cpp index 5267a64c..7c1ac04f 100644 --- a/cores/nRF5/wiring_analog.cpp +++ b/cores/nRF5/wiring_analog.cpp @@ -96,11 +96,9 @@ void analogWrite( uint32_t pin, uint32_t value ) for(int i=0; iisOwner(_analogToken)) { - LOG_LV3("ANA", "not currently owner of PWM %d", i); continue; } if (!HwPWMx[i]->addPin(pin)) { - LOG_LV3("ANA", "could not add pin %" PRIu32 " to PWM %d", pin, i); continue; } @@ -116,7 +114,6 @@ void analogWrite( uint32_t pin, uint32_t value ) for(int i=0; itakeOwnership(_analogToken)) { - LOG_LV3("ANA", "Could not take ownership of PWM %d", i); continue; }