diff --git a/arch/arm/src/xmc4/Kconfig b/arch/arm/src/xmc4/Kconfig index 096a65fb85..c73e281fb5 100644 --- a/arch/arm/src/xmc4/Kconfig +++ b/arch/arm/src/xmc4/Kconfig @@ -66,263 +66,272 @@ config XMC4_USIC1 Support USIC1 config XMC4_USIC2 - bool "USIC3" + bool "USIC2" default n select XMC4_USIC ---help--- Support USIC2 -config XMC4_USIC3 - bool "USIC3" - default n - select XMC4_USIC - ---help--- - Support USIC3 - -config XMC4_USIC4 - bool "USIC4" - default n - select XMC4_USIC - ---help--- - Support USIC4 - -config XMC4_USIC5 - bool "USIC5" - default n - select XMC4_USIC - ---help--- - Support USIC5 - endmenu menu "XMC4xxx USIC Configuration" depends on XMC4_USIC choice - prompt "USIC0 Configuration" - default XMC4_USIC0_ISUART + prompt "USIC0 Channel 0 Configuration" + default XMC4_USIC0_CHAN0_ISUART depends on XMC4_USIC0 -config XMC4_USIC0_ISUART - bool "UART" +config XMC4_USIC0_CHAN0_NONE + bool "Not used" + ---help--- + USIC0 Channel 0 will not be enabled + +config XMC4_USIC0_CHAN0_ISUART + bool "UART0" select UART0_SERIALDRIVER select XMC4_USCI_UART ---help--- - Configure USIC0 as a UART + Configure USIC0 Channel 0 as a UART -config XMC4_USIC0_ISLIN +config XMC4_USIC0_CHAN0_ISLIN bool "LIN" select XMC4_USCI_LIN ---help--- - Configure USIC0 as a LIN UART + Configure USIC0 Channel 0 as a LIN UART -config XMC4_USIC0_ISSPI +config XMC4_USIC0_CHAN0_ISSPI bool "SPI" select XMC4_USCI_SPI ---help--- - Configure USIC0 For SPI communications + Configure USIC0 Channel 0 for SPI communications -config XMC4_USIC0_ISI2C +config XMC4_USIC0_CHAN0_ISI2C bool "I2C" select XMC4_USCI_I2C ---help--- - Configure USIC0 For I2C communications + Configure USIC0 Channel 0 for I2C communications -config XMC4_USIC0_ISI2S +config XMC4_USIC0_CHAN0_ISI2S bool "I2S" select XMC4_USCI_I2S ---help--- - Configure USIC0 For I2S audio + Configure USIC0 Channel 0 for I2S audio -endchoice # USIC0 Configuration +endchoice # USIC0 Channel 0 Configuration choice - prompt "USIC1 Configuration" - default XMC4_USIC1_ISUART - depends on XMC4_USIC1 + prompt "USIC0 Channel 1 Configuration" + default XMC4_USIC0_CHAN1_ISUART + depends on XMC4_USIC0 -config XMC4_USIC1_ISUART - bool "UART" +config XMC4_USIC0_CHAN1_NONE + bool "Not used" + ---help--- + USIC0 Channel 1 will not be enabled + +config XMC4_USIC0_CHAN1_ISUART + bool "UART1" select UART1_SERIALDRIVER select XMC4_USCI_UART ---help--- - Configure USIC1 as a UART + Configure USIC0 Channel 1 as a UART -config XMC4_USIC1_ISLIN +config XMC4_USIC0_CHAN1_ISLIN bool "LIN" select XMC4_USCI_LIN ---help--- - Configure USIC1 as a LIN UART + Configure USIC0 Channel 1 as a LIN UART -config XMC4_USIC1_ISSPI +config XMC4_USIC0_CHAN1_ISSPI bool "SPI" select XMC4_USCI_SPI ---help--- - Configure USIC1 For SPI communications + Configure USIC0 Channel 1 for SPI communications -config XMC4_USIC1_ISI2C +config XMC4_USIC0_CHAN1_ISI2C bool "I2C" select XMC4_USCI_I2C ---help--- - Configure USIC1 For I2C communications + Configure USIC0 Channel 1 for I2C communications -config XMC4_USIC1_ISI2S +config XMC4_USIC0_CHAN1_ISI2S bool "I2S" select XMC4_USCI_I2S ---help--- - Configure USIC1 For I2S audio + Configure USIC0 Channel 1 for I2S audio -endchoice # USIC1 Configuration +endchoice # USIC0 Channel 1 Configuration choice - prompt "USIC2 Configuration" - default XMC4_USIC2_ISUART - depends on XMC4_USIC2 + prompt "USIC1 Channel 0 Configuration" + default XMC4_USIC1_CHAN0_ISUART + depends on XMC4_USIC1 -config XMC4_USIC2_ISUART - bool "UART" +config XMC4_USIC1_CHAN0_NONE + bool "Not used" + ---help--- + USIC0 Channel 0 will not be enabled + +config XMC4_USIC1_CHAN0_ISUART + bool "UART2" select UART2_SERIALDRIVER select XMC4_USCI_UART ---help--- - Configure USIC2 as a UART + Configure USIC1 Channel 0 as a UART -config XMC4_USIC2_ISLIN +config XMC4_USIC1_CHAN0_ISLIN bool "LIN" select XMC4_USCI_LIN ---help--- - Configure USIC2 as a LIN UART + Configure USIC1 Channel 0 as a LIN UART -config XMC4_USIC2_ISSPI +config XMC4_USIC1_CHAN0_ISSPI bool "SPI" select XMC4_USCI_SPI ---help--- - Configure USIC2 For SPI communications + Configure USIC1 Channel 0 for SPI communications -config XMC4_USIC2_ISI2C +config XMC4_USIC1_CHAN0_ISI2C bool "I2C" select XMC4_USCI_I2C ---help--- - Configure USIC2 For I2C communications + Configure USIC1 Channel 0 for I2C communications -config XMC4_USIC2_ISI2S +config XMC4_USIC1_CHAN0_ISI2S bool "I2S" select XMC4_USCI_I2S ---help--- - Configure USIC2 For I2S audio + Configure USIC1 Channel 0 for I2S audio -endchoice # USIC2 Configuration +endchoice # USIC1 Channel 0 Configuration choice - prompt "USIC3 Configuration" - default XMC4_USIC3_ISUART - depends on XMC4_USIC3 + prompt "USIC1 Channel 1 Configuration" + default XMC4_USIC1_CHAN1_ISUART + depends on XMC4_USIC1 -config XMC4_USIC3_ISUART - bool "UART" +config XMC4_USIC1_CHAN1_NONE + bool "Not used" + ---help--- + USIC0 Channel 1 will not be enabled + +config XMC4_USIC1_CHAN1_ISUART + bool "UART3" select UART3_SERIALDRIVER select XMC4_USCI_UART ---help--- - Configure USIC3 as a UART + Configure USIC1 Channel 1 as a UART -config XMC4_USIC3_ISLIN +config XMC4_USIC1_CHAN1_ISLIN bool "LIN" select XMC4_USCI_LIN ---help--- - Configure USIC3 as a LIN UART + Configure USIC1 Channel 1 as a LIN UART -config XMC4_USIC3_ISSPI +config XMC4_USIC1_CHAN1_ISSPI bool "SPI" select XMC4_USCI_SPI ---help--- - Configure USIC3 For SPI communications + Configure USIC1 Channel 1 for SPI communications -config XMC4_USIC3_ISI2C +config XMC4_USIC1_CHAN1_ISI2C bool "I2C" select XMC4_USCI_I2C ---help--- - Configure USIC3 For I2C communications + Configure USIC1 Channel 1 for I2C communications -config XMC4_USIC3_ISI2S +config XMC4_USIC1_CHAN1_ISI2S bool "I2S" select XMC4_USCI_I2S ---help--- - Configure USIC3 For I2S audio + Configure USIC1 Channel 1 for I2S audio -endchoice # USIC3 Configuration +endchoice # USIC1 Channel 1 Configuration choice - prompt "USIC4 Configuration" - default XMC4_USIC4_ISUART - depends on XMC4_USIC4 + prompt "USIC2 Channel 0 Configuration" + default XMC4_USIC2_CHAN0_ISUART + depends on XMC4_USIC2 -config XMC4_USIC4_ISUART - bool "UART" +config XMC4_USIC2_CHAN0_NONE + bool "Not used" + ---help--- + USIC0 Channel 0 will not be enabled + +config XMC4_USIC2_CHAN0_ISUART + bool "UART4" select UART4_SERIALDRIVER select XMC4_USCI_UART ---help--- - Configure USIC4 as a UART + Configure USIC2 Channel 0 as a UART -config XMC4_USIC4_ISLIN +config XMC4_USIC2_CHAN0_ISLIN bool "LIN" select XMC4_USCI_LIN ---help--- - Configure USIC4 as a LIN UART + Configure USIC2 Channel 0 as a LIN UART -config XMC4_USIC4_ISSPI +config XMC4_USIC2_CHAN0_ISSPI bool "SPI" select XMC4_USCI_SPI ---help--- - Configure USIC4 For SPI communications + Configure USIC2 Channel 0 for SPI communications -config XMC4_USIC4_ISI2C +config XMC4_USIC2_CHAN0_ISI2C bool "I2C" select XMC4_USCI_I2C ---help--- - Configure USIC4 For I2C communications + Configure USIC2 Channel 0 for I2C communications -config XMC4_USIC4_ISI2S +config XMC4_USIC2_CHAN0_ISI2S bool "I2S" select XMC4_USCI_I2S ---help--- - Configure USIC4 For I2S audio + Configure USIC2 Channel 0 for I2S audio -endchoice # USIC4 Configuration +endchoice # USIC2 Channel 0 Configuration choice - prompt "USIC5 Configuration" - default XMC4_USIC5_ISUART - depends on XMC4_USIC5 + prompt "USIC2 Channel 1 Configuration" + default XMC4_USIC2_CHAN1_ISUART + depends on XMC4_USIC2 -config XMC4_USIC5_ISUART - bool "UART" - select UART0_SERIALDRIVER +config XMC4_USIC2_CHAN1_NONE + bool "Not used" + ---help--- + USIC0 Channel 1 will not be enabled + +config XMC4_USIC2_CHAN1_ISUART + bool "UART5" + select UART5_SERIALDRIVER select XMC4_USCI_UART ---help--- - Configure USIC5 as a UART + Configure USIC2 Channel 1 as a UART -config XMC4_USIC5_ISLIN +config XMC4_USIC2_CHAN1_ISLIN bool "LIN" select XMC4_USCI_LIN ---help--- - Configure USIC5 as a LIN UART + Configure USIC2 Channel 1 as a LIN UART -config XMC4_USIC5_ISSPI +config XMC4_USIC2_CHAN1_ISSPI bool "SPI" select XMC4_USCI_SPI ---help--- - Configure USIC5 For SPI communications + Configure USIC2 Channel 1 for SPI communications -config XMC4_USIC5_ISI2C +config XMC4_USIC2_CHAN1_ISI2C bool "I2C" select XMC4_USCI_I2C ---help--- - Configure USIC5 For I2C communications + Configure USIC2 Channel 1 for I2C communications -config XMC4_USIC5_ISI2S +config XMC4_USIC2_CHAN1_ISI2S bool "I2S" select XMC4_USCI_I2S ---help--- - Configure USIC5 For I2S audio + Configure USIC2 Channel 1 for I2S audio -endchoice # USIC5 Configuration +endchoice # USIC2 Channel 1 Configuration endmenu # XMC4xxx USIC Configuration diff --git a/arch/arm/src/xmc4/xmc4_config.h b/arch/arm/src/xmc4/xmc4_config.h index e81932569e..0a9c204268 100644 --- a/arch/arm/src/xmc4/xmc4_config.h +++ b/arch/arm/src/xmc4/xmc4_config.h @@ -53,30 +53,51 @@ /* Make sure that no unsupported UARTs are enabled */ #ifndef CONFIG_XMC4_USIC0 -# undef CONFIG_XMC4_USIC0_ISUART +# undef CONFIG_XMC4_USIC0_CHAN0_ISUART +# undef CONFIG_XMC4_USIC0_CHAN1_ISUART #endif #ifndef CONFIG_XMC4_USIC1 -# undef CONFIG_XMC4_USIC1_ISUART +# undef CONFIG_XMC4_USIC1_CHAN0_ISUART +# undef CONFIG_XMC4_USIC1_CHAN1_ISUART #endif #ifndef CONFIG_XMC4_USIC2 -# undef CONFIG_XMC4_USIC2_ISUART +# undef CONFIG_XMC4_USIC2_CHAN0_ISUART +# undef CONFIG_XMC4_USIC2_CHAN1_ISUART #endif -#ifndef CONFIG_XMC4_USIC3 -# undef CONFIG_XMC4_USIC3_ISUART + +/* Map logical UART names (Just for simplicity of naming) */ + +#undef HAVE_UART0 +#undef HAVE_UART1 +#undef HAVE_UART2 +#undef HAVE_UART3 +#undef HAVE_UART4 +#undef HAVE_UART5 + +#ifdef CONFIG_XMC4_USIC0_CHAN0_ISUART +# define HAVE_UART0 #endif -#ifndef CONFIG_XMC4_USIC4 -# undef CONFIG_XMC4_USIC4_ISUART +#ifdef CONFIG_XMC4_USIC0_CHAN1_ISUART +# define HAVE_UART1 #endif -#ifndef CONFIG_XMC4_USIC5 -# undef CONFIG_XMC4_USIC5_ISUART +#ifdef CONFIG_XMC4_USIC1_CHAN0_ISUART +# define HAVE_UART2 +#endif +#ifdef CONFIG_XMC4_USIC1_CHAN1_ISUART +# define HAVE_UART3 +#endif +#ifdef CONFIG_XMC4_USIC2_CHAN0_ISUART +# define HAVE_UART4 +#endif +#ifdef CONFIG_XMC4_USIC2_CHAN1_ISUART +# define HAVE_UART5 #endif /* Are any UARTs enabled? */ #undef HAVE_UART_DEVICE -#if defined(CONFIG_XMC4_USIC0_ISUART) || defined(CONFIG_XMC4_USIC1_ISUART) || \ - defined(CONFIG_XMC4_USIC2_ISUART) || defined(CONFIG_XMC4_USIC3_ISUART) || \ - defined(CONFIG_XMC4_USIC3_ISUART) || defined(CONFIG_XMC4_USIC4_ISUART) +#if defined(HAVE_UART0) || defined(HAVE_UART1) || defined(HAVE_UART2) || \ + defined(HAVE_UART3) || defined(HAVE_UART4) || defined(HAVE_UART5) # define HAVE_UART_DEVICE 1 #endif @@ -94,42 +115,42 @@ # undef CONFIG_UART4_SERIAL_CONSOLE # undef CONFIG_UART5_SERIAL_CONSOLE #else -# if defined(CONFIG_UART0_SERIAL_CONSOLE) && defined(CONFIG_XMC4_USIC0_ISUART) +# if defined(CONFIG_UART0_SERIAL_CONSOLE) && defined(HAVE_UART0) # undef CONFIG_UART1_SERIAL_CONSOLE # undef CONFIG_UART2_SERIAL_CONSOLE # undef CONFIG_UART3_SERIAL_CONSOLE # undef CONFIG_UART4_SERIAL_CONSOLE # undef CONFIG_UART5_SERIAL_CONSOLE # define HAVE_UART_CONSOLE 1 -# elif defined(CONFIG_UART1_SERIAL_CONSOLE) && defined(CONFIG_XMC4_USIC1_ISUART) +# elif defined(CONFIG_UART1_SERIAL_CONSOLE) && defined(HAVE_UART1) # undef CONFIG_UART0_SERIAL_CONSOLE # undef CONFIG_UART2_SERIAL_CONSOLE # undef CONFIG_UART3_SERIAL_CONSOLE # undef CONFIG_UART4_SERIAL_CONSOLE # undef CONFIG_UART5_SERIAL_CONSOLE # define HAVE_UART_CONSOLE 1 -# elif defined(CONFIG_UART2_SERIAL_CONSOLE) && defined(CONFIG_XMC4_USIC2_ISUART) +# elif defined(CONFIG_UART2_SERIAL_CONSOLE) && defined(HAVE_UART2) # undef CONFIG_UART0_SERIAL_CONSOLE # undef CONFIG_UART1_SERIAL_CONSOLE # undef CONFIG_UART3_SERIAL_CONSOLE # undef CONFIG_UART4_SERIAL_CONSOLE # undef CONFIG_UART5_SERIAL_CONSOLE # define HAVE_UART_CONSOLE 1 -# elif defined(CONFIG_UART3_SERIAL_CONSOLE) && defined(CONFIG_XMC4_USIC3_ISUART) +# elif defined(CONFIG_UART3_SERIAL_CONSOLE) && defined(HAVE_UART3) # undef CONFIG_UART0_SERIAL_CONSOLE # undef CONFIG_UART1_SERIAL_CONSOLE # undef CONFIG_UART2_SERIAL_CONSOLE # undef CONFIG_UART4_SERIAL_CONSOLE # undef CONFIG_UART5_SERIAL_CONSOLE # define HAVE_UART_CONSOLE 1 -# elif defined(CONFIG_UART4_SERIAL_CONSOLE) && defined(CONFIG_XMC4_USIC4_ISUART) +# elif defined(CONFIG_UART4_SERIAL_CONSOLE) && defined(HAVE_UART4) # undef CONFIG_UART0_SERIAL_CONSOLE # undef CONFIG_UART1_SERIAL_CONSOLE # undef CONFIG_UART2_SERIAL_CONSOLE # undef CONFIG_UART3_SERIAL_CONSOLE # undef CONFIG_UART5_SERIAL_CONSOLE # define HAVE_UART_CONSOLE 1 -# elif defined(CONFIG_UART5_SERIAL_CONSOLE) && defined(CONFIG_XMC4_USIC5_ISUART) +# elif defined(CONFIG_UART5_SERIAL_CONSOLE) && defined(HAVE_UART5) # undef CONFIG_UART0_SERIAL_CONSOLE # undef CONFIG_UART1_SERIAL_CONSOLE # undef CONFIG_UART2_SERIAL_CONSOLE diff --git a/arch/arm/src/xmc4/xmc4_lowputc.c b/arch/arm/src/xmc4/xmc4_lowputc.c index 28ae38195b..6df364565c 100644 --- a/arch/arm/src/xmc4/xmc4_lowputc.c +++ b/arch/arm/src/xmc4/xmc4_lowputc.c @@ -60,42 +60,42 @@ #if defined(HAVE_UART_CONSOLE) # if defined(CONFIG_UART0_SERIAL_CONSOLE) -# define CONSOLE_BASE XMC4_UART0_BASE +# define CONSOLE_BASE XMC4_USIC0_CH0_BASE # define CONSOLE_FREQ BOARD_CORECLK_FREQ # define CONSOLE_BAUD CONFIG_UART0_BAUD # define CONSOLE_BITS CONFIG_UART0_BITS # define CONSOLE_2STOP CONFIG_UART0_2STOP # define CONSOLE_PARITY CONFIG_UART0_PARITY # elif defined(CONFIG_UART1_SERIAL_CONSOLE) -# define CONSOLE_BASE XMC4_UART1_BASE +# define CONSOLE_BASE XMC4_USIC0_CH1_BASE # define CONSOLE_FREQ BOARD_CORECLK_FREQ # define CONSOLE_BAUD CONFIG_UART1_BAUD # define CONSOLE_BITS CONFIG_UART1_BITS # define CONSOLE_2STOP CONFIG_UART1_2STOP # define CONSOLE_PARITY CONFIG_UART1_PARITY # elif defined(CONFIG_UART2_SERIAL_CONSOLE) -# define CONSOLE_BASE XMC4_UART2_BASE +# define CONSOLE_BASE XMC4_USIC1_CH0_BASE # define CONSOLE_FREQ BOARD_BUS_FREQ # define CONSOLE_BAUD CONFIG_UART2_BAUD # define CONSOLE_BITS CONFIG_UART2_BITS # define CONSOLE_2STOP CONFIG_UART2_2STOP # define CONSOLE_PARITY CONFIG_UART2_PARITY # elif defined(CONFIG_UART3_SERIAL_CONSOLE) -# define CONSOLE_BASE XMC4_UART3_BASE +# define CONSOLE_BASE XMC4_USIC1_CH1_BASE # define CONSOLE_FREQ BOARD_BUS_FREQ # define CONSOLE_BAUD CONFIG_UART3_BAUD # define CONSOLE_BITS CONFIG_UART3_BITS # define CONSOLE_2STOP CONFIG_UART3_2STOP # define CONSOLE_PARITY CONFIG_UART3_PARITY # elif defined(CONFIG_UART4_SERIAL_CONSOLE) -# define CONSOLE_BASE XMC4_UART4_BASE +# define CONSOLE_BASE XMC4_USIC2_CH0_BASE # define CONSOLE_FREQ BOARD_BUS_FREQ # define CONSOLE_BAUD CONFIG_UART4_BAUD # define CONSOLE_BITS CONFIG_UART4_BITS # define CONSOLE_2STOP CONFIG_UART4_2STOP # define CONSOLE_PARITY CONFIG_UART4_PARITY # elif defined(CONFIG_UART5_SERIAL_CONSOLE) -# define CONSOLE_BASE XMC4_UART5_BASE +# define CONSOLE_BASE XMC4_USIC2_CH1_BASE # define CONSOLE_FREQ BOARD_BUS_FREQ # define CONSOLE_BAUD CONFIG_UART5_BAUD # define CONSOLE_BITS CONFIG_UART5_BITS @@ -161,7 +161,7 @@ void xmc4_lowsetup(void) uint32_t regval; /* Enable peripheral clocking for all enabled UARTs. */ -#wanring Missing logic +#warning Missing logic /* Configure UART pins for the all enabled UARTs */ diff --git a/arch/arm/src/xmc4/xmc4_lowputc.h b/arch/arm/src/xmc4/xmc4_lowputc.h new file mode 100644 index 0000000000..7287855a7b --- /dev/null +++ b/arch/arm/src/xmc4/xmc4_lowputc.h @@ -0,0 +1,90 @@ +/**************************************************************************** + * arch/arm/src/xmc4/xmc4_lowputc.h + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __ARCH_ARM_SRC_XMC4_XMC4_LOWPUTC_H +#define __ARCH_ARM_SRC_XMC4_XMC4_LOWPUTC_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include "xmc4_config.h" + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: xmc4_lowsetup + * + * Description: + * This performs basic initialization of the UART used for the serial + * console. Its purpose is to get the console output available as soon + * as possible. + * + ****************************************************************************/ + +void xmc4_lowsetup(void); + +/**************************************************************************** + * Name: xmc4_uart_reset + * + * Description: + * Reset a UART. + * + ****************************************************************************/ + +#ifdef HAVE_UART_DEVICE +void xmc4_uart_reset(uintptr_t uart_base); +#endif + +/**************************************************************************** + * Name: xmc4_uart_configure + * + * Description: + * Configure a UART as a RS-232 UART. + * + ****************************************************************************/ + +#ifdef HAVE_UART_DEVICE +void xmc4_uart_configure(uintptr_t uart_base, uint32_t baud, + uint32_t clock, unsigned int parity, + unsigned int nbits, unsigned int stop2); +#endif + + +#endif /* __ARCH_ARM_SRC_XMC4_XMC4_LOWPUTC_H */ diff --git a/arch/arm/src/xmc4/xmc4_serial.c b/arch/arm/src/xmc4/xmc4_serial.c index 4992ddaeb8..e09a23ef55 100644 --- a/arch/arm/src/xmc4/xmc4_serial.c +++ b/arch/arm/src/xmc4/xmc4_serial.c @@ -110,22 +110,22 @@ # define UART5_ASSIGNED 1 #else # undef CONSOLE_DEV /* No console */ -# if defined(CONFIG_XMC4_USIC0_ISUART) +# if defined(HAVE_UART0) # define TTYS0_DEV g_uart0port /* UART0 is ttyS0 */ # define UART0_ASSIGNED 1 -# elif defined(CONFIG_XMC4_USIC1_ISUART) +# elif defined(HAVE_UART1) # define TTYS0_DEV g_uart1port /* UART1 is ttyS0 */ # define UART1_ASSIGNED 1 -# elif defined(CONFIG_XMC4_USIC2_ISUART) +# elif defined(HAVE_UART2) # define TTYS0_DEV g_uart2port /* UART2 is ttyS0 */ # define UART2_ASSIGNED 1 -# elif defined(CONFIG_XMC4_USIC3_ISUART) +# elif defined(HAVE_UART3) # define TTYS0_DEV g_uart3port /* UART3 is ttyS0 */ # define UART3_ASSIGNED 1 -# elif defined(CONFIG_XMC4_USIC4_ISUART) +# elif defined(HAVE_UART4) # define TTYS0_DEV g_uart4port /* UART4 is ttyS0 */ # define UART4_ASSIGNED 1 -# elif defined(CONFIG_XMC4_USIC5_ISUART) +# elif defined(HAVE_UART5) # define TTYS0_DEV g_uart5port /* UART5 is ttyS0 */ # define UART5_ASSIGNED 1 # endif @@ -133,22 +133,22 @@ /* Pick ttys1. This could be any of UART0-5 excluding the console UART. */ -#if defined(CONFIG_XMC4_USIC0_ISUART) && !defined(UART0_ASSIGNED) +#if defined(HAVE_UART0) && !defined(UART0_ASSIGNED) # define TTYS1_DEV g_uart0port /* UART0 is ttyS1 */ # define UART0_ASSIGNED 1 -#elif defined(CONFIG_XMC4_USIC1_ISUART) && !defined(UART1_ASSIGNED) +#elif defined(HAVE_UART1) && !defined(UART1_ASSIGNED) # define TTYS1_DEV g_uart1port /* UART1 is ttyS1 */ # define UART1_ASSIGNED 1 -#elif defined(CONFIG_XMC4_USIC2_ISUART) && !defined(UART2_ASSIGNED) +#elif defined(HAVE_UART2) && !defined(UART2_ASSIGNED) # define TTYS1_DEV g_uart2port /* UART2 is ttyS1 */ # define UART2_ASSIGNED 1 -#elif defined(CONFIG_XMC4_USIC3_ISUART) && !defined(UART3_ASSIGNED) +#elif defined(HAVE_UART3) && !defined(UART3_ASSIGNED) # define TTYS1_DEV g_uart3port /* UART3 is ttyS1 */ # define UART3_ASSIGNED 1 -#elif defined(CONFIG_XMC4_USIC4_ISUART) && !defined(UART4_ASSIGNED) +#elif defined(HAVE_UART4) && !defined(UART4_ASSIGNED) # define TTYS1_DEV g_uart4port /* UART4 is ttyS1 */ # define UART4_ASSIGNED 1 -#elif defined(CONFIG_XMC4_USIC5_ISUART) && !defined(UART5_ASSIGNED) +#elif defined(HAVE_UART5) && !defined(UART5_ASSIGNED) # define TTYS1_DEV g_uart5port /* UART5 is ttyS1 */ # define UART5_ASSIGNED 1 #endif @@ -158,19 +158,19 @@ * console. */ -#if defined(CONFIG_XMC4_USIC1_ISUART) && !defined(UART1_ASSIGNED) +#if defined(HAVE_UART1) && !defined(UART1_ASSIGNED) # define TTYS2_DEV g_uart1port /* UART1 is ttyS2 */ # define UART1_ASSIGNED 1 -#elif defined(CONFIG_XMC4_USIC2_ISUART) && !defined(UART2_ASSIGNED) +#elif defined(HAVE_UART2) && !defined(UART2_ASSIGNED) # define TTYS2_DEV g_uart2port /* UART2 is ttyS2 */ # define UART2_ASSIGNED 1 -#elif defined(CONFIG_XMC4_USIC3_ISUART) && !defined(UART3_ASSIGNED) +#elif defined(HAVE_UART3) && !defined(UART3_ASSIGNED) # define TTYS2_DEV g_uart3port /* UART3 is ttyS2 */ # define UART3_ASSIGNED 1 -#elif defined(CONFIG_XMC4_USIC4_ISUART) && !defined(UART4_ASSIGNED) +#elif defined(HAVE_UART4) && !defined(UART4_ASSIGNED) # define TTYS2_DEV g_uart4port /* UART4 is ttyS2 */ # define UART4_ASSIGNED 1 -#elif defined(CONFIG_XMC4_USIC5_ISUART) && !defined(UART5_ASSIGNED) +#elif defined(HAVE_UART5) && !defined(UART5_ASSIGNED) # define TTYS2_DEV g_uart5port /* UART5 is ttyS2 */ # define UART5_ASSIGNED 1 #endif @@ -180,16 +180,16 @@ * UART 2-5 could also be the console. */ -#if defined(CONFIG_XMC4_USIC2_ISUART) && !defined(UART2_ASSIGNED) +#if defined(HAVE_UART2) && !defined(UART2_ASSIGNED) # define TTYS3_DEV g_uart2port /* UART2 is ttyS3 */ # define UART2_ASSIGNED 1 -#elif defined(CONFIG_XMC4_USIC3_ISUART) && !defined(UART3_ASSIGNED) +#elif defined(HAVE_UART3) && !defined(UART3_ASSIGNED) # define TTYS3_DEV g_uart3port /* UART3 is ttyS3 */ # define UART3_ASSIGNED 1 -#elif defined(CONFIG_XMC4_USIC4_ISUART) && !defined(UART4_ASSIGNED) +#elif defined(HAVE_UART4) && !defined(UART4_ASSIGNED) # define TTYS3_DEV g_uart4port /* UART4 is ttyS3 */ # define UART4_ASSIGNED 1 -#elif defined(CONFIG_XMC4_USIC5_ISUART) && !defined(UART5_ASSIGNED) +#elif defined(HAVE_UART5) && !defined(UART5_ASSIGNED) # define TTYS3_DEV g_uart5port /* UART5 is ttyS3 */ # define UART5_ASSIGNED 1 #endif @@ -199,13 +199,13 @@ * UART 3-5 could also be the console. */ -#if defined(CONFIG_XMC4_USIC3_ISUART) && !defined(UART3_ASSIGNED) +#if defined(HAVE_UART3) && !defined(UART3_ASSIGNED) # define TTYS4_DEV g_uart3port /* UART3 is ttyS4 */ # define UART3_ASSIGNED 1 -#elif defined(CONFIG_XMC4_USIC4_ISUART) && !defined(UART4_ASSIGNED) +#elif defined(HAVE_UART4) && !defined(UART4_ASSIGNED) # define TTYS4_DEV g_uart4port /* UART4 is ttyS4 */ # define UART4_ASSIGNED 1 -#elif defined(CONFIG_XMC4_USIC5_ISUART) && !defined(UART5_ASSIGNED) +#elif defined(HAVE_UART5) && !defined(UART5_ASSIGNED) # define TTYS4_DEV g_uart5port /* UART5 is ttyS4 */ # define UART5_ASSIGNED 1 #endif @@ -215,10 +215,10 @@ * UART 4-5 could also be the console. */ -#if defined(CONFIG_XMC4_USIC4_ISUART) && !defined(UART4_ASSIGNED) +#if defined(HAVE_UART4) && !defined(UART4_ASSIGNED) # define TTYS5_DEV g_uart4port /* UART4 is ttyS5 */ # define UART4_ASSIGNED 1 -#elif defined(CONFIG_XMC4_USIC5_ISUART) && !defined(UART5_ASSIGNED) +#elif defined(HAVE_UART5) && !defined(UART5_ASSIGNED) # define TTYS5_DEV g_uart5port /* UART5 is ttyS5 */ # define UART5_ASSIGNED 1 #endif @@ -282,34 +282,34 @@ static const struct uart_ops_s g_uart_ops = /* I/O buffers */ -#ifdef CONFIG_XMC4_USIC0_ISUART +#ifdef HAVE_UART0 static char g_uart0rxbuffer[CONFIG_UART0_RXBUFSIZE]; static char g_uart0txbuffer[CONFIG_UART0_TXBUFSIZE]; #endif -#ifdef CONFIG_XMC4_USIC1_ISUART +#ifdef HAVE_UART1 static char g_uart1rxbuffer[CONFIG_UART1_RXBUFSIZE]; static char g_uart1txbuffer[CONFIG_UART1_TXBUFSIZE]; #endif -#ifdef CONFIG_XMC4_USIC2_ISUART +#ifdef HAVE_UART2 static char g_uart2rxbuffer[CONFIG_UART2_RXBUFSIZE]; static char g_uart2txbuffer[CONFIG_UART2_TXBUFSIZE]; #endif -#ifdef CONFIG_XMC4_USIC3_ISUART +#ifdef HAVE_UART3 static char g_uart3rxbuffer[CONFIG_UART3_RXBUFSIZE]; static char g_uart3txbuffer[CONFIG_UART3_TXBUFSIZE]; #endif -#ifdef CONFIG_XMC4_USIC4_ISUART +#ifdef HAVE_UART4 static char g_uart4rxbuffer[CONFIG_UART4_RXBUFSIZE]; static char g_uart4txbuffer[CONFIG_UART4_TXBUFSIZE]; #endif -#ifdef CONFIG_XMC4_USIC5_ISUART +#ifdef HAVE_UART5 static char g_uart5rxbuffer[CONFIG_UART5_RXBUFSIZE]; static char g_uart5txbuffer[CONFIG_UART5_TXBUFSIZE]; #endif /* This describes the state of the Kinetis UART0 port. */ -#ifdef CONFIG_XMC4_USIC0_ISUART +#ifdef HAVE_UART0 static struct xmc4_dev_s g_uart0priv = { .uartbase = XMC4_UART0_BASE, @@ -340,7 +340,7 @@ static uart_dev_t g_uart0port = /* This describes the state of the Kinetis UART1 port. */ -#ifdef CONFIG_XMC4_USIC1_ISUART +#ifdef HAVE_UART1 static struct xmc4_dev_s g_uart1priv = { .uartbase = XMC4_UART1_BASE, @@ -371,7 +371,7 @@ static uart_dev_t g_uart1port = /* This describes the state of the Kinetis UART2 port. */ -#ifdef CONFIG_XMC4_USIC2_ISUART +#ifdef HAVE_UART2 static struct xmc4_dev_s g_uart2priv = { .uartbase = XMC4_UART2_BASE, @@ -402,7 +402,7 @@ static uart_dev_t g_uart2port = /* This describes the state of the Kinetis UART3 port. */ -#ifdef CONFIG_XMC4_USIC3_ISUART +#ifdef HAVE_UART3 static struct xmc4_dev_s g_uart3priv = { .uartbase = XMC4_UART3_BASE, @@ -433,7 +433,7 @@ static uart_dev_t g_uart3port = /* This describes the state of the Kinetis UART4 port. */ -#ifdef CONFIG_XMC4_USIC4_ISUART +#ifdef HAVE_UART4 static struct xmc4_dev_s g_uart4priv = { .uartbase = XMC4_UART4_BASE, @@ -464,7 +464,7 @@ static uart_dev_t g_uart4port = /* This describes the state of the Kinetis UART5 port. */ -#ifdef CONFIG_XMC4_USIC5_ISUART +#ifdef HAVE_UART5 static struct xmc4_dev_s g_uart5priv = { .uartbase = XMC4_UART5_BASE, diff --git a/arch/arm/src/xmc4/xmc4_usic.h b/arch/arm/src/xmc4/xmc4_usic.h new file mode 100644 index 0000000000..d589459037 --- /dev/null +++ b/arch/arm/src/xmc4/xmc4_usic.h @@ -0,0 +1,109 @@ +/**************************************************************************** + * arch/arm/src/xmc4/xmc4_usic.h + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __ARCH_ARM_SRC_XMC4_XMC4_USIC_H +#define __ARCH_ARM_SRC_XMC4_XMC4_USIC_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include "xmc4_config.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* This enumeration identifies the USIC */ + +enum usic_e +{ + USIC0 = 0, /* USIC0 */ + USIC1 = 1, /* USIC1 */ + USIC2 = 2 /* USIC2 */ +}; + +/* This enumeration identifies USIC channels */ + +enum usic_channel_e +{ + USIC0_CHAN0 = 0, /* USIC0, Channel 0 */ + USIC0_CHAN1 = 1, /* USIC0, Channel 1 */ + USIC1_CHAN0 = 0, /* USIC1, Channel 0 */ + USIC1_CHAN1 = 1, /* USIC1, Channel 1 */ + USIC2_CHAN0 = 0, /* USIC2, Channel 0 */ + USIC2_CHAN1 = 1 /* USIC2, Channel 1 */ +}; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: xmc4_enable_usic + * + * Description: + * Enable the USIC module indicated by the 'usic' enumeration value + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned to + * indicate the nature of any failure. + * + ****************************************************************************/ + +int xmc4_enable_usic(enum usic_e usic); + +/**************************************************************************** + * Name: xmc4_enable_usic_channel + * + * Description: + * Enable the USIC channel indicated by 'channel'. Also enable and reset + * the USIC module if it is not already enabled. + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned to + * indicate the nature of any failure. + * + ****************************************************************************/ + +int xmc4_enable_usic_channel(enum usic_channel_e channel); + +#endif /* __ARCH_ARM_SRC_XMC4_XMC4_USIC_H */ diff --git a/configs/xmc4500-relax/nsh/defconfig b/configs/xmc4500-relax/nsh/defconfig index 54bd16a392..f938e18bc4 100644 --- a/configs/xmc4500-relax/nsh/defconfig +++ b/configs/xmc4500-relax/nsh/defconfig @@ -177,18 +177,22 @@ CONFIG_XMC4_USCI_UART=y CONFIG_XMC4_USIC0=y # CONFIG_XMC4_USIC1 is not set # CONFIG_XMC4_USIC2 is not set -# CONFIG_XMC4_USIC3 is not set -# CONFIG_XMC4_USIC4 is not set -# CONFIG_XMC4_USIC5 is not set # # XMC4xxx USIC Configuration # -CONFIG_XMC4_USIC0_ISUART=y -# CONFIG_XMC4_USIC0_ISLIN is not set -# CONFIG_XMC4_USIC0_ISSPI is not set -# CONFIG_XMC4_USIC0_ISI2C is not set -# CONFIG_XMC4_USIC0_ISI2S is not set +# CONFIG_XMC4_USIC0_CHAN0_NONE is not set +CONFIG_XMC4_USIC0_CHAN0_ISUART=y +# CONFIG_XMC4_USIC0_CHAN0_ISLIN is not set +# CONFIG_XMC4_USIC0_CHAN0_ISSPI is not set +# CONFIG_XMC4_USIC0_CHAN0_ISI2C is not set +# CONFIG_XMC4_USIC0_CHAN0_ISI2S is not set +CONFIG_XMC4_USIC0_CHAN1_NONE=y +# CONFIG_XMC4_USIC0_CHAN1_ISUART is not set +# CONFIG_XMC4_USIC0_CHAN1_ISLIN is not set +# CONFIG_XMC4_USIC0_CHAN1_ISSPI is not set +# CONFIG_XMC4_USIC0_CHAN1_ISI2C is not set +# CONFIG_XMC4_USIC0_CHAN1_ISI2S is not set # # Architecture Options @@ -554,6 +558,7 @@ CONFIG_STANDARD_SERIAL=y # CONFIG_SERIAL_DMA is not set # CONFIG_ARCH_HAVE_SERIAL_TERMIOS is not set CONFIG_UART0_SERIAL_CONSOLE=y +# CONFIG_UART1_SERIAL_CONSOLE is not set # CONFIG_OTHER_SERIAL_CONSOLE is not set # CONFIG_NO_SERIAL_CONSOLE is not set