OSDN Git Service

[ADC][Battery] Fix stability, but still not collect.
[openi2cradio/OpenI2CRadio.git] / eeprom.c
index 8d1e46f..1d56b74 100644 (file)
--- a/eeprom.c
+++ b/eeprom.c
@@ -93,19 +93,20 @@ unsigned char eeprom_writebyte(unsigned int offset, unsigned char data)
     return 0xff;
 }
 
-unsigned char readbyte_eeprom(unsigned int p, unsigned int *sum)
+unsigned char readbyte_eeprom(unsigned int *p, unsigned int *sum)
 {
     unsigned char b;
 
     ClrWdt();
 
-    b = eeprom_readbyte(p);
+    b = eeprom_readbyte(*p);
     *sum = calcsum_byte(*sum, b);
+    *p = *p + 1;
 
     return b;
 }
 
-unsigned int readword_eeprom(unsigned int p, unsigned int *sum)
+unsigned int readword_eeprom(unsigned int *p, unsigned int *sum)
 {
     unsigned char h,l;
     unsigned int s;
@@ -113,7 +114,7 @@ unsigned int readword_eeprom(unsigned int p, unsigned int *sum)
 //    ClrWdt();
 
     h = readbyte_eeprom(p, sum);
-    l = readbyte_eeprom(p + 1, sum);
+    l = readbyte_eeprom(p, sum);
 
     s = (h << 8) | l;
     return s;
@@ -144,19 +145,20 @@ unsigned char checksum_eeprom(unsigned int seed, unsigned int offset, unsigned i
     return 0xff;
 }
 
-unsigned int writebyte_eeprom(unsigned int p, unsigned int *sum, unsigned char b)
+unsigned int writebyte_eeprom(unsigned int *p, unsigned int *sum, unsigned char b)
 {
     ClrWdt();
-    if(eeprom_writebyte(p, b) == 0) return p; // Error
+    if(eeprom_writebyte(*p, b) == 0) return *p; // Error
     *sum = calcsum_byte(*sum, b);
+    *p = *p + 1;
     return 0xffff;
 }
 
-unsigned int writeword_eeprom(unsigned int p, unsigned int *sum, unsigned int word)
+unsigned int writeword_eeprom(unsigned int *p, unsigned int *sum, unsigned int word)
 {
 //    ClrWdt();
-    if(writebyte_eeprom(p, sum, word >> 8) == 0) return p; // Error
-    if(writebyte_eeprom(p + 1, sum, word & 0xff) == 0) return p + 1; // Error
+    if(writebyte_eeprom(p, sum, word >> 8) == 0) return *p; // Error
+    if(writebyte_eeprom(p, sum, word & 0xff) == 0) return *p; // Error
     return 0xffff;
 }
 
@@ -176,6 +178,6 @@ unsigned int format_eeprom(unsigned int start, unsigned int bytes)
 //        p = p + 1;
     }
     _CLS();
-    _LOCATE(0,0);
+//    _LOCATE(0,0);
     return 0xffff; // Normal end
 }