[En-Nut-Discussion] Read and Write EEPROM

Alexander Baranov baranov at intech21.com
Mon Oct 3 21:42:43 CEST 2005


>
> Would you send little example (C-code) how to do this?
>
> -jari
>
>
>
void SaveCommSettingsToEEPROM( void ){
 /* write a byte VAL to EEPROM address ADDR */
 pSettingsComm->crc = get_crc( (u_char*)pSettingsComm,
sizeof(SETTINGSCOMM)-sizeof(u_int));
 u_char* p = (u_char*)pSettingsComm;
 u_int i=0;
 for(i=0;i<sizeof(SETTINGSCOMM);i++){
  eeprom_wb(SETTINGSCOMM_EE_OFFSET+i, *p++);
 }
 for(i=0;i<sizeof(SETTINGSCOMM);i++){    //double reserve
  eeprom_wb(SETTINGSCOMM_EE_OFFSET+sizeof(SETTINGSCOMM)+1, *p++);
 }
}





More information about the En-Nut-Discussion mailing list