Edits as a result of review
This commit is contained in:
parent
490a808bf6
commit
24405cabaf
@ -65,7 +65,7 @@ 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)) {
|
if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert)) {
|
||||||
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
mp_float_t timeout, uint16_t receiver_buffer_size) {
|
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)) {
|
if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert)) {
|
||||||
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,41 +123,38 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
// For IMXRT the RTS pin is used for RS485 direction
|
// For IMXRT the RTS pin is used for RS485 direction
|
||||||
rts = rs485_dir;
|
rts = rs485_dir;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if (rs485_invert) {
|
||||||
if (rs485_invert == true) {
|
mp_raise_ValueError(translate("RS485 inversion specified when not in RS485 mode"));
|
||||||
mp_raise_ValueError(translate("RS485 inversion specified when not in RS485 mode"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Now check for RTS/CTS (or overloaded RS485 direction) pin(s)
|
// Now check for RTS/CTS (or overloaded RS485 direction) pin(s)
|
||||||
const uint32_t rts_count = sizeof(mcu_uart_rts_list) / sizeof(mcu_periph_obj_t);
|
const uint32_t rts_count = sizeof(mcu_uart_rts_list) / sizeof(mcu_periph_obj_t);
|
||||||
const uint32_t cts_count = sizeof(mcu_uart_cts_list) / sizeof(mcu_periph_obj_t);
|
const uint32_t cts_count = sizeof(mcu_uart_cts_list) / sizeof(mcu_periph_obj_t);
|
||||||
|
|
||||||
if (rts != mp_const_none) {
|
if (rts != mp_const_none) {
|
||||||
for (uint32_t i=0; i < rts_count; ++i)
|
for (uint32_t i=0; i < rts_count; ++i) {
|
||||||
{
|
if (mcu_uart_rts_list[i].bank_idx == self->rx_pin->bank_idx) {
|
||||||
if (mcu_uart_rts_list[i].bank_idx == self->rx_pin->bank_idx) {
|
if (mcu_uart_rts_list[i].pin == rts) {
|
||||||
if (mcu_uart_rts_list[i].pin == rts) {
|
self->rts_pin = &mcu_uart_rts_list[i];
|
||||||
self->rts_pin = &mcu_uart_rts_list[i];
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (self->rts_pin == NULL)
|
if (self->rts_pin == NULL)
|
||||||
mp_raise_ValueError(translate("Selected RTS pin not valid"));
|
mp_raise_ValueError(translate("Selected RTS pin not valid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cts != mp_const_none) {
|
if (cts != mp_const_none) {
|
||||||
for (uint32_t i=0; i < cts_count; ++i)
|
for (uint32_t i=0; i < cts_count; ++i) {
|
||||||
{
|
if (mcu_uart_cts_list[i].bank_idx == self->rx_pin->bank_idx) {
|
||||||
if (mcu_uart_cts_list[i].bank_idx == self->rx_pin->bank_idx) {
|
if (mcu_uart_cts_list[i].pin == cts) {
|
||||||
if (mcu_uart_cts_list[i].pin == cts) {
|
self->cts_pin = &mcu_uart_cts_list[i];
|
||||||
self->cts_pin = &mcu_uart_cts_list[i];
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (self->cts_pin == NULL)
|
if (self->cts_pin == NULL)
|
||||||
mp_raise_ValueError(translate("Selected CTS pin not valid"));
|
mp_raise_ValueError(translate("Selected CTS pin not valid"));
|
||||||
}
|
}
|
||||||
@ -192,7 +189,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
uint32_t modir = (self->uart->MODIR) & ~(LPUART_MODIR_TXRTSPOL_MASK | LPUART_MODIR_TXRTSE_MASK);
|
uint32_t modir = (self->uart->MODIR) & ~(LPUART_MODIR_TXRTSPOL_MASK | LPUART_MODIR_TXRTSE_MASK);
|
||||||
if (rs485_dir != mp_const_none) {
|
if (rs485_dir != mp_const_none) {
|
||||||
modir |= LPUART_MODIR_TXRTSE_MASK;
|
modir |= LPUART_MODIR_TXRTSE_MASK;
|
||||||
if ( rs485_invert == true )
|
if (rs485_invert)
|
||||||
modir |= LPUART_MODIR_TXRTSPOL_MASK;
|
modir |= LPUART_MODIR_TXRTSPOL_MASK;
|
||||||
}
|
}
|
||||||
self->uart->MODIR = modir;
|
self->uart->MODIR = modir;
|
||||||
|
@ -36,8 +36,8 @@ extern const mcu_periph_obj_t mcu_spi_miso_list[4];
|
|||||||
|
|
||||||
extern const mcu_periph_obj_t mcu_uart_rx_list[9];
|
extern const mcu_periph_obj_t mcu_uart_rx_list[9];
|
||||||
extern const mcu_periph_obj_t mcu_uart_tx_list[9];
|
extern const mcu_periph_obj_t mcu_uart_tx_list[9];
|
||||||
const mcu_periph_obj_t mcu_uart_rts_list[4];
|
extern const mcu_periph_obj_t mcu_uart_rts_list[4];
|
||||||
const mcu_periph_obj_t mcu_uart_cts_list[4];
|
extern const mcu_periph_obj_t mcu_uart_cts_list[4];
|
||||||
|
|
||||||
extern const mcu_pwm_obj_t mcu_pwm_list[20];
|
extern const mcu_pwm_obj_t mcu_pwm_list[20];
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ extern const mcu_periph_obj_t mcu_spi_miso_list[8];
|
|||||||
|
|
||||||
extern const mcu_periph_obj_t mcu_uart_rx_list[18];
|
extern const mcu_periph_obj_t mcu_uart_rx_list[18];
|
||||||
extern const mcu_periph_obj_t mcu_uart_tx_list[18];
|
extern const mcu_periph_obj_t mcu_uart_tx_list[18];
|
||||||
const mcu_periph_obj_t mcu_uart_rts_list[9];
|
extern const mcu_periph_obj_t mcu_uart_rts_list[9];
|
||||||
const mcu_periph_obj_t mcu_uart_cts_list[9];
|
extern const mcu_periph_obj_t mcu_uart_cts_list[9];
|
||||||
|
|
||||||
extern const mcu_pwm_obj_t mcu_pwm_list[67];
|
extern const mcu_pwm_obj_t mcu_pwm_list[67];
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
|
|||||||
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
|
uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop,
|
||||||
mp_float_t timeout, uint16_t receiver_buffer_size) {
|
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)) {
|
if ((rts != mp_const_none) || (cts != mp_const_none) || (rs485_dir != mp_const_none) || (rs485_invert)) {
|
||||||
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
mp_raise_ValueError(translate("RTS/CTS/RS485 Not yet supported on this device"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user