2019-01-01 02:23:52 +00:00
|
|
|
#include <stdio.h>
|
2019-01-01 14:37:14 +00:00
|
|
|
#include <irq.h>
|
2019-01-01 14:10:02 +00:00
|
|
|
#include <printf.h>
|
|
|
|
#include <uart.h>
|
2019-01-01 14:37:14 +00:00
|
|
|
#include <usb.h>
|
2019-01-01 02:23:52 +00:00
|
|
|
|
2019-01-01 14:10:02 +00:00
|
|
|
#include <generated/csr.h>
|
|
|
|
|
|
|
|
void isr(void) {
|
2019-01-01 14:37:14 +00:00
|
|
|
unsigned int irqs;
|
|
|
|
|
|
|
|
irqs = irq_pending() & irq_getmask();
|
|
|
|
|
2019-01-22 01:01:46 +00:00
|
|
|
// if (irqs & (1 << USB_INTERRUPT))
|
|
|
|
// usb_isr();
|
2019-01-01 14:37:14 +00:00
|
|
|
|
|
|
|
if (irqs & (1 << UART_INTERRUPT))
|
|
|
|
uart_isr();
|
2019-01-01 14:10:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rv_putchar(void *ignored, char c) {
|
|
|
|
(void)ignored;
|
|
|
|
uart_write(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void init(void) {
|
|
|
|
irq_setmask(0);
|
2019-01-01 14:37:14 +00:00
|
|
|
irq_setie(1);
|
|
|
|
uart_init();
|
2019-01-01 15:03:45 +00:00
|
|
|
usb_init();
|
2019-01-01 14:10:02 +00:00
|
|
|
init_printf(NULL, rv_putchar);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
(void)argc;
|
|
|
|
(void)argv;
|
|
|
|
|
|
|
|
init();
|
|
|
|
|
|
|
|
int i = 0;
|
2019-01-01 02:23:52 +00:00
|
|
|
printf("Hello, world!\n");
|
|
|
|
while (1) {
|
|
|
|
printf("10 PRINT HELLO, WORLD\n");
|
|
|
|
printf("20 GOTO 10\n");
|
2019-01-01 14:10:02 +00:00
|
|
|
printf("i: %d\n", i++);
|
2019-01-01 02:23:52 +00:00
|
|
|
}
|
2019-01-01 14:10:02 +00:00
|
|
|
return 0;
|
2019-01-01 02:23:52 +00:00
|
|
|
}
|