1Mbit EEPROMを便利に使うためのライブラリ

Dependents:   EEPROM_Reset_Program EEPROM_Encode_Program SWAN_IZU2019_v1

Revision:
1:66c2c82f4b34
Parent:
0:a945081a4a9e
Child:
3:d040fa9b5bb9
--- a/EEPROM_lib.cpp	Mon Feb 11 15:41:56 2019 +0000
+++ b/EEPROM_lib.cpp	Mon Feb 11 16:59:46 2019 +0000
@@ -5,10 +5,8 @@
     i2c = &user_i2c;
     i2c -> frequency(400000);
     
-    //max_ptr = 1024 * 1024 * num - 1;
     max_num = num;
     buff_ptr = 0;
-    //eeprom_ptr = 0;
     ptr[3] = ptr[2] = ptr[1] = ptr[0] = 0x00;
 }
 
@@ -107,31 +105,26 @@
 }
 
 int EEPROM_lib::chargeBuff(char DATA){
-    //if(eeprom_ptr < max_ptr && buff_ptr < 128){
     if(buff_ptr < 128){
         EEPROM_cast.c = DATA;
         cmd[buff_ptr + 2] = EEPROM_cast.cast[0];
         
         buff_ptr ++;
-        //eeprom_ptr ++;
     }
     return buff_ptr;
 }
 
 int EEPROM_lib::chargeBuff(bool DATA){
-    //if(eeprom_ptr < max_ptr && buff_ptr < 128){
     if(buff_ptr < 128){
         EEPROM_cast.b = DATA;
         cmd[buff_ptr + 2] = EEPROM_cast.cast[0];
         
         buff_ptr ++;
-        //eeprom_ptr ++;
     }
     return buff_ptr;
 }
 
 int EEPROM_lib::chargeBuff(int DATA){
-    //if(eeprom_ptr < max_ptr - 3 && buff_ptr < 128 - 3){
     if(buff_ptr < 128 - 3){
         EEPROM_cast.i = DATA;
         cmd[buff_ptr + 2] = EEPROM_cast.cast[3];
@@ -140,26 +133,22 @@
         cmd[buff_ptr + 5] = EEPROM_cast.cast[0];
         
         buff_ptr += 4;
-        //eeprom_ptr += 4;
     }
     return buff_ptr;
 }
 
 int EEPROM_lib::chargeBuff(short DATA){
-    //if(eeprom_ptr < max_ptr - 1 && buff_ptr < 128 - 1){
     if(buff_ptr < 128 - 1){
         EEPROM_cast.s = DATA;
         cmd[buff_ptr + 2] = EEPROM_cast.cast[1];
         cmd[buff_ptr + 3] = EEPROM_cast.cast[0];
         
         buff_ptr += 2;
-        //eeprom_ptr += 2;
     }
     return buff_ptr;
 }
 
 int EEPROM_lib::chargeBuff(long long DATA){
-    //if(eeprom_ptr < max_ptr - 7 && buff_ptr < 128 - 7){
     if(buff_ptr < 128 - 7){
         EEPROM_cast.ll = DATA;
         cmd[buff_ptr + 2] = EEPROM_cast.cast[7];
@@ -172,13 +161,11 @@
         cmd[buff_ptr + 9] = EEPROM_cast.cast[0];
         
         buff_ptr += 8;
-        //eeprom_ptr += 8;
     }
     return buff_ptr;
 }
 
 int EEPROM_lib::chargeBuff(float DATA){
-    //if(eeprom_ptr < max_ptr - 3 && buff_ptr < 128 - 3){
     if(buff_ptr < 128 - 3){
         EEPROM_cast.f = DATA;
         cmd[buff_ptr + 2] = EEPROM_cast.cast[3];
@@ -187,13 +174,11 @@
         cmd[buff_ptr + 5] = EEPROM_cast.cast[0];
         
         buff_ptr += 4;
-        //eeprom_ptr += 4;
     }
     return buff_ptr;
 }
 
 int EEPROM_lib::chargeBuff(double DATA){
-    //if(eeprom_ptr < max_ptr - 7 && buff_ptr < 128 - 7){
     if(buff_ptr < 128 - 7){
         EEPROM_cast.d = DATA;
         cmd[buff_ptr + 2] = EEPROM_cast.cast[7];
@@ -206,7 +191,6 @@
         cmd[buff_ptr + 9] = EEPROM_cast.cast[0];
         
         buff_ptr += 8;
-        //eeprom_ptr += 8;
     }
     return buff_ptr;
 }