Browse Source

stm32/uart: Move config of char_width/char_mask to uart.c.

pull/4343/head
Damien George 6 years ago
parent
commit
61ef031687
  1. 11
      ports/stm32/machine_uart.c
  2. 12
      ports/stm32/uart.c

11
ports/stm32/machine_uart.c

@ -217,17 +217,6 @@ STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, size_t n_args, const
// setup the read buffer
m_del(byte, self->read_buf, self->read_buf_len << self->char_width);
if (bits == UART_WORDLENGTH_9B && parity == UART_PARITY_NONE) {
self->char_mask = 0x1ff;
self->char_width = CHAR_WIDTH_9BIT;
} else {
if (bits == UART_WORDLENGTH_9B || parity == UART_PARITY_NONE) {
self->char_mask = 0xff;
} else {
self->char_mask = 0x7f;
}
self->char_width = CHAR_WIDTH_8BIT;
}
if (args.rxbuf.u_int >= 0) {
// rxbuf overrides legacy read_buf_len
args.read_buf_len.u_int = args.rxbuf.u_int;

12
ports/stm32/uart.c

@ -318,6 +318,18 @@ bool uart_init(pyb_uart_obj_t *uart_obj,
uart_obj->is_enabled = true;
uart_obj->attached_to_repl = false;
if (bits == UART_WORDLENGTH_9B && parity == UART_PARITY_NONE) {
uart_obj->char_mask = 0x1ff;
uart_obj->char_width = CHAR_WIDTH_9BIT;
} else {
if (bits == UART_WORDLENGTH_9B || parity == UART_PARITY_NONE) {
uart_obj->char_mask = 0xff;
} else {
uart_obj->char_mask = 0x7f;
}
uart_obj->char_width = CHAR_WIDTH_8BIT;
}
return true;
}

Loading…
Cancel
Save