diff options
author | Dave Hylands <dhylands@gmail.com> | 2015-07-28 11:13:33 -0700 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-07-30 00:38:32 +0100 |
commit | 92d4b51ad5d828930334f87d9619a78b5877a384 (patch) | |
tree | b055ba812bfce720130c6c52272bde38e80a00c9 /stmhal/uart.c | |
parent | 7e7fb0b7a3d716062281c2366de97a41a1ea87c1 (diff) | |
download | micropython-92d4b51ad5d828930334f87d9619a78b5877a384.tar.gz micropython-92d4b51ad5d828930334f87d9619a78b5877a384.zip |
stmhal: Add STM32F7DISC and associated changes.
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); |