diff options
author | Damien George <damien.p.george@gmail.com> | 2014-10-11 17:57:10 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-10-21 22:15:20 +0100 |
commit | 481d714bd56e0173668b249760e9cea8fce9b04f (patch) | |
tree | 4a1e9458676177d05b18e7d50966469bf44e1ec1 /teensy/uart.c | |
parent | 20f59e182e1ca5874a94ce939f8a81af6c3dd71a (diff) |
stmhal: Overhaul UART class to use read/write, and improve it.v1.3.4
UART object now uses a stream-like interface: read, readall, readline,
readinto, readchar, write, writechar.
Timeouts are configured when the UART object is initialised, using
timeout and timeout_char keyword args.
The object includes optional read buffering, using interrupts. You can set
the buffer size dynamically using read_buf_len keyword arg. A size of 0
disables buffering.
Diffstat (limited to 'teensy/uart.c')
-rw-r--r-- | teensy/uart.c | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/teensy/uart.c b/teensy/uart.c index 48149c795..4751e3293 100644 --- a/teensy/uart.c +++ b/teensy/uart.c @@ -177,35 +177,6 @@ bool uart_init(pyb_uart_obj_t *uart_obj, uint32_t baudrate) { return uart_init2(uart_obj); } -void uart_deinit(pyb_uart_obj_t *uart_obj) { -#if 0 - uart_obj->is_enabled = false; - UART_HandleTypeDef *uart = &uart_obj->uart; - HAL_UART_DeInit(uart); - if (uart->Instance == USART1) { - __USART1_FORCE_RESET(); - __USART1_RELEASE_RESET(); - __USART1_CLK_DISABLE(); - } else if (uart->Instance == USART2) { - __USART2_FORCE_RESET(); - __USART2_RELEASE_RESET(); - __USART2_CLK_DISABLE(); - } else if (uart->Instance == USART3) { - __USART3_FORCE_RESET(); - __USART3_RELEASE_RESET(); - __USART3_CLK_DISABLE(); - } else if (uart->Instance == UART4) { - __UART4_FORCE_RESET(); - __UART4_RELEASE_RESET(); - __UART4_CLK_DISABLE(); - } else if (uart->Instance == USART6) { - __USART6_FORCE_RESET(); - __USART6_RELEASE_RESET(); - __USART6_CLK_DISABLE(); - } -#endif -} - bool uart_rx_any(pyb_uart_obj_t *uart_obj) { #if 0 return __HAL_UART_GET_FLAG(&uart_obj->uart, UART_FLAG_RXNE); @@ -390,8 +361,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_uart_init_obj, 1, pyb_uart_init); /// \method deinit() /// Turn off the UART bus. STATIC mp_obj_t pyb_uart_deinit(mp_obj_t self_in) { - pyb_uart_obj_t *self = self_in; - uart_deinit(self); + //pyb_uart_obj_t *self = self_in; + // TODO return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_uart_deinit_obj, pyb_uart_deinit); |