root / trunk / code / tools / eeprom / program_eeprom.c @ 1023
History | View | Annotate | Download (1.34 KB)
1 | 1023 | bneuman | #include <dragonfly_lib.h> |
---|---|---|---|
2 | #include <eeprom.h> |
||
3 | |||
4 | int main()
|
||
5 | { |
||
6 | char str[5]; |
||
7 | int i=0,id; |
||
8 | char c;
|
||
9 | |||
10 | dragonfly_init(ALL_ON); |
||
11 | |||
12 | usb_puts("Here is the current setup:\r\n ID: ");
|
||
13 | itoa(get_robotid(), str, 10);
|
||
14 | usb_puts(str); |
||
15 | usb_puts("\r\n BOM type: ");
|
||
16 | itoa(get_bom_type(), str, 10);
|
||
17 | usb_puts(str); |
||
18 | usb_puts("\r\n\r\nEnter new ID:");
|
||
19 | |||
20 | while((c = usb_getc()) != '\n' && c != '\r') |
||
21 | { |
||
22 | usb_putc(c); |
||
23 | if(i>=4) |
||
24 | { |
||
25 | usb_puts("ERROR: filled buffer\n");
|
||
26 | while(1); |
||
27 | } |
||
28 | str[i++] = c; |
||
29 | } |
||
30 | while(i<5) |
||
31 | str[i++] = 0;
|
||
32 | |||
33 | id = atoi(str); |
||
34 | |||
35 | usb_puts("\r\nsetting new id to: ");
|
||
36 | usb_puti(id); |
||
37 | |||
38 | |||
39 | eeprom_put_byte(EEPROM_ROBOT_ID_ADDR, 'I');
|
||
40 | eeprom_put_byte(EEPROM_ROBOT_ID_ADDR+1, 'D'); |
||
41 | eeprom_put_byte(EEPROM_ROBOT_ID_ADDR+2, id);
|
||
42 | |||
43 | |||
44 | usb_puts("\r\nEnter BOM type:\r\b"
|
||
45 | "1 for BOM 1.0\r\n"
|
||
46 | "5 for BOM 1.5\r\n"
|
||
47 | "r for RBOM\r\n>");
|
||
48 | |||
49 | c = usb_getc(); |
||
50 | usb_putc(c); |
||
51 | |||
52 | switch(c)
|
||
53 | { |
||
54 | case '1': id = BOM10; break; |
||
55 | case '5': id = BOM15; break; |
||
56 | case 'r': id = RBOM; break; |
||
57 | default:
|
||
58 | usb_puts("ERROR: invalid input");
|
||
59 | while(1); |
||
60 | } |
||
61 | |||
62 | eeprom_put_byte(EEPROM_BOM_TYPE_ADDR, 'B');
|
||
63 | eeprom_put_byte(EEPROM_BOM_TYPE_ADDR+1, 'O'); |
||
64 | eeprom_put_byte(EEPROM_BOM_TYPE_ADDR+2, 'M'); |
||
65 | eeprom_put_byte(EEPROM_BOM_TYPE_ADDR+3, id);
|
||
66 | |||
67 | |||
68 | |||
69 | usb_puts("\r\ndone! have a nice day\r\n");
|
||
70 | |||
71 | |||
72 | while(1); |
||
73 | |||
74 | return 0; |
||
75 | } |