From 5cde57cb653839ec6265a9b60440522d23b2215d Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 6 Feb 2012 17:53:41 +0100 Subject: [PATCH] software: use new UART --- software/bios/main.c | 2 +- software/include/hw/uart.h | 21 ++++++++------------- software/libbase/uart.c | 12 ++++++------ 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/software/bios/main.c b/software/bios/main.c index c479dfcf..b2f90e3b 100644 --- a/software/bios/main.c +++ b/software/bios/main.c @@ -3,7 +3,7 @@ static void print(const char *s) { while(*s) { - while(!(CSR_UART_STAT & UART_STAT_THRE)); + while(CSR_UART_EV_STAT & UART_EV_TX); CSR_UART_RXTX = *s; s++; } diff --git a/software/include/hw/uart.h b/software/include/hw/uart.h index 5540ca44..c9e1e194 100644 --- a/software/include/hw/uart.h +++ b/software/include/hw/uart.h @@ -1,6 +1,6 @@ /* * Milkymist SoC (Software) - * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq + * Copyright (C) 2007, 2008, 2009, 2010, 2012 Sebastien Bourdeauducq * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,19 +21,14 @@ #include #define CSR_UART_RXTX MMPTR(0xe0000000) -#define CSR_UART_DIVISOR MMPTR(0xe0000004) -#define CSR_UART_STAT MMPTR(0xe0000008) -#define CSR_UART_CTRL MMPTR(0xe000000c) -#define CSR_UART_DEBUG MMPTR(0xe0000010) +#define CSR_UART_DIVISORH MMPTR(0xe0000004) +#define CSR_UART_DIVISORL MMPTR(0xe0000008) -#define UART_STAT_THRE (0x1) -#define UART_STAT_RX_EVT (0x2) -#define UART_STAT_TX_EVT (0x4) +#define CSR_UART_EV_STAT MMPTR(0xe000000c) +#define CSR_UART_EV_PENDING MMPTR(0xe0000010) +#define CSR_UART_EV_ENABLE MMPTR(0xe0000014) -#define UART_CTRL_RX_INT (0x1) -#define UART_CTRL_TX_INT (0x2) -#define UART_CTRL_THRU (0x4) - -#define UART_DEBUG_BREAK_EN (0x1) +#define UART_EV_TX (0x1) +#define UART_EV_RX (0x2) #endif /* __HW_UART_H */ diff --git a/software/libbase/uart.c b/software/libbase/uart.c index 9ec12ab1..6ca28629 100644 --- a/software/libbase/uart.c +++ b/software/libbase/uart.c @@ -44,14 +44,14 @@ static volatile int tx_cts; void uart_isr(void) { - unsigned int stat = CSR_UART_STAT; + unsigned int stat = CSR_UART_EV_PENDING; - if(stat & UART_STAT_RX_EVT) { + if(stat & UART_EV_RX) { rx_buf[rx_produce] = CSR_UART_RXTX; rx_produce = (rx_produce + 1) & UART_RINGBUFFER_MASK_RX; } - if(stat & UART_STAT_TX_EVT) { + if(stat & UART_EV_TX) { if(tx_produce != tx_consume) { CSR_UART_RXTX = tx_buf[tx_consume]; tx_consume = (tx_consume + 1) & UART_RINGBUFFER_MASK_TX; @@ -59,7 +59,7 @@ void uart_isr(void) tx_cts = 1; } - CSR_UART_STAT = stat; + CSR_UART_EV_PENDING = stat; irq_ack(IRQ_UART); } @@ -109,10 +109,10 @@ void uart_init(void) irq_ack(IRQ_UART); /* ack any events */ - CSR_UART_STAT = CSR_UART_STAT; + CSR_UART_EV_PENDING = CSR_UART_EV_PENDING; /* enable interrupts */ - CSR_UART_CTRL = UART_CTRL_TX_INT | UART_CTRL_RX_INT; + CSR_UART_EV_ENABLE = UART_EV_TX | UART_EV_RX; mask = irq_getmask(); mask |= IRQ_UART; -- 2.30.2