Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RP2040: Support for UART #4224

Merged
merged 7 commits into from
Feb 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ msgid "All SPI peripherals are in use"
msgstr ""

#: ports/esp32s2/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
#: ports/raspberrypi/common-hal/busio/UART.c
msgid "All UART peripherals are in use"
msgstr ""

Expand Down Expand Up @@ -952,6 +953,7 @@ msgid "Failed to acquire mutex, err 0x%04x"
msgstr ""

#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/UART.c
#: ports/raspberrypi/common-hal/busio/UART.c
msgid "Failed to allocate RX buffer"
msgstr ""

Expand Down Expand Up @@ -1219,7 +1221,8 @@ msgstr ""
msgid "Invalid bits per value"
msgstr ""

#: ports/nrf/common-hal/busio/UART.c ports/stm/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 "Invalid buffer size"
msgstr ""

Expand Down Expand Up @@ -1294,10 +1297,10 @@ msgstr ""
#: ports/esp32s2/common-hal/busio/I2C.c ports/esp32s2/common-hal/busio/SPI.c
#: ports/esp32s2/common-hal/busio/UART.c ports/esp32s2/common-hal/canio/CAN.c
#: ports/mimxrt10xx/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c
#: ports/mimxrt10xx/common-hal/busio/UART.c ports/nrf/common-hal/busio/I2C.c
#: ports/mimxrt10xx/common-hal/busio/SPI.c ports/nrf/common-hal/busio/I2C.c
#: ports/raspberrypi/common-hal/busio/I2C.c
#: ports/raspberrypi/common-hal/busio/SPI.c
#: ports/raspberrypi/common-hal/busio/UART.c
msgid "Invalid pins"
msgstr ""

Expand Down Expand Up @@ -1346,7 +1349,8 @@ msgstr ""
msgid "Invalid wave file"
msgstr ""

#: ports/stm/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 "Invalid word/bit length"
msgstr ""

Expand Down Expand Up @@ -1846,7 +1850,7 @@ msgstr ""
msgid "RNG Init Error"
msgstr ""

#: ports/nrf/common-hal/busio/UART.c
#: ports/nrf/common-hal/busio/UART.c ports/raspberrypi/common-hal/busio/UART.c
msgid "RS485 Not yet supported on this device"
msgstr ""

Expand Down Expand Up @@ -2156,10 +2160,6 @@ msgstr ""
msgid "UART Re-init error"
msgstr ""

#: ports/raspberrypi/common-hal/busio/UART.c
msgid "UART not yet supported"
msgstr ""

#: ports/stm/common-hal/busio/UART.c
msgid "UART write error"
msgstr ""
Expand Down Expand Up @@ -2488,7 +2488,7 @@ msgid "binary op %q not implemented"
msgstr ""

#: shared-bindings/busio/UART.c
msgid "bits must be 7, 8 or 9"
msgid "bits must be in range 5 to 9"
msgstr ""

#: shared-bindings/audiomixer/Mixer.c
Expand Down
2 changes: 2 additions & 0 deletions ports/atmel-samd/boards/catwan_usbstick/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0
CIRCUITPY_COUNTIO = 0
CIRCUITPY_ROTARYIO = 0

SUPEROPT_GC = 0
8 changes: 4 additions & 4 deletions ports/mimxrt10xx/common-hal/busio/UART.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
self->character_bits = bits;
self->timeout_ms = timeout * 1000;

if (self->character_bits != 7 && self->character_bits != 8) {
mp_raise_ValueError(translate("Invalid word/bit length"));
}

// We are transmitting one direction if one pin is NULL and the other isn't.
bool is_onedirection = (rx == NULL) != (tx == NULL);
bool uart_taken = false;
Expand Down Expand Up @@ -154,10 +158,6 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
mp_raise_ValueError(translate("Hardware in use, try alternative pins"));
}

if(self->rx == NULL && self->tx == NULL) {
mp_raise_ValueError(translate("Invalid pins"));
}

if (is_onedirection && ((rts != NULL) || (cts != NULL))) {
mp_raise_ValueError(translate("Both RX and TX required for flow control"));
}
Expand Down
8 changes: 6 additions & 2 deletions ports/nrf/common-hal/busio/UART.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ static uint32_t get_nrf_baud (uint32_t baudrate) {
{ 14400, NRF_UARTE_BAUDRATE_14400 },
{ 19200, NRF_UARTE_BAUDRATE_19200 },
{ 28800, NRF_UARTE_BAUDRATE_28800 },
{ 31250, NRF_UARTE_BAUDRATE_31250 },
{ 31250, NRF_UARTE_BAUDRATE_31250 },
{ 38400, NRF_UARTE_BAUDRATE_38400 },
{ 56000, NRF_UARTE_BAUDRATE_56000 },
{ 56000, NRF_UARTE_BAUDRATE_56000 },
{ 57600, NRF_UARTE_BAUDRATE_57600 },
{ 76800, NRF_UARTE_BAUDRATE_76800 },
{ 115200, NRF_UARTE_BAUDRATE_115200 },
Expand Down Expand Up @@ -144,6 +144,10 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer,
bool sigint_enabled) {

if (bits != 8) {
mp_raise_ValueError(translate("Invalid word/bit length"));
}

if ((rs485_dir != NULL) || (rs485_invert)) {
mp_raise_ValueError(translate("RS485 Not yet supported on this device"));
}
Expand Down
Loading