diff options
Diffstat (limited to 'stmhal/uart.c')
-rw-r--r-- | stmhal/uart.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/stmhal/uart.c b/stmhal/uart.c index 70b7390c0a..fb1386d041 100644 --- a/stmhal/uart.c +++ b/stmhal/uart.c @@ -36,6 +36,8 @@ #include "pybioctl.h" #include MICROPY_HAL_H +//TODO: Add UART7/8 support for STM32F7 + /// \moduleref pyb /// \class UART - duplex serial communication bus /// @@ -297,7 +299,11 @@ int uart_rx_char(pyb_uart_obj_t *self) { return data; } else { // no buffering + #if defined(STM32F7) + return self->uart.Instance->RDR & self->char_mask; + #else return self->uart.Instance->DR & self->char_mask; + #endif } } @@ -331,7 +337,11 @@ void uart_irq_handler(mp_uint_t uart_id) { } if (__HAL_UART_GET_FLAG(&self->uart, UART_FLAG_RXNE) != RESET) { + #if defined(STM32F7) + int data = self->uart.Instance->RDR; // clears UART_FLAG_RXNE + #else int data = self->uart.Instance->DR; // clears UART_FLAG_RXNE + #endif data &= self->char_mask; if (self->read_buf_len != 0) { uint16_t next_head = (self->read_buf_head + 1) % self->read_buf_len; @@ -687,7 +697,11 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_uart_readchar_obj, pyb_uart_readchar); // uart.sendbreak() STATIC mp_obj_t pyb_uart_sendbreak(mp_obj_t self_in) { pyb_uart_obj_t *self = self_in; + #if defined(STM32F7) + self->uart.Instance->RQR = USART_RQR_SBKRQ; // write-only register + #else self->uart.Instance->CR1 |= USART_CR1_SBK; + #endif return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_uart_sendbreak_obj, pyb_uart_sendbreak); |