From 2246ac0290831b32d83952e70823fc679f3508f9 Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Sun, 14 Aug 2016 04:17:06 +0200 Subject: [PATCH] Print log data over UART --- src/main.c | 90 ++++++++++++++++-------------------------------------- 1 file changed, 27 insertions(+), 63 deletions(-) diff --git a/src/main.c b/src/main.c index 827a890..eb70c6d 100644 --- a/src/main.c +++ b/src/main.c @@ -325,6 +325,33 @@ static void init_systick(int freq) } #endif +static void report_status(fxp_t vin, fxp_t vout, fxp_t current, + int32_t pwm, enum OperState operState) +{ + char number[FXP_STR_MAXLEN]; + + debug_send_string("DATA:"); + + fxp_format(vin, number, 3); + debug_send_string(number); + debug_send_string(":"); + + fxp_format(vout, number, 3); + debug_send_string(number); + debug_send_string(":"); + + fxp_format(current, number, 3); + debug_send_string(number); + debug_send_string(":"); + + fxp_format_int(pwm, number); + debug_send_string(number); + debug_send_string(":"); + + fxp_format_int((int32_t)operState, number); + debug_send_string(number); + debug_send_string("\r\n"); +} int main(void) { @@ -711,69 +738,6 @@ int main(void) } } - if((timebase_ms % 500) == 0) { - debug_send_string("ADC:"); - - for(uint8_t i = 0; i < ADC_NUM_CHANNELS; i++) { - fxp_format_int(adc_values[i], msg); - debug_send_string(" "); - debug_send_string(msg); - } - - sentSomething = 1; - } - - if((timebase_ms % 500) == 100) { - debug_send_string("pErr="); - fxp_format(pErr, msg, 3); - debug_send_string(msg); - - debug_send_string("; iErr="); - fxp_format(iErr, msg, 3); - debug_send_string(msg); - - debug_send_string("; action="); - fxp_format(controlAction, msg, 1); - debug_send_string(msg); - - sentSomething = 1; - } - - if((timebase_ms % 500) == 200) { - debug_send_string("power_avg="); - fxp_format(power_avg, msg, 2); - debug_send_string(msg); - - debug_send_string("; ref="); - fxp_format(refPower, msg, 2); - debug_send_string(msg); - - debug_send_string("; pwm="); - fxp_format_int(pwm, msg); - debug_send_string(msg); - - sentSomething = 1; - } - - if((timebase_ms % 500) == 300) { - debug_send_string("RTC seconds: "); - - fxp_format_int((RTC_TR >> RTC_TR_SU_SHIFT) & RTC_TR_SU_MASK, msg); - debug_send_string(msg); - - debug_send_string(" - ALRAF: "); - - fxp_format_int(RTC_ISR & RTC_ISR_ALRAF, msg); - debug_send_string(msg); - - debug_send_string(" - EXTI17: "); - - fxp_format_int(exti_get_flag_status(EXTI17), msg); - debug_send_string(msg); - - sentSomething = 1; - } - if(sentSomething) { debug_send_string("\r\n"); sentSomething = 0;