Introduce cmd_worker() that handles commands cyclically.
This commit is contained in:
parent
ebd763cbe7
commit
4ca7afbb6f
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user