software: use new UART

This commit is contained in:
Sebastien Bourdeauducq 2012-02-06 17:53:41 +01:00
parent 33f1c456bf
commit 5cde57cb65
3 changed files with 15 additions and 20 deletions

View file

@ -3,7 +3,7 @@
static void print(const char *s) static void print(const char *s)
{ {
while(*s) { while(*s) {
while(!(CSR_UART_STAT & UART_STAT_THRE)); while(CSR_UART_EV_STAT & UART_EV_TX);
CSR_UART_RXTX = *s; CSR_UART_RXTX = *s;
s++; s++;
} }

View file

@ -1,6 +1,6 @@
/* /*
* Milkymist SoC (Software) * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -21,19 +21,14 @@
#include <hw/common.h> #include <hw/common.h>
#define CSR_UART_RXTX MMPTR(0xe0000000) #define CSR_UART_RXTX MMPTR(0xe0000000)
#define CSR_UART_DIVISOR MMPTR(0xe0000004) #define CSR_UART_DIVISORH MMPTR(0xe0000004)
#define CSR_UART_STAT MMPTR(0xe0000008) #define CSR_UART_DIVISORL MMPTR(0xe0000008)
#define CSR_UART_CTRL MMPTR(0xe000000c)
#define CSR_UART_DEBUG MMPTR(0xe0000010)
#define UART_STAT_THRE (0x1) #define CSR_UART_EV_STAT MMPTR(0xe000000c)
#define UART_STAT_RX_EVT (0x2) #define CSR_UART_EV_PENDING MMPTR(0xe0000010)
#define UART_STAT_TX_EVT (0x4) #define CSR_UART_EV_ENABLE MMPTR(0xe0000014)
#define UART_CTRL_RX_INT (0x1) #define UART_EV_TX (0x1)
#define UART_CTRL_TX_INT (0x2) #define UART_EV_RX (0x2)
#define UART_CTRL_THRU (0x4)
#define UART_DEBUG_BREAK_EN (0x1)
#endif /* __HW_UART_H */ #endif /* __HW_UART_H */

View file

@ -44,14 +44,14 @@ static volatile int tx_cts;
void uart_isr(void) 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_buf[rx_produce] = CSR_UART_RXTX;
rx_produce = (rx_produce + 1) & UART_RINGBUFFER_MASK_RX; 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) { if(tx_produce != tx_consume) {
CSR_UART_RXTX = tx_buf[tx_consume]; CSR_UART_RXTX = tx_buf[tx_consume];
tx_consume = (tx_consume + 1) & UART_RINGBUFFER_MASK_TX; tx_consume = (tx_consume + 1) & UART_RINGBUFFER_MASK_TX;
@ -59,7 +59,7 @@ void uart_isr(void)
tx_cts = 1; tx_cts = 1;
} }
CSR_UART_STAT = stat; CSR_UART_EV_PENDING = stat;
irq_ack(IRQ_UART); irq_ack(IRQ_UART);
} }
@ -109,10 +109,10 @@ void uart_init(void)
irq_ack(IRQ_UART); irq_ack(IRQ_UART);
/* ack any events */ /* ack any events */
CSR_UART_STAT = CSR_UART_STAT; CSR_UART_EV_PENDING = CSR_UART_EV_PENDING;
/* enable interrupts */ /* 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_getmask();
mask |= IRQ_UART; mask |= IRQ_UART;