diff options
| author | Dan Halbert <halbert@halwitz.org> | 2021-03-11 08:52:47 -0500 |
|---|---|---|
| committer | Dan Halbert <halbert@halwitz.org> | 2021-03-11 08:52:47 -0500 |
| commit | 08c5dbb0033c2f3838d7d52f98d3844a56253f81 (patch) | |
| tree | 81c6967882451709878cd9380d48feb7cb7246c6 /ports/esp32s2 | |
| parent | 702978398573a652fb5df5540669424d3fa54c78 (diff) | |
use return values in STM PWMOut constructor, not exceptions
Diffstat (limited to 'ports/esp32s2')
| -rw-r--r-- | ports/esp32s2/boards/adafruit_funhouse/board.c | 10 | ||||
| -rw-r--r-- | ports/esp32s2/boards/adafruit_funhouse/pins.c | 2 | ||||
| -rw-r--r-- | ports/esp32s2/common-hal/pwmio/PWMOut.c | 6 |
3 files changed, 11 insertions, 7 deletions
diff --git a/ports/esp32s2/boards/adafruit_funhouse/board.c b/ports/esp32s2/boards/adafruit_funhouse/board.c index 1b3505378..09eb9266e 100644 --- a/ports/esp32s2/boards/adafruit_funhouse/board.c +++ b/ports/esp32s2/boards/adafruit_funhouse/board.c @@ -54,8 +54,8 @@ void board_init(void) { // Debug UART #ifdef DEBUG - common_hal_never_reset_pin(&pin_GPIO43); - common_hal_never_reset_pin(&pin_GPIO44); + common_hal_never_reset_pin(&pin_GPIO37); + common_hal_never_reset_pin(&pin_GPIO38); #endif /* DEBUG */ busio_spi_obj_t* spi = &displays[0].fourwire_bus.inline_bus; @@ -73,9 +73,13 @@ void board_init(void) { 0, // Polarity 0); // Phase + // workaround as board_init() is called before reset_port() in main.c + pwmout_reset(); + displayio_display_obj_t* display = &displays[0].display; display->base.type = &displayio_display_type; - common_hal_displayio_display_construct(display, + common_hal_displayio_display_construct( + display, bus, 240, // Width (after rotation) 240, // Height (after rotation) diff --git a/ports/esp32s2/boards/adafruit_funhouse/pins.c b/ports/esp32s2/boards/adafruit_funhouse/pins.c index 2721a301c..0ad5beb6c 100644 --- a/ports/esp32s2/boards/adafruit_funhouse/pins.c +++ b/ports/esp32s2/boards/adafruit_funhouse/pins.c @@ -33,7 +33,7 @@ STATIC const mp_rom_map_elem_t board_global_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_LIGHT), MP_ROM_PTR(&pin_GPIO18) }, - { MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO46) }, +// { MP_ROM_QSTR(MP_QSTR_SPEAKER), MP_ROM_PTR(&pin_GPIO46) }, { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_GPIO37) }, diff --git a/ports/esp32s2/common-hal/pwmio/PWMOut.c b/ports/esp32s2/common-hal/pwmio/PWMOut.c index e1fdd4760..dfba42bb8 100644 --- a/ports/esp32s2/common-hal/pwmio/PWMOut.c +++ b/ports/esp32s2/common-hal/pwmio/PWMOut.c @@ -93,7 +93,7 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self, } if (timer_index == INDEX_EMPTY) { // Running out of timers isn't pin related on ESP32S2 so we can't re-use error messages - mp_raise_ValueError(translate("No more timers available")); + return PWMOUT_ALL_TIMERS_IN_USE; } // Find a viable channel @@ -104,7 +104,7 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self, } } if (channel_index == INDEX_EMPTY) { - mp_raise_ValueError(translate("No more channels available")); + return PWMOUT_ALL_CHANNELS_IN_USE; } // Run configuration @@ -126,7 +126,7 @@ pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self, self->chan_handle.timer_sel = timer_index; if (ledc_channel_config(&(self->chan_handle))) { - mp_raise_ValueError(translate("Could not initialize channel")); + return PWMOUT_INITIALIZATION_ERROR; } // Make reservations |
