From 1bd5ff87c4f9b3079e827b30cabd1f8aa205f1df Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 12 Feb 2014 18:29:23 -0600 Subject: [PATCH] Fix-up some SAMD20 SERCOM conditionals --- arch/arm/src/samd/sam_config.h | 104 +++++++++++++++--- configs/samd20-xplained/src/Makefile | 6 +- configs/samd20-xplained/src/sam_boot.c | 3 +- configs/samd20-xplained/src/sam_mmcsd.c | 7 +- configs/samd20-xplained/src/sam_nsh.c | 2 +- configs/samd20-xplained/src/sam_spi.c | 5 +- .../samd20-xplained/src/sam_ug2832hsweg04.c | 4 +- configs/samd20-xplained/src/samd20-xplained.h | 13 ++- 8 files changed, 113 insertions(+), 31 deletions(-) diff --git a/arch/arm/src/samd/sam_config.h b/arch/arm/src/samd/sam_config.h index e5b8a3941a..cc126fa115 100644 --- a/arch/arm/src/samd/sam_config.h +++ b/arch/arm/src/samd/sam_config.h @@ -46,7 +46,7 @@ /************************************************************************************ * Pre-processor Definitions ************************************************************************************/ -/* How many SERCOM peripherals are configured as peripherals */ +/* How many SERCOM peripherals are configured as UART peripherals? */ #define SAMD_HAVE_UART0 1 #define SAMD_HAVE_UART1 1 @@ -55,54 +55,54 @@ #define SAMD_HAVE_UART4 1 #define SAMD_HAVE_UART5 1 -#if !defined(CONFIG_SAMD_SERCOM0) || !defined(CONFIG_SAMD_SERCOM0_UART) +#if !defined(CONFIG_SAMD_SERCOM0) || !defined(CONFIG_SAMD_SERCOM0_ISUART) # undef SAMD_HAVE_UART0 -# undef CONFIG_SAMD_SERCOM0_UART +# undef CONFIG_SAMD_SERCOM0_ISUART # undef CONFIG_UART0_SERIAL_CONSOLE # undef CONFIG_UART0_FLOW_CONTROL # undef CONFIG_UART0_IRDAMODE # undef CONFIG_UART0_RS485MODE #endif -#if !defined(CONFIG_SAMD_SERCOM1) || !defined(CONFIG_SAMD_SERCOM1_UART) +#if !defined(CONFIG_SAMD_SERCOM1) || !defined(CONFIG_SAMD_SERCOM1_ISUART) # undef SAMD_HAVE_UART1 -# undef CONFIG_SAMD_SERCOM1_UART +# undef CONFIG_SAMD_SERCOM1_ISUART # undef CONFIG_UART1_SERIAL_CONSOLE # undef CONFIG_UART1_FLOW_CONTROL # undef CONFIG_UART1_IRDAMODE # undef CONFIG_UART1_RS485MODE #endif -#if !defined(CONFIG_SAMD_SERCOM2) || !defined(CONFIG_SAMD_SERCOM2_UART) +#if !defined(CONFIG_SAMD_SERCOM2) || !defined(CONFIG_SAMD_SERCOM2_ISUART) # undef SAMD_HAVE_UART2 -# undef CONFIG_SAMD_SERCOM2_UART +# undef CONFIG_SAMD_SERCOM2_ISUART # undef CONFIG_UART2_SERIAL_CONSOLE # undef CONFIG_UART2_FLOW_CONTROL # undef CONFIG_UART2_IRDAMODE # undef CONFIG_UART2_RS485MODE #endif -#if !defined(CONFIG_SAMD_SERCOM3) || !defined(CONFIG_SAMD_SERCOM3_UART) +#if !defined(CONFIG_SAMD_SERCOM3) || !defined(CONFIG_SAMD_SERCOM3_ISUART) # undef SAMD_HAVE_UART3 -# undef CONFIG_SAMD_SERCOM3_UART +# undef CONFIG_SAMD_SERCOM3_ISUART # undef CONFIG_UART3_SERIAL_CONSOLE # undef CONFIG_UART3_FLOW_CONTROL # undef CONFIG_UART3_IRDAMODE # undef CONFIG_UART3_RS485MODE #endif -#if !defined(CONFIG_SAMD_SERCOM4) || !defined(CONFIG_SAMD_SERCOM4_UART) +#if !defined(CONFIG_SAMD_SERCOM4) || !defined(CONFIG_SAMD_SERCOM4_ISUART) # undef SAMD_HAVE_UART4 -# undef CONFIG_SAMD_SERCOM4_UART +# undef CONFIG_SAMD_SERCOM4_ISUART # undef CONFIG_UART4_SERIAL_CONSOLE # undef CONFIG_UART4_FLOW_CONTROL # undef CONFIG_UART4_IRDAMODE # undef CONFIG_UART4_RS485MODE #endif -#if !defined(CONFIG_SAMD_SERCOM5) || !defined(CONFIG_SAMD_SERCOM5_UART) +#if !defined(CONFIG_SAMD_SERCOM5) || !defined(CONFIG_SAMD_SERCOM5_ISUART) # undef SAMD_HAVE_UART5 -# undef CONFIG_SAMD_SERCOM5_UART +# undef CONFIG_SAMD_SERCOM5_ISUART # undef CONFIG_UART5_SERIAL_CONSOLE # undef CONFIG_UART5_FLOW_CONTROL # undef CONFIG_UART5_IRDAMODE @@ -174,6 +174,84 @@ # undef HAVE_SERIAL_CONSOLE #endif +/* Are any SERCOM peripherals are configured as SPI peripherals? */ + +#define SAMD_HAVE_SPI0 1 +#define SAMD_HAVE_SPI1 1 +#define SAMD_HAVE_SPI2 1 +#define SAMD_HAVE_SPI3 1 +#define SAMD_HAVE_SPI4 1 +#define SAMD_HAVE_SPI5 1 + +#if !defined(CONFIG_SAMD_SERCOM0) || !defined(CONFIG_SAMD_SERCOM0_ISSPI) +# undef SAMD_HAVE_SPI0 +# undef CONFIG_SAMD_SERCOM0_ISSPI +#endif + +#if !defined(CONFIG_SAMD_SERCOM1) || !defined(CONFIG_SAMD_SERCOM1_ISSPI) +# undef SAMD_HAVE_SPI1 +# undef CONFIG_SAMD_SERCOM1_ISSPI +#endif + +#if !defined(CONFIG_SAMD_SERCOM2) || !defined(CONFIG_SAMD_SERCOM2_ISSPI) +# undef SAMD_HAVE_SPI2 +# undef CONFIG_SAMD_SERCOM2_ISSPI +#endif + +#if !defined(CONFIG_SAMD_SERCOM3) || !defined(CONFIG_SAMD_SERCOM3_ISSPI) +# undef SAMD_HAVE_SPI3 +# undef CONFIG_SAMD_SERCOM3_ISSPI +#endif + +#if !defined(CONFIG_SAMD_SERCOM4) || !defined(CONFIG_SAMD_SERCOM4_ISSPI) +# undef SAMD_HAVE_SPI4 +# undef CONFIG_SAMD_SERCOM4_ISSPI +#endif + +#if !defined(CONFIG_SAMD_SERCOM5) || !defined(CONFIG_SAMD_SERCOM5_ISSPI) +# undef SAMD_HAVE_SPI5 +# undef CONFIG_SAMD_SERCOM5_ISSPI +#endif + +/* Are any SERCOM peripherals are configured as I2C peripherals? */ + +#define SAMD_HAVE_I2C0 1 +#define SAMD_HAVE_I2C1 1 +#define SAMD_HAVE_I2C2 1 +#define SAMD_HAVE_I2C3 1 +#define SAMD_HAVE_I2C4 1 +#define SAMD_HAVE_I2C5 1 + +#if !defined(CONFIG_SAMD_SERCOM0) || !defined(CONFIG_SAMD_SERCOM0_ISI2C) +# undef SAMD_HAVE_I2C0 +# undef CONFIG_SAMD_SERCOM0_ISI2C +#endif + +#if !defined(CONFIG_SAMD_SERCOM1) || !defined(CONFIG_SAMD_SERCOM1_ISI2C) +# undef SAMD_HAVE_I2C1 +# undef CONFIG_SAMD_SERCOM1_ISI2C +#endif + +#if !defined(CONFIG_SAMD_SERCOM2) || !defined(CONFIG_SAMD_SERCOM2_ISI2C) +# undef SAMD_HAVE_I2C2 +# undef CONFIG_SAMD_SERCOM2_ISI2C +#endif + +#if !defined(CONFIG_SAMD_SERCOM3) || !defined(CONFIG_SAMD_SERCOM3_ISI2C) +# undef SAMD_HAVE_I2C3 +# undef CONFIG_SAMD_SERCOM3_ISI2C +#endif + +#if !defined(CONFIG_SAMD_SERCOM4) || !defined(CONFIG_SAMD_SERCOM4_ISI2C) +# undef SAMD_HAVE_I2C4 +# undef CONFIG_SAMD_SERCOM4_ISI2C +#endif + +#if !defined(CONFIG_SAMD_SERCOM5) || !defined(CONFIG_SAMD_SERCOM5_ISI2C) +# undef SAMD_HAVE_I2C5 +# undef CONFIG_SAMD_SERCOM5_ISI2C +#endif + /************************************************************************************ * Public Types ************************************************************************************/ diff --git a/configs/samd20-xplained/src/Makefile b/configs/samd20-xplained/src/Makefile index d27dde71d7..6be9b5e5e0 100644 --- a/configs/samd20-xplained/src/Makefile +++ b/configs/samd20-xplained/src/Makefile @@ -46,7 +46,7 @@ ifeq ($(CONFIG_HAVE_CXX),y) CSRCS += sam_cxxinitialize.c endif -ifeq ($(CONFIG_SAMD_SPI0),y) +ifeq ($(CONFIG_SAMD_SERCOM0),y) CSRCS += sam_spi.c endif @@ -64,13 +64,13 @@ ifeq ($(CONFIG_NSH_ARCHINIT),y) CSRCS += sam_nsh.c endif -ifeq ($(CONFIG_SAMD_SPI0),y) +ifeq ($(CONFIG_SAMD_SERCOM0),y) ifeq ($(CONFIG_SAM4L_XPLAINED_IOMODULE),y) CSRCS += sam_mmcsd.c endif endif -ifeq ($(CONFIG_SAMD_SPI0),y) +ifeq ($(CONFIG_SAMD_SERCOM0),y) ifeq ($(CONFIG_SAM4L_XPLAINED_OLED1MODULE),y) ifeq ($(CONFIG_LCD_UG2832HSWEG04),y) CSRCS += sam_ug2832hsweg04.c diff --git a/configs/samd20-xplained/src/sam_boot.c b/configs/samd20-xplained/src/sam_boot.c index b806b2a813..082638fbb6 100644 --- a/configs/samd20-xplained/src/sam_boot.c +++ b/configs/samd20-xplained/src/sam_boot.c @@ -41,6 +41,7 @@ #include +#include "sam_config.h" #include "samd20-xplained.h" /************************************************************************************ @@ -71,7 +72,7 @@ void sam_boardinitialize(void) * sam_spiinitialize() has been brought into the link. */ -#ifdef CONFIG_SAMD_SPI0 +#ifdef SAMD_HAVE_SPI0 if (sam_spiinitialize) { sam_spiinitialize(); diff --git a/configs/samd20-xplained/src/sam_mmcsd.c b/configs/samd20-xplained/src/sam_mmcsd.c index 0c4e297af2..0cb4ddef37 100644 --- a/configs/samd20-xplained/src/sam_mmcsd.c +++ b/configs/samd20-xplained/src/sam_mmcsd.c @@ -46,6 +46,7 @@ #include #include +#include "sam_config.h" #include "samd20-xplained.h" #ifdef CONFIG_SAM4L_XPLAINED_IOMODULE @@ -59,8 +60,8 @@ # error Mountpoints are disabled (CONFIG_DISABLE_MOUNTPOINT=y) #endif -#ifndef CONFIG_SAMD_SPI0 /* REVISIT */ -# error SPI support is required (CONFIG_SAMD_SPI0) +#ifndef SAMD_HAVE_SPI0 +# error SERCOM0 SPI support is required #endif #ifndef CONFIG_MMCSD @@ -81,7 +82,7 @@ * - CONFIG_SAM4L_XPLAINED_IOMODULE=y, * - CONFIG_DISABLE_MOUNTPOINT=n, * - CONFIG_MMCSD=y, and - * - CONFIG_SAMD_SPI0=y + * - SAMD_HAVE_SPI0=y (CONFIG_SAMD_SERCOM0 && CONFIG_SAMD_SERCOM0_ISSPI) * *****************************************************************************/ diff --git a/configs/samd20-xplained/src/sam_nsh.c b/configs/samd20-xplained/src/sam_nsh.c index 0b028ce9e7..a90c6457f4 100644 --- a/configs/samd20-xplained/src/sam_nsh.c +++ b/configs/samd20-xplained/src/sam_nsh.c @@ -99,7 +99,7 @@ int nsh_archinitialize(void) { -#if defined(CONFIG_SAMD_SPI0) && defined(CONFIG_SAM4L_XPLAINED_IOMODULE) +#if defined(SAMD_HAVE_SPI0) && defined(CONFIG_SAM4L_XPLAINED_IOMODULE) /* Initialize the SPI-based MMC/SD slot */ { diff --git a/configs/samd20-xplained/src/sam_spi.c b/configs/samd20-xplained/src/sam_spi.c index b802dfec05..19a18d17c4 100644 --- a/configs/samd20-xplained/src/sam_spi.c +++ b/configs/samd20-xplained/src/sam_spi.c @@ -45,11 +45,12 @@ #include +#include "sam_config.h" #include "sam_gpio.h" #include "sam_spi.h" #include "samd20-xplained.h" -#ifdef CONFIG_SAMD_SPI0 /* REVISIT */ +#ifdef SAMD_HAVE_SPI0 /************************************************************************************ * Definitions @@ -236,7 +237,7 @@ uint8_t sam_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid) return ret; } -#endif /* CONFIG_SAMD_SPI0 */ +#endif /* SAMD_HAVE_SPI0 */ /**************************************************************************** * Name: sam_spicmddata diff --git a/configs/samd20-xplained/src/sam_ug2832hsweg04.c b/configs/samd20-xplained/src/sam_ug2832hsweg04.c index b7b6194188..42772cf00a 100644 --- a/configs/samd20-xplained/src/sam_ug2832hsweg04.c +++ b/configs/samd20-xplained/src/sam_ug2832hsweg04.c @@ -133,8 +133,8 @@ # error "The OLED driver requires CONFIG_LCD_UG2832HSWEG04 in the configuration" #endif -#ifndef CONFIG_SAMD_SPI0 -# error "The OLED driver requires CONFIG_SAMD_SPI0 in the configuration" +#ifndef SAMD_HAVE_SPI0 +# error "The OLED driver requires SAMD_HAVE_SPI0 in the configuration" #endif #ifndef CONFIG_SPI_CMDDATA diff --git a/configs/samd20-xplained/src/samd20-xplained.h b/configs/samd20-xplained/src/samd20-xplained.h index 72157ab2ef..89d7928c62 100644 --- a/configs/samd20-xplained/src/samd20-xplained.h +++ b/configs/samd20-xplained/src/samd20-xplained.h @@ -48,6 +48,7 @@ #include #include +#include "sam_config.h" #include "chip/sam_pinmap.h" /************************************************************************************ @@ -115,8 +116,8 @@ #ifdef CONFIG_SAMD20_XPLAINED_IOMODULE -# ifndef CONFIG_SAMD_SPI0 -# error CONFIG_SAMD_SPI0 is required to use the I/O1 module +# ifndef SAMD_HAVE_SPI0 +# error SAMD_HAVE_SPI0 is required to use the I/O1 module # endif # if defined(CONFIG_SAMD20_XPLAINED_IOMODULE_EXT1) @@ -171,8 +172,8 @@ #ifdef CONFIG_SAMD20_XPLAINED_OLED1MODULE -# ifndef CONFIG_SAMD_SPI0 /* REVISIT */ -# error CONFIG_SAMD_SPI0 is required to use the OLED1 module +# ifndef SAMD_HAVE_SPI0 +# error SAMD_HAVE_SPI0 is required to use the OLED1 module # endif # ifndef CONFIG_SPI_CMDDATA @@ -256,11 +257,11 @@ void weak_function sam_spiinitialize(void); * * Description: * Initialize the SPI-based SD card. Requires CONFIG_SAMD20_XPLAINED_IOMODULE=y, - * CONFIG_DISABLE_MOUNTPOINT=n, CONFIG_MMCSD=y, and CONFIG_SAMD_SPI0=y + * CONFIG_DISABLE_MOUNTPOINT=n, CONFIG_MMCSD=y, and SAMD_HAVE_SPI0 * ************************************************************************************/ -#if defined(CONFIG_SAMD_SPI0) && defined(CONFIG_SAMD20_XPLAINED_IOMODULE) +#if defined(SAMD_HAVE_SPI0) && defined(CONFIG_SAMD20_XPLAINED_IOMODULE) int sam_sdinitialize(int minor); #endif