Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

software: interrupt driven UART working

  • Loading branch information...
commit 4aaf48afb0bae3a39bcb59f22537eb3f0802e829 1 parent 58f4f78
Sébastien Bourdeauducq authored February 06, 2012
6  software/bios/isr.c
@@ -16,10 +16,16 @@
16 16
  */
17 17
 
18 18
 #include <hw/interrupts.h>
  19
+#include <hw/uart.h>
19 20
 #include <irq.h>
  21
+#include <uart.h>
20 22
 
21 23
 void isr(void)
22 24
 {
23 25
 	unsigned int irqs;
  26
+	
24 27
 	irqs = irq_pending() & irq_getmask();
  28
+	
  29
+	if(irqs & IRQ_UART)
  30
+		uart_isr();
25 31
 }
20  software/bios/main.c
... ...
@@ -1,16 +1,14 @@
1  
-#include <hw/uart.h>
2  
-
3  
-static void print(const char *s)
4  
-{
5  
-	while(*s) {
6  
-		while(CSR_UART_EV_STAT & UART_EV_TX);
7  
-		CSR_UART_RXTX = *s;
8  
-		s++;
9  
-	}
10  
-}
  1
+#include <stdio.h>
  2
+#include <irq.h>
  3
+#include <uart.h>
11 4
 
12 5
 int main(void)
13 6
 {
14  
-	print("Hello World\n");
  7
+	irq_setmask(0);
  8
+	irq_setie(1);
  9
+	uart_init();
  10
+	
  11
+	printf("Hello World with IRQs\n");
  12
+	
15 13
 	while(1);
16 14
 }
23  software/include/base/irq.h
@@ -18,9 +18,16 @@
18 18
 #ifndef __IRQ_H
19 19
 #define __IRQ_H
20 20
 
21  
-static inline void irq_enable(unsigned int en)
  21
+static inline unsigned int irq_getie(void)
22 22
 {
23  
-       __asm__ __volatile__("wcsr IE, %0" : : "r" (en));
  23
+       unsigned int ie;
  24
+       __asm__ __volatile__("rcsr %0, IE" : "=r" (ie));
  25
+       return ie;
  26
+}
  27
+
  28
+static inline void irq_setie(unsigned int ie)
  29
+{
  30
+       __asm__ __volatile__("wcsr IE, %0" : : "r" (ie));
24 31
 }
25 32
 
26 33
 static inline unsigned int irq_getmask(void)
@@ -47,16 +54,4 @@ static inline void irq_ack(unsigned int mask)
47 54
        __asm__ __volatile__("wcsr IP, %0" : : "r" (mask));
48 55
 }
49 56
 
50  
-static inline unsigned int irq_getie(void)
51  
-{
52  
-       unsigned int ie;
53  
-       __asm__ __volatile__("rcsr %0, IE" : "=r" (ie));
54  
-       return ie;
55  
-}
56  
-
57  
-static inline void irq_setie(unsigned int ie)
58  
-{
59  
-       __asm__ __volatile__("wcsr IE, %0" : : "r" (ie));
60  
-}
61  
-
62 57
 #endif /* __IRQ_H */
4  software/libbase/uart.c
@@ -44,7 +44,9 @@ static volatile int tx_cts;
44 44
 
45 45
 void uart_isr(void)
46 46
 {
47  
-	unsigned int stat = CSR_UART_EV_PENDING;
  47
+	unsigned int stat;
  48
+	
  49
+	stat = CSR_UART_EV_PENDING;
48 50
 
49 51
 	if(stat & UART_EV_RX) {
50 52
 		rx_buf[rx_produce] = CSR_UART_RXTX;

0 notes on commit 4aaf48a

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