diff --git a/Source/ElektronischeLast.cpp b/Source/ElektronischeLast.cpp index b9cad85..001573a 100644 --- a/Source/ElektronischeLast.cpp +++ b/Source/ElektronischeLast.cpp @@ -27,8 +27,8 @@ using namespace ElektronischeLast; #define EEPROM_ADDRESS_VOLTAGE 0U #define EEPROM_ADDRESS_CURRENT 4U -static void do_icall(iADC& adc, iI2C& eeprom); -static void do_ucall(iADC& dac, iI2C& eeprom); +static bool do_icall(iADC& adc, iI2C& eeprom); +static bool do_ucall(iADC& dac, iI2C& eeprom); uint16_t set_solltrom (CLI_OutFunction pfvOutFunction, char *acCommands[], uint16_t u16ArgCount); uint16_t set_dutyCyle (CLI_OutFunction pfvOutFunction, char *acCommands[], uint16_t u16ArgCount); @@ -68,6 +68,7 @@ int main (void) { __enable_irq(); serial_init(); + printf("\r\nElektronische Last\r\n"); CLI_Init(commands, sizeof(commands)/sizeof(commands[0])); LED led = LED(500U); FanControl fan = FanControl(); @@ -79,10 +80,12 @@ int main (void) eeprom.read(EEPROM_ADDRESS_CURRENT, 4UL, (uint8_t*)¤t_gain); if(std::isnan(voltage_gain)) { + printf("* Default für voltage_gain\r\n"); voltage_gain = 22.272125f; } if(std::isnan(current_gain)) { + printf("* Default für current_gain\r\n"); current_gain = 3.685331f; } @@ -90,7 +93,6 @@ int main (void) iADC adc = iADC(voltage_gain, current_gain); std::uint32_t last_tick = systick; - printf("\r\nElektronische Last\r\n"); printf("- Initialisierung erfolgreich\r\n"); printf("- Verstärkung U: %f, Verstärkung I: %f\r\n", voltage_gain, current_gain); printf("Elektronische Last>"); @@ -107,14 +109,18 @@ int main (void) switch(modus) { case icall: - do_icall(adc, eeprom); - while(!LL_LPUART_IsActiveFlag_TC(LPUART1)); - NVIC_SystemReset(); + if(do_icall(adc, eeprom)) + { + while(!LL_LPUART_IsActiveFlag_TC(LPUART1)); + NVIC_SystemReset(); + } break; case ucall: - do_ucall(adc, eeprom); - while(!LL_LPUART_IsActiveFlag_TC(LPUART1)); - NVIC_SystemReset(); + if(do_ucall(adc, eeprom)) + { + while(!LL_LPUART_IsActiveFlag_TC(LPUART1)); + NVIC_SystemReset(); + } break; case normal: default: @@ -222,8 +228,9 @@ uint16_t set_icall(CLI_OutFunction pfvOutFunction, char *acCommands[], uint16_t return 0U; } -static void do_icall(iADC& adc, iI2C& eeprom) +static bool do_icall(iADC& adc, iI2C& eeprom) { + bool done = false; strom += adc.get_current_raw(); spannung++; if(spannung == 1000UL) @@ -234,10 +241,13 @@ static void do_icall(iADC& adc, iI2C& eeprom) modus = normal; spannung = 0UL; strom = 0UL; + done = true; } + return done; } -static void do_ucall(iADC& adc, iI2C& eeprom) +static bool do_ucall(iADC& adc, iI2C& eeprom) { + bool done = false; spannung += adc.get_voltage_raw(); strom++; if(strom == 1000UL) @@ -248,5 +258,7 @@ static void do_ucall(iADC& adc, iI2C& eeprom) modus = normal; spannung = 0UL; strom = 0UL; + done = true; } + return done; }