Revision 1572 branches/ir_branch/code/tools/eeprom/program_eeprom.c

View differences:

program_eeprom.c
1 1
#include <dragonfly_lib.h>
2
#include <stdlib.h>
2 3
#include <eeprom.h>
3 4

  
4 5
int main()
5 6
{
6 7
  char str[5];
7
  int i=0,id;
8
  int i=0,id,ir_offset;
8 9
  char c;
9 10

  
10 11
  dragonfly_init(ALL_ON);
......
12 13
  usb_puts("Here is the current setup:\r\n  ID: ");
13 14
  itoa(get_robotid(), str, 10);
14 15
  usb_puts(str);
16
  
15 17
  usb_puts("\r\n  BOM type: ");
16 18
  itoa(get_bom_type(), str, 10);
17 19
  usb_puts(str);
20
  
21
  usb_puts("\r\n  IR Offset: ");
22
  itoa(get_ir_offset(), str, 10);
23
  usb_puts(str);
24
  
25
  
18 26
  usb_puts("\r\n\r\nEnter new ID:");
19 27

  
20 28
  while((c = usb_getc()) != '\n' && c != '\r')
......
64 72
  eeprom_put_byte(EEPROM_BOM_TYPE_ADDR+2, 'M');
65 73
  eeprom_put_byte(EEPROM_BOM_TYPE_ADDR+3, id);
66 74

  
75
  usb_puts("\r\n\r\nEnter new IR Offset:");
76
  i = 0;
77
  while((c = usb_getc()) != '\n' && c != '\r')
78
    {
79
      usb_putc(c);
80
      if(i>=4)
81
      {
82
        usb_puts("ERROR: filled buffer\n");
83
        while(1);
84
      }
85
      str[i++] = c;
86
    }
87
  while(i<5)
88
    str[i++] = 0;
67 89

  
90
  ir_offset = atoi(str);
68 91

  
92
  usb_puts("\r\nsetting new IR_offset to: ");
93
  usb_puti(ir_offset);
94
  
95
  eeprom_put_byte(EEPROM_IR_OFFSET_ADDR, 'I');
96
  eeprom_put_byte(EEPROM_IR_OFFSET_ADDR+1, 'R');
97
  eeprom_put_byte(EEPROM_IR_OFFSET_ADDR+2, ir_offset);
98

  
69 99
  usb_puts("\r\ndone! have a nice day\r\n");
70 100

  
71 101

  

Also available in: Unified diff