From 30620dfeb620b2448e672758d7d6d2868cffcbf8 Mon Sep 17 00:00:00 2001 From: Dave Marples Date: Thu, 30 May 2019 17:22:18 -0600 Subject: [PATCH] arch/arm/src/imxrt/imxrt_lowputc.c: Add changes omitted from 173897afb967418aeef9a6c607ec0e0c27b832a6 --- arch/arm/src/imxrt/imxrt_lowputc.c | 54 +++++++++++++++++++++++++----- arch/arm/src/imxrt/imxrt_lpi2c.c | 2 +- arch/arm/src/imxrt/imxrt_lpspi.c | 2 +- arch/arm/src/imxrt/imxrt_usdhc.c | 2 +- 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/arch/arm/src/imxrt/imxrt_lowputc.c b/arch/arm/src/imxrt/imxrt_lowputc.c index f5ee6300c7..8d002d2995 100644 --- a/arch/arm/src/imxrt/imxrt_lowputc.c +++ b/arch/arm/src/imxrt/imxrt_lowputc.c @@ -235,7 +235,8 @@ void imxrt_lowsetup(void) #ifdef CONFIG_LPUART1_OFLOWCONTROL (void)imxrt_config_gpio(GPIO_LPUART1_CTS); #endif -#ifdef CONFIG_LPUART1_IFLOWCONTROL +#if ((defined(CONFIG_SERIAL_RS485CONTROL) && defined(CONFIG_LPUART1_RS485RTSCONTROL)) || \ + (defined(CONFIG_SERIAL_IFLOWCONTROL) && defined(CONFIG_LPUART1_IFLOWCONTROL))) (void)imxrt_config_gpio(GPIO_LPUART1_RTS); #endif #endif @@ -251,7 +252,8 @@ void imxrt_lowsetup(void) #ifdef CONFIG_LPUART2_OFLOWCONTROL (void)imxrt_config_gpio(GPIO_LPUART2_CTS); #endif -#ifdef CONFIG_LPUART2_IFLOWCONTROL +#if ((defined(CONFIG_SERIAL_RS485CONTROL) && defined(CONFIG_LPUART2_RS485RTSCONTROL)) || \ + (defined(CONFIG_SERIAL_IFLOWCONTROL) && defined(CONFIG_LPUART2_IFLOWCONTROL))) (void)imxrt_config_gpio(GPIO_LPUART2_RTS); #endif #endif @@ -267,7 +269,8 @@ void imxrt_lowsetup(void) #ifdef CONFIG_LPUART3_OFLOWCONTROL (void)imxrt_config_gpio(GPIO_LPUART3_CTS); #endif -#ifdef CONFIG_LPUART3_IFLOWCONTROL +#if ((defined(CONFIG_SERIAL_RS485CONTROL) && defined(CONFIG_LPUART3_RS485RTSCONTROL)) || \ + (defined(CONFIG_SERIAL_IFLOWCONTROL) && defined(CONFIG_LPUART3_IFLOWCONTROL))) (void)imxrt_config_gpio(GPIO_LPUART3_RTS); #endif #endif @@ -283,7 +286,8 @@ void imxrt_lowsetup(void) #ifdef CONFIG_LPUART4_OFLOWCONTROL (void)imxrt_config_gpio(GPIO_LPUART4_CTS); #endif -#ifdef CONFIG_LPUART4_IFLOWCONTROL +#if ((defined(CONFIG_SERIAL_RS485CONTROL) && defined(CONFIG_LPUART4_RS485RTSCONTROL)) || \ + (defined(CONFIG_SERIAL_IFLOWCONTROL) && defined(CONFIG_LPUART4_IFLOWCONTROL))) (void)imxrt_config_gpio(GPIO_LPUART4_RTS); #endif #endif @@ -299,7 +303,8 @@ void imxrt_lowsetup(void) #ifdef CONFIG_LPUART5_OFLOWCONTROL (void)imxrt_config_gpio(GPIO_LPUART5_CTS); #endif -#ifdef CONFIG_LPUART5_IFLOWCONTROL +#if ((defined(CONFIG_SERIAL_RS485CONTROL) && defined(CONFIG_LPUART5_RS485RTSCONTROL)) || \ + (defined(CONFIG_SERIAL_IFLOWCONTROL) && defined(CONFIG_LPUART5_IFLOWCONTROL))) (void)imxrt_config_gpio(GPIO_LPUART5_RTS); #endif #endif @@ -315,7 +320,8 @@ void imxrt_lowsetup(void) #ifdef CONFIG_LPUART6_OFLOWCONTROL (void)imxrt_config_gpio(GPIO_LPUART6_CTS); #endif -#ifdef CONFIG_LPUART6_IFLOWCONTROL +#if ((defined(CONFIG_SERIAL_RS485CONTROL) && defined(CONFIG_LPUART6_RS485RTSCONTROL)) || \ + (defined(CONFIG_SERIAL_IFLOWCONTROL) && defined(CONFIG_LPUART6_IFLOWCONTROL))) (void)imxrt_config_gpio(GPIO_LPUART6_RTS); #endif #endif @@ -331,7 +337,8 @@ void imxrt_lowsetup(void) #ifdef CONFIG_LPUART7_OFLOWCONTROL (void)imxrt_config_gpio(GPIO_LPUART7_CTS); #endif -#ifdef CONFIG_LPUART7_IFLOWCONTROL +#if ((defined(CONFIG_SERIAL_RS485CONTROL) && defined(CONFIG_LPUART7_RS485RTSCONTROL)) || \ + (defined(CONFIG_SERIAL_IFLOWCONTROL) && defined(CONFIG_LPUART7_IFLOWCONTROL))) (void)imxrt_config_gpio(GPIO_LPUART7_RTS); #endif #endif @@ -347,7 +354,8 @@ void imxrt_lowsetup(void) #ifdef CONFIG_LPUART8_OFLOWCONTROL (void)imxrt_config_gpio(GPIO_LPUART8_CTS); #endif -#ifdef CONFIG_LPUART8_IFLOWCONTROL +#if ((defined(CONFIG_SERIAL_RS485CONTROL) && defined(CONFIG_LPUART8_RS485RTSCONTROL)) || \ + (defined(CONFIG_SERIAL_IFLOWCONTROL) && defined(CONFIG_LPUART8_IFLOWCONTROL))) (void)imxrt_config_gpio(GPIO_LPUART8_RTS); #endif #endif @@ -477,6 +485,36 @@ int imxrt_lpuart_configure(uint32_t base, regval &= ~LPUART_GLOBAL_RST; putreg32(regval, base + IMXRT_LPUART_GLOBAL_OFFSET); + /* Construct MODIR register */ + + regval = 0; + + if (config->userts) + { + regval |= LPUART_MODIR_RXRTSE; + } + else if (config->users485) + { + /* Both TX and RX side can't control RTS, so this gives + * the RX side precidence. This should have been filtered + * in layers above anyway, but it's just a precaution. + */ + + regval |= LPUART_MODIR_TXRTSE; + } + + if (config->usects) + { + regval |= LPUART_MODIR_TXCTSE; + } + + if (config->invrts) + { + regval |= LPUART_MODIR_TXRTSPOL; + } + + putreg32(regval, base + IMXRT_LPUART_MODIR_OFFSET); + regval = 0; if ((osr > 3) && (osr < 8)) diff --git a/arch/arm/src/imxrt/imxrt_lpi2c.c b/arch/arm/src/imxrt/imxrt_lpi2c.c index 310055badb..8309b263f7 100644 --- a/arch/arm/src/imxrt/imxrt_lpi2c.c +++ b/arch/arm/src/imxrt/imxrt_lpi2c.c @@ -63,7 +63,7 @@ #include "hardware/imxrt_pinmux.h" #include "hardware/imxrt_ccm.h" -#include "hardware/imxrt_periphclks.h" +#include "imxrt_periphclks.h" /* At least one I2C peripheral must be enabled */ diff --git a/arch/arm/src/imxrt/imxrt_lpspi.c b/arch/arm/src/imxrt/imxrt_lpspi.c index 58001ec3b8..174aad1895 100644 --- a/arch/arm/src/imxrt/imxrt_lpspi.c +++ b/arch/arm/src/imxrt/imxrt_lpspi.c @@ -89,7 +89,7 @@ #include "hardware/imxrt_pinmux.h" #include "hardware/imxrt_lpspi.h" #include "hardware/imxrt_ccm.h" -#include "hardware/imxrt_periphclks.h" +#include "imxrt_periphclks.h" #if defined(CONFIG_IMXRT_LPSPI1) || defined(CONFIG_IMXRT_LPSPI2) || \ defined(CONFIG_IMXRT_LPSPI3) || defined(CONFIG_IMXRT_LPSPI4) diff --git a/arch/arm/src/imxrt/imxrt_usdhc.c b/arch/arm/src/imxrt/imxrt_usdhc.c index 4b9e2150af..eaad361e77 100644 --- a/arch/arm/src/imxrt/imxrt_usdhc.c +++ b/arch/arm/src/imxrt/imxrt_usdhc.c @@ -66,7 +66,7 @@ #include "imxrt_gpio.h" #include "hardware/imxrt_pinmux.h" #include "hardware/imxrt_ccm.h" -#include "hardware/imxrt_periphclks.h" +#include "imxrt_periphclks.h" #include "hardware/imxrt_usdhc.h" #ifdef CONFIG_IMXRT_USDHC