aboutsummaryrefslogtreecommitdiffstats
path: root/src/sam3x8e/serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sam3x8e/serial.c')
-rw-r--r--src/sam3x8e/serial.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/sam3x8e/serial.c b/src/sam3x8e/serial.c
index 652d54d4..c0653443 100644
--- a/src/sam3x8e/serial.c
+++ b/src/sam3x8e/serial.c
@@ -83,7 +83,7 @@ enable_tx_irq(void)
****************************************************************/
// Return a buffer (and length) containing any incoming messages
-char *
+static char *
console_get_input(uint8_t *plen)
{
*plen = readl(&receive_pos);
@@ -91,7 +91,7 @@ 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)
{
uint32_t copied = 0;
@@ -115,6 +115,20 @@ console_pop_input(uint8_t len)
}
}
+// 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 > 0)
+ command_dispatch(buf, pop_count);
+ if (ret)
+ 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)