summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2018-05-14 16:36:43 -0400
committerGitHub <noreply@github.com>2018-05-14 16:36:43 -0400
commitd655e2194c8cc5d17a8e86c78104912228f09550 (patch)
treea1f271f25287d4e9fa98379c69b2b0c29fcc6295
parent321f882b6c301548256e7245c7b72b4c0d3ee727 (diff)
parenta0954b9e11f9d768908858855fdc96d7814633c6 (diff)
Merge pull request #833 from rhooper/master
Fix for Issue #770 - Provide a better error message when timers are s…
-rw-r--r--ports/atmel-samd/common-hal/pulseio/PWMOut.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ports/atmel-samd/common-hal/pulseio/PWMOut.c b/ports/atmel-samd/common-hal/pulseio/PWMOut.c
index f1464c4b4..24cd154c2 100644
--- a/ports/atmel-samd/common-hal/pulseio/PWMOut.c
+++ b/ports/atmel-samd/common-hal/pulseio/PWMOut.c
@@ -151,6 +151,7 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
// one output so we start with the TCs to see if they work.
int8_t direction = -1;
uint8_t start = NUM_TIMERS_PER_PIN - 1;
+ bool found = false;
if (variable_frequency) {
direction = 1;
start = 0;
@@ -162,6 +163,7 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
continue;
}
if (t->is_tc) {
+ found = true;
Tc* tc = tc_insts[t->index];
if (tc->COUNT16.CTRLA.bit.ENABLE == 0 && t->wave_output == 1) {
timer = t;
@@ -177,7 +179,11 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
}
if (timer == NULL) {
- mp_raise_RuntimeError("All timers in use");
+ if (found) {
+ mp_raise_ValueError("All timers for this pin are in use");
+ } else {
+ mp_raise_RuntimeError("All timers in use");
+ }
return;
}