Skip to content

Commit da75445

Browse files
committed
Style changes, reposition runtime errors
1 parent d0d6a95 commit da75445

File tree

10 files changed

+22
-11
lines changed

10 files changed

+22
-11
lines changed

locale/circuitpython.pot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2020-08-17 10:10-0400\n"
11+
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -1334,7 +1334,7 @@ msgstr ""
13341334
#: ports/stm/common-hal/pulseio/PulseOut.c
13351335
msgid ""
13361336
"Port does not accept pins or frequency. "
1337-
"Construct and pass a PWM Carrier instead"
1337+
"Construct and pass a PWMOut Carrier instead"
13381338
msgstr ""
13391339

13401340
#: shared-bindings/_bleio/Adapter.c

ports/atmel-samd/common-hal/pulseio/PulseOut.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
102102
uint16_t duty_cycle) {
103103
if (!carrier || pin || frequency) {
104104
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
105-
Construct and pass a PWM Carrier instead"));
105+
Construct and pass a PWMOut Carrier instead"));
106106
}
107107

108108
if (refcount == 0) {

ports/cxd56/common-hal/pulseio/PulseOut.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
6565
uint16_t duty_cycle) {
6666
if (!carrier || pin || frequency) {
6767
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
68-
Construct and pass a PWM Carrier instead"));
68+
Construct and pass a PWMOut Carrier instead"));
6969
}
7070

7171
if (pulse_fd < 0) {

ports/esp32s2/common-hal/neopixel_write/__init__.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout
9393
// Reserve channel
9494
uint8_t number = digitalinout->pin->number;
9595
rmt_channel_t channel = esp32s2_peripherals_find_and_reserve_rmt();
96+
if (channel == RMT_CHANNEL_MAX) {
97+
mp_raise_RuntimeError(translate("All timers in use"));
98+
}
9699

97100
// Configure Channel
98101
rmt_config_t config = RMT_DEFAULT_CONFIG_TX(number, channel);

ports/esp32s2/common-hal/pulseio/PulseIn.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, const mcu
105105

106106
// Find a free RMT Channel and configure it
107107
rmt_channel_t channel = esp32s2_peripherals_find_and_reserve_rmt();
108+
if (channel == RMT_CHANNEL_MAX) {
109+
mp_raise_RuntimeError(translate("All timers in use"));
110+
}
108111
rmt_config_t config = RMT_DEFAULT_CONFIG_RX(pin->number, channel);
109112
config.rx_config.filter_en = true;
110113
config.rx_config.idle_threshold = 30000; // 30*3=90ms idle required to register a sequence

ports/esp32s2/common-hal/pulseio/PulseOut.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
4242
}
4343

4444
rmt_channel_t channel = esp32s2_peripherals_find_and_reserve_rmt();
45+
if (channel == RMT_CHANNEL_MAX) {
46+
mp_raise_RuntimeError(translate("All timers in use"));
47+
}
4548

4649
// Configure Channel
4750
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
8285
}
8386

8487
rmt_write_items(self->channel, items, length, true);
85-
rmt_wait_tx_done(self->channel, pdMS_TO_TICKS(100));
88+
while (rmt_wait_tx_done(self->channel, 0) != ESP_OK) {
89+
RUN_BACKGROUND_TASKS();
90+
}
8691
}

ports/esp32s2/peripherals/rmt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ rmt_channel_t esp32s2_peripherals_find_and_reserve_rmt(void) {
4444
return i;
4545
}
4646
}
47-
mp_raise_RuntimeError(translate("All timers in use"));
48-
return false;
47+
// Returning the max indicates a reservation failure.
48+
return RMT_CHANNEL_MAX;
4949
}
5050

5151
void esp32s2_peripherals_free_rmt(rmt_channel_t chan) {

ports/nrf/common-hal/pulseio/PulseOut.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
106106
uint16_t duty_cycle) {
107107
if (!carrier || pin || frequency) {
108108
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
109-
Construct and pass a PWM Carrier instead"));
109+
Construct and pass a PWMOut Carrier instead"));
110110
}
111111

112112
if (refcount == 0) {

ports/stm/common-hal/pulseio/PulseOut.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
119119
uint16_t duty_cycle) {
120120
if (!carrier || pin || frequency) {
121121
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
122-
Construct and pass a PWM Carrier instead"));
122+
Construct and pass a PWMOut Carrier instead"));
123123
}
124124

125125
// Add to active PulseOuts

shared-bindings/pulseio/PulseOut.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_ar
7171

7272
mp_obj_t carrier_obj = pos_args[0];
7373
if (MP_OBJ_IS_TYPE(carrier_obj, &pulseio_pwmout_type)) {
74-
// PWM Carrier
74+
// Use a PWMOut Carrier
7575
mp_arg_check_num(n_args, kw_args, 1, 1, false);
7676
common_hal_pulseio_pulseout_construct(self, (pulseio_pwmout_obj_t *)MP_OBJ_TO_PTR(carrier_obj), NULL, 0, 0);
7777
} else {
78-
// Pin and Frequency
78+
// Use a Pin, frequency, and duty cycle
7979
enum { ARG_pin, ARG_frequency};
8080
static const mp_arg_t allowed_args[] = {
8181
{ MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ },

0 commit comments

Comments
 (0)