27 lines
		
	
	
		
			346 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			346 B
		
	
	
	
		
			C
		
	
	
	
	
	
| #include "led.h"
 | |
| #include "uart.h"
 | |
| 
 | |
| #define uart0 ((struct uart*)0xc010)
 | |
| 
 | |
| int main() {
 | |
|   int c;
 | |
|   int led = 0;
 | |
| 
 | |
|   while (1) {
 | |
|     led_write(1 << led);
 | |
|     c = uart_read(uart0);
 | |
| 
 | |
|     if (c == 'a') {
 | |
|       led++;
 | |
|     } else if (c == 'd') {
 | |
|       led--;
 | |
|     }
 | |
| 
 | |
|     if (led == 8) {
 | |
|       led = 0;
 | |
|     } else if (led < 0) {
 | |
|       led = 7;
 | |
|     }
 | |
|   }
 | |
| }
 |