Revision 1496
Reverted "libdragonfly" folder back to version before Init Checking was implemented and did "make dist" to recompile the library. BOM LEDs now shine
correctly.
eeprom.c | ||
---|---|---|
1 |
/** |
|
2 |
* @file eeprom.c |
|
3 |
* @brief handles eeprom storage for persistent data |
|
4 |
* |
|
5 |
* Contains functions and definitions for reading and writing to eeprom |
|
6 |
* |
|
7 |
* @author Colony Project, Brad Neuman |
|
8 |
*/ |
|
9 |
|
|
10 | 1 |
#include <avr/io.h> |
11 | 2 |
#include "eeprom.h" |
12 | 3 |
|
13 |
/** @brief store a byte to eeproem |
|
14 |
* @return 0 if success, nonzero on failure |
|
15 |
*/ |
|
16 | 4 |
int eeprom_put_byte(unsigned int uiAddress, unsigned char ucData) { |
17 | 5 |
/* Wait for completion of previous write */ |
18 | 6 |
while(EECR & (1<<EEWE)); |
... | ... | |
27 | 15 |
return 0; |
28 | 16 |
} |
29 | 17 |
|
30 |
/** @brief reads a byte from eeprom |
|
31 |
* |
|
32 |
* Pass it thge address and a pointer to a byte where the byte at the |
|
33 |
* address will be stored |
|
34 |
* |
|
35 |
* @return 0 if successful (byte is set to the eeprom value at addr), |
|
36 |
* nonzero if there was a problem |
|
37 |
*/ |
|
38 | 18 |
int eeprom_get_byte(unsigned int uiAddress, unsigned char *byte) { |
39 | 19 |
/* Wait for completion of previous write */ |
40 | 20 |
while(EECR & (1<<EEWE)); |
... | ... | |
48 | 28 |
return 0; |
49 | 29 |
} |
50 | 30 |
|
51 |
/** @brief get stored robot ID |
|
52 |
* |
|
53 |
* checks that EEPROM has been programed with an ID and returns it |
|
54 |
* |
|
55 |
* @return the robot id, if it is stored. If it returns 0xFF it is probably invalid |
|
56 |
*/ |
|
31 |
|
|
57 | 32 |
unsigned char get_robotid(void) { |
58 | 33 |
unsigned char c0, c1, c2; |
59 | 34 |
|
... | ... | |
66 | 41 |
return 0xFF; |
67 | 42 |
} |
68 | 43 |
|
69 |
/** @brief get stored robot ID |
|
70 |
* |
|
71 |
* checks that EEPROM has been programed with an BOM type and returns it |
|
72 |
* |
|
73 |
* @return the robot bom type as defined in bom.h, if it is stored. If it returns 0xFF it is probably invalid |
|
74 |
*/ |
|
75 | 44 |
unsigned char get_bom_type(void) { |
76 | 45 |
unsigned char c0, c1, c2, c3; |
77 | 46 |
|
Also available in: Unified diff