From b1f6a608c324097a25d1d26ed851213a1020d1e4 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 25 May 2021 12:58:26 -0400 Subject: [PATCH] lpc176x: Add support for serial on UART3 P4.29/P4.28 Signed-off-by: Kevin O'Connor --- src/lpc176x/Kconfig | 7 +++++-- src/lpc176x/internal.h | 1 + src/lpc176x/serial.c | 24 +++++++++++++++++------- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/lpc176x/Kconfig b/src/lpc176x/Kconfig index 4fef74cc..81a98b05 100644 --- a/src/lpc176x/Kconfig +++ b/src/lpc176x/Kconfig @@ -70,8 +70,11 @@ choice config LPC_USB bool "USB" select USBSERIAL - config LPC_SERIAL - bool "Serial" + config LPC_SERIAL_UART0_P03_P02 + bool "Serial (on UART0 P0.3/P0.2)" + select SERIAL + config LPC_SERIAL_UART3_P429_P428 + bool "Serial (on UART3 P4.29/P4.28)" if LOW_LEVEL_OPTIONS select SERIAL endchoice diff --git a/src/lpc176x/internal.h b/src/lpc176x/internal.h index d46bf66d..3adb7e19 100644 --- a/src/lpc176x/internal.h +++ b/src/lpc176x/internal.h @@ -16,6 +16,7 @@ #define PCLK_ADC 12 #define PCLK_I2C1 19 #define PCLK_SSP0 21 +#define PCLK_UART3 25 #define PCLK_I2C2 26 #define PCLK_USB 31 int is_enabled_pclock(uint32_t pclk); diff --git a/src/lpc176x/serial.c b/src/lpc176x/serial.c index 65f08ba7..87a79270 100644 --- a/src/lpc176x/serial.c +++ b/src/lpc176x/serial.c @@ -12,13 +12,23 @@ #include "internal.h" // gpio_peripheral #include "sched.h" // DECL_INIT -DECL_CONSTANT_STR("RESERVE_PINS_serial", "P0.3,P0.2"); -#define GPIO_Rx GPIO(0, 3) -#define GPIO_Tx GPIO(0, 2) -#define GPIO_FUNCTION_UARTx 1 -#define LPC_UARTx LPC_UART0 -#define UARTx_IRQn UART0_IRQn -#define PCLK_UARTx PCLK_UART0 +#if CONFIG_LPC_SERIAL_UART0_P03_P02 + DECL_CONSTANT_STR("RESERVE_PINS_serial", "P0.3,P0.2"); + #define GPIO_Rx GPIO(0, 3) + #define GPIO_Tx GPIO(0, 2) + #define GPIO_FUNCTION_UARTx 1 + #define LPC_UARTx LPC_UART0 + #define UARTx_IRQn UART0_IRQn + #define PCLK_UARTx PCLK_UART0 +#elif CONFIG_LPC_SERIAL_UART3_P429_P428 + DECL_CONSTANT_STR("RESERVE_PINS_serial", "P4.29,P4.28"); + #define GPIO_Rx GPIO(4, 29) + #define GPIO_Tx GPIO(4, 28) + #define GPIO_FUNCTION_UARTx 3 + #define LPC_UARTx LPC_UART3 + #define UARTx_IRQn UART3_IRQn + #define PCLK_UARTx PCLK_UART3 +#endif // Write tx bytes to the serial port static void