From 4ca7afbb6f57dfa4da9e3157975e547975fd581a Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 31 May 2022 20:23:10 +0200 Subject: [PATCH] Introduce cmd_worker() that handles commands cyclically. --- src/commands.c | 4 ++-- src/include/commands.h | 2 +- src/inverter.c | 8 +------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/commands.c b/src/commands.c index fa9ce16..2a60f69 100644 --- a/src/commands.c +++ b/src/commands.c @@ -16,9 +16,9 @@ cmd_t command = { int cmd_terminated = 0; -cmd_t *cmd_getcommand(void) +void cmd_worker(void) { - return &command; + cmd_handle(&command); } void cmd_collect_char(char c) diff --git a/src/include/commands.h b/src/include/commands.h index 43b368c..8378439 100644 --- a/src/include/commands.h +++ b/src/include/commands.h @@ -3,7 +3,7 @@ typedef struct { int index; } cmd_t; -cmd_t *cmd_getcommand(void); +void cmd_worker(void); void cmd_collect_char(char c); void cmd_handle(cmd_t *command); diff --git a/src/inverter.c b/src/inverter.c index 48ceaa3..4546183 100644 --- a/src/inverter.c +++ b/src/inverter.c @@ -15,22 +15,16 @@ int main() /* With this MCU frequency (8MHz), 12 is a baudrate of 38.4k baud */ uart_init(12); - pwm_init(); - timer_initT1(); - DDRB |= (1 << DDB5); DDRD |= (1 << DDD7); printf("Up and running.\n\r"); while (1) { - /* We handle terminated commands here. - Outside of the context of the UART receive interrupt. */ - cmd_handle(cmd_getcommand()); - + cmd_worker(); pwm_worker(); }