Skip to content
Snippets Groups Projects
Commit 61ef0316 authored by Damien George's avatar Damien George
Browse files

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

parent 6ea45277
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment