87 #define EEPROMADDRESS (0x00)
92 #define EEPROMPAGEMASK (0x7F)
100 #define SDA_HIGH (P5OUT |= 0x04)
101 #define SDA_LOW (P5OUT &= 0xFB)
102 #define SCL_HIGH (P5OUT |= 0x08)
103 #define SCL_LOW (P5OUT &= 0xF7)
149 write_bus(
unsigned char byte)
155 for(i = 0; i < 8; ++i) {
199 read_bus(
unsigned char ack)
202 unsigned char byte = 0;
206 for(i = 0; i < 8; ++i) {
253 }
while(!write_bus(0xa0 | EEPROMADDRESS));
257 write_bus(addr >> 8);
258 write_bus(addr & 0xff);
261 write_bus(0xa1 | EEPROMADDRESS);
263 for(i = 0; i < (size - 1); ++i){
264 buf[i] = read_bus(1);
266 buf[size - 1] = read_bus(0);
278 unsigned int curaddr;
288 for(i = 0; i < size; ++i) {
291 if(i == 0 || (curaddr & EEPROMPAGEMASK) == 0) {
295 }
while(!write_bus(0xa0 | EEPROMADDRESS));
298 if(write_bus(curaddr >> 8) == 0) {
301 if(write_bus(curaddr) == 0) {
307 if(write_bus(buf[i]) == 0) {
313 if(i == size - 1 || (curaddr & EEPROMPAGEMASK) == EEPROMPAGEMASK) {