From 1a6e8d8789d01f1a297fce5d94cc27c543b8a494 Mon Sep 17 00:00:00 2001 From: ameall Date: Thu, 4 Apr 2024 16:08:19 -0400 Subject: [PATCH] General improvements to code structure to address make errors --- Core/Src/eepromdirectory.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/Core/Src/eepromdirectory.c b/Core/Src/eepromdirectory.c index b1bc923..107a385 100644 --- a/Core/Src/eepromdirectory.c +++ b/Core/Src/eepromdirectory.c @@ -168,8 +168,8 @@ void get_faults() //TODO: Consolidate these into a single function after testing bool test_EEPROM(){ - test_main_EEPROM(); - test_fault_EEPROM(); + bool EEPROM_main_check test_main_EEPROM(); + bool EEPROM_fault_check = test_fault_EEPROM(); } //TODO: Verify that this code works as intended in hardware @@ -184,15 +184,14 @@ bool test_main_EEPROM(){ eeprom_write_data_address(root_address, ®_to_write, 1); eeprom_read_data_address(root_address, &data_read, 1); - if (data_read == known_data){ - printf("Data was successfully written and read from EEPROM"); - } - else{ - printf("Data was not successfully written/read from EEPROM"); - } - // Write data previously stored in EEPROM address back to EEPROM eeprom_write_data_address(root_address, ®_to_write, 1); + + if (data_read != known_data){ + return false; + } + + return true; } //TODO: Verify that this code works as intended in hardware @@ -252,17 +251,16 @@ bool test_fault_EEPROM(){ log_fault(test_fault); eeprom_read_data_address(curr_Address, &temp_Faults[index_reg], 4); - if (temp_Faults[index_reg] == test_fault){ - printf("Old fault successfully overwritten"); - } - else{ - printf("Old fault was not overwritten"); - } - // Re-write old faults back into register curr_Iter = 0; while (curr_Iter < NUM_EEPROM_FAULTS){ log_fault(read_Faults[curr_Iter]); curr_Iter++; } + + if (temp_Faults[index_reg] != test_fault){ + return false; + } + + return true; } \ No newline at end of file