Revision 1461
updated all the library code to have sensible _init behavior.
Almost all of the library components have a global variable which gets set after init and the functions inside will fail with an error code if init has not been called. Also, the init functions themselves check this variable and will bail out without doing any damage if that init has already been called
eeprom.h | ||
---|---|---|
1 |
/** |
|
2 |
* @file eeprom.h |
|
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 |
#ifndef _EEPROM_H_ |
11 | 2 |
#define _EEPROM_H_ |
12 | 3 |
|
13 | 4 |
#define EEPROM_ROBOT_ID_ADDR 0x10 |
14 | 5 |
#define EEPROM_BOM_TYPE_ADDR 0x14 |
15 | 6 |
|
16 |
/** @brief store a byte to eeproem |
|
17 |
* @return 0 if success, nonzero on failure |
|
18 |
*/ |
|
19 | 7 |
int eeprom_put_byte(unsigned int addr, unsigned char byte); |
20 | 8 |
|
21 |
/** @brief reads a byte from eeprom |
|
22 |
* |
|
23 |
* Pass it thge address and a pointer to a byte where the byte at the |
|
24 |
* address will be stored |
|
25 |
* |
|
26 |
* @return 0 if successful (byte is set to the eeprom value at addr), |
|
27 |
* nonzero if there was a problem |
|
28 |
*/ |
|
29 | 9 |
int eeprom_get_byte(unsigned int addr, unsigned char *byte); |
30 | 10 |
|
31 |
/** @brief get stored robot ID |
|
32 |
* |
|
33 |
* checks that EEPROM has been programed with an ID and returns it |
|
34 |
* |
|
35 |
* @return the robot id, if it is stored. If it returns 0xFF it is probably invalid |
|
36 |
*/ |
|
37 | 11 |
unsigned char get_robotid(void); |
38 | 12 |
|
39 |
/** @brief get stored robot ID |
|
40 |
* |
|
41 |
* checks that EEPROM has been programed with an BOM type and returns it |
|
42 |
* |
|
43 |
* @return the robot bom type as defined in bom.h, if it is stored. If it returns 0xFF it is probably invalid |
|
44 |
*/ |
|
45 | 13 |
unsigned char get_bom_type(void); |
46 | 14 |
|
47 | 15 |
#endif |
Also available in: Unified diff