Created
May 1, 2018 09:36
-
-
Save abdul-rehman-2050/d69511fe4388816863dfc3682c4c4892 to your computer and use it in GitHub Desktop.
16 bit integer read and write to eeprom
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//=========================================================================================== | |
//This function will write a 2 byte integer to the eeprom at the specified address and address + 1 | |
void EEPROMWriteInt(int p_address, int p_value) | |
{ | |
byte lowByte = ((p_value >> 0) & 0xFF); | |
byte highByte = ((p_value >> 8) & 0xFF); | |
EEPROM.write(p_address, lowByte); | |
EEPROM.write(p_address + 1, highByte); | |
} | |
//This function will read a 2 byte integer from the eeprom at the specified address and address + 1 | |
unsigned int EEPROMReadInt(int p_address) | |
{ | |
byte lowByte = EEPROM.read(p_address); | |
byte highByte = EEPROM.read(p_address + 1); | |
return ((lowByte << 0) & 0xFF) + ((highByte << 8) & 0xFF00); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment