2021-02-23 04:37:18 +00:00
|
|
|
#include "led.h"
|
|
|
|
#include "uart.h"
|
|
|
|
|
2021-03-13 23:49:28 +00:00
|
|
|
#define uart0 ((struct uart*)0xc010)
|
|
|
|
|
2021-02-23 04:37:18 +00:00
|
|
|
int main() {
|
|
|
|
int c;
|
|
|
|
int led = 0;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
led_write(1 << led);
|
2021-03-13 23:49:28 +00:00
|
|
|
c = uart_read(uart0);
|
2021-02-23 04:37:18 +00:00
|
|
|
|
|
|
|
if (c == 'a') {
|
|
|
|
led++;
|
|
|
|
} else if (c == 'd') {
|
|
|
|
led--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (led == 8) {
|
|
|
|
led = 0;
|
|
|
|
} else if (led < 0) {
|
|
|
|
led = 7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|