I have this structure:
#define MEMORY 400
#define NUMBER 2
struct __attribute__((aligned(4))) Watering_valve
{
char Name[9];
short set=LOW;
short state=LOW;
short autom=LOW;
short timeout=LOW;
uint16_t voltage[MEMORY];
int16_t temp[MEMORY];
uint16_t count=0;
time_t login_epoch=0;
time_t watering_epoch=0;
Time auto_watering_time;
uint8_t temperature_graph;
uint8_t voltage_graph;
};
struct Watering_valve watering_valve[NUMBER];
I need to save it into the flash memory. I doing it by this way:
spi_flash_erase_sector(0x7b);
spi_flash_write(mem_sector0,(uint32_t *)&watering_valve[0],sizeof(watering_valve[0]));
or read:
spi_flash_read(mem_sector0,(uint32_t *)&watering_valve[0],sizeof(watering_valve[0]));
But this saves only the the watering_valve[0] structure, its going fine.
I tried to save all of the structure like this:
spi_flash_erase_sector(0x7b);
spi_flash_write(mem_sector0,(uint32_t *)&watering_valve[0],sizeof(watering_valve));
or read:
spi_flash_read(mem_sector0,(uint32_t *)&watering_valve[0],sizeof(watering_valve));
But this will cause reset on reading.