summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucian Copeland <hierophect@gmail.com>2020-08-18 11:42:06 -0400
committerLucian Copeland <hierophect@gmail.com>2020-08-18 11:42:06 -0400
commitda75445cd58d0fbf72c6b323b1b0bd53197f9cf3 (patch)
tree8cea954b6bc6ce3a2949f57c24d3459a6ddfcd51
parentd0d6a951da9ef39f68a0d118db6c22c7e4ec9b2b (diff)
Style changes, reposition runtime errors
-rw-r--r--locale/circuitpython.pot4
-rw-r--r--ports/atmel-samd/common-hal/pulseio/PulseOut.c2
-rw-r--r--ports/cxd56/common-hal/pulseio/PulseOut.c2
-rw-r--r--ports/esp32s2/common-hal/neopixel_write/__init__.c3
-rw-r--r--ports/esp32s2/common-hal/pulseio/PulseIn.c3
-rw-r--r--ports/esp32s2/common-hal/pulseio/PulseOut.c7
-rw-r--r--ports/esp32s2/peripherals/rmt.c4
-rw-r--r--ports/nrf/common-hal/pulseio/PulseOut.c2
-rw-r--r--ports/stm/common-hal/pulseio/PulseOut.c2
-rw-r--r--shared-bindings/pulseio/PulseOut.c4
10 files changed, 22 insertions, 11 deletions
diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot
index b98e0e213..d9d5d6e17 100644
--- a/locale/circuitpython.pot
+++ b/locale/circuitpython.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2020-08-17 10:10-0400\n"
+"POT-Creation-Date: 2020-08-18 11:19-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -1334,7 +1334,7 @@ msgstr ""
#: ports/stm/common-hal/pulseio/PulseOut.c
msgid ""
"Port does not accept pins or frequency. "
-"Construct and pass a PWM Carrier instead"
+"Construct and pass a PWMOut Carrier instead"
msgstr ""
#: shared-bindings/_bleio/Adapter.c
diff --git a/ports/atmel-samd/common-hal/pulseio/PulseOut.c b/ports/atmel-samd/common-hal/pulseio/PulseOut.c
index de2f7b8d2..b53c8da2b 100644
--- a/ports/atmel-samd/common-hal/pulseio/PulseOut.c
+++ b/ports/atmel-samd/common-hal/pulseio/PulseOut.c
@@ -102,7 +102,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
uint16_t duty_cycle) {
if (!carrier || pin || frequency) {
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
- Construct and pass a PWM Carrier instead"));
+ Construct and pass a PWMOut Carrier instead"));
}
if (refcount == 0) {
diff --git a/ports/cxd56/common-hal/pulseio/PulseOut.c b/ports/cxd56/common-hal/pulseio/PulseOut.c
index 2851a0465..08081020f 100644
--- a/ports/cxd56/common-hal/pulseio/PulseOut.c
+++ b/ports/cxd56/common-hal/pulseio/PulseOut.c
@@ -65,7 +65,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
uint16_t duty_cycle) {
if (!carrier || pin || frequency) {
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
- Construct and pass a PWM Carrier instead"));
+ Construct and pass a PWMOut Carrier instead"));
}
if (pulse_fd < 0) {
diff --git a/ports/esp32s2/common-hal/neopixel_write/__init__.c b/ports/esp32s2/common-hal/neopixel_write/__init__.c
index 1fc976ec3..193d754f4 100644
--- a/ports/esp32s2/common-hal/neopixel_write/__init__.c
+++ b/ports/esp32s2/common-hal/neopixel_write/__init__.c
@@ -93,6 +93,9 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout
// Reserve channel
uint8_t number = digitalinout->pin->number;
rmt_channel_t channel = esp32s2_peripherals_find_and_reserve_rmt();
+ if (channel == RMT_CHANNEL_MAX) {
+ mp_raise_RuntimeError(translate("All timers in use"));
+ }
// Configure Channel
rmt_config_t config = RMT_DEFAULT_CONFIG_TX(number, channel);
diff --git a/ports/esp32s2/common-hal/pulseio/PulseIn.c b/ports/esp32s2/common-hal/pulseio/PulseIn.c
index d74162830..f7429ec12 100644
--- a/ports/esp32s2/common-hal/pulseio/PulseIn.c
+++ b/ports/esp32s2/common-hal/pulseio/PulseIn.c
@@ -105,6 +105,9 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, const mcu
// Find a free RMT Channel and configure it
rmt_channel_t channel = esp32s2_peripherals_find_and_reserve_rmt();
+ if (channel == RMT_CHANNEL_MAX) {
+ mp_raise_RuntimeError(translate("All timers in use"));
+ }
rmt_config_t config = RMT_DEFAULT_CONFIG_RX(pin->number, channel);
config.rx_config.filter_en = true;
config.rx_config.idle_threshold = 30000; // 30*3=90ms idle required to register a sequence
diff --git a/ports/esp32s2/common-hal/pulseio/PulseOut.c b/ports/esp32s2/common-hal/pulseio/PulseOut.c
index 463443ef0..a07ec39dc 100644
--- a/ports/esp32s2/common-hal/pulseio/PulseOut.c
+++ b/ports/esp32s2/common-hal/pulseio/PulseOut.c
@@ -42,6 +42,9 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
}
rmt_channel_t channel = esp32s2_peripherals_find_and_reserve_rmt();
+ if (channel == RMT_CHANNEL_MAX) {
+ mp_raise_RuntimeError(translate("All timers in use"));
+ }
// Configure Channel
rmt_config_t config = RMT_DEFAULT_CONFIG_TX(pin->number, channel);
@@ -82,5 +85,7 @@ void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t* self, uint16_t* pu
}
rmt_write_items(self->channel, items, length, true);
- rmt_wait_tx_done(self->channel, pdMS_TO_TICKS(100));
+ while (rmt_wait_tx_done(self->channel, 0) != ESP_OK) {
+ RUN_BACKGROUND_TASKS();
+ }
}
diff --git a/ports/esp32s2/peripherals/rmt.c b/ports/esp32s2/peripherals/rmt.c
index 16605edf5..b7629dbd5 100644
--- a/ports/esp32s2/peripherals/rmt.c
+++ b/ports/esp32s2/peripherals/rmt.c
@@ -44,8 +44,8 @@ rmt_channel_t esp32s2_peripherals_find_and_reserve_rmt(void) {
return i;
}
}
- mp_raise_RuntimeError(translate("All timers in use"));
- return false;
+ // Returning the max indicates a reservation failure.
+ return RMT_CHANNEL_MAX;
}
void esp32s2_peripherals_free_rmt(rmt_channel_t chan) {
diff --git a/ports/nrf/common-hal/pulseio/PulseOut.c b/ports/nrf/common-hal/pulseio/PulseOut.c
index 9f5efcfdc..bdc5cfbef 100644
--- a/ports/nrf/common-hal/pulseio/PulseOut.c
+++ b/ports/nrf/common-hal/pulseio/PulseOut.c
@@ -106,7 +106,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
uint16_t duty_cycle) {
if (!carrier || pin || frequency) {
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
- Construct and pass a PWM Carrier instead"));
+ Construct and pass a PWMOut Carrier instead"));
}
if (refcount == 0) {
diff --git a/ports/stm/common-hal/pulseio/PulseOut.c b/ports/stm/common-hal/pulseio/PulseOut.c
index 33311fd53..eec1049dd 100644
--- a/ports/stm/common-hal/pulseio/PulseOut.c
+++ b/ports/stm/common-hal/pulseio/PulseOut.c
@@ -119,7 +119,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
uint16_t duty_cycle) {
if (!carrier || pin || frequency) {
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
- Construct and pass a PWM Carrier instead"));
+ Construct and pass a PWMOut Carrier instead"));
}
// Add to active PulseOuts
diff --git a/shared-bindings/pulseio/PulseOut.c b/shared-bindings/pulseio/PulseOut.c
index 2adbc3cf6..3fd722558 100644
--- a/shared-bindings/pulseio/PulseOut.c
+++ b/shared-bindings/pulseio/PulseOut.c
@@ -71,11 +71,11 @@ STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_ar
mp_obj_t carrier_obj = pos_args[0];
if (MP_OBJ_IS_TYPE(carrier_obj, &pulseio_pwmout_type)) {
- // PWM Carrier
+ // Use a PWMOut Carrier
mp_arg_check_num(n_args, kw_args, 1, 1, false);
common_hal_pulseio_pulseout_construct(self, (pulseio_pwmout_obj_t *)MP_OBJ_TO_PTR(carrier_obj), NULL, 0, 0);
} else {
- // Pin and Frequency
+ // Use a Pin, frequency, and duty cycle
enum { ARG_pin, ARG_frequency};
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ },