From d83bbc2f25bbd51b6f13c56b54ddcd54980e600d Mon Sep 17 00:00:00 2001 From: Maureen Helm Date: Mon, 17 May 2021 16:35:47 -0500 Subject: [PATCH] boards: arm: Enable arduino serial port on lpcxpresso55s69 Configures flexcomm2 to operate in USART mode and enables the associated peripheral clock and pinmuxes. This instance is attached to the Arduino serial header pins and can be used for Bluetooth serial HCI with a frdm_kw41z or other BLE controller shield. Signed-off-by: Maureen Helm --- boards/arm/lpcxpresso55s69/doc/index.rst | 4 ++++ .../arm/lpcxpresso55s69/lpcxpresso55s69.dtsi | 5 ++++ .../lpcxpresso55s69/lpcxpresso55s69_cpu0.yaml | 1 + boards/arm/lpcxpresso55s69/pinmux.c | 24 +++++++++++++++++++ soc/arm/nxp_lpc/lpc55xxx/soc.c | 4 ++++ 5 files changed, 38 insertions(+) diff --git a/boards/arm/lpcxpresso55s69/doc/index.rst b/boards/arm/lpcxpresso55s69/doc/index.rst index 4e7c1494b68..beacd0efad4 100644 --- a/boards/arm/lpcxpresso55s69/doc/index.rst +++ b/boards/arm/lpcxpresso55s69/doc/index.rst @@ -113,6 +113,8 @@ functionality of a pin. +=========+=================+============================+ | PIO0_26 | SPI | SPI MOSI | +---------+-----------------+----------------------------+ +| PIO0_27 | USART | USART TX | ++---------+-----------------+----------------------------+ | PIO0_29 | USART | USART RX | +---------+-----------------+----------------------------+ | PIO0_30 | USART | USART TX | @@ -133,6 +135,8 @@ functionality of a pin. +---------+-----------------+----------------------------+ | PIO1_21 | I2C | I2C SDA | +---------+-----------------+----------------------------+ +| PIO1_24 | USART | USART RX | ++---------+-----------------+----------------------------+ Memory mappings =============== diff --git a/boards/arm/lpcxpresso55s69/lpcxpresso55s69.dtsi b/boards/arm/lpcxpresso55s69/lpcxpresso55s69.dtsi index e7b4bb356a9..ad6a54c782a 100644 --- a/boards/arm/lpcxpresso55s69/lpcxpresso55s69.dtsi +++ b/boards/arm/lpcxpresso55s69/lpcxpresso55s69.dtsi @@ -163,6 +163,11 @@ arduino_i2c: &flexcomm4 { }; }; +arduino_serial: &flexcomm2 { + compatible = "nxp,lpc-usart"; + current-speed = <115200>; +}; + arduino_spi: &hs_lspi { }; diff --git a/boards/arm/lpcxpresso55s69/lpcxpresso55s69_cpu0.yaml b/boards/arm/lpcxpresso55s69/lpcxpresso55s69_cpu0.yaml index b193c24aecb..782d4024514 100644 --- a/boards/arm/lpcxpresso55s69/lpcxpresso55s69_cpu0.yaml +++ b/boards/arm/lpcxpresso55s69/lpcxpresso55s69_cpu0.yaml @@ -17,6 +17,7 @@ toolchain: supported: - adc - arduino_i2c + - arduino_serial - arduino_spi - gpio - i2c diff --git a/boards/arm/lpcxpresso55s69/pinmux.c b/boards/arm/lpcxpresso55s69/pinmux.c index 96d1ba0f8b9..fd471a889de 100644 --- a/boards/arm/lpcxpresso55s69/pinmux.c +++ b/boards/arm/lpcxpresso55s69/pinmux.c @@ -53,6 +53,30 @@ static int lpcxpresso_55s69_pinmux_init(const struct device *dev) #endif +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm2), nxp_lpc_usart, okay) && CONFIG_SERIAL + /* USART2 RX, TX */ + uint32_t port1_pin24_config = ( + IOCON_PIO_FUNC1 | + IOCON_PIO_MODE_INACT | + IOCON_PIO_INV_DI | + IOCON_PIO_DIGITAL_EN | + IOCON_PIO_SLEW_STANDARD | + IOCON_PIO_OPENDRAIN_DI + ); + + uint32_t port0_pin27_config = ( + IOCON_PIO_FUNC1 | + IOCON_PIO_MODE_INACT | + IOCON_PIO_INV_DI | + IOCON_PIO_DIGITAL_EN | + IOCON_PIO_SLEW_STANDARD | + IOCON_PIO_OPENDRAIN_DI + ); + + pinmux_pin_set(port1, 24, port1_pin24_config); + pinmux_pin_set(port0, 27, port0_pin27_config); +#endif + #if DT_PHA_HAS_CELL(DT_ALIAS(sw0), gpios, pin) uint32_t sw0_config = ( IOCON_PIO_FUNC0 | diff --git a/soc/arm/nxp_lpc/lpc55xxx/soc.c b/soc/arm/nxp_lpc/lpc55xxx/soc.c index 7b4277f1ff2..38a835fba57 100644 --- a/soc/arm/nxp_lpc/lpc55xxx/soc.c +++ b/soc/arm/nxp_lpc/lpc55xxx/soc.c @@ -64,6 +64,10 @@ static ALWAYS_INLINE void clock_init(void) /* Enables the clock for the I/O controller.: Enable Clock. */ CLOCK_EnableClock(kCLOCK_Iocon); +#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm2), nxp_lpc_usart, okay) + CLOCK_AttachClk(kFRO12M_to_FLEXCOMM2); +#endif + #if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(flexcomm4), nxp_lpc_i2c, okay) /* attach 12 MHz clock to FLEXCOMM4 */ CLOCK_AttachClk(kFRO12M_to_FLEXCOMM4);