From 49148e76706e5e24c2ba7f6ccc1d7ec4736ab2f3 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 3 Mar 2021 15:24:13 +0000 Subject: support cheap chinese blue pill boards, make usb dfu compatible with dfuse --- app/usart.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'app/usart.c') diff --git a/app/usart.c b/app/usart.c index ecd8e56..8659ab0 100644 --- a/app/usart.c +++ b/app/usart.c @@ -14,30 +14,28 @@ usart1_isr (void) uint8_t data; /* Check if we were called because of RXNE. */ - if ( ( (USART_CR1 (USART1) & USART_CR1_RXNEIE) != 0) && - ( (USART_SR (USART1) & USART_SR_RXNE) != 0)) { + if (((USART_CR1 (USART1) & USART_CR1_RXNEIE) != 0) && + ((USART_SR (USART1) & USART_SR_RXNE) != 0)) { /* Retrieve the data from the peripheral. */ data = usart_recv (USART1); ring_write_byte (&usart_rx_ring, data); } /* Check if we were called because of TXE. */ - if ( ( (USART_CR1 (USART1) & USART_CR1_TXEIE) != 0) && - ( (USART_SR (USART1) & USART_SR_TXE) != 0)) { + if (((USART_CR1 (USART1) & USART_CR1_TXEIE) != 0) && + ((USART_SR (USART1) & USART_SR_TXE) != 0)) { if (ring_read_byte (&usart_tx_ring, &data)) { /*No more data, Disable the TXE interrupt, it's no longer needed. */ USART_CR1 (USART1) &= ~USART_CR1_TXEIE; - } else { + } else usart_send (USART1, data); - } } } void usart_kick (void) { - if (!ring_empty (&usart_tx_ring)) { + if (!ring_empty (&usart_tx_ring)) USART_CR1 (USART1) |= USART_CR1_TXEIE; - } } @@ -49,10 +47,10 @@ _write (int file, char *ptr, int len) if (file == 1) { ret = ring_write (&usart_tx_ring, (uint8_t *) ptr, len); usart_kick(); + ring_write (&cdcacm_tx_ring, (uint8_t *) ptr, len); - if (ret < 0) { + if (ret < 0) ret = -ret; - } return ret; } -- cgit v1.2.3