summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerrit <chrome-bot@google.com>2012-03-14 09:17:41 -0700
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2012-03-14 09:17:41 -0700
commit1a3becdbc2b99e9b215d8b21dba95f85b1469def (patch)
treec9bebe25f25c9ce4622835361bb00add68d77631
parent5f83ab456c08feb6c62dc79d4800c60e357125c3 (diff)
parent1c6709a332f496bbd92315c5af8573a804617aa5 (diff)
downloadchrome-ec-1a3becdbc2b99e9b215d8b21dba95f85b1469def.tar.gz
Merge "Add comxtest debug command"
-rw-r--r--chip/lm4/uart.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/chip/lm4/uart.c b/chip/lm4/uart.c
index 9d2fe0c950..e3201056fe 100644
--- a/chip/lm4/uart.c
+++ b/chip/lm4/uart.c
@@ -193,17 +193,18 @@ int uart_init(void)
/*****************************************************************************/
/* COMx functions */
+/* Write a character to COMx, waiting for space in the output buffer if
+ * necessary. */
+static void uart_comx_putc_wait(int c)
+{
+ while (!uart_comx_putc_ok()) {}
+ uart_comx_putc(c);
+}
+
+
void uart_comx_enable(void)
{
task_enable_irq(LM4_IRQ_UART1);
-
- /* Print hello on UART1 for debugging */
- /* TODO: remove in production */
- {
- const char *c = "Hello on UART1\r\n";
- while (*c)
- uart_comx_putc(*c++);
- }
}
@@ -224,3 +225,24 @@ void uart_comx_putc(int c)
{
LM4_UART_DR(1) = c;
}
+
+
+/*****************************************************************************/
+/* Console commands */
+
+static int command_comxtest(int argc, char **argv)
+{
+ /* Put characters to COMX port */
+ const char *c = argc > 1 ? argv[1] : "testing comx output!";
+
+ uart_printf("Writing \"%s\\r\\n\" to COMx UART...\n", c);
+
+ while (*c)
+ uart_comx_putc_wait(*c++);
+
+ uart_comx_putc_wait('\r');
+ uart_comx_putc_wait('\n');
+
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(comxtest, command_comxtest);