#include "eeprom.h" // The start address for the controller data uint16_t EEMEM start_address_controller = 0x1400; // Checks if the EEPROM memory is ready to be written in and waits until it is. void check_eeprom_is_ready(){ while(1){ if (eeprom_is_ready()){ break; }else{ ; } } } void write_struct_from_EEPROM(config_t write_struct){ // Calculate the required storage size uint8_t struct_size = sizeof(write_struct); // Wait for the EEPROM to be ready check_eeprom_is_ready(); // Update the stored config stuct eeprom_update_block((void*) &write_struct,(void*) &start_address_controller, struct_size); } config_t read_struct_from_EEPROM(){ // Create a config struct to hold the received data config_t read_struct = { 0 }; uint8_t struct_size = sizeof(read_struct); // Wait for the EEPROM to be ready check_eeprom_is_ready(); // Read the data from the EEPROM eeprom_read_block((void *) &read_struct,(void*) &start_address_controller, struct_size); // Return the data return read_struct; }