外部EEPROM读写
void WRITE_FLOAT_EXT_EEPROM(long int n, float data) { //写浮点数到外部EEPROM int i; for (i = 0; i < 4; i++) write_ext_eeprom(i + n, *(&data + i) ) ; } float READ_FLOAT_EXT_EEPROM(long int n) {//从外部EEPROM读出浮点数 int i; float data; for (i = 0; i < 4; i++) *(&data + i) = read_ext_eeprom(i + n); return(data); } void WRITE_LONG_EXT_EEPROM(long int n, long data) { //写长整型数到外部EEPROM int i; for (i = 0; i < 4; i++) write_ext_eeprom(i + n, *(&data + i) ) ; } float READ_LONG_EXT_EEPROM(long int n) {//从外部EEPROM读出写入的长整型数 int i; long data; for (i = 0; i < 4; i++) *(&data + i) = read_ext_eeprom(i + n); return(data); }
用户评论
24LC65 EEPROM的读写程序,比较完整,说明更详细一点就更好了。