5 #include <avr/interrupt.h>
6 #include <util/delay.h>
9 /* TODO before board arrive:
11 * - RTC time/data setting
12 * - hack the digit drivers with 7seg?
16 * B[0,2]: serial clock for the 3 shift registers
17 * B4: SPI MISO connected to RTC I/O pin
18 * B5: SPI SCK connected to RTC serial clock
20 * C0: serial data for the 3 shift registers
21 * C1: hour separator LEDs
22 * C2: RTC chip select (active high)
29 #define PB_RTC_DATA 0x10
30 #define PB_RTC_CK 0x20
33 #define PC_RTC_EN 0x04
41 static void proc_cmd(char *input);
45 static char input[128];
46 static unsigned char inp_cidx;
51 /* SPI (SS/MOSI/SCK) are outputs */
52 DDRB = ~PB_RTC_DATA; /* port B all outputs except the RTC data line */
54 DDRC = 0xff; /* port C all outputs */
56 DDRD = 0xff; /* port D all outputs */
59 /* init the serial port we use to talk to the host */
70 if(c == '\r' || c == '\n') {
74 } else if(inp_cidx < sizeof input - 1) {
75 input[inp_cidx++] = c;
82 static void proc_cmd(char *input)
86 echo = input[1] == '1' ? 1 : 0;
87 printf("OK echo %s\n", echo ? "on" : "off");
91 puts("OK command help");
92 puts(" e 0|1: turn echo on/off");
96 printf("ERR unknown command: '%c'\n", input[0]);