Revision 1302
removed eeprom files from test directory becuase they are now in the library. the current test directory now compiles.
trunk/code/projects/test/eeprom.c | ||
---|---|---|
1 |
#include <avr/io.h> |
|
2 |
#include "eeprom.h" |
|
3 |
|
|
4 |
int eeprom_put_byte(unsigned int uiAddress, unsigned char ucData) { |
|
5 |
/* Wait for completion of previous write */ |
|
6 |
while(EECR & (1<<EEWE)); |
|
7 |
/* Set up address and data registers */ |
|
8 |
EEAR = uiAddress; |
|
9 |
EEDR = ucData; |
|
10 |
/* Write logical one to EEMWE */ |
|
11 |
EECR |= (1<<EEMWE); |
|
12 |
/* Start eeprom write by setting EEWE */ |
|
13 |
EECR |= (1<<EEWE); |
|
14 |
|
|
15 |
return 0; |
|
16 |
} |
|
17 |
|
|
18 |
int eeprom_get_byte(unsigned int uiAddress, unsigned char *byte) { |
|
19 |
/* Wait for completion of previous write */ |
|
20 |
while(EECR & (1<<EEWE)); |
|
21 |
/* Set up address register */ |
|
22 |
EEAR = uiAddress; |
|
23 |
/* Start eeprom read by writing EERE */ |
|
24 |
EECR |= (1<<EERE); |
|
25 |
/* get data from data register */ |
|
26 |
*byte=EEDR; |
|
27 |
|
|
28 |
return 0; |
|
29 |
} |
|
30 |
|
|
31 |
|
|
32 |
unsigned char get_robotid(void) { |
|
33 |
unsigned char ret; |
|
34 |
|
|
35 |
eeprom_get_byte(EEPROM_ROBOT_ID_ADDR, &ret); |
|
36 |
|
|
37 |
return ret; |
|
38 |
} |
trunk/code/projects/test/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 |
#ifndef _EEPROM_H_ |
|
11 |
#define _EEPROM_H_ |
|
12 |
|
|
13 |
#define EEPROM_ROBOT_ID_ADDR 0x0b |
|
14 |
|
|
15 |
/** @brief store a byte to eeproem |
|
16 |
* @return 0 if success, nonzero on failure |
|
17 |
*/ |
|
18 |
int eeprom_put_byte(unsigned int addr, unsigned char byte); |
|
19 |
|
|
20 |
/** @brief reads a byte from eeprom |
|
21 |
* |
|
22 |
* Pass it thge address and a pointer to a byte where the byte at the |
|
23 |
* address will be stored |
|
24 |
* |
|
25 |
* @return 0 if successful (byte is set to the eeprom value at addr), |
|
26 |
* nonzero if there was a problem |
|
27 |
*/ |
|
28 |
int eeprom_get_byte(unsigned int addr, unsigned char *byte); |
|
29 |
|
|
30 |
/** @brief get stored robot ID |
|
31 |
* |
|
32 |
* returnes the value of eerpom at EEPROM_ROBOT_ID_ADDR |
|
33 |
* |
|
34 |
* @return the robot id, if it is stored. If it returns 0xff it is probably invalid |
|
35 |
*/ |
|
36 |
unsigned char get_robotid(void); |
|
37 |
|
|
38 |
#endif |
|
39 |
|
trunk/code/projects/test/main.c | ||
---|---|---|
8 | 8 |
//testlcd(); |
9 | 9 |
//testrangefinders(); |
10 | 10 |
//testanalog(); |
11 |
//testtokenring();
|
|
11 |
testtokenring(); |
|
12 | 12 |
//testencoders(); |
13 | 13 |
//testlights(); |
14 |
testmotors(); |
|
14 |
//testmotors();
|
|
15 | 15 |
|
16 | 16 |
return 0; |
17 | 17 |
} |
Also available in: Unified diff