Skip to content

Commit

Permalink
fixup! fixup! EEPROM functions modifications to read and write every …
Browse files Browse the repository at this point in the history
…byte
  • Loading branch information
cua-cua committed Nov 5, 2018
1 parent cfe617c commit 80aff94
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/solve.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "solve.h"

#define EEPROM_NUM_BYTES_ERASED_CHECKED ((uint8_t)1)
#define EEPROM_NUM_BYTES_ERASED_CHECKED ((uint8_t)4)
#define EEPROM_BYTE_ERASED_VALUE 255
static char run_sequence[MAZE_AREA];

Expand Down Expand Up @@ -175,12 +175,15 @@ void reset_maze(void)
*/
bool maze_is_saved(void)
{
uint8_t byte = 0, *byte_pointer = &byte;
uint8_t maze_sample[EEPROM_NUM_BYTES_ERASED_CHECKED];

eeprom_read_data(FLASH_EEPROM_ADDRESS_MAZE, 1, byte_pointer);
eeprom_read_data(FLASH_EEPROM_ADDRESS_MAZE,
EEPROM_NUM_BYTES_ERASED_CHECKED, maze_sample);

if (*byte_pointer != EEPROM_BYTE_ERASED_VALUE)
return true;
for (uint8_t iter = 0; iter < EEPROM_NUM_BYTES_ERASED_CHECKED; iter++) {
if (maze_sample[iter] != EEPROM_BYTE_ERASED_VALUE)
return true;
}

return false;
}

0 comments on commit 80aff94

Please sign in to comment.