mikrokontrollersystemer-pro.../prosjekt.X/eeprom.c
Sebastian H. Gabrielli d31f03b6c7 Delete unused EEPROM code & update comments
We don't use a lot of the written EEPROM code.
This unused code has now been deleted
2024-04-28 20:21:56 +02:00

42 lines
1.1 KiB
C

#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;
}