Intial commit

This commit is contained in:
CVR
2021-09-16 12:25:25 +12:00
parent 913afdb5dd
commit 8206c11344
10 changed files with 143 additions and 0 deletions

28
src/eeprom.cpp Normal file
View File

@@ -0,0 +1,28 @@
#include "eeprom.h"
namespace eeprom
{
void write(uint8_t address, uint8_t data) {
/* Wait for completion of previous write */
while(EECR & (1<<EEWE));
/* Set up address and data registers */
EEAR = address;
EEDR = data;
/* Write logical one to EEMWE */
EECR |= (1<<EEMWE);
/* Start eeprom write by setting EEWE */
EECR |= (1<<EEWE);
}
uint8_t read(uint8_t address) {
/* Wait for completion of previous write */
while(EECR & (1<<EEWE));
/* Set up address register */
EEAR = address;
/* Start eeprom read by writing EERE */
EECR |= (1<<EERE);
/* Return data from data register */
return EEDR;
}
} // namespace eeprom