Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

software: use new UART

  • Loading branch information...
commit 5cde57cb653839ec6265a9b60440522d23b2215d 1 parent 33f1c45
Sébastien Bourdeauducq authored February 06, 2012
2  software/bios/main.c
@@ -3,7 +3,7 @@
3 3
 static void print(const char *s)
4 4
 {
5 5
 	while(*s) {
6  
-		while(!(CSR_UART_STAT & UART_STAT_THRE));
  6
+		while(CSR_UART_EV_STAT & UART_EV_TX);
7 7
 		CSR_UART_RXTX = *s;
8 8
 		s++;
9 9
 	}
21  software/include/hw/uart.h
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * Milkymist SoC (Software)
3  
- * Copyright (C) 2007, 2008, 2009, 2010 Sebastien Bourdeauducq
  3
+ * Copyright (C) 2007, 2008, 2009, 2010, 2012 Sebastien Bourdeauducq
4 4
  *
5 5
  * This program is free software: you can redistribute it and/or modify
6 6
  * it under the terms of the GNU General Public License as published by
@@ -21,19 +21,14 @@
21 21
 #include <hw/common.h>
22 22
 
23 23
 #define CSR_UART_RXTX 		MMPTR(0xe0000000)
24  
-#define CSR_UART_DIVISOR	MMPTR(0xe0000004)
25  
-#define CSR_UART_STAT		MMPTR(0xe0000008)
26  
-#define CSR_UART_CTRL		MMPTR(0xe000000c)
27  
-#define CSR_UART_DEBUG		MMPTR(0xe0000010)
  24
+#define CSR_UART_DIVISORH	MMPTR(0xe0000004)
  25
+#define CSR_UART_DIVISORL	MMPTR(0xe0000008)
28 26
 
29  
-#define UART_STAT_THRE		(0x1)
30  
-#define UART_STAT_RX_EVT	(0x2)
31  
-#define UART_STAT_TX_EVT	(0x4)
  27
+#define CSR_UART_EV_STAT	MMPTR(0xe000000c)
  28
+#define CSR_UART_EV_PENDING	MMPTR(0xe0000010)
  29
+#define CSR_UART_EV_ENABLE	MMPTR(0xe0000014)
32 30
 
33  
-#define UART_CTRL_RX_INT	(0x1)
34  
-#define UART_CTRL_TX_INT	(0x2)
35  
-#define UART_CTRL_THRU		(0x4)
36  
-
37  
-#define UART_DEBUG_BREAK_EN	(0x1)
  31
+#define UART_EV_TX		(0x1)
  32
+#define UART_EV_RX		(0x2)
38 33
 
39 34
 #endif /* __HW_UART_H */
12  software/libbase/uart.c
@@ -44,14 +44,14 @@ static volatile int tx_cts;
44 44
 
45 45
 void uart_isr(void)
46 46
 {
47  
-	unsigned int stat = CSR_UART_STAT;
  47
+	unsigned int stat = CSR_UART_EV_PENDING;
48 48
 
49  
-	if(stat & UART_STAT_RX_EVT) {
  49
+	if(stat & UART_EV_RX) {
50 50
 		rx_buf[rx_produce] = CSR_UART_RXTX;
51 51
 		rx_produce = (rx_produce + 1) & UART_RINGBUFFER_MASK_RX;
52 52
 	}
53 53
 
54  
-	if(stat & UART_STAT_TX_EVT) {
  54
+	if(stat & UART_EV_TX) {
55 55
 		if(tx_produce != tx_consume) {
56 56
 			CSR_UART_RXTX = tx_buf[tx_consume];
57 57
 			tx_consume = (tx_consume + 1) & UART_RINGBUFFER_MASK_TX;
@@ -59,7 +59,7 @@ void uart_isr(void)
59 59
 			tx_cts = 1;
60 60
 	}
61 61
 
62  
-	CSR_UART_STAT = stat;
  62
+	CSR_UART_EV_PENDING = stat;
63 63
 	irq_ack(IRQ_UART);
64 64
 }
65 65
 
@@ -109,10 +109,10 @@ void uart_init(void)
109 109
 	irq_ack(IRQ_UART);
110 110
 
111 111
 	/* ack any events */
112  
-	CSR_UART_STAT = CSR_UART_STAT;
  112
+	CSR_UART_EV_PENDING = CSR_UART_EV_PENDING;
113 113
 
114 114
 	/* enable interrupts */
115  
-	CSR_UART_CTRL = UART_CTRL_TX_INT | UART_CTRL_RX_INT;
  115
+	CSR_UART_EV_ENABLE = UART_EV_TX | UART_EV_RX;
116 116
 
117 117
 	mask = irq_getmask();
118 118
 	mask |= IRQ_UART;

0 notes on commit 5cde57c

Please sign in to comment.
Something went wrong with that request. Please try again.