Skip to content

Commit

Permalink
Update EEPROM.h
Browse files Browse the repository at this point in the history
EEPROM.h now works

I had it working about the same time you did - then got distracted by how annoying it was to print hex bytes and worked on that for a while. But anyway, this looks like it works.
  • Loading branch information
SpenceKonde committed Oct 11, 2020
1 parent 085051d commit 5403512
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion megaavr/libraries/EEPROM/src/EEPROM.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ struct EERef {
return *this = *ref;
}
EERef &operator=(uint8_t in) {
return eeprom_write_byte((uint8_t *)(uint16_t) index, in), *this;
_PROTECTED_WRITE_SPM(NVMCTRL.CTRLA, NVMCTRL_CMD_EEERWR_gc);
*(uint8_t*)(uint16_t)(MAPPED_EEPROM_START+index)=in;
while (NVMCTRL.STATUS & NVMCTRL_EEBUSY_bm);
_PROTECTED_WRITE_SPM(NVMCTRL.CTRLA, NVMCTRL_CMD_NONE_gc);
return *this;
}
EERef &operator +=(uint8_t in) {
return *this = **this + in;
Expand Down

0 comments on commit 5403512

Please sign in to comment.