From 5f082561b32ea010b9bd2a2f797d577d037cae46 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Thu, 20 Jul 2023 11:16:31 -0700 Subject: [PATCH] Unify some error strings --- locale/circuitpython.pot | 70 +++++-------------- ports/broadcom/common-hal/busio/UART.c | 4 +- ports/espressif/common-hal/busio/SPI.c | 8 +-- ports/espressif/common-hal/busio/UART.c | 4 +- ports/mimxrt10xx/common-hal/busio/SPI.c | 13 ++-- ports/mimxrt10xx/common-hal/busio/UART.c | 4 +- ports/nrf/common-hal/busio/UART.c | 4 +- ports/raspberrypi/common-hal/busio/UART.c | 4 +- ports/silabs/common-hal/busio/I2C.c | 2 +- ports/silabs/common-hal/busio/SPI.c | 2 +- ports/silabs/common-hal/busio/UART.c | 2 +- ports/stm/common-hal/busio/I2C.c | 2 +- ports/stm/common-hal/busio/SPI.c | 15 ++-- ports/stm/common-hal/busio/UART.c | 4 +- ports/stm/common-hal/canio/CAN.c | 2 +- ports/stm/common-hal/sdioio/SDCard.c | 2 +- shared-bindings/displayio/FourWire.c | 2 +- shared-bindings/displayio/I2CDisplay.c | 2 +- shared-bindings/paralleldisplay/ParallelBus.c | 2 +- shared-module/bitbangio/SPI.c | 11 +-- 20 files changed, 65 insertions(+), 94 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 368836a4db..9ebb85d13f 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -126,8 +126,10 @@ msgstr "" #: ports/espressif/common-hal/espulp/ULP.c #: ports/mimxrt10xx/common-hal/audiobusio/__init__.c +#: ports/mimxrt10xx/common-hal/usb_host/Port.c #: ports/raspberrypi/common-hal/picodvi/Framebuffer.c #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c +#: ports/raspberrypi/common-hal/usb_host/Port.c #: shared-bindings/digitalio/DigitalInOut.c #: shared-bindings/microcontroller/Pin.c msgid "%q in use" @@ -182,6 +184,7 @@ msgid "%q must be 1 when %q is True" msgstr "" #: py/argcheck.c shared-bindings/gifio/GifWriter.c +#: shared-module/gifio/OnDiskGif.c msgid "%q must be <= %d" msgstr "" @@ -779,10 +782,6 @@ msgstr "" msgid "Cannot subclass slice" msgstr "" -#: shared-module/bitbangio/SPI.c -msgid "Cannot transfer without MOSI and MISO pins" -msgstr "" - #: shared-bindings/pwmio/PWMOut.c msgid "Cannot vary frequency on a timer that is already in use" msgstr "" @@ -1090,13 +1089,10 @@ msgstr "" msgid "Half duplex SPI is not implemented" msgstr "" -#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/stm/common-hal/busio/I2C.c -#: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/canio/CAN.c -#: ports/stm/common-hal/sdioio/SDCard.c -msgid "Hardware busy, try alternative pins" -msgstr "" - -#: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/stm/common-hal/busio/I2C.c +#: ports/stm/common-hal/busio/SPI.c ports/stm/common-hal/busio/UART.c +#: ports/stm/common-hal/canio/CAN.c ports/stm/common-hal/sdioio/SDCard.c msgid "Hardware in use, try alternative pins" msgstr "" @@ -1355,14 +1351,6 @@ msgstr "" msgid "Mismatched swap flag" msgstr "" -#: ports/mimxrt10xx/common-hal/busio/SPI.c -msgid "Missing MISO or MOSI Pin" -msgstr "" - -#: ports/stm/common-hal/busio/SPI.c -msgid "Missing MISO or MOSI pin" -msgstr "" - #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #, c-format msgid "Missing first_in_pin. Instruction %d reads pin(s)" @@ -1436,6 +1424,14 @@ msgid "Nimble out of memory" msgstr "" #: ports/atmel-samd/common-hal/busio/UART.c +#: ports/espressif/common-hal/busio/SPI.c +#: ports/espressif/common-hal/busio/UART.c +#: ports/mimxrt10xx/common-hal/busio/SPI.c +#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c +#: ports/raspberrypi/common-hal/busio/UART.c ports/stm/common-hal/busio/SPI.c +#: ports/stm/common-hal/busio/UART.c shared-bindings/displayio/FourWire.c +#: shared-bindings/displayio/I2CDisplay.c +#: shared-bindings/paralleldisplay/ParallelBus.c shared-module/bitbangio/SPI.c msgid "No %q pin" msgstr "" @@ -1469,36 +1465,6 @@ msgstr "" msgid "No IP" msgstr "" -#: ports/espressif/common-hal/busio/SPI.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c -msgid "No MISO Pin" -msgstr "" - -#: ports/stm/common-hal/busio/SPI.c shared-module/bitbangio/SPI.c -msgid "No MISO pin" -msgstr "" - -#: ports/espressif/common-hal/busio/SPI.c -#: ports/mimxrt10xx/common-hal/busio/SPI.c -msgid "No MOSI Pin" -msgstr "" - -#: ports/stm/common-hal/busio/SPI.c shared-module/bitbangio/SPI.c -msgid "No MOSI pin" -msgstr "" - -#: ports/espressif/common-hal/busio/UART.c -#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c -#: ports/raspberrypi/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c -msgid "No RX pin" -msgstr "" - -#: ports/espressif/common-hal/busio/UART.c -#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c -#: ports/raspberrypi/common-hal/busio/UART.c ports/stm/common-hal/busio/UART.c -msgid "No TX pin" -msgstr "" - #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c msgid "No available clocks" msgstr "" @@ -2405,6 +2371,7 @@ msgstr "" #: ports/espressif/boards/m5stack_core_basic/mpconfigboard.h #: ports/espressif/boards/m5stack_core_fire/mpconfigboard.h #: ports/espressif/boards/m5stack_stick_c/mpconfigboard.h +#: ports/espressif/boards/m5stack_stick_c_plus/mpconfigboard.h msgid "You pressed button A at start up." msgstr "" @@ -3628,11 +3595,6 @@ msgstr "" msgid "no module named '%q'" msgstr "" -#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c -#: shared-bindings/paralleldisplay/ParallelBus.c -msgid "no reset pin available" -msgstr "" - #: shared-module/sdcardio/SDCard.c msgid "no response from SD card" msgstr "" diff --git a/ports/broadcom/common-hal/busio/UART.c b/ports/broadcom/common-hal/busio/UART.c index 5be098cf03..0eb72b1456 100644 --- a/ports/broadcom/common-hal/busio/UART.c +++ b/ports/broadcom/common-hal/busio/UART.c @@ -352,7 +352,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { // Write characters. size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { if (self->tx_pin == NULL) { - mp_raise_ValueError(translate("No TX pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx); } COMPLETE_MEMORY_READS; @@ -400,7 +400,7 @@ STATIC void enable_interrupt(busio_uart_obj_t *self) { // Read characters. size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { if (self->rx_pin == NULL) { - mp_raise_ValueError(translate("No RX pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx); } if (len == 0) { diff --git a/ports/espressif/common-hal/busio/SPI.c b/ports/espressif/common-hal/busio/SPI.c index 5218fdbf9d..0b6b395c51 100644 --- a/ports/espressif/common-hal/busio/SPI.c +++ b/ports/espressif/common-hal/busio/SPI.c @@ -186,7 +186,7 @@ void common_hal_busio_spi_unlock(busio_spi_obj_t *self) { bool common_hal_busio_spi_write(busio_spi_obj_t *self, const uint8_t *data, size_t len) { if (self->MOSI == NULL) { - mp_raise_ValueError(translate("No MOSI Pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); } return common_hal_busio_spi_transfer(self, data, NULL, len); } @@ -194,7 +194,7 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self, bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size_t len, uint8_t write_value) { if (self->MISO == NULL) { - mp_raise_ValueError(translate("No MISO Pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso); } if (self->MOSI == NULL) { return common_hal_busio_spi_transfer(self, NULL, data, len); @@ -210,10 +210,10 @@ bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, return true; } if (self->MOSI == NULL && data_out != NULL) { - mp_raise_ValueError(translate("No MOSI Pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); } if (self->MISO == NULL && data_in != NULL) { - mp_raise_ValueError(translate("No MISO Pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso); } spi_transaction_t transactions[MAX_SPI_TRANSACTIONS]; diff --git a/ports/espressif/common-hal/busio/UART.c b/ports/espressif/common-hal/busio/UART.c index c13bdedac0..37e0092726 100644 --- a/ports/espressif/common-hal/busio/UART.c +++ b/ports/espressif/common-hal/busio/UART.c @@ -304,7 +304,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { // Read characters. size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { if (self->rx_pin == NULL) { - mp_raise_ValueError(translate("No RX pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx); } if (len == 0) { // Nothing to read. @@ -357,7 +357,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // Write characters. size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { if (self->tx_pin == NULL) { - mp_raise_ValueError(translate("No TX pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx); } size_t left_to_write = len; diff --git a/ports/mimxrt10xx/common-hal/busio/SPI.c b/ports/mimxrt10xx/common-hal/busio/SPI.c index 1ab9394244..e32b635611 100644 --- a/ports/mimxrt10xx/common-hal/busio/SPI.c +++ b/ports/mimxrt10xx/common-hal/busio/SPI.c @@ -182,7 +182,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, self->spi = mcu_spi_banks[self->clock->bank_idx - 1]; } else { if (spi_taken) { - mp_raise_ValueError(translate("Hardware busy, try alternative pins")); + mp_raise_ValueError(translate("Hardware in use, try alternative pins")); } else { raise_ValueError_invalid_pins(); } @@ -331,7 +331,7 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self, return true; } if (self->mosi == NULL) { - mp_raise_ValueError(translate("No MOSI Pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); } lpspi_transfer_t xfer = { 0 }; @@ -349,7 +349,7 @@ bool common_hal_busio_spi_read(busio_spi_obj_t *self, return true; } if (self->miso == NULL) { - mp_raise_ValueError(translate("No MISO Pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso); } LPSPI_SetDummyData(self->spi, write_value); @@ -367,8 +367,11 @@ bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, const uint8_t *data_ou if (len == 0) { return true; } - if (self->miso == NULL || self->mosi == NULL) { - mp_raise_ValueError(translate("Missing MISO or MOSI Pin")); + if (self->MOSI == NULL && data_out != NULL) { + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); + } + if (self->MISO == NULL && data_in != NULL) { + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso); } LPSPI_SetDummyData(self->spi, 0xFF); diff --git a/ports/mimxrt10xx/common-hal/busio/UART.c b/ports/mimxrt10xx/common-hal/busio/UART.c index e4d5fda6ae..d069836295 100644 --- a/ports/mimxrt10xx/common-hal/busio/UART.c +++ b/ports/mimxrt10xx/common-hal/busio/UART.c @@ -401,7 +401,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { // Read characters. size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { if (self->rx == NULL) { - mp_raise_ValueError(translate("No RX pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx); } if (len == 0) { @@ -458,7 +458,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // Write characters. size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { if (self->tx == NULL) { - mp_raise_ValueError(translate("No TX pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx); } if (self->rs485_dir && len) { GPIO_PinWrite(self->rs485_dir->gpio, self->rs485_dir->number, !self->rs485_invert); diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 626956946f..1c63e73092 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -297,7 +297,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { // Read characters. size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { if (nrf_uarte_rx_pin_get(self->uarte->p_reg) == NRF_UARTE_PSEL_DISCONNECTED) { - mp_raise_ValueError(translate("No RX pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx); } uint64_t start_ticks = supervisor_ticks_ms64(); @@ -347,7 +347,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // Write characters. size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { if (nrf_uarte_tx_pin_get(self->uarte->p_reg) == NRF_UARTE_PSEL_DISCONNECTED) { - mp_raise_ValueError(translate("No TX pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx); } if (len == 0) { diff --git a/ports/raspberrypi/common-hal/busio/UART.c b/ports/raspberrypi/common-hal/busio/UART.c index 156a5e11ce..28cfc8b052 100644 --- a/ports/raspberrypi/common-hal/busio/UART.c +++ b/ports/raspberrypi/common-hal/busio/UART.c @@ -211,7 +211,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { // Write characters. size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { if (self->tx_pin == NO_PIN) { - mp_raise_ValueError(translate("No TX pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx); } if (self->rs485_dir_pin != NO_PIN) { @@ -239,7 +239,7 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, // Read characters. size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { if (self->rx_pin == NO_PIN) { - mp_raise_ValueError(translate("No RX pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx); } if (len == 0) { diff --git a/ports/silabs/common-hal/busio/I2C.c b/ports/silabs/common-hal/busio/I2C.c index 6d858be85e..62ac14f4e9 100644 --- a/ports/silabs/common-hal/busio/I2C.c +++ b/ports/silabs/common-hal/busio/I2C.c @@ -72,7 +72,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, common_hal_mcu_pin_claim(sda); in_used = true; } else { - mp_raise_ValueError(translate("Hardware busy, try alternative pins")); + mp_raise_ValueError(translate("Hardware in use, try alternative pins")); } } else { raise_ValueError_invalid_pins(); diff --git a/ports/silabs/common-hal/busio/SPI.c b/ports/silabs/common-hal/busio/SPI.c index a6f3109a32..89c8012477 100644 --- a/ports/silabs/common-hal/busio/SPI.c +++ b/ports/silabs/common-hal/busio/SPI.c @@ -95,7 +95,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, mp_raise_ValueError(translate("SPI init error")); } } else { - mp_raise_ValueError(translate("Hardware busy, try alternative pins")); + mp_raise_ValueError(translate("Hardware in use, try alternative pins")); } } else { raise_ValueError_invalid_pins(); diff --git a/ports/silabs/common-hal/busio/UART.c b/ports/silabs/common-hal/busio/UART.c index 8b1883d906..75c46f4725 100644 --- a/ports/silabs/common-hal/busio/UART.c +++ b/ports/silabs/common-hal/busio/UART.c @@ -131,7 +131,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, context = self; } else { - mp_raise_ValueError(translate("Hardware busy, try alternative pins")); + mp_raise_ValueError(translate("Hardware in use, try alternative pins")); } } else { diff --git a/ports/stm/common-hal/busio/I2C.c b/ports/stm/common-hal/busio/I2C.c index 259d678f2b..42c32b2b52 100644 --- a/ports/stm/common-hal/busio/I2C.c +++ b/ports/stm/common-hal/busio/I2C.c @@ -117,7 +117,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, I2Cx = mcu_i2c_banks[self->sda->periph_index - 1]; } else { if (i2c_taken) { - mp_raise_ValueError(translate("Hardware busy, try alternative pins")); + mp_raise_ValueError(translate("Hardware in use, try alternative pins")); } else { raise_ValueError_invalid_pins(); } diff --git a/ports/stm/common-hal/busio/SPI.c b/ports/stm/common-hal/busio/SPI.c index 89ec4b7cdc..2fea1149eb 100644 --- a/ports/stm/common-hal/busio/SPI.c +++ b/ports/stm/common-hal/busio/SPI.c @@ -160,7 +160,7 @@ STATIC int check_pins(busio_spi_obj_t *self, } if (spi_taken) { - mp_raise_ValueError(translate("Hardware busy, try alternative pins")); + mp_raise_ValueError(translate("Hardware in use, try alternative pins")); } else { raise_ValueError_invalid_pin(); } @@ -347,7 +347,7 @@ void common_hal_busio_spi_unlock(busio_spi_obj_t *self) { bool common_hal_busio_spi_write(busio_spi_obj_t *self, const uint8_t *data, size_t len) { if (self->mosi == NULL) { - mp_raise_ValueError(translate("No MOSI pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); } HAL_StatusTypeDef result = HAL_SPI_Transmit(&self->handle, (uint8_t *)data, (uint16_t)len, HAL_MAX_DELAY); return result == HAL_OK; @@ -356,9 +356,9 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self, bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size_t len, uint8_t write_value) { if (self->miso == NULL && !self->half_duplex) { - mp_raise_ValueError(translate("No MISO pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso); } else if (self->half_duplex && self->mosi == NULL) { - mp_raise_ValueError(translate("No MOSI pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); } HAL_StatusTypeDef result = HAL_OK; if ((!self->half_duplex && self->mosi == NULL) || (self->half_duplex && self->mosi != NULL && self->miso == NULL)) { @@ -372,8 +372,11 @@ bool common_hal_busio_spi_read(busio_spi_obj_t *self, bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, const uint8_t *data_out, uint8_t *data_in, size_t len) { - if (self->miso == NULL || self->mosi == NULL) { - mp_raise_ValueError(translate("Missing MISO or MOSI pin")); + if (self->mosi == NULL && data_out != NULL) { + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); + } + if (self->miso == NULL && data_in != NULL) { + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso); } HAL_StatusTypeDef result = HAL_SPI_TransmitReceive(&self->handle, (uint8_t *)data_out, data_in, (uint16_t)len,HAL_MAX_DELAY); diff --git a/ports/stm/common-hal/busio/UART.c b/ports/stm/common-hal/busio/UART.c index cdace31639..abf37ab881 100644 --- a/ports/stm/common-hal/busio/UART.c +++ b/ports/stm/common-hal/busio/UART.c @@ -293,7 +293,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { if (self->rx == NULL) { - mp_raise_ValueError(translate("No RX pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx); } uint64_t start_ticks = supervisor_ticks_ms64(); @@ -327,7 +327,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // Write characters. size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { if (self->tx == NULL) { - mp_raise_ValueError(translate("No TX pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx); } // Disable UART IRQ to avoid resource hazards in Rx IRQ handler diff --git a/ports/stm/common-hal/canio/CAN.c b/ports/stm/common-hal/canio/CAN.c index 992745b80a..ca857d5643 100644 --- a/ports/stm/common-hal/canio/CAN.c +++ b/ports/stm/common-hal/canio/CAN.c @@ -69,7 +69,7 @@ void common_hal_canio_can_construct(canio_can_obj_t *self, const mcu_pin_obj_t * } if (reserved_can[periph_index]) { - mp_raise_ValueError(translate("Hardware busy, try alternative pins")); + mp_raise_ValueError(translate("Hardware in use, try alternative pins")); } const uint32_t can_frequency = 42000000; diff --git a/ports/stm/common-hal/sdioio/SDCard.c b/ports/stm/common-hal/sdioio/SDCard.c index 8eeae2781d..6f3eb682df 100644 --- a/ports/stm/common-hal/sdioio/SDCard.c +++ b/ports/stm/common-hal/sdioio/SDCard.c @@ -113,7 +113,7 @@ STATIC int check_pins(sdioio_sdcard_obj_t *self, } if (sdio_taken) { - mp_raise_ValueError(translate("Hardware busy, try alternative pins")); + mp_raise_ValueError(translate("Hardware in use, try alternative pins")); } else { raise_ValueError_invalid_pin(); } diff --git a/shared-bindings/displayio/FourWire.c b/shared-bindings/displayio/FourWire.c index 1f099f5061..29cdf09299 100644 --- a/shared-bindings/displayio/FourWire.c +++ b/shared-bindings/displayio/FourWire.c @@ -114,7 +114,7 @@ STATIC mp_obj_t displayio_fourwire_obj_reset(mp_obj_t self_in) { displayio_fourwire_obj_t *self = self_in; if (!common_hal_displayio_fourwire_reset(self)) { - mp_raise_RuntimeError(translate("no reset pin available")); + mp_raise_RuntimeError_varg(translate("No %q pin"), MP_QSTR_reset); } return mp_const_none; } diff --git a/shared-bindings/displayio/I2CDisplay.c b/shared-bindings/displayio/I2CDisplay.c index f2647b0b16..ca5968421c 100644 --- a/shared-bindings/displayio/I2CDisplay.c +++ b/shared-bindings/displayio/I2CDisplay.c @@ -91,7 +91,7 @@ STATIC mp_obj_t displayio_i2cdisplay_obj_reset(mp_obj_t self_in) { displayio_i2cdisplay_obj_t *self = self_in; if (!common_hal_displayio_i2cdisplay_reset(self)) { - mp_raise_RuntimeError(translate("no reset pin available")); + mp_raise_RuntimeError_varg(translate("No %q pin"), MP_QSTR_reset); } return mp_const_none; } diff --git a/shared-bindings/paralleldisplay/ParallelBus.c b/shared-bindings/paralleldisplay/ParallelBus.c index ad9a1efdce..f8ab6470e4 100644 --- a/shared-bindings/paralleldisplay/ParallelBus.c +++ b/shared-bindings/paralleldisplay/ParallelBus.c @@ -122,7 +122,7 @@ STATIC mp_obj_t paralleldisplay_parallelbus_obj_reset(mp_obj_t self_in) { paralleldisplay_parallelbus_obj_t *self = self_in; if (!common_hal_paralleldisplay_parallelbus_reset(self)) { - mp_raise_RuntimeError(translate("no reset pin available")); + mp_raise_RuntimeError_varg(translate("No %q pin"), MP_QSTR_reset); } return mp_const_none; } diff --git a/shared-module/bitbangio/SPI.c b/shared-module/bitbangio/SPI.c index d740a214e7..c82cecff62 100644 --- a/shared-module/bitbangio/SPI.c +++ b/shared-module/bitbangio/SPI.c @@ -123,7 +123,7 @@ void shared_module_bitbangio_spi_unlock(bitbangio_spi_obj_t *self) { // Writes out the given data. bool shared_module_bitbangio_spi_write(bitbangio_spi_obj_t *self, const uint8_t *data, size_t len) { if (len > 0 && !self->has_mosi) { - mp_raise_ValueError(translate("No MOSI pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); } uint32_t delay_half = self->delay_half; @@ -178,7 +178,7 @@ bool shared_module_bitbangio_spi_write(bitbangio_spi_obj_t *self, const uint8_t // Reads in len bytes while outputting zeroes. bool shared_module_bitbangio_spi_read(bitbangio_spi_obj_t *self, uint8_t *data, size_t len, uint8_t write_data) { if (len > 0 && !self->has_miso) { - mp_raise_ValueError(translate("No MISO pin")); + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso); } uint32_t delay_half = self->delay_half; @@ -245,8 +245,11 @@ bool shared_module_bitbangio_spi_read(bitbangio_spi_obj_t *self, uint8_t *data, // transfer bool shared_module_bitbangio_spi_transfer(bitbangio_spi_obj_t *self, const uint8_t *dout, uint8_t *din, size_t len) { - if (len > 0 && (!self->has_mosi || !self->has_miso)) { - mp_raise_ValueError(translate("Cannot transfer without MOSI and MISO pins")); + if (!self->has_mosi && dout != NULL) { + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); + } + if (!self->has_miso && din != NULL) { + mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso); } uint32_t delay_half = self->delay_half;