Change namingsheme

This commit is contained in:
Elp03 2024-03-13 11:48:58 +01:00
parent c48f87bcea
commit 4a8b6137d1
3 changed files with 39 additions and 41 deletions

View File

@ -1,25 +1,23 @@
#include "eeprom.h" #include "eeprom.h"
// The start address for the controller data // The start address for the controller data
uint8_t EEMEM startAddressController = 0x00; uint8_t EEMEM start_address_controller = 0x00;
// Where the writing of the fans points start // Where the writing of the fans points start
uint8_t EEMEM startAddressFan1 = 0x30; uint8_t EEMEM start_address_fan1 = 0x30;
uint8_t EEMEM startAddressFan2 = 0x60; uint8_t EEMEM start_address_fan2 = 0x60;
// The placement for the next datapoint form the fans. // The placement for the next datapoint form the fans.
uint8_t EEMEM currentAddressFan1 = 0x30; uint8_t EEMEM current_address_fan1 = 0x30;
uint8_t EEMEM currentAddressFan2 = 0x60; uint8_t EEMEM current_address_fan2 = 0x60;
// Checks if the EEPROM memory is ready to be written in. // Checks if the EEPROM memory is ready to be written in.
void checkEEpromIsReady(){ void check_eeprom_is_ready(){
while(1){ while(1){
if (eeprom_is_ready()){ if (eeprom_is_ready()){
break; break;
printf("it is");
}else{ }else{
; ;
printf("its not");
} }
} }
} }
@ -30,42 +28,42 @@ void checkEEpromIsReady(){
// Checks if it has been written information at the address // Checks if it has been written information at the address
// If true, the infromation is replaced with the intaken struct // If true, the infromation is replaced with the intaken struct
// else the intaken struct is written at the address. // else the intaken struct is written at the address.
void WriteStructInEEPROM(config_t writeStruct){ void write_struct_in_EEPROM(config_t write_struct){
uint8_t structSize; uint8_t struct_size;
structSize = sizeof(writeStruct); struct_size = sizeof(write_struct);
checkEEpromIsReady(); check_eeprom_is_ready();
eeprom_update_block((void*) &writeStruct,(void*) &startAddressController, structSize); eeprom_update_block((void*) &write_struct,(void*) &start_address_controller, struct_size);
} }
// Reads the memory block at the address 0x00 // Reads the memory block at the address 0x00
// returns a struct in form of config_t // returns a struct in form of config_t
config_t ReadStructInEEPROM(){ config_t read_struct_from_EEPROM(){
//is eeprom ready?? //is eeprom ready??
config_t readStruct; config_t read_struct;
uint8_t structsize = sizeof(readStruct); uint8_t struct_size = sizeof(read_struct);
checkEEpromIsReady(); check_eeprom_is_ready();
eeprom_read_block((void *) &readStruct,(void*) &startAddressController, structsize); eeprom_read_block((void *) &read_struct,(void*) &start_address_controller, struct_size);
return readStruct; return read_struct;
} }
// Takes inn a dataPoint and what data set it belongs to // Takes inn a dataPoint and what data set it belongs to
// checks if EEPROM is ready // checks if EEPROM is ready
// If the dataset is 1, the datapoint is written at the address. // If the dataset is 1, the datapoint is written at the address.
// If the dataset is 2 its written at another point. // If the dataset is 2 its written at another point.
void WriteDataPointInEEPROM(uint8_t dataPoint, uint8_t data){ void write_data_point_in_EEPROM(uint8_t data_point, uint8_t data){
checkEEpromIsReady(); check_eeprom_is_ready();
if (data == 1){ if (data == 1){
eeprom_update_byte(currentAddressFan1, dataPoint); eeprom_update_byte(current_address_fan1, data_point);
currentAddressFan1++; current_address_fan1++;
} else if (data == 2){ } else if (data == 2){
eeprom_update_byte(currentAddressFan2, dataPoint); eeprom_update_byte(current_address_fan2, data_point);
currentAddressFan2++; current_address_fan2++;
} else{ } else{
// error??? // error???
; ;
@ -74,25 +72,25 @@ void WriteDataPointInEEPROM(uint8_t dataPoint, uint8_t data){
// Reads all the datapoints to the choosen data. // Reads all the datapoints to the choosen data.
// it writes the data points in the USART stream. // it writes the data points in the USART stream.
void ReadDataPointSpeedInfo(uint8_t data){ void read_data_point_speed_info(uint8_t data){
uint8_t dataPoint = 0; uint8_t data_point = 0;
if (data == 1){ if (data == 1){
uint8_t len = currentAddressFan1 - startAddressFan1; uint8_t len = current_address_fan1 - start_address_fan1;
checkEEpromIsReady(); check_eeprom_is_ready();
for (uint8_t i = 0; i <len; i++){ for (uint8_t i = 0; i <len; i++){
dataPoint = eeprom_read_byte(i); data_point = eeprom_read_byte(i);
printf("Fanspeed nr %u : %u", i, dataPoint); printf("Fanspeed nr %u : %u", i, data_point);
} }
} else if (data == 2){ } else if (data == 2){
uint8_t len = currentAddressFan2 - startAddressFan2; uint8_t len = current_address_fan2 - start_address_fan2;
checkEEpromIsReady(); check_eeprom_is_ready();
for (uint8_t i = 0; i <len; i++){ for (uint8_t i = 0; i <len; i++){
dataPoint = eeprom_read_byte(i); data_point = eeprom_read_byte(i);
printf("Fanspeed nr %u : %u", i, dataPoint); printf("Fanspeed nr %u : %u", i, data_point);
} }
} }
} }

View File

@ -27,19 +27,19 @@ typedef struct {
} config_t; } config_t;
// Check if EEPROM is ready to be written in // Check if EEPROM is ready to be written in
void checkEEpromIsReady(); void check_eeprom_is_ready();
// Writes a struct in EEPROM // Writes a struct in EEPROM
void WriteStructInEEPROM(config_t writeStruct); void write_struct_in_EEPROM(config_t write_struct);
// Read data from EEPROM and return it as a controller struct // Read data from EEPROM and return it as a controller struct
config_t ReadStructInEEPROM(); config_t read_struct_from_EEPROM();
// Writes a datapoint in EEPROM // Writes a datapoint in EEPROM
void WriteDataPointInEEPROM(uint8_t dataPoint, uint8_t data); void write_data_point_in_EEPROM(uint8_t data_point, uint8_t data);
// Reads all the dataPoints form EEPROM // Reads all the dataPoints form EEPROM
void ReadDataPointSpeedInfo(uint8_t data); void read_data_point_speed_info(uint8_t data);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -4,6 +4,7 @@
<logicalFolder name="HeaderFiles" <logicalFolder name="HeaderFiles"
displayName="Header Files" displayName="Header Files"
projectFiles="true"> projectFiles="true">
<itemPath>eeprom.h</itemPath>
</logicalFolder> </logicalFolder>
<logicalFolder name="LinkerScript" <logicalFolder name="LinkerScript"
displayName="Linker Files" displayName="Linker Files"
@ -13,7 +14,6 @@
displayName="Source Files" displayName="Source Files"
projectFiles="true"> projectFiles="true">
<itemPath>main.c</itemPath> <itemPath>main.c</itemPath>
<itemPath>eeprom.h</itemPath>
<itemPath>eeprom.c</itemPath> <itemPath>eeprom.c</itemPath>
</logicalFolder> </logicalFolder>
<logicalFolder name="ExternalFiles" <logicalFolder name="ExternalFiles"