aboutsummaryrefslogtreecommitdiffstats
path: root/app/usart.c
diff options
context:
space:
mode:
authorroot <root@ka-ata-killa.ourano.james.local>2021-03-03 15:24:13 +0000
committerroot <root@ka-ata-killa.ourano.james.local>2021-03-03 16:03:28 +0000
commit49148e76706e5e24c2ba7f6ccc1d7ec4736ab2f3 (patch)
treef65cb7440711ea1708c25fe78819e9986b2d8566 /app/usart.c
parent129a103238d69bd90b4fe9a44bbed943b9488fc2 (diff)
downloadserial_over_dp-49148e76706e5e24c2ba7f6ccc1d7ec4736ab2f3.tar.gz
serial_over_dp-49148e76706e5e24c2ba7f6ccc1d7ec4736ab2f3.tar.bz2
serial_over_dp-49148e76706e5e24c2ba7f6ccc1d7ec4736ab2f3.zip
support cheap chinese blue pill boards, make usb dfu compatible with dfuse
Diffstat (limited to 'app/usart.c')
-rw-r--r--app/usart.c18
1 files changed, 8 insertions, 10 deletions
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;
}