Skip to content
Permalink
Browse files
software: use new UART
  • Loading branch information
Sebastien Bourdeauducq committed Feb 6, 2012
1 parent 33f1c45 commit 5cde57cb653839ec6265a9b60440522d23b2215d
Showing with 15 additions and 20 deletions.
  1. +1 −1 software/bios/main.c
  2. +8 −13 software/include/hw/uart.h
  3. +6 −6 software/libbase/uart.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++;
}
@@ -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 <hw/common.h>

#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 */
@@ -44,22 +44,22 @@ 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;
} else
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;

0 comments on commit 5cde57c

Please sign in to comment.