summaryrefslogtreecommitdiff
path: root/include/uart.h
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2012-01-26 21:38:59 +0000
committerVincent Palatin <vpalatin@chromium.org>2012-01-26 22:07:00 +0000
commit53eaf213d5ebe4f57162824104c460819b7e56af (patch)
tree44cd01380a4c64caac69b278b320a7a8d99e2eb0 /include/uart.h
parentc4a867984ef707d974f95f4f06f80c4b04db3bc2 (diff)
downloadchrome-ec-53eaf213d5ebe4f57162824104c460819b7e56af.tar.gz
Split UART code
Preparatory work to introduce a second SoC : 3rd series 1/2 Most of the code is handling the buffering and the printf, thus put it in an hardware independant location and only implement the UART dependant portions in the chip driver. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BUG=None TEST=run on BDS and stress the console. Change-Id: I9376f2fa1dad341eac808e1756dbeff32900bd51
Diffstat (limited to 'include/uart.h')
-rw-r--r--include/uart.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/include/uart.h b/include/uart.h
index 75ff43e9e7..32e8446c2d 100644
--- a/include/uart.h
+++ b/include/uart.h
@@ -110,6 +110,66 @@ int uart_gets(char *dest, int size);
/* TODO: getc(), putc() equivalents? */
/*****************************************************************************/
+/* Hardware UART driver functions */
+
+/* Flushes the transmit FIFO. */
+void uart_tx_flush(void);
+
+/* Returns true if there is room to transmit a character immediatly. */
+int uart_tx_ready(void);
+
+/* Returns true if the UART has character available. */
+int uart_rx_available(void);
+
+/**
+ * Sends a character to the UART data register.
+ *
+ * c : byte to send.
+ */
+void uart_write_char(char c);
+
+/**
+ * Reads and returns one char from the UART data register.
+ *
+ * Called when uart_rx_available once returns true.
+ */
+int uart_read_char(void);
+
+/**
+ * Disables all UART related IRQs.
+ *
+ * To avoid concurrent accesses on UART management variables.
+ */
+void uart_disable_interrupt(void);
+
+/* Re-enables UART IRQs. */
+void uart_enable_interrupt(void);
+
+/**
+ * Re-enables the UART transmit interrupt.
+ *
+ * It also forces triggering an interrupt if the hardware doesn't automatically
+ * trigger it when the transmit buffer was filled beforehand.
+ */
+void uart_tx_start(void);
+
+/* Disables the UART transmit interrupt. */
+void uart_tx_stop(void);
+
+/* Returns true if the UART transmit interrupt is disabled */
+int uart_tx_stopped(void);
+
+/**
+ * Helper for UART processing.
+ * Read the input FIFO until empty, then fill the output FIFO until the transmit
+ * buffer is empty or the FIFO full.
+ *
+ * Designed to be called from the driver interrupt handler.
+ */
+void uart_process(void);
+
+
+/*****************************************************************************/
/* COMx functions */
/* Returns non-zero if ok to put a character via uart_comx_putc(). */