summaryrefslogtreecommitdiffstats
path: root/app/usart.c
diff options
context:
space:
mode:
authorroot <root@circe.panaceas.james.local>2014-11-13 17:39:18 +0000
committerroot <root@circe.panaceas.james.local>2014-11-13 17:39:18 +0000
commit5950acfb05fb3e172fa5710f1cda6ab347f51f2f (patch)
tree6188f6041b360bc37d3278dd6eac8fb3b5ec6b7d /app/usart.c
parent12287ff0a55f929bf840dcb4780d3f77b862c434 (diff)
downloadstm32_usb_kvm-5950acfb05fb3e172fa5710f1cda6ab347f51f2f.tar.gz
stm32_usb_kvm-5950acfb05fb3e172fa5710f1cda6ab347f51f2f.tar.bz2
stm32_usb_kvm-5950acfb05fb3e172fa5710f1cda6ab347f51f2f.zip
leds
Diffstat (limited to 'app/usart.c')
-rw-r--r--app/usart.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/app/usart.c b/app/usart.c
index f510682..273c3bc 100644
--- a/app/usart.c
+++ b/app/usart.c
@@ -2,8 +2,11 @@
#define BUFFER_SIZE 256
-static ring_t output_ring;
-static uint8_t output_ring_buf[BUFFER_SIZE];
+ring_t rx_ring;
+static uint8_t rx_ring_buf[BUFFER_SIZE];
+
+ring_t tx_ring;
+static uint8_t tx_ring_buf[BUFFER_SIZE];
void
usart1_isr (void)
@@ -18,7 +21,7 @@ usart1_isr (void)
/* Retrieve the data from the peripheral. */
data = usart_recv (USART1);
- kvm_recv (data);
+ ring_write_byte(&rx_ring,data);
}
/* Check if we were called because of TXE. */
@@ -26,7 +29,7 @@ usart1_isr (void)
((USART_SR (USART1) & USART_SR_TXE) != 0))
{
- if (ring_read_byte (&output_ring, &data))
+ if (ring_read_byte (&tx_ring, &data))
{
/*No more data, Disable the TXE interrupt, it's no longer needed. */
USART_CR1 (USART1) &= ~USART_CR1_TXEIE;
@@ -46,7 +49,7 @@ _write (int file, char *ptr, int len)
if (file == 1)
{
- ret = ring_write (&output_ring, (uint8_t *) ptr, len);
+ ret = ring_write (&tx_ring, (uint8_t *) ptr, len);
if (ret < 0)
ret = -ret;
@@ -62,7 +65,8 @@ _write (int file, char *ptr, int len)
void
usart_queue (uint8_t d)
{
- ring_write_byte (&output_ring, d);
+
+ ring_write_byte (&tx_ring, d);
USART_CR1 (USART1) |= USART_CR1_TXEIE;
#if 0
@@ -75,7 +79,8 @@ usart_queue (uint8_t d)
void
usart_init (void)
{
- ring_init (&output_ring, output_ring_buf, sizeof (output_ring_buf));
+ ring_init (&tx_ring, tx_ring_buf, sizeof (tx_ring_buf));
+ ring_init (&rx_ring, rx_ring_buf, sizeof (rx_ring_buf));
/* Enable the USART1 interrupt. */
nvic_enable_irq (NVIC_USART1_IRQ);