Skip to content

Commit c328ae8

Browse files
committed
Addition of stubs for rs485/CTS/RTS handling on non-implemented chips
1 parent f8bf307 commit c328ae8

File tree

4 files changed

+40
-14
lines changed
  • ports

4 files changed

+40
-14
lines changed

ports/atmel-samd/common-hal/busio/UART.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,23 @@ static void usart_async_rxc_callback(const struct usart_async_descriptor *const
5252
}
5353

5454
void common_hal_busio_uart_construct(busio_uart_obj_t *self,
55-
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate,
56-
uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout,
57-
uint16_t receiver_buffer_size) {
55+
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx,
56+
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
57+
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
58+
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
59+
mp_float_t timeout, uint16_t receiver_buffer_size) {
60+
5861
Sercom* sercom = NULL;
5962
uint8_t sercom_index = 255; // Unset index
6063
uint32_t rx_pinmux = 0;
6164
uint8_t rx_pad = 255; // Unset pad
6265
uint32_t tx_pinmux = 0;
6366
uint8_t tx_pad = 255; // Unset pad
6467

68+
if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert == true)) {
69+
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
70+
}
71+
6572
if (bits > 8) {
6673
mp_raise_NotImplementedError(translate("bytes > 8 bits not supported"));
6774
}

ports/cxd56/common-hal/busio/UART.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,17 @@ STATIC busio_uart_dev_t busio_uart_dev[] = {
5353
};
5454

5555
void common_hal_busio_uart_construct(busio_uart_obj_t *self,
56-
const mcu_pin_obj_t *tx, const mcu_pin_obj_t *rx, uint32_t baudrate,
57-
uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout,
58-
uint16_t receiver_buffer_size) {
56+
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx,
57+
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
58+
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
59+
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
60+
mp_float_t timeout, uint16_t receiver_buffer_size) {
5961
struct termios tio;
6062

63+
if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert == true)) {
64+
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
65+
}
66+
6167
if (bits != 8) {
6268
mp_raise_ValueError(translate("Could not initialize UART"));
6369
}

ports/nrf/common-hal/busio/UART.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,17 @@ void uart_reset(void) {
128128
}
129129
}
130130

131-
void common_hal_busio_uart_construct (busio_uart_obj_t *self,
132-
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate,
133-
uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout,
134-
uint16_t receiver_buffer_size) {
131+
void common_hal_busio_uart_construct(busio_uart_obj_t *self,
132+
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx,
133+
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
134+
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
135+
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
136+
mp_float_t timeout, uint16_t receiver_buffer_size) {
137+
138+
if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert == true)) {
139+
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
140+
}
141+
135142
// Find a free UART peripheral.
136143
self->uarte = NULL;
137144
for (size_t i = 0 ; i < MP_ARRAY_SIZE(nrfx_uartes); i++) {

ports/stm32f4/common-hal/busio/UART.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ void uart_reset(void) {
7171
uart_clock_disable(ALL_UARTS);
7272
}
7373

74-
void common_hal_busio_uart_construct(busio_uart_obj_t* self,
75-
const mcu_pin_obj_t* tx, const mcu_pin_obj_t* rx, uint32_t baudrate,
76-
uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout,
77-
uint16_t receiver_buffer_size) {
74+
void common_hal_busio_uart_construct(busio_uart_obj_t *self,
75+
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx,
76+
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
77+
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
78+
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
79+
mp_float_t timeout, uint16_t receiver_buffer_size) {
7880

7981
//match pins to UART objects
8082
USART_TypeDef * USARTx;
@@ -84,6 +86,10 @@ void common_hal_busio_uart_construct(busio_uart_obj_t* self,
8486
bool uart_taken = false;
8587
uint8_t uart_index = 0; //origin 0 corrected
8688

89+
if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert == true)) {
90+
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
91+
}
92+
8793
//Can have both pins, or either
8894
if ((tx != mp_const_none) && (rx != mp_const_none)) {
8995
//normal find loop if both pins exist

0 commit comments

Comments
 (0)