Addition of stubs for rs485/CTS/RTS handling on non-implemented chips
This commit is contained in:
parent
f0e5341b0f
commit
490a808bf6
@ -52,9 +52,12 @@ static void usart_async_rxc_callback(const struct usart_async_descriptor *const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
||||||
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate,
|
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx,
|
||||||
uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout,
|
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
|
||||||
uint16_t receiver_buffer_size) {
|
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
|
||||||
|
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
|
||||||
|
mp_float_t timeout, uint16_t receiver_buffer_size) {
|
||||||
|
|
||||||
Sercom* sercom = NULL;
|
Sercom* sercom = NULL;
|
||||||
uint8_t sercom_index = 255; // Unset index
|
uint8_t sercom_index = 255; // Unset index
|
||||||
uint32_t rx_pinmux = 0;
|
uint32_t rx_pinmux = 0;
|
||||||
@ -62,6 +65,10 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
uint32_t tx_pinmux = 0;
|
uint32_t tx_pinmux = 0;
|
||||||
uint8_t tx_pad = 255; // Unset pad
|
uint8_t tx_pad = 255; // Unset pad
|
||||||
|
|
||||||
|
if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert == true)) {
|
||||||
|
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
||||||
|
}
|
||||||
|
|
||||||
if (bits > 8) {
|
if (bits > 8) {
|
||||||
mp_raise_NotImplementedError(translate("bytes > 8 bits not supported"));
|
mp_raise_NotImplementedError(translate("bytes > 8 bits not supported"));
|
||||||
}
|
}
|
||||||
|
@ -53,11 +53,17 @@ STATIC busio_uart_dev_t busio_uart_dev[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
||||||
const mcu_pin_obj_t *tx, const mcu_pin_obj_t *rx, uint32_t baudrate,
|
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx,
|
||||||
uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout,
|
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
|
||||||
uint16_t receiver_buffer_size) {
|
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
|
||||||
|
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
|
||||||
|
mp_float_t timeout, uint16_t receiver_buffer_size) {
|
||||||
struct termios tio;
|
struct termios tio;
|
||||||
|
|
||||||
|
if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert == true)) {
|
||||||
|
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
||||||
|
}
|
||||||
|
|
||||||
if (bits != 8) {
|
if (bits != 8) {
|
||||||
mp_raise_ValueError(translate("Could not initialize UART"));
|
mp_raise_ValueError(translate("Could not initialize UART"));
|
||||||
}
|
}
|
||||||
|
@ -128,10 +128,17 @@ void uart_reset(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_busio_uart_construct (busio_uart_obj_t *self,
|
void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
||||||
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate,
|
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx,
|
||||||
uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout,
|
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
|
||||||
uint16_t receiver_buffer_size) {
|
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
|
||||||
|
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
|
||||||
|
mp_float_t timeout, uint16_t receiver_buffer_size) {
|
||||||
|
|
||||||
|
if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert == true)) {
|
||||||
|
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
||||||
|
}
|
||||||
|
|
||||||
// Find a free UART peripheral.
|
// Find a free UART peripheral.
|
||||||
self->uarte = NULL;
|
self->uarte = NULL;
|
||||||
for (size_t i = 0 ; i < MP_ARRAY_SIZE(nrfx_uartes); i++) {
|
for (size_t i = 0 ; i < MP_ARRAY_SIZE(nrfx_uartes); i++) {
|
||||||
|
@ -71,10 +71,12 @@ void uart_reset(void) {
|
|||||||
uart_clock_disable(ALL_UARTS);
|
uart_clock_disable(ALL_UARTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void common_hal_busio_uart_construct(busio_uart_obj_t* self,
|
void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
||||||
const mcu_pin_obj_t* tx, const mcu_pin_obj_t* rx, uint32_t baudrate,
|
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx,
|
||||||
uint8_t bits, uart_parity_t parity, uint8_t stop, mp_float_t timeout,
|
const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts,
|
||||||
uint16_t receiver_buffer_size) {
|
const mcu_pin_obj_t * rs485_dir, bool rs485_invert,
|
||||||
|
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
|
||||||
|
mp_float_t timeout, uint16_t receiver_buffer_size) {
|
||||||
|
|
||||||
//match pins to UART objects
|
//match pins to UART objects
|
||||||
USART_TypeDef * USARTx;
|
USART_TypeDef * USARTx;
|
||||||
@ -84,6 +86,10 @@ void common_hal_busio_uart_construct(busio_uart_obj_t* self,
|
|||||||
bool uart_taken = false;
|
bool uart_taken = false;
|
||||||
uint8_t uart_index = 0; //origin 0 corrected
|
uint8_t uart_index = 0; //origin 0 corrected
|
||||||
|
|
||||||
|
if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert == true)) {
|
||||||
|
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
||||||
|
}
|
||||||
|
|
||||||
//Can have both pins, or either
|
//Can have both pins, or either
|
||||||
if ((tx != mp_const_none) && (rx != mp_const_none)) {
|
if ((tx != mp_const_none) && (rx != mp_const_none)) {
|
||||||
//normal find loop if both pins exist
|
//normal find loop if both pins exist
|
||||||
|
Loading…
Reference in New Issue
Block a user