-INLINE void uart_enable(size_t base)
-{
- /* Enable the FIFO */
- HWREG(base + UART_O_LCRH) |= UART_LCRH_FEN;
- /* Enable RX, TX, and the UART */
- HWREG(base + UART_O_CTL) |=
- UART_CTL_UARTEN | UART_CTL_TXE | UART_CTL_RXE;
-}
+#if CONFIG_KDEBUG_PORT == 0
+ #define UART_BASE UART0_BASE
+ #define UART_GPIO_BASE GPIO_PORTA_BASE
+ #define UART_PINS (BV(1) | BV(0))
+ #define UART_REG_SYSCTL SYSCTL_RCGC2_GPIOA
+#elif CONFIG_KDEBUG_PORT == 1
+ #define UART_BASE UART1_BASE
+ #define UART_GPIO_BASE GPIO_PORTD_BASE
+ #define UART_PINS (BV(3) | BV(2))
+ #define UART_REG_SYSCTL SYSCTL_RCGC2_GPIOD
+#elif CONFIG_KDEBUG_PORT == 2
+ #define UART_BASE UART2_BASE
+ #define UART_GPIO_BASE GPIO_PORTG_BASE
+ #define UART_PINS (BV(1) | BV(0))
+ #define UART_REG_SYSCTL SYSCTL_RCGC2_GPIOG
+#else
+ #error "UART port not supported in this board"
+#endif
+
+#define KDBG_WAIT_READY() while (!lm3s_uartReady(UART_BASE)) {}
+#define KDBG_WAIT_TXDONE() while (!lm3s_uartTxDone(UART_BASE)) {}
+
+#define KDBG_WRITE_CHAR(c) do { lm3s_uartPutCharNonBlocking(UART_BASE, c); } while(0)
+
+/* Debug unit is used only for debug purposes so does not generate interrupts. */
+#define KDBG_MASK_IRQ(old) do { (void)old; } while(0)