From 119aa1b0ff32b8723320e9c1302c4ea74f9ffd80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Mon, 27 Apr 2020 21:08:53 +0200 Subject: [PATCH] Add main loop counter --- stm-firmware/main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/stm-firmware/main.c b/stm-firmware/main.c index b5db715..4dc7585 100644 --- a/stm-firmware/main.c +++ b/stm-firmware/main.c @@ -132,7 +132,7 @@ static bool mount_sd_card_if_avail(bool mounted) const char *oven_controller_hello_world = "Hello world :)\n"; static volatile enum button_state button; - +static volatile uint32_t main_loops_per_ms; int main() { bool sd_card_mounted = false; @@ -142,6 +142,9 @@ int main() shellmatta_handle_t shell_handle; int uart_receive_status; + uint32_t main_loop_cnt = 0UL; + uint64_t ms_stamp = 0ULL; + static struct pid_controller pid; uint64_t pid_timestamp = 0; @@ -173,7 +176,11 @@ int main() pid_zero(&pid); while (1) { - + if (systick_get_global_tick() - ms_stamp >= 1) { + ms_stamp = systick_get_global_tick(); + main_loops_per_ms = main_loop_cnt; + main_loop_cnt = 0UL; + } sd_card_mounted = mount_sd_card_if_avail(sd_card_mounted); pt1000_value_status = adc_pt1000_get_current_resistance(&pt1000_value); @@ -191,6 +198,8 @@ int main() uart_receive_status = uart_receive_data_with_dma(&shell_uart, &uart_input, &uart_input_len); if (uart_receive_status >= 1) shell_handle_input(shell_handle, uart_input, uart_input_len); + + main_loop_cnt++; } }