Add main loop counter

This commit is contained in:
Mario Hüttel 2020-04-27 21:08:53 +02:00
parent 415979e211
commit 119aa1b0ff
1 changed files with 11 additions and 2 deletions

View File

@ -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++;
}
}