-#include <hw/uart.h>
-
-static void print(const char *s)
-{
- while(*s) {
- while(CSR_UART_EV_STAT & UART_EV_TX);
- CSR_UART_RXTX = *s;
- s++;
- }
-}
+#include <stdio.h>
+#include <irq.h>
+#include <uart.h>
int main(void)
{
- print("Hello World\n");
+ irq_setmask(0);
+ irq_setie(1);
+ uart_init();
+
+ printf("Hello World with IRQs\n");
+
while(1);
}
#ifndef __IRQ_H
#define __IRQ_H
-static inline void irq_enable(unsigned int en)
+static inline unsigned int irq_getie(void)
{
- __asm__ __volatile__("wcsr IE, %0" : : "r" (en));
+ unsigned int ie;
+ __asm__ __volatile__("rcsr %0, IE" : "=r" (ie));
+ return ie;
+}
+
+static inline void irq_setie(unsigned int ie)
+{
+ __asm__ __volatile__("wcsr IE, %0" : : "r" (ie));
}
static inline unsigned int irq_getmask(void)
__asm__ __volatile__("wcsr IP, %0" : : "r" (mask));
}
-static inline unsigned int irq_getie(void)
-{
- unsigned int ie;
- __asm__ __volatile__("rcsr %0, IE" : "=r" (ie));
- return ie;
-}
-
-static inline void irq_setie(unsigned int ie)
-{
- __asm__ __volatile__("wcsr IE, %0" : : "r" (ie));
-}
-
#endif /* __IRQ_H */