LPC176x SPI / I2C PersistentStore (#17651)

This commit is contained in:
randellhodges
2020-04-28 02:27:55 -05:00
committed by GitHub
parent 7c3909bc3f
commit 5f7a75979f
29 changed files with 132 additions and 210 deletions

View File

@ -80,7 +80,7 @@ void eeprom_write_byte(uint8_t *pos, unsigned char value) {
HAL_FLASH_Unlock();
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR |FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR);
uint16_t eeprom_address = unsigned(pos);
const unsigned eeprom_address = (unsigned)pos;
if (EE_WriteVariable(eeprom_address, uint16_t(value)) != EE_OK)
for (;;) HAL_Delay(1); // Spin forever until watchdog reset
@ -91,7 +91,7 @@ uint8_t eeprom_read_byte(uint8_t *pos) {
eeprom_init();
uint16_t data = 0xFF;
uint16_t eeprom_address = unsigned(pos);
const unsigned eeprom_address = (unsigned)pos;
(void)EE_ReadVariable(eeprom_address, &data); // Data unchanged on error
return uint8_t(data);
@ -101,7 +101,7 @@ void eeprom_read_block(void *__dst, const void *__src, size_t __n) {
eeprom_init();
uint16_t data = 0xFF;
uint16_t eeprom_address = unsigned(__src);
const unsigned eeprom_address = (unsigned)__src;
LOOP_L_N(c, __n) {
EE_ReadVariable(eeprom_address+c, &data);
*((uint8_t*)__dst + c) = data;

View File

@ -26,4 +26,5 @@
#undef SRAM_EEPROM_EMULATION
#undef SDCARD_EEPROM_EMULATION
#define FLASH_EEPROM_EMULATION
#warning "Forcing use of FLASH_EEPROM_EMULATION."
#endif