command: Move command_task() to board specific code
Move the command_task() code from the generic code to the board specific code. This enables more flexibility in how the board specific code processes input. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
@@ -100,7 +100,7 @@ DECL_INIT(timer_init);
|
||||
****************************************************************/
|
||||
|
||||
// Return a buffer (and length) containing any incoming messages
|
||||
char *
|
||||
static char *
|
||||
console_get_input(uint8_t *plen)
|
||||
{
|
||||
uint32_t read_count = readl(&SHARED_MEM->read_count);
|
||||
@@ -111,12 +111,25 @@ console_get_input(uint8_t *plen)
|
||||
}
|
||||
|
||||
// Remove from the receive buffer the given number of bytes
|
||||
void
|
||||
static void
|
||||
console_pop_input(uint8_t len)
|
||||
{
|
||||
writel(&SHARED_MEM->read_count, 0);
|
||||
}
|
||||
|
||||
// Process any incoming commands
|
||||
void
|
||||
console_task(void)
|
||||
{
|
||||
uint8_t buf_len, pop_count;
|
||||
char *buf = console_get_input(&buf_len);
|
||||
int8_t ret = command_find_block(buf, buf_len, &pop_count);
|
||||
if (ret)
|
||||
command_dispatch(buf, pop_count);
|
||||
console_pop_input(pop_count);
|
||||
}
|
||||
DECL_TASK(console_task);
|
||||
|
||||
// Return an output buffer that the caller may fill with transmit messages
|
||||
char *
|
||||
console_get_output(uint8_t len)
|
||||
|
||||
Reference in New Issue
Block a user