diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-08-06 10:20:17 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-08-06 10:20:17 -0600 |
commit | e6ec4e102eeec5de869db6eea6a5093abdb7782c (patch) | |
tree | e9e1e1b2ef3368d235bdce508609eecce9f0eced /nuttx/configs | |
parent | f959801dada491a15db46b48bc9d86408e31e915 (diff) | |
download | px4-nuttx-e6ec4e102eeec5de869db6eea6a5093abdb7782c.tar.gz px4-nuttx-e6ec4e102eeec5de869db6eea6a5093abdb7782c.tar.bz2 px4-nuttx-e6ec4e102eeec5de869db6eea6a5093abdb7782c.zip |
SAMA5: Add PIO interrupt support. Massive name changes for consistency in PIO vs GPIO naming. SAMA5D3x-EK: Add support for SD card detection PIO interrupts
Diffstat (limited to 'nuttx/configs')
-rw-r--r-- | nuttx/configs/sama5d3x-ek/README.txt | 32 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/hello/defconfig | 2 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/include/board.h | 4 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/norboot/defconfig | 2 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/nsh/defconfig | 2 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/ostest/defconfig | 2 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/sam_autoleds.c | 17 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/sam_buttons.c | 22 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/sam_hsmci.c | 213 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/sam_spi.c | 16 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/sam_userleds.c | 21 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h | 34 |
12 files changed, 219 insertions, 148 deletions
diff --git a/nuttx/configs/sama5d3x-ek/README.txt b/nuttx/configs/sama5d3x-ek/README.txt index 37b186aad..aef5e235f 100644 --- a/nuttx/configs/sama5d3x-ek/README.txt +++ b/nuttx/configs/sama5d3x-ek/README.txt @@ -433,7 +433,7 @@ Buttons and LEDs LEDs ---- There are two LEDs on the SAMA5D3 series-CM board that can be controlled - by software. A blue LED is controlled via GPIO pins. A red LED normally + by software. A blue LED is controlled via PIO pins. A red LED normally provides an indication that power is supplied to the board but can also be controlled via software. @@ -480,23 +480,23 @@ Serial Consoles USART1 Connector J8 ------------------------------- - SAMA5 FUNCTION NUTTX GPIO + SAMA5 FUNCTION NUTTX PIO PIO NAME CONFIGURATION ---- ---------- --------------- - PB27 RTS1 GPIO_USART1_RTS - PB29 TXD1 GPIO_USART1_TXD - PB28 RXD1 GPIO_USART1_RXD - PB26 CTS1 GPIO_USART1_CTS + PB27 RTS1 PIO_USART1_RTS + PB29 TXD1 PIO_USART1_TXD + PB28 RXD1 PIO_USART1_RXD + PB26 CTS1 PIO_USART1_CTS NOTE: Debug TX and RX pins also go the the ADM3312EARU, but I am uncertain of the functionality. ------------------------------- - SAMA5 FUNCTION NUTTX GPIO + SAMA5 FUNCTION NUTTX PIO PIO NAME CONFIGURATION ---- ---------- --------------- - PB31 DTXD GPIO_DBGU_DTXD - PB30 DRXD GPIO_DBGU_DRXD + PB31 DTXD PIO_DBGU_DTXD + PB30 DRXD PIO_DBGU_DRXD Hardware UART via CDC --------------------- @@ -694,11 +694,11 @@ SAMA5D3x-EK Configuration Options Some subsystems can be configured to operate in different ways. The drivers need to know how to configure the subsystem. - CONFIG_PIOA_IRQ - Support PIOA interrupts - CONFIG_PIOB_IRQ - Support PIOB interrupts - CONFIG_PIOC_IRQ - Support PIOD interrupts - CONFIG_PIOD_IRQ - Support PIOD interrupts - CONFIG_PIOE_IRQ - Support PIOE interrupts + CONFIG_SAMA5_PIOA_IRQ - Support PIOA interrupts + CONFIG_SAMA5_PIOB_IRQ - Support PIOB interrupts + CONFIG_SAMA5_PIOC_IRQ - Support PIOD interrupts + CONFIG_SAMA5_PIOD_IRQ - Support PIOD interrupts + CONFIG_SAMA5_PIOE_IRQ - Support PIOE interrupts CONFIG_USART0_ISUART - USART0 is configured as a UART CONFIG_USART1_ISUART - USART1 is configured as a UART @@ -1017,9 +1017,13 @@ Configurations CONFIG_SAMA5_DMAC0=y : DMAC0 is needed by HSMCI0 CONFIG_SAMA5_DMAC1=y : DMAC1 is needed by HSMCI1 + CONFIG_SAMA5_PIO_IRQ=y : PIO interrupts needed + CONFIG_SAMA5_PIOD_IRQ=y : Card detect pins are on PIOD + Device Drivers -> CONFIG_MMCSD=y : Enable MMC/SD support CONFIG_MMSCD_NSLOTS=1 : One slot per driver instance + CONFIG_MMCSD_HAVECARDDETECT=y : Supports card-detect PIOs CONFIG_MMCSD_SDIO=y : SDIO-based MMC/SD support CONFIG_SDIO_DMA=y : Use SDIO DMA CONFIG_SDIO_BLOCKSETUP=y : Needs to know block sizes diff --git a/nuttx/configs/sama5d3x-ek/hello/defconfig b/nuttx/configs/sama5d3x-ek/hello/defconfig index 2166fc65f..a89e0e977 100644 --- a/nuttx/configs/sama5d3x-ek/hello/defconfig +++ b/nuttx/configs/sama5d3x-ek/hello/defconfig @@ -162,7 +162,7 @@ CONFIG_SAMA5_USART1=y # CONFIG_SAMA5_ARM is not set # CONFIG_SAMA5_FUSE is not set # CONFIG_SAMA5_MPDDRC is not set -# CONFIG_PIO_IRQ is not set +# CONFIG_SAMA5_PIO_IRQ is not set # # External Memory Configuration diff --git a/nuttx/configs/sama5d3x-ek/include/board.h b/nuttx/configs/sama5d3x-ek/include/board.h index fd6470e34..ce5d89d57 100644 --- a/nuttx/configs/sama5d3x-ek/include/board.h +++ b/nuttx/configs/sama5d3x-ek/include/board.h @@ -146,7 +146,7 @@ /* LED definitions ******************************************************************/ /* There are two LEDs on the SAMA5D3 series-CM board that can be controlled - * by software. A blue LED is controlled via GPIO pins. A red LED normally + * by software. A blue LED is controlled via PIO pins. A red LED normally * provides an indication that power is supplied to the board but can also * be controlled via software. * @@ -308,7 +308,7 @@ uint8_t up_buttons(void); * ************************************************************************************/ -#ifdef CONFIG_PIOA_IRQ +#ifdef CONFIG_SAMA5_PIOE_IRQ xcpt_t up_irqbutton(int id, xcpt_t irqhandler); #endif #endif /* CONFIG_ARCH_BUTTONS */ diff --git a/nuttx/configs/sama5d3x-ek/norboot/defconfig b/nuttx/configs/sama5d3x-ek/norboot/defconfig index 7aad0a187..8af56b68b 100644 --- a/nuttx/configs/sama5d3x-ek/norboot/defconfig +++ b/nuttx/configs/sama5d3x-ek/norboot/defconfig @@ -162,7 +162,7 @@ CONFIG_SAMA5_USART1=y # CONFIG_SAMA5_ARM is not set # CONFIG_SAMA5_FUSE is not set # CONFIG_SAMA5_MPDDRC is not set -# CONFIG_PIO_IRQ is not set +# CONFIG_SAMA5_PIO_IRQ is not set # # External Memory Configuration diff --git a/nuttx/configs/sama5d3x-ek/nsh/defconfig b/nuttx/configs/sama5d3x-ek/nsh/defconfig index 4c27a7742..d3b30de71 100644 --- a/nuttx/configs/sama5d3x-ek/nsh/defconfig +++ b/nuttx/configs/sama5d3x-ek/nsh/defconfig @@ -162,7 +162,7 @@ CONFIG_SAMA5_USART1=y # CONFIG_SAMA5_ARM is not set # CONFIG_SAMA5_FUSE is not set # CONFIG_SAMA5_MPDDRC is not set -# CONFIG_PIO_IRQ is not set +# CONFIG_SAMA5_PIO_IRQ is not set # # SPI device driver options diff --git a/nuttx/configs/sama5d3x-ek/ostest/defconfig b/nuttx/configs/sama5d3x-ek/ostest/defconfig index 31c6253e3..0ca320fb2 100644 --- a/nuttx/configs/sama5d3x-ek/ostest/defconfig +++ b/nuttx/configs/sama5d3x-ek/ostest/defconfig @@ -162,7 +162,7 @@ CONFIG_SAMA5_USART1=y # CONFIG_SAMA5_ARM is not set # CONFIG_SAMA5_FUSE is not set # CONFIG_SAMA5_MPDDRC is not set -# CONFIG_PIO_IRQ is not set +# CONFIG_SAMA5_PIO_IRQ is not set # # External Memory Configuration diff --git a/nuttx/configs/sama5d3x-ek/src/sam_autoleds.c b/nuttx/configs/sama5d3x-ek/src/sam_autoleds.c index da56cde6e..afef4f3b2 100644 --- a/nuttx/configs/sama5d3x-ek/src/sam_autoleds.c +++ b/nuttx/configs/sama5d3x-ek/src/sam_autoleds.c @@ -33,7 +33,7 @@ * ****************************************************************************/ /* There are two LEDs on the SAMA5D3 series-CM board that can be controlled - * by software. A blue LED is controlled via GPIO pins. A red LED normally + * by software. A blue LED is controlled via PIO pins. A red LED normally * provides an indication that power is supplied to the board but can also * be controlled via software. * @@ -81,6 +81,7 @@ #include <arch/board/board.h> +#include "sam_pio.h" #include "sama5d3x-ek.h" #ifdef CONFIG_ARCH_LEDS @@ -119,10 +120,10 @@ void up_ledinit(void) { - /* Configure LED GPIOs for output */ + /* Configure LED PIOs for output */ - sam_configgpio(GPIO_BLUE); - sam_configgpio(GPIO_RED); + sam_configpio(PIO_BLUE); + sam_configpio(PIO_RED); } /**************************************************************************** @@ -152,8 +153,8 @@ void up_ledon(int led) break; } - sam_gpiowrite(GPIO_BLUE, blueoff); - sam_gpiowrite(GPIO_RED, redon); + sam_piowrite(PIO_BLUE, blueoff); + sam_piowrite(PIO_RED, redon); } /**************************************************************************** @@ -164,8 +165,8 @@ void up_ledoff(int led) { if (led != 2) { - sam_gpiowrite(GPIO_BLUE, true); /* Low illuminates */ - sam_gpiowrite(GPIO_RED, false); /* High illuminates */ + sam_piowrite(PIO_BLUE, true); /* Low illuminates */ + sam_piowrite(PIO_RED, false); /* High illuminates */ } } diff --git a/nuttx/configs/sama5d3x-ek/src/sam_buttons.c b/nuttx/configs/sama5d3x-ek/src/sam_buttons.c index bce98dbd5..2a6de2908 100644 --- a/nuttx/configs/sama5d3x-ek/src/sam_buttons.c +++ b/nuttx/configs/sama5d3x-ek/src/sam_buttons.c @@ -61,7 +61,7 @@ #include <arch/irq.h> #include <arch/board/board.h> -#include "sam_gpio.h" +#include "sam_pio.h" #include "sama5d3x-ek.h" #ifdef CONFIG_ARCH_BUTTONS @@ -74,7 +74,7 @@ * Private Data ****************************************************************************/ -#if defined(CONFIG_PIOE_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS) +#if defined(CONFIG_SAMA5_PIOE_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS) static xcpt_t g_irquser1; #endif @@ -99,7 +99,7 @@ static xcpt_t g_irquser1; void up_buttoninit(void) { - (void)sam_configgpio(GPIO_USER1); + (void)sam_configpio(PIO_USER1); } /************************************************************************************ @@ -115,7 +115,7 @@ void up_buttoninit(void) uint8_t up_buttons(void) { - return sam_gpioread(GPIO_USER1) ? 0 : BUTTON_USER1_BIT; + return sam_pioread(PIO_USER1) ? 0 : BUTTON_USER1_BIT; } /**************************************************************************** @@ -128,15 +128,13 @@ uint8_t up_buttons(void) * handler address isreturned (so that it may restored, if so desired). * * Configuration Notes: - * Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the - * overall GPIO IRQ feature and CONFIG_AVR32_GPIOIRQSETA and/or - * CONFIG_AVR32_GPIOIRQSETB must be enabled to select GPIOs to support - * interrupts on. For button support, bits 2 and 3 must be set in - * CONFIG_AVR32_GPIOIRQSETB (PB2 and PB3). + * Configuration CONFIG_SAMA5_PIO_IRQ must be selected to enable the + * overall PIO IRQ feature and CONFIG_SAMA5_PIOE_IRQ must be enabled to select + * PIOs to support interrupts on PIOE. * ****************************************************************************/ -#if defined(CONFIG_PIOE_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS) +#if defined(CONFIG_SAMA5_PIOE_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS) xcpt_t up_irqbutton(int id, xcpt_t irqhandler) { xcpt_t oldhandler = NULL; @@ -158,9 +156,9 @@ xcpt_t up_irqbutton(int id, xcpt_t irqhandler) /* Configure the interrupt */ - sam_gpioirq(IRQ_USER1); + sam_pioirq(IRQ_USER1); (void)irq_attach(IRQ_USER1, irqhandler); - sam_gpioirqenable(IRQ_USER1); + sam_pioirqenable(IRQ_USER1); } /* Return the old button handler (so that it can be restored) */ diff --git a/nuttx/configs/sama5d3x-ek/src/sam_hsmci.c b/nuttx/configs/sama5d3x-ek/src/sam_hsmci.c index 635bcfeda..cdef2940b 100644 --- a/nuttx/configs/sama5d3x-ek/src/sam_hsmci.c +++ b/nuttx/configs/sama5d3x-ek/src/sam_hsmci.c @@ -65,30 +65,6 @@ * PB19 MCI1_CDA */ - -/* SPI Chip Selects *****************************************************************/ -/* Both the Ronetix and Embest versions of the SAMAD3x CPU modules include an - * Atmel AT25DF321A, 32-megabit, 2.7-volt SPI serial flash. The SPI - * connection is as follows: - * - * AT25DF321A SAMA5 - * --------------- ----------------------------------------------- - * SI PD11 SPI0_MOSI - * SO PD10 SPI0_MIS0 - * SCK PD12 SPI0_SPCK - * /CS PD13 via NL17SZ126 if JP1 is closed (See below) - * - * JP1 and JP2 seem to related to /CS on the Ronetix board, but the usage is - * less clear. For the Embest module, JP1 must be closed to connect /CS to - * PD13; on the Ronetix schematic, JP11 seems only to bypass a resistor (may - * not be populated?). I think closing JP1 is correct in either case. - */ - -#define GPIO_AT25_NPCS0 (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \ - GPIO_PORT_PIOD | GPIO_PIN13) -#define AT25_PORT SPI0_CS0 - - /**************************************************************************** * Included Files ****************************************************************************/ @@ -103,36 +79,42 @@ #include <nuttx/sdio.h> #include <nuttx/mmcsd.h> +#include "sam_pio.h" #include "sam_hsmci.h" + #include "sama5d3x-ek.h" /**************************************************************************** * Pre-Processor Definitions ****************************************************************************/ -/* This needs to be extended. The card detect GPIO must be configured as an - * interrupt. When the interrupt indicating that a card has been inserted - * or removed is received, this function must call sio_mediachange() to - * handle that event. - */ - -#warning "Card detect interrupt handling needed" - /* Configuration ************************************************************/ #define HAVE_MMCSD 1 /* Can't support MMC/SD if the card interface(s) are not enable */ -#if !defined(CONFIG_SAMA5_HSMCI0) && !defined(CONFIG_SAMA5_HSMCI0) +#if !defined(CONFIG_SAMA5_HSMCI0) && !defined(CONFIG_SAMA5_HSMCI1) # undef HAVE_MMCSD #endif /* Can't support MMC/SD features if mountpoints are disabled */ -#if defined(CONFIG_DISABLE_MOUNTPOINT) +#if defined(HAVE_MMCSD) && defined(CONFIG_DISABLE_MOUNTPOINT) +# warning Mountpoints disabled. No MMC/SD support # undef HAVE_MMCSD #endif +/* We need PIO interrupts on PIOD to support card detect interrupts */ + +#if defined(HAVE_MMCSD) && !defined(CONFIG_SAMA5_PIOD_IRQ) +# warning PIOD interrupts not enabled. No MMC/SD support. +# undef HAVE_MMCSD +#endif + +/* The NSH slot and minor numbers are useless for us because we have + * multiple HSMCI devices. + */ + #ifdef HAVE_MMCSD # if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != 0 # undef CONFIG_NSH_MMCSDSLOTNO @@ -148,26 +130,102 @@ #endif /**************************************************************************** - * Public Functions + * Private Types + ****************************************************************************/ +/* This structure holds information unique to one HSMCI peripheral */ + +struct sam_hsmci_info_s +{ + pio_pinset_t pincfg; + uint8_t irq; + xcpt_t handler; + struct sdio_dev_s **hsmci; +}; + +/**************************************************************************** + * Private Data ****************************************************************************/ -/************************************************************************************ - * Name: sam_hsmci_gpioinit + +/* Retained HSMCI driver handles for use by interrupt handlers */ + +#ifdef HAVE_MMCSD +#ifdef CONFIG_SAMA5_HSMCI0 +static struct sdio_dev_s *g_hsmci0; +#endif +#ifdef CONFIG_SAMA5_HSMCI1 +static struct sdio_dev_s *g_hsmci1; +#endif + +/* HSCMI device characteristics */ + +#ifdef CONFIG_SAMA5_HSMCI0 +static int sam_hsmci0_cardetect(int irq, void *regs); + +static const struct sam_hsmci_info_s g_hsmci0_info = +{ + PIO_MCI0_CD, IRQ_MCI0_CD, sam_hsmci0_cardetect, &g_hsmci0 +}; +#endif + +#ifdef CONFIG_SAMA5_HSMCI1 +static int sam_hsmci1_cardetect(int irq, void *regs); + +static const struct sam_hsmci_info_s g_hsmci1_info = +{ + PIO_MCI1_CD, IRQ_MCI1_CD, sam_hsmci1_cardetect, &g_hsmci1 +}; +#endif +#endif + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: sam_hsmci0_cardetect and sam_hsmci1_cardetect + * + * Description: + * Card detect interrupt handlers + * + ****************************************************************************/ + +#ifdef HAVE_MMCSD +#ifdef CONFIG_SAMA5_HSMCI0 +static int sam_hsmci0_cardetect(int irq, void *regs) +{ + sdio_mediachange(g_hsmci0, sam_cardinserted(0)); + return OK; +} +#endif + +#ifdef CONFIG_SAMA5_HSMCI1 +static int sam_hsmci1_cardetect(int irq, void *regs) +{ + sdio_mediachange(g_hsmci1, sam_cardinserted(1)); + return OK; +} +#endif +#endif + +/**************************************************************************** + * Name: sam_hsmci_info * * Description: - * Initialize HSMCI support. This function is called very early in board - * initialization. + * Initialize HSMCI PIOs. * - ************************************************************************************/ + ****************************************************************************/ #ifdef HAVE_MMCSD -static void sam_hsmci_gpioinit(int slotno) +static const struct sam_hsmci_info_s *sam_hsmci_info(int slotno) { + const struct sam_hsmci_info_s *info = NULL; + #ifdef CONFIG_SAMA5_HSMCI0 #ifdef CONFIG_SAMA5_HSMCI1 if (slotno == 0) #endif { - sam_configgpio(GPIO_MCI0_CD); + info = &g_hsmci0_info; } #ifdef CONFIG_SAMA5_HSMCI1 else @@ -176,9 +234,11 @@ static void sam_hsmci_gpioinit(int slotno) #ifdef CONFIG_SAMA5_HSMCI1 { - sam_configgpio(GPIO_MCI1_CD); + info = &g_hsmci1_info; } #endif + + return info; } #endif @@ -198,18 +258,27 @@ static void sam_hsmci_gpioinit(int slotno) int sam_hsmci_initialize(int slotno, int minor) { #ifdef HAVE_MMCSD - FAR struct sdio_dev_s *sdio; + const struct sam_hsmci_info_s *info; int ret; - /* Initialize card-detect and write-protect GPIOs */ + /* Get the HSMI description */ + + info = sam_hsmci_info(slotno); + if (info) + { + fdbg("No info for slotno &d\n", slotno); + return -EINVAL; + } + + /* Initialize card-detect and write-protect PIOs */ - sam_hsmci_gpioinit(slotno); + sam_configpio(info->pincfg); /* Mount the SDIO-based MMC/SD block driver */ /* First, get an instance of the SDIO interface */ - sdio = sdio_initialize(slotno); - if (!sdio) + *info->hsmci = sdio_initialize(slotno); + if (!*info->hsmci) { fdbg("Failed to initialize SDIO slot %d\n", slotno); return -ENODEV; @@ -217,57 +286,57 @@ int sam_hsmci_initialize(int slotno, int minor) /* Now bind the SDIO interface to the MMC/SD driver */ - ret = mmcsd_slotinitialize(minor, sdio); + ret = mmcsd_slotinitialize(minor, *info->hsmci); if (ret != OK) { fdbg("Failed to bind SDIO to the MMC/SD driver: %d\n", ret); return ret; } + /* Configure card detect interrupts */ + + sam_pioirq(info->pincfg); + (void)irq_attach(info->irq, info->handler); + sam_pioirqenable(info->irq); + /* Then inform the HSMCI driver if there is or is not a card in the slot. */ - sdio_mediachange(sdio, sam_cardinserted(slotno)); + sdio_mediachange(*info->hsmci, sam_cardinserted(slotno)); #endif return OK; } -/************************************************************************************ +/**************************************************************************** * Name: sam_cardinserted * * Description: * Check if a card is inserted into the selected HSMCI slot * - ************************************************************************************/ + ****************************************************************************/ #if defined(CONFIG_SAMA5_HSMCI0) || defined(CONFIG_SAMA5_HSMCI1) bool sam_cardinserted(int slotno) { #ifdef HAVE_MMCSD + const struct sam_hsmci_info_s *info; + bool inserted; -#ifdef CONFIG_SAMA5_HSMCI0 -#ifdef CONFIG_SAMA5_HSMCI1 - if (slotno == 0) -#endif /* CONFIG_SAMA5_HSMCI1 */ + /* Get the HSMI description */ + + info = sam_hsmci_info(slotno); + if (info) { - bool inserted = sam_gpioread(GPIO_MCI0_CD); - fvdbg("Slot 0 inserted: %s\n", inserted ? "NO" : "YES"); - return !inserted; + fdbg("No info for slotno &d\n", slotno); + return false; } -#ifdef CONFIG_SAMA5_HSMCI1 - else -#endif /* CONFIG_SAMA5_HSMCI1 */ -#endif /* CONFIG_SAMA5_HSMCI0 */ + /* Get the state of the PIO pin */ -#ifdef CONFIG_SAMA5_HSMCI1 - { - bool inserted = sam_gpioread(GPIO_MCI1_CD); - fvdbg("Slot 1 inserted: %s\n", inserted ? "NO" : "YES"); - return !inserted; - } + inserted = sam_pioread(PIO_MCI0_CD); + fvdbg("Slot 0 inserted: %s\n", slotno, inserted ? "NO" : "YES"); + return !inserted; -#endif /* CONFIG_SAMA5_HSMCI1 */ #else /* HAVE_MMCSD */ return false; @@ -276,13 +345,13 @@ bool sam_cardinserted(int slotno) } #endif /* CONFIG_SAMA5_HSMCIO || CONFIG_SAMA5_HSMCI1 */ -/************************************************************************************ +/**************************************************************************** * Name: sam_writeprotected * * Description: * Check if a card is inserted into the selected HSMCI slot * - ************************************************************************************/ + ****************************************************************************/ #if defined(CONFIG_SAMA5_HSMCI0) || defined(CONFIG_SAMA5_HSMCI1) bool sam_writeprotected(int slotno) diff --git a/nuttx/configs/sama5d3x-ek/src/sam_spi.c b/nuttx/configs/sama5d3x-ek/src/sam_spi.c index ee27f1f64..2871d01da 100644 --- a/nuttx/configs/sama5d3x-ek/src/sam_spi.c +++ b/nuttx/configs/sama5d3x-ek/src/sam_spi.c @@ -49,7 +49,7 @@ #include "up_arch.h" #include "chip.h" -#include "sam_gpio.h" +#include "sam_pio.h" #include "sam_spi.h" #include "sama5d3x-ek.h" @@ -89,7 +89,7 @@ * Name: sam_spiinitialize * * Description: - * Called to configure SPI chip select GPIO pins for the SAMA5D3x-EK board. + * Called to configure SPI chip select PIO pins for the SAMA5D3x-EK board. * ************************************************************************************/ @@ -99,7 +99,7 @@ void weak_function sam_spiinitialize(void) #ifdef CONFIG_MTD_AT25 /* The AT25 serial FLASH connects using NPCS0 */ - sam_configgpio(GPIO_AT25_NPCS0); + sam_configpio(PIO_AT25_NPCS0); #endif #endif @@ -126,10 +126,10 @@ void weak_function sam_spiinitialize(void) * pins. * 2. Provide sam_spi[0|1]select() and sam_spi[0|1]status() functions in your board- * specific logic. These functions will perform chip selection and - * status operations using GPIOs in the way your board is configured. + * status operations using PIOs in the way your board is configured. * 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide * sam_spi[0|1]cmddata() functions in your board-specific logic. This - * function will perform cmd/data selection operations using GPIOs in + * function will perform cmd/data selection operations using PIOs in * the way your board is configured. * 3. Add a call to up_spiinitialize() in your low level application * initialization logic @@ -151,9 +151,9 @@ void weak_function sam_spiinitialize(void) * a stub. * * An alternative way to program the PIO chip select pins is as a normal - * GPIO output. In that case, the automatic control of the CS pins is + * PIO output. In that case, the automatic control of the CS pins is * bypassed and this function must provide control of the chip select. - * NOTE: In this case, the GPIO output pin does *not* have to be the + * NOTE: In this case, the PIO output pin does *not* have to be the * same as the NPCS pin normal associated with the chip select number. * * Input Parameters: @@ -173,7 +173,7 @@ void sam_spi0select(enum spi_dev_e devid, bool selected) if (devid == SPIDEV_FLASH) { - sam_gpiowrite(GPIO_AT25_NPCS0, !selected); + sam_piowrite(PIO_AT25_NPCS0, !selected); } #endif } diff --git a/nuttx/configs/sama5d3x-ek/src/sam_userleds.c b/nuttx/configs/sama5d3x-ek/src/sam_userleds.c index 21d5b04b4..8adbd6ee3 100644 --- a/nuttx/configs/sama5d3x-ek/src/sam_userleds.c +++ b/nuttx/configs/sama5d3x-ek/src/sam_userleds.c @@ -33,7 +33,7 @@ * ****************************************************************************/ /* There are two LEDs on the SAMA5D3 series-CM board that can be controlled - * by software. A blue LED is controlled via GPIO pins. A red LED normally + * by software. A blue LED is controlled via PIO pins. A red LED normally * provides an indication that power is supplied to the board but can also * be controlled via software. * @@ -58,8 +58,7 @@ #include <arch/board/board.h> -#include "chip.h" -#include "sam_gpio.h" +#include "sam_pio.h" #include "sama5d3x-ek.h" #ifndef CONFIG_ARCH_LEDS @@ -106,10 +105,10 @@ void sam_ledinit(void) { - /* Configure LED GPIOs for output */ + /* Configure LED PIOs for output */ - sam_configgpio(GPIO_BLUE); - sam_configgpio(GPIO_RED); + sam_configpio(PIO_BLUE); + sam_configpio(PIO_RED); } /**************************************************************************** @@ -124,21 +123,21 @@ void sam_setled(int led, bool ledon) { /* Low illuminates */ - ledcfg = GPIO_BLUE; + ledcfg = PIO_BLUE; ledon = !ledon; } else if (led == BOARD_RED) { /* High illuminates */ - ledcfg = GPIO_RED; + ledcfg = PIO_RED; } else { return; } - sam_gpiowrite(ledcfg, ledon); + sam_piowrite(ledcfg, ledon); } /**************************************************************************** @@ -152,12 +151,12 @@ void sam_setleds(uint8_t ledset) /* Low illuminates */ ledon = ((ledset & BOARD_BLUE_BIT) == 0); - sam_gpiowrite(GPIO_BLUE, ledon); + sam_piowrite(PIO_BLUE, ledon); /* High illuminates */ ledon = ((ledset & BOARD_RED_BIT) != 0); - sam_gpiowrite(GPIO_RED, ledon); + sam_piowrite(PIO_RED, ledon); } #endif /* !CONFIG_ARCH_LEDS */ diff --git a/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h b/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h index 65793cb77..8c20ab537 100644 --- a/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h +++ b/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h @@ -55,7 +55,7 @@ ************************************************************************************/ /* LEDs *****************************************************************************/ /* There are two LEDs on the SAMA5D3 series-CM board that can be controlled - * by software. A blue LED is controlled via GPIO pins. A red LED normally + * by software. A blue LED is controlled via PIO pins. A red LED normally * provides an indication that power is supplied to the board but can also * be controlled via software. * @@ -68,10 +68,10 @@ * LCD is illuminated by a high output. */ -#define GPIO_BLUE (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \ - GPIO_PORT_PIOE | GPIO_PIN25) -#define GPIO_RED (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_CLEAR | \ - GPIO_PORT_PIOE | GPIO_PIN24) +#define PIO_BLUE (PIO_OUTPUT | PIO_CFG_PULLUP | PIO_OUTPUT_SET | \ + PIO_PORT_PIOE | PIO_PIN25) +#define PIO_RED (PIO_OUTPUT | PIO_CFG_PULLUP | PIO_OUTPUT_CLEAR | \ + PIO_PORT_PIOE | PIO_PIN24) /* Buttons **************************************************************************/ /* There are five push button switches on the SAMA5D3X-EK base board: @@ -90,9 +90,9 @@ * will sense "0" is on PE27. */ -#define GPIO_USER1 (GPIO_INPUT | GPIO_CFG_PULLUP | GPIO_CFG_DEGLITCH | \ - GPIO_INT_BOTHEDGES | GPIO_PORT_PIOE | GPIO_PIN27) -#define IRQ_USER1 SAM_IRQ_PE27 +#define PIO_USER1 (PIO_INPUT | PIO_CFG_PULLUP | PIO_CFG_DEGLITCH | \ + PIO_INT_BOTHEDGES | PIO_PORT_PIOE | PIO_PIN27) +#define IRQ_USER1 SAM_IRQ_PE27 /* HSMCI Card Slots *****************************************************************/ /* The SAMA5D3x-EK provides a two SD memory card slots: (1) a full size SD card @@ -117,9 +117,9 @@ * PD0 MCI0_CDA */ -#define GPIO_MCI0_CD (GPIO_INPUT | GPIO_CFG_DEFAULT | GPIO_CFG_DEGLITCH | \ - GPIO_INT_BOTHEDGES | GPIO_PORT_PIOD | GPIO_PIN17) -#define IRQ_MCI0_CD SAM_IRQ_PD17 +#define PIO_MCI0_CD (PIO_INPUT | PIO_CFG_DEFAULT | PIO_CFG_DEGLITCH | \ + PIO_INT_BOTHEDGES | PIO_PORT_PIOD | PIO_PIN17) +#define IRQ_MCI0_CD SAM_IRQ_PD17 /* The microSD connects vi HSMCI1. The card detect discrete is available on * PB18 (pulled high): @@ -133,9 +133,9 @@ * PB19 MCI1_CDA */ -#define GPIO_MCI1_CD (GPIO_INPUT | GPIO_CFG_DEFAULT | GPIO_CFG_DEGLITCH | \ - GPIO_INT_BOTHEDGES | GPIO_PORT_PIOD | GPIO_PIN18) -#define IRQ_MCI1_CD SAM_IRQ_PD18 +#define PIO_MCI1_CD (PIO_INPUT | PIO_CFG_DEFAULT | PIO_CFG_DEGLITCH | \ + PIO_INT_BOTHEDGES | PIO_PORT_PIOD | PIO_PIN18) +#define IRQ_MCI1_CD SAM_IRQ_PD18 /* SPI Chip Selects *****************************************************************/ /* Both the Ronetix and Embest versions of the SAMAD3x CPU modules include an @@ -155,9 +155,9 @@ * not be populated?). I think closing JP1 is correct in either case. */ -#define GPIO_AT25_NPCS0 (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \ - GPIO_PORT_PIOD | GPIO_PIN13) -#define AT25_PORT SPI0_CS0 +#define PIO_AT25_NPCS0 (PIO_OUTPUT | PIO_CFG_PULLUP | PIO_OUTPUT_SET | \ + PIO_PORT_PIOD | PIO_PIN13) +#define AT25_PORT SPI0_CS0 /************************************************************************************ * Public Types |