From e6ec4e102eeec5de869db6eea6a5093abdb7782c Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 6 Aug 2013 10:20:17 -0600 Subject: 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 --- nuttx/ChangeLog | 9 + nuttx/arch/arm/src/sama5/Kconfig | 14 +- nuttx/arch/arm/src/sama5/Make.defs | 6 +- nuttx/arch/arm/src/sama5/chip/sama5d3x_pinmap.h | 560 ++++++++++++------------ nuttx/arch/arm/src/sama5/sam_boot.c | 2 +- nuttx/arch/arm/src/sama5/sam_gpio.c | 547 ----------------------- nuttx/arch/arm/src/sama5/sam_gpio.h | 340 -------------- nuttx/arch/arm/src/sama5/sam_hsmci.c | 50 +-- nuttx/arch/arm/src/sama5/sam_irq.c | 10 +- nuttx/arch/arm/src/sama5/sam_lowputc.c | 42 +- nuttx/arch/arm/src/sama5/sam_pio.c | 547 +++++++++++++++++++++++ nuttx/arch/arm/src/sama5/sam_pio.h | 339 ++++++++++++++ nuttx/arch/arm/src/sama5/sam_pioirq.c | 462 +++++++++++++++++++ nuttx/arch/arm/src/sama5/sam_serial.c | 2 +- nuttx/arch/arm/src/sama5/sam_spi.c | 18 +- nuttx/arch/arm/src/sama5/sam_spi.h | 10 +- nuttx/configs/sama5d3x-ek/README.txt | 32 +- nuttx/configs/sama5d3x-ek/hello/defconfig | 2 +- nuttx/configs/sama5d3x-ek/include/board.h | 4 +- nuttx/configs/sama5d3x-ek/norboot/defconfig | 2 +- nuttx/configs/sama5d3x-ek/nsh/defconfig | 2 +- nuttx/configs/sama5d3x-ek/ostest/defconfig | 2 +- nuttx/configs/sama5d3x-ek/src/sam_autoleds.c | 17 +- nuttx/configs/sama5d3x-ek/src/sam_buttons.c | 22 +- nuttx/configs/sama5d3x-ek/src/sam_hsmci.c | 213 ++++++--- nuttx/configs/sama5d3x-ek/src/sam_spi.c | 16 +- nuttx/configs/sama5d3x-ek/src/sam_userleds.c | 21 +- nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h | 34 +- 28 files changed, 1935 insertions(+), 1390 deletions(-) delete mode 100644 nuttx/arch/arm/src/sama5/sam_gpio.c delete mode 100644 nuttx/arch/arm/src/sama5/sam_gpio.h create mode 100644 nuttx/arch/arm/src/sama5/sam_pio.c create mode 100644 nuttx/arch/arm/src/sama5/sam_pio.h create mode 100644 nuttx/arch/arm/src/sama5/sam_pioirq.c (limited to 'nuttx') diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 2d4dd58e3..26a91bed6 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -5307,3 +5307,12 @@ * nuttx/configs/sama5d3x-ek/src/sam_hsmci.c and sam_nsh.c: Add support for the (2) SD card slots provided on the SAMA5D3x-EK boards. Untested on initial commit (2013-8-5). + * arch/arm/src/sama5 and nuttx/configs/sama5d3x-ek: Massive renaming + to get consistent once and for in the usage of PIO vs GPIO. Other + platforms use the term GPIO more, but Atmel prefers PIO. I prefer + consistency. Also fixed CONFIG_PIO vs CONFIG_SAMA5_PIO and renamed + files sam_gpio.* to sam_pio.* (2013-8-6). + * arch/arm/src/sama5/sam_pioirq.c: Add support for SAMA5 PIO interrupts + (2013-8-6). + * confgs/sama5d3x-ek/src/sam_hsmci.c: Add support for SD slot card + detection PIO interrupts (2013-8-6). diff --git a/nuttx/arch/arm/src/sama5/Kconfig b/nuttx/arch/arm/src/sama5/Kconfig index bfa2bc3a6..042ed7947 100644 --- a/nuttx/arch/arm/src/sama5/Kconfig +++ b/nuttx/arch/arm/src/sama5/Kconfig @@ -212,30 +212,30 @@ config SAMA5_MPDDRC endmenu # ATSAMA5 Peripheral Support -config PIO_IRQ +config SAMA5_PIO_IRQ bool "PIO pin interrupts" ---help--- Enable support for interrupting PIO pins -if PIO_IRQ +if SAMA5_PIO_IRQ -config PIOA_IRQ +config SAMA5_PIOA_IRQ bool "PIOA interrupts" default n -config PIOB_IRQ +config SAMA5_PIOB_IRQ bool "PIOB interrupts" default n -config PIOC_IRQ +config SAMA5_PIOC_IRQ bool "PIOC interrupts" default n -config PIOD_IRQ +config SAMA5_PIOD_IRQ bool "PIOD interrupts" default n -config PIOE_IRQ +config SAMA5_PIOE_IRQ bool "PIOE interrupts" default n diff --git a/nuttx/arch/arm/src/sama5/Make.defs b/nuttx/arch/arm/src/sama5/Make.defs index 1eca33f9f..8cfd15861 100644 --- a/nuttx/arch/arm/src/sama5/Make.defs +++ b/nuttx/arch/arm/src/sama5/Make.defs @@ -89,7 +89,7 @@ CHIP_ASRCS = # SAMA5-specific C source files -CHIP_CSRCS = sam_allocateheap.c sam_boot.c sam_clockconfig.c sam_gpio.c +CHIP_CSRCS = sam_allocateheap.c sam_boot.c sam_clockconfig.c sam_pio.c CHIP_CSRCS += sam_irq.c sam_lowputc.c sam_serial.c sam_timerisr.c # Configuration dependent C and assembly language files @@ -102,6 +102,10 @@ CHIP_CSRCS += sam_dmac.c endif endif +ifeq ($(CONFIG_SAMA5_PIO_IRQ),y) +CHIP_CSRCS += sam_pioirq.c +endif + ifeq ($(CONFIG_SAMA5_SPI0),y) CHIP_CSRCS += sam_spi.c else diff --git a/nuttx/arch/arm/src/sama5/chip/sama5d3x_pinmap.h b/nuttx/arch/arm/src/sama5/chip/sama5d3x_pinmap.h index decda4ac4..8498ac876 100644 --- a/nuttx/arch/arm/src/sama5/chip/sama5d3x_pinmap.h +++ b/nuttx/arch/arm/src/sama5/chip/sama5d3x_pinmap.h @@ -43,13 +43,13 @@ #include #include "chip.h" -#include "sam_gpio.h" +#include "sam_pio.h" /************************************************************************************************************ * Pre-processor Definitions ************************************************************************************************************/ -/* GPIO pin definitions *************************************************************************************/ +/* PIO pin definitions **************************************************************************************/ /* Alternate Pin Functions. * * Alternative pin selections are provided with a numeric suffix like _1, _2, etc. Drivers, however, will @@ -57,356 +57,356 @@ * file. For example, if we wanted the LCD data bit 16 on PA16, then the following definition should appear * in the board.h header file for that board: * - * #define GPIO_LCD_DAT16 GPIO_LCD_DAT16_1 + * #define PIO_LCD_DAT16 PIO_LCD_DAT16_1 * * The LCD driver will then automatically configre PA16 as the DAT16 pin. */ /* WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! - * Additional effort is required to select specific GPIO options such as frequency, open-drain/push-pull, + * Additional effort is required to select specific PIO options such as frequency, open-drain/push-pull, * and pull-up/down! Just the basics are defined for most pins in this file at the present time. */ /* Touch Screen Analog-to-Digital Converter - ADC */ -#define GPIO_ADC_AD0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN20) /* Type: GPIO_ANA */ -#define GPIO_ADC_AD1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN21) /* Type: GPIO_ANA */ -#define GPIO_ADC_AD2 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN22) /* Type: GPIO_ANA */ -#define GPIO_ADC_AD3 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN23) /* Type: GPIO_ANA */ -#define GPIO_ADC_AD4 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN24) /* Type: GPIO_ANA */ -#define GPIO_ADC_AD5 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN25) /* Type: GPIO_ANA */ -#define GPIO_ADC_AD6 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN26) /* Type: GPIO_ANA */ -#define GPIO_ADC_AD7 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN27) /* Type: GPIO_ANA */ -#define GPIO_ADC_AD8 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN28) /* Type: GPIO_ANA */ -#define GPIO_ADC_AD9 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN29) /* Type: GPIO_ANA */ -#define GPIO_ADC_AD10 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN30) /* Type: GPIO_ANA */ -#define GPIO_ADC_AD11 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN31) /* Type: GPIO_ANA */ -#define GPIO_ADC_TRG (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN19) /* Type: GPIO */ +#define PIO_ADC_AD0 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN20) /* Type: GPIO_ANA */ +#define PIO_ADC_AD1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN21) /* Type: GPIO_ANA */ +#define PIO_ADC_AD2 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN22) /* Type: GPIO_ANA */ +#define PIO_ADC_AD3 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN23) /* Type: GPIO_ANA */ +#define PIO_ADC_AD4 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN24) /* Type: GPIO_ANA */ +#define PIO_ADC_AD5 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN25) /* Type: GPIO_ANA */ +#define PIO_ADC_AD6 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN26) /* Type: GPIO_ANA */ +#define PIO_ADC_AD7 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN27) /* Type: GPIO_ANA */ +#define PIO_ADC_AD8 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN28) /* Type: GPIO_ANA */ +#define PIO_ADC_AD9 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN29) /* Type: GPIO_ANA */ +#define PIO_ADC_AD10 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN30) /* Type: GPIO_ANA */ +#define PIO_ADC_AD11 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN31) /* Type: GPIO_ANA */ +#define PIO_ADC_TRG (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN19) /* Type: GPIO */ /* Advanced Interrupt Controller - AIC */ -#define GPIO_AIC_FIQ (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN31) /* Type: GPIO */ -#define GPIO_AIC_IRQ (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN31) /* Type: EBI */ +#define PIO_AIC_FIQ (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN31) /* Type: GPIO */ +#define PIO_AIC_IRQ (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN31) /* Type: EBI */ /* CAN controller - CANx */ -#define GPIO_CAN0_RX (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN14) /* Type: GPIO */ -#define GPIO_CAN0_TX (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN15) /* Type: GPIO */ +#define PIO_CAN0_RX (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN14) /* Type: GPIO */ +#define PIO_CAN0_TX (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN15) /* Type: GPIO */ -#define GPIO_CAN1_RX (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN14) /* Type: GMAC */ -#define GPIO_CAN1_TX (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN15) /* Type: GMAC */ +#define PIO_CAN1_RX (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN14) /* Type: GMAC */ +#define PIO_CAN1_TX (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN15) /* Type: GMAC */ /* Debug Unit - DBGU */ -#define GPIO_DBGU_DRXD (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN30) /* Type: GPIO */ -#define GPIO_DBGU_DTXD (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN31) /* Type: GPIO */ +#define PIO_DBGU_DRXD (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN30) /* Type: GPIO */ +#define PIO_DBGU_DTXD (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN31) /* Type: GPIO */ /* External Bus Interface - EBI */ -#define GPIO_EBI_A0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN0) /* Type: EBI */ -#define GPIO_EBI_A1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN1) /* Type: EBI */ -#define GPIO_EBI_A10 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN10) /* Type: EBI */ -#define GPIO_EBI_A11 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN11) /* Type: EBI */ -#define GPIO_EBI_A12 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN12) /* Type: EBI */ -#define GPIO_EBI_A13 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN13) /* Type: EBI */ -#define GPIO_EBI_A14 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN14) /* Type: EBI */ -#define GPIO_EBI_A15 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN15) /* Type: EBI */ -#define GPIO_EBI_A16 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN16) /* Type: EBI */ -#define GPIO_EBI_A17 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN17) /* Type: EBI */ -#define GPIO_EBI_A18 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN18) /* Type: EBI */ -#define GPIO_EBI_A19 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN19) /* Type: EBI */ -#define GPIO_EBI_A2 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN2) /* Type: EBI */ -#define GPIO_EBI_A20 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN20) /* Type: EBI */ -#define GPIO_EBI_A21 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN21) /* Type: EBI */ -#define GPIO_EBI_A22 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN22) /* Type: EBI */ -#define GPIO_EBI_A23 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN23) /* Type: EBI */ -#define GPIO_EBI_A24 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN24) /* Type: EBI */ -#define GPIO_EBI_A25 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN25) /* Type: EBI */ -#define GPIO_EBI_A3 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN3) /* Type: EBI */ -#define GPIO_EBI_A4 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN4) /* Type: EBI */ -#define GPIO_EBI_A5 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN5) /* Type: EBI */ -#define GPIO_EBI_A6 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN6) /* Type: EBI */ -#define GPIO_EBI_A7 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN7) /* Type: EBI */ -#define GPIO_EBI_A8 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN8) /* Type: EBI */ -#define GPIO_EBI_A9 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN9) /* Type: EBI */ -#define GPIO_EBI_NWAIT (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN30) /* Type: EBI */ +#define PIO_EBI_A0 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN0) /* Type: EBI */ +#define PIO_EBI_A1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN1) /* Type: EBI */ +#define PIO_EBI_A10 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN10) /* Type: EBI */ +#define PIO_EBI_A11 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN11) /* Type: EBI */ +#define PIO_EBI_A12 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN12) /* Type: EBI */ +#define PIO_EBI_A13 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN13) /* Type: EBI */ +#define PIO_EBI_A14 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN14) /* Type: EBI */ +#define PIO_EBI_A15 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN15) /* Type: EBI */ +#define PIO_EBI_A16 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN16) /* Type: EBI */ +#define PIO_EBI_A17 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN17) /* Type: EBI */ +#define PIO_EBI_A18 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN18) /* Type: EBI */ +#define PIO_EBI_A19 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN19) /* Type: EBI */ +#define PIO_EBI_A2 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN2) /* Type: EBI */ +#define PIO_EBI_A20 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN20) /* Type: EBI */ +#define PIO_EBI_A21 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN21) /* Type: EBI */ +#define PIO_EBI_A22 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN22) /* Type: EBI */ +#define PIO_EBI_A23 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN23) /* Type: EBI */ +#define PIO_EBI_A24 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN24) /* Type: EBI */ +#define PIO_EBI_A25 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN25) /* Type: EBI */ +#define PIO_EBI_A3 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN3) /* Type: EBI */ +#define PIO_EBI_A4 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN4) /* Type: EBI */ +#define PIO_EBI_A5 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN5) /* Type: EBI */ +#define PIO_EBI_A6 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN6) /* Type: EBI */ +#define PIO_EBI_A7 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN7) /* Type: EBI */ +#define PIO_EBI_A8 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN8) /* Type: EBI */ +#define PIO_EBI_A9 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN9) /* Type: EBI */ +#define PIO_EBI_NWAIT (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN30) /* Type: EBI */ /* RMII Ethernet 10/100 - EMAC */ -#define GPIO_EMAC_CRSDV (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN5) /* Type: GPIO */ -#define GPIO_EMAC_MDC (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN8) /* Type: GPIO */ -#define GPIO_EMAC_MDIO (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN9) /* Type: GPIO */ -#define GPIO_EMAC_REFCK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN7) /* Type: GPIO */ -#define GPIO_EMAC_RX0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN2) /* Type: GPIO */ -#define GPIO_EMAC_RX1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN3) /* Type: GPIO */ -#define GPIO_EMAC_RXER (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN6) /* Type: GPIO */ -#define GPIO_EMAC_TX0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN0) /* Type: GPIO */ -#define GPIO_EMAC_TX1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN1) /* Type: GPIO */ -#define GPIO_EMAC_TXEN (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN4) /* Type: GPIO */ +#define PIO_EMAC_CRSDV (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN5) /* Type: GPIO */ +#define PIO_EMAC_MDC (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN8) /* Type: GPIO */ +#define PIO_EMAC_MDIO (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN9) /* Type: GPIO */ +#define PIO_EMAC_REFCK (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN7) /* Type: GPIO */ +#define PIO_EMAC_RX0 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN2) /* Type: GPIO */ +#define PIO_EMAC_RX1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN3) /* Type: GPIO */ +#define PIO_EMAC_RXER (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN6) /* Type: GPIO */ +#define PIO_EMAC_TX0 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN0) /* Type: GPIO */ +#define PIO_EMAC_TX1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN1) /* Type: GPIO */ +#define PIO_EMAC_TXEN (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN4) /* Type: GPIO */ /* GIgabit Ethernet 10/100/1000 - GMAC */ -#define GPIO_GMAC_125CK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN18) /* Type: GMAC */ -#define GPIO_GMAC_125CKO (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN27) /* Type: GPIO */ -#define GPIO_GMAC_COL (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN15) /* Type: GMAC */ -#define GPIO_GMAC_CRS (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN14) /* Type: GMAC */ -#define GPIO_GMAC_MDC (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN16) /* Type: GMAC */ -#define GPIO_GMAC_MDIO (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN17) /* Type: GMAC */ -#define GPIO_GMAC_RX0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN4) /* Type: GMAC */ -#define GPIO_GMAC_RX1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN5) /* Type: GMAC */ -#define GPIO_GMAC_RX2 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN6) /* Type: GMAC */ -#define GPIO_GMAC_RX3 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN7) /* Type: GMAC */ -#define GPIO_GMAC_RX4 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN23) /* Type: GMAC */ -#define GPIO_GMAC_RX5 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN24) /* Type: GMAC */ -#define GPIO_GMAC_RX6 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN25) /* Type: GMAC */ -#define GPIO_GMAC_RX7 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN26) /* Type: GMAC */ -#define GPIO_GMAC_RXCK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN11) /* Type: GMAC */ -#define GPIO_GMAC_RXDV (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN12) /* Type: GMAC */ -#define GPIO_GMAC_RXER (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN13) /* Type: GMAC */ -#define GPIO_GMAC_TX0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN0) /* Type: GMAC */ -#define GPIO_GMAC_TX1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN1) /* Type: GMAC */ -#define GPIO_GMAC_TX2 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN2) /* Type: GMAC */ -#define GPIO_GMAC_TX3 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN3) /* Type: GMAC */ -#define GPIO_GMAC_TX4 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN19) /* Type: GMAC */ -#define GPIO_GMAC_TX5 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN20) /* Type: GMAC */ -#define GPIO_GMAC_TX6 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN21) /* Type: GMAC */ -#define GPIO_GMAC_TX7 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN22) /* Type: GMAC */ -#define GPIO_GMAC_TXCK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN8) /* Type: GMAC */ -#define GPIO_GMAC_TXEN (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN9) /* Type: GMAC */ -#define GPIO_GMAC_TXER (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN10) /* Type: GMAC */ +#define PIO_GMAC_125CK (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN18) /* Type: GMAC */ +#define PIO_GMAC_125CKO (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN27) /* Type: GPIO */ +#define PIO_GMAC_COL (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN15) /* Type: GMAC */ +#define PIO_GMAC_CRS (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN14) /* Type: GMAC */ +#define PIO_GMAC_MDC (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN16) /* Type: GMAC */ +#define PIO_GMAC_MDIO (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN17) /* Type: GMAC */ +#define PIO_GMAC_RX0 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN4) /* Type: GMAC */ +#define PIO_GMAC_RX1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN5) /* Type: GMAC */ +#define PIO_GMAC_RX2 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN6) /* Type: GMAC */ +#define PIO_GMAC_RX3 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN7) /* Type: GMAC */ +#define PIO_GMAC_RX4 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN23) /* Type: GMAC */ +#define PIO_GMAC_RX5 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN24) /* Type: GMAC */ +#define PIO_GMAC_RX6 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN25) /* Type: GMAC */ +#define PIO_GMAC_RX7 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN26) /* Type: GMAC */ +#define PIO_GMAC_RXCK (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN11) /* Type: GMAC */ +#define PIO_GMAC_RXDV (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN12) /* Type: GMAC */ +#define PIO_GMAC_RXER (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN13) /* Type: GMAC */ +#define PIO_GMAC_TX0 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN0) /* Type: GMAC */ +#define PIO_GMAC_TX1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN1) /* Type: GMAC */ +#define PIO_GMAC_TX2 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN2) /* Type: GMAC */ +#define PIO_GMAC_TX3 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN3) /* Type: GMAC */ +#define PIO_GMAC_TX4 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN19) /* Type: GMAC */ +#define PIO_GMAC_TX5 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN20) /* Type: GMAC */ +#define PIO_GMAC_TX6 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN21) /* Type: GMAC */ +#define PIO_GMAC_TX7 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN22) /* Type: GMAC */ +#define PIO_GMAC_TXCK (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN8) /* Type: GMAC */ +#define PIO_GMAC_TXEN (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN9) /* Type: GMAC */ +#define PIO_GMAC_TXER (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN10) /* Type: GMAC */ /* Static Memory Controller - HSMC */ -#define GPIO_HSMC_NANDALE (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN21) /* Type: EBI */ -#define GPIO_HSMC_NANDCLE (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN22) /* Type: EBI */ -#define GPIO_HSMC_NBS0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN0) /* Type: EBI */ -#define GPIO_HSMC_NBS1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN29) /* Type: EBI */ -#define GPIO_HSMC_NCS0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN26) /* Type: EBI */ -#define GPIO_HSMC_NCS1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN27) /* Type: EBI */ -#define GPIO_HSMC_NCS2 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN28) /* Type: EBI */ -#define GPIO_HSMC_NWR1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN29) /* Type: EBI */ +#define PIO_HSMC_NANDALE (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN21) /* Type: EBI */ +#define PIO_HSMC_NANDCLE (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN22) /* Type: EBI */ +#define PIO_HSMC_NBS0 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN0) /* Type: EBI */ +#define PIO_HSMC_NBS1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN29) /* Type: EBI */ +#define PIO_HSMC_NCS0 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN26) /* Type: EBI */ +#define PIO_HSMC_NCS1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN27) /* Type: EBI */ +#define PIO_HSMC_NCS2 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN28) /* Type: EBI */ +#define PIO_HSMC_NWR1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN29) /* Type: EBI */ /* Image Sensor Interface - ISI */ -#define GPIO_ISI_D0 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN16) /* Type: GPIO */ -#define GPIO_ISI_D1 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN17) /* Type: GPIO */ -#define GPIO_ISI_D10 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN27) /* Type: GPIO */ -#define GPIO_ISI_D11 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN26) /* Type: GPIO */ -#define GPIO_ISI_D2 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN18) /* Type: GPIO */ -#define GPIO_ISI_D3 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN19) /* Type: GPIO */ -#define GPIO_ISI_D4 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN20) /* Type: GPIO */ -#define GPIO_ISI_D5 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN21) /* Type: GPIO */ -#define GPIO_ISI_D6 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN22) /* Type: GPIO */ -#define GPIO_ISI_D7 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN23) /* Type: GPIO */ -#define GPIO_ISI_D8 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN29) /* Type: GPIO */ -#define GPIO_ISI_D9 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN28) /* Type: GPIO */ -#define GPIO_ISI_HSYNC (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN31) /* Type: GPIO */ -#define GPIO_ISI_PCK (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN30) /* Type: GPIO */ -#define GPIO_ISI_VSYNC (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN30) /* Type: GPIO */ +#define PIO_ISI_D0 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN16) /* Type: GPIO */ +#define PIO_ISI_D1 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN17) /* Type: GPIO */ +#define PIO_ISI_D10 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN27) /* Type: GPIO */ +#define PIO_ISI_D11 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN26) /* Type: GPIO */ +#define PIO_ISI_D2 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN18) /* Type: GPIO */ +#define PIO_ISI_D3 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN19) /* Type: GPIO */ +#define PIO_ISI_D4 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN20) /* Type: GPIO */ +#define PIO_ISI_D5 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN21) /* Type: GPIO */ +#define PIO_ISI_D6 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN22) /* Type: GPIO */ +#define PIO_ISI_D7 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN23) /* Type: GPIO */ +#define PIO_ISI_D8 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN29) /* Type: GPIO */ +#define PIO_ISI_D9 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN28) /* Type: GPIO */ +#define PIO_ISI_HSYNC (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN31) /* Type: GPIO */ +#define PIO_ISI_PCK (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN30) /* Type: GPIO */ +#define PIO_ISI_VSYNC (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN30) /* Type: GPIO */ /* LCD Controller - LCDC */ -#define GPIO_LCD_DAT0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN0) /* Type: GPIO */ -#define GPIO_LCD_DAT1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN1) /* Type: GPIO */ -#define GPIO_LCD_DAT10 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN10) /* Type: GPIO */ -#define GPIO_LCD_DAT11 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN11) /* Type: GPIO */ -#define GPIO_LCD_DAT12 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN12) /* Type: GPIO */ -#define GPIO_LCD_DAT13 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN13) /* Type: GPIO */ -#define GPIO_LCD_DAT14 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN14) /* Type: GPIO */ -#define GPIO_LCD_DAT15 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN15) /* Type: GPIO */ -#define GPIO_LCD_DAT16_1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN16) /* Type: GPIO */ -#define GPIO_LCD_DAT16_2 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN14) /* Type: GPIO */ -#define GPIO_LCD_DAT17_1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN17) /* Type: GPIO */ -#define GPIO_LCD_DAT17_2 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN13) /* Type: GPIO */ -#define GPIO_LCD_DAT18_1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN18) /* Type: GPIO */ -#define GPIO_LCD_DAT18_2 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN12) /* Type: GPIO */ -#define GPIO_LCD_DAT19_1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN19) /* Type: GPIO */ -#define GPIO_LCD_DAT19_2 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN11) /* Type: GPIO */ -#define GPIO_LCD_DAT2 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN2) /* Type: GPIO */ -#define GPIO_LCD_DAT20_1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN20) /* Type: GPIO */ -#define GPIO_LCD_DAT20_2 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN10) /* Type: GPIO */ -#define GPIO_LCD_DAT21_1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN21) /* Type: GPIO */ -#define GPIO_LCD_DAT21_2 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN15) /* Type: MCI_CLK */ -#define GPIO_LCD_DAT22_1 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN27) /* Type: EBI */ -#define GPIO_LCD_DAT22_2 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN22) /* Type: GPIO */ -#define GPIO_LCD_DAT23_1 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN28) /* Type: EBI */ -#define GPIO_LCD_DAT23_2 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN23) /* Type: GPIO */ -#define GPIO_LCD_DAT3 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN3) /* Type: GPIO */ -#define GPIO_LCD_DAT4 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN4) /* Type: GPIO */ -#define GPIO_LCD_DAT5 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN5) /* Type: GPIO */ -#define GPIO_LCD_DAT6 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN6) /* Type: GPIO */ -#define GPIO_LCD_DAT7 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN7) /* Type: GPIO */ -#define GPIO_LCD_DAT8 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN8) /* Type: GPIO */ -#define GPIO_LCD_DAT9 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN9) /* Type: GPIO */ -#define GPIO_LCD_DEN (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN29) /* Type: GPIO */ -#define GPIO_LCD_DISP (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN25) /* Type: GPIO */ -#define GPIO_LCD_HSYNC (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN27) /* Type: GPIO */ -#define GPIO_LCD_PCK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN28) /* Type: GPIO_CLK2 */ -#define GPIO_LCD_PWM (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN24) /* Type: GPIO */ -#define GPIO_LCD_VSYNC (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN26) /* Type: GPIO */ +#define PIO_LCD_DAT0 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN0) /* Type: GPIO */ +#define PIO_LCD_DAT1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN1) /* Type: GPIO */ +#define PIO_LCD_DAT10 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN10) /* Type: GPIO */ +#define PIO_LCD_DAT11 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN11) /* Type: GPIO */ +#define PIO_LCD_DAT12 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN12) /* Type: GPIO */ +#define PIO_LCD_DAT13 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN13) /* Type: GPIO */ +#define PIO_LCD_DAT14 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN14) /* Type: GPIO */ +#define PIO_LCD_DAT15 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN15) /* Type: GPIO */ +#define PIO_LCD_DAT16_1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN16) /* Type: GPIO */ +#define PIO_LCD_DAT16_2 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN14) /* Type: GPIO */ +#define PIO_LCD_DAT17_1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN17) /* Type: GPIO */ +#define PIO_LCD_DAT17_2 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN13) /* Type: GPIO */ +#define PIO_LCD_DAT18_1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN18) /* Type: GPIO */ +#define PIO_LCD_DAT18_2 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN12) /* Type: GPIO */ +#define PIO_LCD_DAT19_1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN19) /* Type: GPIO */ +#define PIO_LCD_DAT19_2 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN11) /* Type: GPIO */ +#define PIO_LCD_DAT2 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN2) /* Type: GPIO */ +#define PIO_LCD_DAT20_1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN20) /* Type: GPIO */ +#define PIO_LCD_DAT20_2 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN10) /* Type: GPIO */ +#define PIO_LCD_DAT21_1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN21) /* Type: GPIO */ +#define PIO_LCD_DAT21_2 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN15) /* Type: MCI_CLK */ +#define PIO_LCD_DAT22_1 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN27) /* Type: EBI */ +#define PIO_LCD_DAT22_2 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN22) /* Type: GPIO */ +#define PIO_LCD_DAT23_1 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN28) /* Type: EBI */ +#define PIO_LCD_DAT23_2 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN23) /* Type: GPIO */ +#define PIO_LCD_DAT3 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN3) /* Type: GPIO */ +#define PIO_LCD_DAT4 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN4) /* Type: GPIO */ +#define PIO_LCD_DAT5 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN5) /* Type: GPIO */ +#define PIO_LCD_DAT6 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN6) /* Type: GPIO */ +#define PIO_LCD_DAT7 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN7) /* Type: GPIO */ +#define PIO_LCD_DAT8 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN8) /* Type: GPIO */ +#define PIO_LCD_DAT9 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN9) /* Type: GPIO */ +#define PIO_LCD_DEN (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN29) /* Type: GPIO */ +#define PIO_LCD_DISP (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN25) /* Type: GPIO */ +#define PIO_LCD_HSYNC (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN27) /* Type: GPIO */ +#define PIO_LCD_PCK (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN28) /* Type: GPIO_CLK2 */ +#define PIO_LCD_PWM (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN24) /* Type: GPIO */ +#define PIO_LCD_VSYNC (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN26) /* Type: GPIO */ /* High Speed Multimedia Card Interface - HSMCI0-2 */ -#define GPIO_MCI0_CDA (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN0) /* Type: GPIO */ -#define GPIO_MCI0_CK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN9) /* Type: MCI_CLK */ -#define GPIO_MCI0_DA0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN1) /* Type: GPIO */ -#define GPIO_MCI0_DA1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN2) /* Type: GPIO */ -#define GPIO_MCI0_DA2 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN3) /* Type: GPIO */ -#define GPIO_MCI0_DA3 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN4) /* Type: GPIO */ -#define GPIO_MCI0_DA4 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN5) /* Type: GPIO */ -#define GPIO_MCI0_DA5 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN6) /* Type: GPIO */ -#define GPIO_MCI0_DA6 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN7) /* Type: GPIO */ -#define GPIO_MCI0_DA7 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN8) /* Type: GPIO */ - -#define GPIO_MCI1_CDA (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN19) /* Type: GMAC */ -#define GPIO_MCI1_CK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN24) /* Type: GMAC */ -#define GPIO_MCI1_DA0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN20) /* Type: GMAC */ -#define GPIO_MCI1_DA1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN21) /* Type: GMAC */ -#define GPIO_MCI1_DA2 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN22) /* Type: GMAC */ -#define GPIO_MCI1_DA3 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN23) /* Type: GMAC */ - -#define GPIO_MCI2_CDA (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN10) /* Type: GPIO */ -#define GPIO_MCI2_CK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN15) /* Type: MCI_CLK */ -#define GPIO_MCI2_DA0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN11) /* Type: GPIO */ -#define GPIO_MCI2_DA1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN12) /* Type: GPIO */ -#define GPIO_MCI2_DA2 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN13) /* Type: GPIO */ -#define GPIO_MCI2_DA3 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN14) /* Type: GPIO */ +#define PIO_MCI0_CDA (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN0) /* Type: GPIO */ +#define PIO_MCI0_CK (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN9) /* Type: MCI_CLK */ +#define PIO_MCI0_DA0 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN1) /* Type: GPIO */ +#define PIO_MCI0_DA1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN2) /* Type: GPIO */ +#define PIO_MCI0_DA2 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN3) /* Type: GPIO */ +#define PIO_MCI0_DA3 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN4) /* Type: GPIO */ +#define PIO_MCI0_DA4 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN5) /* Type: GPIO */ +#define PIO_MCI0_DA5 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN6) /* Type: GPIO */ +#define PIO_MCI0_DA6 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN7) /* Type: GPIO */ +#define PIO_MCI0_DA7 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN8) /* Type: GPIO */ + +#define PIO_MCI1_CDA (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN19) /* Type: GMAC */ +#define PIO_MCI1_CK (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN24) /* Type: GMAC */ +#define PIO_MCI1_DA0 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN20) /* Type: GMAC */ +#define PIO_MCI1_DA1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN21) /* Type: GMAC */ +#define PIO_MCI1_DA2 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN22) /* Type: GMAC */ +#define PIO_MCI1_DA3 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN23) /* Type: GMAC */ + +#define PIO_MCI2_CDA (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN10) /* Type: GPIO */ +#define PIO_MCI2_CK (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN15) /* Type: MCI_CLK */ +#define PIO_MCI2_DA0 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN11) /* Type: GPIO */ +#define PIO_MCI2_DA1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN12) /* Type: GPIO */ +#define PIO_MCI2_DA2 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN13) /* Type: GPIO */ +#define PIO_MCI2_DA3 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN14) /* Type: GPIO */ /* Clocks, Oscillators and PLLs */ -#define GPIO_PMC_PCK0 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN30) /* Type: GPIO_ANA */ -#define GPIO_PMC_PCK1 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN31) /* Type: GPIO_ANA */ -#define GPIO_PMC_PCK2 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN15) /* Type: MCI_CLK */ +#define PIO_PMC_PCK0 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN30) /* Type: GPIO_ANA */ +#define PIO_PMC_PCK1 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN31) /* Type: GPIO_ANA */ +#define PIO_PMC_PCK2 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN15) /* Type: MCI_CLK */ /* Pulse Width Modulation Controller- PWMC */ -#define GPIO_PWM0_FI (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN28) /* Type: GPIO */ -#define GPIO_PWM0_H_1 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN0) /* Type: GMAC */ -#define GPIO_PWM0_H_2 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN20) /* Type: GPIO */ -#define GPIO_PWM0_L_1 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN1) /* Type: GMAC */ -#define GPIO_PWM0_L_2 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN21) /* Type: GPIO */ - -#define GPIO_PWM1_FI (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN31) /* Type: GPIO */ -#define GPIO_PWM1_H_1 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN4) /* Type: GMAC */ -#define GPIO_PWM1_H_2 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN22) /* Type: GPIO */ -#define GPIO_PWM1_L_1 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN5) /* Type: GMAC */ -#define GPIO_PWM1_L_2 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN31) /* Type: EBI */ -#define GPIO_PWM1_L_3 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN23) /* Type: GPIO */ - -#define GPIO_PWM2_FI (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN29) /* Type: GPIO */ -#define GPIO_PWM2_H_1 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN5) /* Type: GPIO */ -#define GPIO_PWM2_H_2 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN8) /* Type: GMAC */ -#define GPIO_PWM2_L_1 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN6) /* Type: GPIO */ -#define GPIO_PWM2_L_2 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN9) /* Type: GMAC */ - -#define GPIO_PWM3_FI (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN16) /* Type: GPIO */ -#define GPIO_PWM3_H_1 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN7) /* Type: GPIO */ -#define GPIO_PWM3_H_2 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN12) /* Type: GMAC */ -#define GPIO_PWM3_L_1 (GPIO_PERIPHC | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN8) /* Type: GPIO */ -#define GPIO_PWM3_L_2 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN13) /* Type: GMAC */ +#define PIO_PWM0_FI (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN28) /* Type: GPIO */ +#define PIO_PWM0_H_1 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN0) /* Type: GMAC */ +#define PIO_PWM0_H_2 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN20) /* Type: GPIO */ +#define PIO_PWM0_L_1 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN1) /* Type: GMAC */ +#define PIO_PWM0_L_2 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN21) /* Type: GPIO */ + +#define PIO_PWM1_FI (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN31) /* Type: GPIO */ +#define PIO_PWM1_H_1 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN4) /* Type: GMAC */ +#define PIO_PWM1_H_2 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN22) /* Type: GPIO */ +#define PIO_PWM1_L_1 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN5) /* Type: GMAC */ +#define PIO_PWM1_L_2 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN31) /* Type: EBI */ +#define PIO_PWM1_L_3 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN23) /* Type: GPIO */ + +#define PIO_PWM2_FI (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN29) /* Type: GPIO */ +#define PIO_PWM2_H_1 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN5) /* Type: GPIO */ +#define PIO_PWM2_H_2 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN8) /* Type: GMAC */ +#define PIO_PWM2_L_1 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN6) /* Type: GPIO */ +#define PIO_PWM2_L_2 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN9) /* Type: GMAC */ + +#define PIO_PWM3_FI (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN16) /* Type: GPIO */ +#define PIO_PWM3_H_1 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN7) /* Type: GPIO */ +#define PIO_PWM3_H_2 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN12) /* Type: GMAC */ +#define PIO_PWM3_L_1 (PIO_PERIPHC | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN8) /* Type: GPIO */ +#define PIO_PWM3_L_2 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN13) /* Type: GMAC */ /* Serial Peripheral Interface - SPIx [1..0] */ -#define GPIO_SPI0_MISO (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN10) /* Type: GPIO */ -#define GPIO_SPI0_MOSI (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN11) /* Type: GPIO */ -#define GPIO_SPI0_NPCS0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN13) /* Type: GPIO */ -#define GPIO_SPI0_NPCS1 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN14) /* Type: GPIO */ -#define GPIO_SPI0_NPCS2 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN15) /* Type: GPIO */ -#define GPIO_SPI0_NPCS3 (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN16) /* Type: GPIO */ -#define GPIO_SPI0_SPCK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN12) /* Type: GPIO_CLK */ - -#define GPIO_SPI1_MISO (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN22) /* Type: GPIO */ -#define GPIO_SPI1_MOSI (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN23) /* Type: GPIO */ -#define GPIO_SPI1_NPCS0 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN25) /* Type: GPIO */ -#define GPIO_SPI1_NPCS1 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN26) /* Type: GPIO */ -#define GPIO_SPI1_NPCS2 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN27) /* Type: GPIO */ -#define GPIO_SPI1_NPCS3 (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN28) /* Type: GPIO */ -#define GPIO_SPI1_SPCK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN24) /* Type: GPIO_CLK */ +#define PIO_SPI0_MISO (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN10) /* Type: GPIO */ +#define PIO_SPI0_MOSI (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN11) /* Type: GPIO */ +#define PIO_SPI0_NPCS0 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN13) /* Type: GPIO */ +#define PIO_SPI0_NPCS1 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN14) /* Type: GPIO */ +#define PIO_SPI0_NPCS2 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN15) /* Type: GPIO */ +#define PIO_SPI0_NPCS3 (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN16) /* Type: GPIO */ +#define PIO_SPI0_SPCK (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN12) /* Type: GPIO_CLK */ + +#define PIO_SPI1_MISO (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN22) /* Type: GPIO */ +#define PIO_SPI1_MOSI (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN23) /* Type: GPIO */ +#define PIO_SPI1_NPCS0 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN25) /* Type: GPIO */ +#define PIO_SPI1_NPCS1 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN26) /* Type: GPIO */ +#define PIO_SPI1_NPCS2 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN27) /* Type: GPIO */ +#define PIO_SPI1_NPCS3 (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN28) /* Type: GPIO */ +#define PIO_SPI1_SPCK (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN24) /* Type: GPIO_CLK */ /* Synchronous Serial Controller - SSCx [1..0] */ -#define GPIO_SSC0_RD (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN21) /* Type: GPIO */ -#define GPIO_SSC0_RF (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN20) /* Type: GPIO */ -#define GPIO_SSC0_RK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN19) /* Type: GPIO */ -#define GPIO_SSC0_TD (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN18) /* Type: GPIO */ -#define GPIO_SSC0_TF (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN17) /* Type: GPIO */ -#define GPIO_SSC0_TK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN16) /* Type: GPIO */ +#define PIO_SSC0_RD (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN21) /* Type: GPIO */ +#define PIO_SSC0_RF (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN20) /* Type: GPIO */ +#define PIO_SSC0_RK (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN19) /* Type: GPIO */ +#define PIO_SSC0_TD (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN18) /* Type: GPIO */ +#define PIO_SSC0_TF (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN17) /* Type: GPIO */ +#define PIO_SSC0_TK (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN16) /* Type: GPIO */ -#define GPIO_SSC1_RD (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN11) /* Type: GMAC */ -#define GPIO_SSC1_RF (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN10) /* Type: GMAC */ -#define GPIO_SSC1_RK (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN7) /* Type: GMAC */ -#define GPIO_SSC1_TD (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN6) /* Type: GMAC */ -#define GPIO_SSC1_TF (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN3) /* Type: GMAC */ -#define GPIO_SSC1_TK (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN2) /* Type: GMAC */ +#define PIO_SSC1_RD (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN11) /* Type: GMAC */ +#define PIO_SSC1_RF (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN10) /* Type: GMAC */ +#define PIO_SSC1_RK (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN7) /* Type: GMAC */ +#define PIO_SSC1_TD (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN6) /* Type: GMAC */ +#define PIO_SSC1_TF (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN3) /* Type: GMAC */ +#define PIO_SSC1_TK (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN2) /* Type: GMAC */ /* Timer/Counter - TCx [5..0] */ -#define GPIO_TC0_CLK (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN7) /* Type: GPIO */ -#define GPIO_TC0_IOA (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN5) /* Type: GPIO */ -#define GPIO_TC0_IOB (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN6) /* Type: GPIO */ +#define PIO_TC0_CLK (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN7) /* Type: GPIO */ +#define PIO_TC0_IOA (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN5) /* Type: GPIO */ +#define PIO_TC0_IOB (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN6) /* Type: GPIO */ -#define GPIO_TC1_CLK (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN14) /* Type: GPIO */ -#define GPIO_TC1_IOA (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN12) /* Type: GPIO */ -#define GPIO_TC1_IOB (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN13) /* Type: GPIO */ +#define PIO_TC1_CLK (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN14) /* Type: GPIO */ +#define PIO_TC1_IOA (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN12) /* Type: GPIO */ +#define PIO_TC1_IOB (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN13) /* Type: GPIO */ -#define GPIO_TC2_CLK (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN29) /* Type: EBI */ -#define GPIO_TC2_IOA (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN27) /* Type: EBI */ -#define GPIO_TC2_IOB (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN28) /* Type: EBI */ +#define PIO_TC2_CLK (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN29) /* Type: EBI */ +#define PIO_TC2_IOA (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN27) /* Type: EBI */ +#define PIO_TC2_IOB (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN28) /* Type: EBI */ -#define GPIO_TC3_CLK (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN2) /* Type: GPIO */ -#define GPIO_TC3_IOA (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN0) /* Type: GPIO */ -#define GPIO_TC3_IOB (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN1) /* Type: GPIO */ +#define PIO_TC3_CLK (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN2) /* Type: GPIO */ +#define PIO_TC3_IOA (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN0) /* Type: GPIO */ +#define PIO_TC3_IOB (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN1) /* Type: GPIO */ -#define GPIO_TC4_CLK (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN5) /* Type: GPIO */ -#define GPIO_TC4_IOA (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN3) /* Type: GPIO */ -#define GPIO_TC4_IOB (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN4) /* Type: GPIO */ +#define PIO_TC4_CLK (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN5) /* Type: GPIO */ +#define PIO_TC4_IOA (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN3) /* Type: GPIO */ +#define PIO_TC4_IOB (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN4) /* Type: GPIO */ -#define GPIO_TC5_CLK (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN8) /* Type: GPIO */ -#define GPIO_TC5_IOA (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN6) /* Type: GPIO */ -#define GPIO_TC5_IOB (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN7) /* Type: GPIO */ +#define PIO_TC5_CLK (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN8) /* Type: GPIO */ +#define PIO_TC5_IOA (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN6) /* Type: GPIO */ +#define PIO_TC5_IOB (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN7) /* Type: GPIO */ /* Two-Wire Interface -TWIx [2..0] */ -#define GPIO_TWI0_CK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN31) /* Type: GPIO */ -#define GPIO_TWI0_D (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN30) /* Type: GPIO */ +#define PIO_TWI0_CK (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN31) /* Type: GPIO */ +#define PIO_TWI0_D (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN30) /* Type: GPIO */ -#define GPIO_TWI1_CK (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN27) /* Type: GPIO */ -#define GPIO_TWI1_D (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN26) /* Type: GPIO */ -#define GPIO_TWI2_CK (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN19) /* Type: GPIO */ -#define GPIO_TWI2_D (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN18) /* Type: GPIO */ +#define PIO_TWI1_CK (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN27) /* Type: GPIO */ +#define PIO_TWI1_D (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN26) /* Type: GPIO */ +#define PIO_TWI2_CK (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN19) /* Type: GPIO */ +#define PIO_TWI2_D (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN18) /* Type: GPIO */ /* Universal Asynchronous Receiver Transmitter - UARTx [1..0] */ -#define GPIO_UART0_RXD (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN29) /* Type: GPIO */ -#define GPIO_UART0_TXD (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOC | GPIO_PIN30) /* Type: GPIO */ +#define PIO_UART0_RXD (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN29) /* Type: GPIO */ +#define PIO_UART0_TXD (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOC | PIO_PIN30) /* Type: GPIO */ -#define GPIO_UART1_RXD (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN30) /* Type: GPIO */ -#define GPIO_UART1_TXD (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOA | GPIO_PIN31) /* Type: GPIO */ +#define PIO_UART1_RXD (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN30) /* Type: GPIO */ +#define PIO_UART1_TXD (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOA | PIO_PIN31) /* Type: GPIO */ /* Universal Synchronous Asynchronous Receiver Transmitter- USART0-3 */ -#define GPIO_USART0_CTS (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN15) /* Type: GPIO */ -#define GPIO_USART0_RTS (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN16) /* Type: GPIO */ -#define GPIO_USART0_RXD (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN17) /* Type: GPIO */ -#define GPIO_USART0_SCK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN14) /* Type: GPIO */ -#define GPIO_USART0_TXD (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOD | GPIO_PIN18) /* Type: GPIO */ - -#define GPIO_USART1_CTS (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN26) /* Type: GMAC */ -#define GPIO_USART1_RTS (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN27) /* Type: GPIO */ -#define GPIO_USART1_RXD (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN28) /* Type: GPIO */ -#define GPIO_USART1_SCK (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN25) /* Type: GMAC */ -#define GPIO_USART1_TXD (GPIO_PERIPHA | GPIO_CFG_DEFAULT | GPIO_PORT_PIOB | GPIO_PIN29) /* Type: GPIO */ - -#define GPIO_USART2_CTS (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN23) /* Type: EBI */ -#define GPIO_USART2_RTS (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN24) /* Type: EBI */ -#define GPIO_USART2_RXD (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN25) /* Type: EBI */ -#define GPIO_USART2_SCK (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN20) /* Type: EBI */ -#define GPIO_USART2_TXD (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN26) /* Type: EBI */ - -#define GPIO_USART3_CTS (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN16) /* Type: EBI */ -#define GPIO_USART3_RTS (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN17) /* Type: EBI */ -#define GPIO_USART3_RXD (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN18) /* Type: EBI */ -#define GPIO_USART3_SCK (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN15) /* Type: EBI */ -#define GPIO_USART3_TXD (GPIO_PERIPHB | GPIO_CFG_DEFAULT | GPIO_PORT_PIOE | GPIO_PIN19) /* Type: EBI */ +#define PIO_USART0_CTS (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN15) /* Type: GPIO */ +#define PIO_USART0_RTS (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN16) /* Type: GPIO */ +#define PIO_USART0_RXD (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN17) /* Type: GPIO */ +#define PIO_USART0_SCK (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN14) /* Type: GPIO */ +#define PIO_USART0_TXD (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOD | PIO_PIN18) /* Type: GPIO */ + +#define PIO_USART1_CTS (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN26) /* Type: GMAC */ +#define PIO_USART1_RTS (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN27) /* Type: GPIO */ +#define PIO_USART1_RXD (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN28) /* Type: GPIO */ +#define PIO_USART1_SCK (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN25) /* Type: GMAC */ +#define PIO_USART1_TXD (PIO_PERIPHA | PIO_CFG_DEFAULT | PIO_PORT_PIOB | PIO_PIN29) /* Type: GPIO */ + +#define PIO_USART2_CTS (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN23) /* Type: EBI */ +#define PIO_USART2_RTS (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN24) /* Type: EBI */ +#define PIO_USART2_RXD (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN25) /* Type: EBI */ +#define PIO_USART2_SCK (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN20) /* Type: EBI */ +#define PIO_USART2_TXD (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN26) /* Type: EBI */ + +#define PIO_USART3_CTS (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN16) /* Type: EBI */ +#define PIO_USART3_RTS (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN17) /* Type: EBI */ +#define PIO_USART3_RXD (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN18) /* Type: EBI */ +#define PIO_USART3_SCK (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN15) /* Type: EBI */ +#define PIO_USART3_TXD (PIO_PERIPHB | PIO_CFG_DEFAULT | PIO_PORT_PIOE | PIO_PIN19) /* Type: EBI */ #endif /* __ARCH_ARM_SRC_SAMA5_CHIP_SAMA5D3X_PINMAP_H */ diff --git a/nuttx/arch/arm/src/sama5/sam_boot.c b/nuttx/arch/arm/src/sama5/sam_boot.c index ec8710d2a..f3b342707 100644 --- a/nuttx/arch/arm/src/sama5/sam_boot.c +++ b/nuttx/arch/arm/src/sama5/sam_boot.c @@ -551,7 +551,7 @@ void up_boot(void) /* Perform board-specific initialization, This must include: * * - Initialization of board-specific memory resources (e.g., SDRAM) - * - Configuration of board specific resources (GPIOs, LEDs, etc). + * - Configuration of board specific resources (PIOs, LEDs, etc). */ sam_boardinitialize(); diff --git a/nuttx/arch/arm/src/sama5/sam_gpio.c b/nuttx/arch/arm/src/sama5/sam_gpio.c deleted file mode 100644 index a330f447b..000000000 --- a/nuttx/arch/arm/src/sama5/sam_gpio.c +++ /dev/null @@ -1,547 +0,0 @@ -/**************************************************************************** - * arch/arm/src/sama5/sam_gpio.c - * General Purpose Input/Output (GPIO) logic for the SAMA5 - * - * Copyright (C) 2013 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. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include -#include - -#include -#include - -#include "up_internal.h" -#include "up_arch.h" - -#include "chip.h" -#include "sam_gpio.h" -#include "chip/sam_pio.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -#ifdef CONFIG_DEBUG_GPIO -static const char g_portchar[4] = { 'A', 'B', 'C', 'D' }; -#endif - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ -/**************************************************************************** - * Name: sam_gpiobase - * - * Description: - * Return the base address of the GPIO register set - * - ****************************************************************************/ - -static inline uintptr_t sam_gpiobase(gpio_pinset_t cfgset) -{ - int port = (cfgset & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT; - return SAM_PION_VBASE(port); -} - -/**************************************************************************** - * Name: sam_gpiopin - * - * Description: - * Returun the base address of the GPIO register set - * - ****************************************************************************/ - -static inline int sam_gpiopin(gpio_pinset_t cfgset) -{ - return 1 << ((cfgset & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT); -} - -/**************************************************************************** - * Name: sam_configinput - * - * Description: - * Configure a GPIO input pin based on bit-encoded description of the pin. - * - ****************************************************************************/ - -static inline int sam_configinput(uintptr_t base, uint32_t pin, - gpio_pinset_t cfgset) -{ -#if defined(GPIO_HAVE_SCHMITT) || defined(GPIO_HAVE_DRIVE) - uint32_t regval; -#endif -#if defined(GPIO_HAVE_DRIVE) - uint32_t offset; - uint32_t mask; - uint32_t drive; - int shift; -#endif - - /* Disable interrupts on the pin */ - - putreg32(pin, base + SAM_PIO_IDR_OFFSET); - - /* Enable/disable the pull-up as requested */ - - if ((cfgset & GPIO_CFG_PULLUP) != 0) - { - putreg32(pin, base + SAM_PIO_PUER_OFFSET); - } - else - { - putreg32(pin, base + SAM_PIO_PUDR_OFFSET); - } - -#ifdef GPIO_HAVE_PULLDOWN - /* Enable/disable the pull-down as requested */ - - if ((cfgset & GPIO_CFG_PULLDOWN) != 0) - { - putreg32(pin, base + SAM_PIO_PPDER_OFFSET); - } - else - { - putreg32(pin, base + SAM_PIO_PPDDR_OFFSET); - } -#endif - - /* Check if filtering should be enabled */ - - if ((cfgset & GPIO_CFG_DEGLITCH) != 0) - { - putreg32(pin, base + SAM_PIO_IFER_OFFSET); - } - else - { - putreg32(pin, base + SAM_PIO_IFDR_OFFSET); - } - -#ifdef GPIO_HAVE_SCHMITT - /* Enable/disable the Schmitt trigger */ - - regval = getreg32(base + SAM_PIO_SCHMITT_OFFSET); - if ((cfgset & GPIO_CFG_PULLDOWN) != 0) - { - regval |= pin; - } - else - { - regval &= ~pin; - } - putreg32(regval, base + SAM_PIO_SCHMITT_OFFSET); -#endif - -#ifdef GPIO_HAVE_DRIVE - /* Configure drive strength */ - - drive = (cfgset & GPIO_DRIVE_MASK) >> GPIO_DRIVE_SHIFT; - if (pin < 32) - { - offset = SAM_PIO_DRIVER1_OFFSET; - mask = PIO_DRIVER1_LINE_MASK(pin); - shift = PIO_DRIVER1_LINE_SHIFT(pin); - } - else - { - offset = SAM_PIO_DRIVER2_OFFSET; - mask = PIO_DRIVER2_LINE_MASK(pin); - shift = PIO_DRIVER2_LINE_SHIFT(pin); - } - - regval = getreg32(base + offset); - regval &= ~mask; - regval |= drive << shift; - putreg32(regval, base + offset); -#endif - - /* Configure the pin as an input and enable the GPIO function */ - - putreg32(pin, base + SAM_PIO_ODR_OFFSET); - putreg32(pin, base + SAM_PIO_PER_OFFSET); - - /* To-Do: If DEGLITCH is selected, need to configure DIFSR, SCIFSR, and - * IFDGSR registers. This would probably best be done with - * another, new API... perhaps sam_configfilter() - */ - - return OK; -} - -/**************************************************************************** - * Name: sam_configoutput - * - * Description: - * Configure a GPIO output pin based on bit-encoded description of the pin. - * - ****************************************************************************/ - -static inline int sam_configoutput(uintptr_t base, uint32_t pin, - gpio_pinset_t cfgset) -{ - /* Disable interrupts on the pin */ - - putreg32(pin, base + SAM_PIO_IDR_OFFSET); - - /* Enable/disable the pull-up as requested */ - - if ((cfgset & GPIO_CFG_PULLUP) != 0) - { - putreg32(pin, base + SAM_PIO_PUER_OFFSET); - } - else - { - putreg32(pin, base + SAM_PIO_PUDR_OFFSET); - } - -#ifdef GPIO_HAVE_PULLDOWN - /* Enable/disable the pull-down as requested */ - - if ((cfgset & GPIO_CFG_PULLDOWN) != 0) - { - putreg32(pin, base + SAM_PIO_PPDER_OFFSET); - } - else - { - putreg32(pin, base + SAM_PIO_PPDDR_OFFSET); - } -#endif - - /* Enable the open drain driver if requrested */ - - if ((cfgset & GPIO_CFG_OPENDRAIN) != 0) - { - putreg32(pin, base + SAM_PIO_MDER_OFFSET); - } - else - { - putreg32(pin, base + SAM_PIO_MDDR_OFFSET); - } - - /* Set default value */ - - if ((cfgset & GPIO_OUTPUT_SET) != 0) - { - putreg32(pin, base + SAM_PIO_SODR_OFFSET); - } - else - { - putreg32(pin, base + SAM_PIO_CODR_OFFSET); - } - - /* Configure the pin as an output and enable the GPIO function */ - - putreg32(pin, base + SAM_PIO_OER_OFFSET); - putreg32(pin, base + SAM_PIO_PER_OFFSET); - return OK; -} - -/**************************************************************************** - * Name: sam_configperiph - * - * Description: - * Configure a GPIO pin driven by a peripheral A or B signal based on - * bit-encoded description of the pin. - * - ****************************************************************************/ - -static inline int sam_configperiph(uintptr_t base, uint32_t pin, - gpio_pinset_t cfgset) -{ - uint32_t regval; - - /* Disable interrupts on the pin */ - - putreg32(pin, base + SAM_PIO_IDR_OFFSET); - - /* Enable/disable the pull-up as requested */ - - if ((cfgset & GPIO_CFG_PULLUP) != 0) - { - putreg32(pin, base + SAM_PIO_PUER_OFFSET); - } - else - { - putreg32(pin, base + SAM_PIO_PUDR_OFFSET); - } - -#ifdef GPIO_HAVE_PULLDOWN - /* Enable/disable the pull-down as requested */ - - if ((cfgset & GPIO_CFG_PULLDOWN) != 0) - { - putreg32(pin, base + SAM_PIO_PPDER_OFFSET); - } - else - { - putreg32(pin, base + SAM_PIO_PPDDR_OFFSET); - } -#endif - -#ifdef GPIO_HAVE_PERIPHCD - /* Configure pin, depending upon the peripheral A, B, C or D - * - * PERIPHA: ABCDSR1[n] = 0 ABCDSR2[n] = 0 - * PERIPHB: ABCDSR1[n] = 1 ABCDSR2[n] = 0 - * PERIPHC: ABCDSR1[n] = 0 ABCDSR2[n] = 1 - * PERIPHD: ABCDSR1[n] = 1 ABCDSR2[n] = 1 - */ - - regval = getreg32(base + SAM_PIO_ABCDSR1_OFFSET); - if ((cfgset & GPIO_MODE_MASK) == GPIO_PERIPHA || - (cfgset & GPIO_MODE_MASK) == GPIO_PERIPHC) - { - regval &= ~pin; - } - else - { - regval |= pin; - } - putreg32(regval, base + SAM_PIO_ABCDSR1_OFFSET); - - regval = getreg32(base + SAM_PIO_ABCDSR2_OFFSET); - if ((cfgset & GPIO_MODE_MASK) == GPIO_PERIPHA || - (cfgset & GPIO_MODE_MASK) == GPIO_PERIPHB) - { - regval &= ~pin; - } - else - { - regval |= pin; - } - putreg32(regval, base + SAM_PIO_ABCDSR2_OFFSET); - -#else - /* Configure pin, depending upon the peripheral A or B: - * - * PERIPHA: ABSR[n] = 0 - * PERIPHB: ABSR[n] = 1 - */ - - regval = getreg32(base + SAM_PIO_ABSR_OFFSET); - if ((cfgset & GPIO_MODE_MASK) == GPIO_PERIPHA) - { - regval &= ~pin; - } - else - { - regval |= pin; - } - putreg32(regval, base + SAM_PIO_ABSR_OFFSET); -#endif - - /* Disable PIO functionality */ - - putreg32(pin, base + SAM_PIO_PDR_OFFSET); - return OK; -} - -/**************************************************************************** - * Global Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: sam_configgpio - * - * Description: - * Configure a GPIO pin based on bit-encoded description of the pin. - * - ****************************************************************************/ - -int sam_configgpio(gpio_pinset_t cfgset) -{ - uintptr_t base = sam_gpiobase(cfgset); - uint32_t pin = sam_gpiopin(cfgset); - irqstate_t flags; - int ret; - - /* Disable interrupts to prohibit re-entrance. */ - - flags = irqsave(); - - /* Enable writing to GPIO registers */ - - putreg32(PIO_WPMR_WPKEY, base + SAM_PIO_WPMR_OFFSET); - - /* Handle the pin configuration according to pin type */ - - switch (cfgset & GPIO_MODE_MASK) - { - case GPIO_INPUT: - ret = sam_configinput(base, pin, cfgset); - break; - - case GPIO_OUTPUT: - ret = sam_configoutput(base, pin, cfgset); - break; - - case GPIO_PERIPHA: - case GPIO_PERIPHB: -#ifdef GPIO_HAVE_PERIPHCD - case GPIO_PERIPHC: - case GPIO_PERIPHD: -#endif - ret = sam_configperiph(base, pin, cfgset); - break; - - default: - ret = -EINVAL; - break; - } - - /* Disable writing to GPIO registers */ - - putreg32(PIO_WPMR_WPEN | PIO_WPMR_WPKEY, base + SAM_PIO_WPMR_OFFSET); - irqrestore(flags); - - return ret; -} - -/**************************************************************************** - * Name: sam_gpiowrite - * - * Description: - * Write one or zero to the selected GPIO pin - * - ****************************************************************************/ - -void sam_gpiowrite(gpio_pinset_t pinset, bool value) -{ - uintptr_t base = sam_gpiobase(pinset); - uint32_t pin = sam_gpiopin(pinset); - - if (value) - { - putreg32(pin, base + SAM_PIO_SODR_OFFSET); - } - else - { - putreg32(pin, base + SAM_PIO_CODR_OFFSET); - } -} - -/**************************************************************************** - * Name: sam_gpioread - * - * Description: - * Read one or zero from the selected GPIO pin - * - ****************************************************************************/ - -bool sam_gpioread(gpio_pinset_t pinset) -{ - uintptr_t base = sam_gpiobase(pinset); - uint32_t pin = sam_gpiopin(pinset); - uint32_t regval; - - if ((pinset & GPIO_MODE_MASK) == GPIO_OUTPUT) - { - regval = getreg32(base + SAM_PIO_ODSR_OFFSET); - } - else - { - regval = getreg32(base + SAM_PIO_PDSR_OFFSET); - } - - return (regval & pin) != 0; -} - -/************************************************************************************ - * Function: sam_dumpgpio - * - * Description: - * Dump all GPIO registers associated with the base address of the provided pinset. - * - ************************************************************************************/ - -#ifdef CONFIG_DEBUG_GPIO -int sam_dumpgpio(uint32_t pinset, const char *msg) -{ - irqstate_t flags; - uintptr_t base; - unsigned int pin; - unsigned int port; - - /* Get the base address associated with the PIO port */ - - pin = sam_gpiopin(pinset); - port = (pinset & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT; - base = SAM_PION_BASE(port); - - /* The following requires exclusive access to the GPIO registers */ - - flags = irqsave(); - lldbg("PIO%c pinset: %08x base: %08x -- %s\n", - g_portchar[port], pinset, base, msg); - lldbg(" PSR: %08x OSR: %08x IFSR: %08x ODSR: %08x\n", - getreg32(base + SAM_PIO_PSR_OFFSET), getreg32(base + SAM_PIO_OSR_OFFSET), - getreg32(base + SAM_PIO_IFSR_OFFSET), getreg32(base + SAM_PIO_ODSR_OFFSET)); - lldbg(" PDSR: %08x IMR: %08x ISR: %08x MDSR: %08x\n", - getreg32(base + SAM_PIO_PDSR_OFFSET), getreg32(base + SAM_PIO_IMR_OFFSET), - getreg32(base + SAM_PIO_ISR_OFFSET), getreg32(base + SAM_PIO_MDSR_OFFSET)); - lldbg(" ABCDSR: %08x %08x IFSCSR: %08x PPDSR: %08x\n", - getreg32(base + SAM_PIO_ABCDSR1_OFFSET), getreg32(base + SAM_PIO_ABCDSR2_OFFSET), - getreg32(base + SAM_PIO_IFSCSR_OFFSET), getreg32(base + SAM_PIOC_PPDSR)); - lldbg(" PUSR: %08x SCDR: %08x OWSR: %08x AIMMR: %08x\n", - getreg32(base + SAM_PIO_PUSR_OFFSET), getreg32(base + SAM_PIO_SCDR_OFFSET), - getreg32(base + SAM_PIO_OWSR_OFFSET), getreg32(base + SAM_PIO_AIMMR_OFFSET)); - lldbg(" ESR: %08x LSR: %08x ELSR: %08x FELLSR: %08x\n", - getreg32(base + SAM_PIO_ESR_OFFSET), getreg32(base + SAM_PIO_LSR_OFFSET), - getreg32(base + SAM_PIO_ELSR_OFFSET), getreg32(base + SAM_PIO_FELLSR_OFFSET)); - lldbg(" FRLHSR: %08x LOCKSR: %08x WPMR: %08x WPSR: %08x\n", - getreg32(base + SAM_PIO_FRLHSR_OFFSET), getreg32(base + SAM_PIO_LOCKSR_OFFSET), - getreg32(base + SAM_PIO_WPMR_OFFSET), getreg32(base + SAM_PIO_WPSR_OFFSET)); - lldbg(" PCMR: %08x PCIMR: %08x PCISR: %08x PCRHR: %08x\n", - getreg32(base + SAM_PIO_PCMR_OFFSET), getreg32(base + SAM_PIO_PCIMR_OFFSET), - getreg32(base + SAM_PIO_PCISR_OFFSET), getreg32(base + SAM_PIO_PCRHR_OFFSET)); - lldbg("SCHMITT: %08x\n", - getreg32(base + SAM_PIO_SCHMITT_OFFSET)); - irqrestore(flags); - return OK; -} -#endif - diff --git a/nuttx/arch/arm/src/sama5/sam_gpio.h b/nuttx/arch/arm/src/sama5/sam_gpio.h deleted file mode 100644 index ebc60d0f2..000000000 --- a/nuttx/arch/arm/src/sama5/sam_gpio.h +++ /dev/null @@ -1,340 +0,0 @@ -/************************************************************************************ - * arch/arm/src/sama5/sam_gpio.h - * General Purpose Input/Output (GPIO) definitions for the SAM4S - * - * Copyright (C) 2013 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_SAMA5_SAM_GPIO_H -#define __ARCH_ARM_SRC_SAMA5_SAM_GPIO_H - -/************************************************************************************ - * Included Files - ************************************************************************************/ - -#include - -#include -#include - -/************************************************************************************ - * Definitions - ************************************************************************************/ -/* Configuration ********************************************************************/ - -#if defined(CONFIG_PIOA_IRQ) || defined(CONFIG_PIOB_IRQ) || \ - defined(CONFIG_PIOC_IRQ) || defined(CONFIG_PIOD_IRQ) || \ - defined(CONFIG_PIOD_IRQ) -# define CONFIG_PIO_IRQ 1 -#else -# undef CONFIG_PIO_IRQ -#endif - -#ifndef CONFIG_DEBUG -# undef CONFIG_DEBUG_GPIO -#endif - -#define GPIO_HAVE_PULLDOWN 1 -#define GPIO_HAVE_PERIPHCD 1 -#define GPIO_HAVE_SCHMITT 1 -#define GPIO_HAVE_DRIVE 1 - -/* Bit-encoded input to sam_configgpio() ********************************************/ - -/* 32-bit Encoding: - * - * ..MM MCCC CCDD IIIV PPPB BBBB - */ - -/* Input/Output mode: - * - * ..MM M... .... .... .... .... - */ - -#define GPIO_MODE_SHIFT (19) /* Bits 19-21: GPIO mode */ -#define GPIO_MODE_MASK (7 << GPIO_MODE_SHIFT) -# define GPIO_INPUT (0 << GPIO_MODE_SHIFT) /* Input */ -# define GPIO_OUTPUT (1 << GPIO_MODE_SHIFT) /* Output */ -# define GPIO_PERIPHA (2 << GPIO_MODE_SHIFT) /* Controlled by periph A signal */ -# define GPIO_PERIPHB (3 << GPIO_MODE_SHIFT) /* Controlled by periph B signal */ -# define GPIO_PERIPHC (4 << GPIO_MODE_SHIFT) /* Controlled by periph C signal */ -# define GPIO_PERIPHD (5 << GPIO_MODE_SHIFT) /* Controlled by periph D signal */ - -/* These bits set the configuration of the pin: - * NOTE: No definitions for parallel capture mode - * - * .... .CCC CC.. .... .... .... - */ - -#define GPIO_CFG_SHIFT (14) /* Bits 14-18: GPIO configuration bits */ -#define GPIO_CFG_MASK (31 << GPIO_CFG_SHIFT) -# define GPIO_CFG_DEFAULT (0 << GPIO_CFG_SHIFT) /* Default, no attribute */ -# define GPIO_CFG_PULLUP (1 << GPIO_CFG_SHIFT) /* Bit 11: Internal pull-up */ -# define GPIO_CFG_PULLDOWN (2 << GPIO_CFG_SHIFT) /* Bit 11: Internal pull-down */ -# define GPIO_CFG_DEGLITCH (4 << GPIO_CFG_SHIFT) /* Bit 12: Internal glitch filter */ -# define GPIO_CFG_OPENDRAIN (8 << GPIO_CFG_SHIFT) /* Bit 13: Open drain */ -# define GPIO_CFG_SCHMITT (16 << GPIO_CFG_SHIFT) /* Bit 13: Schmitt trigger */ - -/* Drive Strength: - * - * .... .... ..DD .... .... .... - */ - -#define GPIO_DRIVE_SHIFT (12) /* Bits 12-13: Drive strength */ -#define GPIO_DRIVE_MASK (7 << GPIO_DRIVE_SHIFT) -# define GPIO_DRIVE_LOW (0 << GPIO_DRIVE_SHIFT) -# define GPIO_DRIVE_MEDIUM (2 << GPIO_DRIVE_SHIFT) -# define GPIO_DRIVE_HIGH (3 << GPIO_DRIVE_SHIFT) - -/* Additional interrupt modes: - * - * .... .... .... III. .... .... - */ - -#define GPIO_INT_SHIFT (9) /* Bits 9-11: GPIO interrupt bits */ -#define GPIO_INT_MASK (7 << GPIO_INT_SHIFT) -# define _GIO_INT_AIM (1 << 10) /* Bit 10: Additional Interrupt modes */ -# define _GPIO_INT_LEVEL (1 << 9) /* Bit 9: Level detection interrupt */ -# define _GPIO_INT_EDGE (0) /* (vs. Edge detection interrupt) */ -# define _GPIO_INT_RH (1 << 8) /* Bit 9: Rising edge/High level detection interrupt */ -# define _GPIO_INT_FL (0) /* (vs. Falling edge/Low level detection interrupt) */ - -# define GPIO_INT_HIGHLEVEL (_GIO_INT_AIM | _GPIO_INT_LEVEL | _GPIO_INT_RH) -# define GPIO_INT_LOWLEVEL (_GIO_INT_AIM | _GPIO_INT_LEVEL | _GPIO_INT_FL) -# define GPIO_INT_RISING (_GIO_INT_AIM | _GPIO_INT_EDGE | _GPIO_INT_RH) -# define GPIO_INT_FALLING (_GIO_INT_AIM | _GPIO_INT_EDGE | _GPIO_INT_FL) -# define GPIO_INT_BOTHEDGES (0) - -/* If the pin is an GPIO output, then this identifies the initial output value: - * - * .... .... .... ...V .... .... - */ - -#define GPIO_OUTPUT_SET (1 << 8) /* Bit 8: Inital value of output */ -#define GPIO_OUTPUT_CLEAR (0) - -/* This identifies the GPIO port: - * - * .... .... .... .... PPP. .... - */ - -#define GPIO_PORT_SHIFT (5) /* Bit 5-7: Port number */ -#define GPIO_PORT_MASK (7 << GPIO_PORT_SHIFT) -# define GPIO_PORT_PIOA (0 << GPIO_PORT_SHIFT) -# define GPIO_PORT_PIOB (1 << GPIO_PORT_SHIFT) -# define GPIO_PORT_PIOC (2 << GPIO_PORT_SHIFT) -# define GPIO_PORT_PIOD (3 << GPIO_PORT_SHIFT) -# define GPIO_PORT_PIOE (4 << GPIO_PORT_SHIFT) - -/* This identifies the bit in the port: - * - * .... .... .... .... ...B BBBB - */ - -#define GPIO_PIN_SHIFT (0) /* Bits 0-4: GPIO number: 0-31 */ -#define GPIO_PIN_MASK (31 << GPIO_PIN_SHIFT) -#define GPIO_PIN0 (0 << GPIO_PIN_SHIFT) -#define GPIO_PIN1 (1 << GPIO_PIN_SHIFT) -#define GPIO_PIN2 (2 << GPIO_PIN_SHIFT) -#define GPIO_PIN3 (3 << GPIO_PIN_SHIFT) -#define GPIO_PIN4 (4 << GPIO_PIN_SHIFT) -#define GPIO_PIN5 (5 << GPIO_PIN_SHIFT) -#define GPIO_PIN6 (6 << GPIO_PIN_SHIFT) -#define GPIO_PIN7 (7 << GPIO_PIN_SHIFT) -#define GPIO_PIN8 (8 << GPIO_PIN_SHIFT) -#define GPIO_PIN9 (9 << GPIO_PIN_SHIFT) -#define GPIO_PIN10 (10 << GPIO_PIN_SHIFT) -#define GPIO_PIN11 (11 << GPIO_PIN_SHIFT) -#define GPIO_PIN12 (12 << GPIO_PIN_SHIFT) -#define GPIO_PIN13 (13 << GPIO_PIN_SHIFT) -#define GPIO_PIN14 (14 << GPIO_PIN_SHIFT) -#define GPIO_PIN15 (15 << GPIO_PIN_SHIFT) -#define GPIO_PIN16 (16 << GPIO_PIN_SHIFT) -#define GPIO_PIN17 (17 << GPIO_PIN_SHIFT) -#define GPIO_PIN18 (18 << GPIO_PIN_SHIFT) -#define GPIO_PIN19 (19 << GPIO_PIN_SHIFT) -#define GPIO_PIN20 (20 << GPIO_PIN_SHIFT) -#define GPIO_PIN21 (21 << GPIO_PIN_SHIFT) -#define GPIO_PIN22 (22 << GPIO_PIN_SHIFT) -#define GPIO_PIN23 (23 << GPIO_PIN_SHIFT) -#define GPIO_PIN24 (24 << GPIO_PIN_SHIFT) -#define GPIO_PIN25 (25 << GPIO_PIN_SHIFT) -#define GPIO_PIN26 (26 << GPIO_PIN_SHIFT) -#define GPIO_PIN27 (27 << GPIO_PIN_SHIFT) -#define GPIO_PIN28 (28 << GPIO_PIN_SHIFT) -#define GPIO_PIN29 (29 << GPIO_PIN_SHIFT) -#define GPIO_PIN30 (30 << GPIO_PIN_SHIFT) -#define GPIO_PIN31 (31 << GPIO_PIN_SHIFT) - -/************************************************************************************ - * Public Types - ************************************************************************************/ - -/* Must be big enough to hold the 32-bit encoding */ - -typedef uint32_t gpio_pinset_t; - -/************************************************************************************ - * Inline Functions - ************************************************************************************/ - -#ifndef __ASSEMBLY__ - -/************************************************************************************ - * Public Data - ************************************************************************************/ - -#undef EXTERN -#if defined(__cplusplus) -#define EXTERN extern "C" -extern "C" -{ -#else -#define EXTERN extern -#endif - -/************************************************************************************ - * Public Function Prototypes - ************************************************************************************/ - -/************************************************************************************ - * Name: sam_gpioirqinitialize - * - * Description: - * Initialize logic to support a second level of interrupt decoding for GPIO pins. - * - ************************************************************************************/ - -#ifdef CONFIG_PIO_IRQ -void sam_gpioirqinitialize(void); -#else -# define sam_gpioirqinitialize() -#endif - -/************************************************************************************ - * Name: sam_configgpio - * - * Description: - * Configure a GPIO pin based on bit-encoded description of the pin. - * - ************************************************************************************/ - -int sam_configgpio(gpio_pinset_t cfgset); - -/************************************************************************************ - * Name: sam_gpiowrite - * - * Description: - * Write one or zero to the selected GPIO pin - * - ************************************************************************************/ - -void sam_gpiowrite(gpio_pinset_t pinset, bool value); - -/************************************************************************************ - * Name: sam_gpioread - * - * Description: - * Read one or zero from the selected GPIO pin - * - ************************************************************************************/ - -bool sam_gpioread(gpio_pinset_t pinset); - -/************************************************************************************ - * Name: sam_gpioirq - * - * Description: - * Configure an interrupt for the specified GPIO pin. - * - ************************************************************************************/ - -#ifdef CONFIG_PIO_IRQ -void sam_gpioirq(gpio_pinset_t pinset); -#else -# define sam_gpioirq(pinset) -#endif - -/************************************************************************************ - * Name: sam_gpioirqenable - * - * Description: - * Enable the interrupt for specified GPIO IRQ - * - ************************************************************************************/ - -#ifdef CONFIG_PIO_IRQ -void sam_gpioirqenable(int irq); -#else -# define sam_gpioirqenable(irq) -#endif - -/************************************************************************************ - * Name: sam_gpioirqdisable - * - * Description: - * Disable the interrupt for specified GPIO IRQ - * - ************************************************************************************/ - -#ifdef CONFIG_PIO_IRQ -void sam_gpioirqdisable(int irq); -#else -# define sam_gpioirqdisable(irq) -#endif - -/************************************************************************************ - * Function: sam_dumpgpio - * - * Description: - * Dump all GPIO registers associated with the base address of the provided pinset. - * - ************************************************************************************/ - -#ifdef CONFIG_DEBUG_GPIO -int sam_dumpgpio(uint32_t pinset, const char *msg); -#else -# define sam_dumpgpio(p,m) -#endif - -#undef EXTERN -#if defined(__cplusplus) -} -#endif - -#undef EXTERN -#if defined(__cplusplus) -} -#endif - -#endif /* __ASSEMBLY__ */ -#endif /* __ARCH_ARM_SRC_SAMA5_SAM_GPIO_H */ diff --git a/nuttx/arch/arm/src/sama5/sam_hsmci.c b/nuttx/arch/arm/src/sama5/sam_hsmci.c index f131a9dfd..69ad49533 100644 --- a/nuttx/arch/arm/src/sama5/sam_hsmci.c +++ b/nuttx/arch/arm/src/sama5/sam_hsmci.c @@ -60,7 +60,7 @@ #include "chip.h" #include "up_arch.h" -#include "sam_gpio.h" +#include "sam_pio.h" #include "sam_dmac.h" #include "sam_hsmci.h" #include "sam_periphclks.h" @@ -2705,17 +2705,17 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno) priv->base = SAM_HSMCI0_VBASE; priv->hsmci = 0; - /* Configure GPIOs for 4-bit, wide-bus operation. NOTE: (1) the chip + /* Configure PIOs for 4-bit, wide-bus operation. NOTE: (1) the chip * is capable of 8-bit wide bus operation but D4-D7 are not configured, - * (2) any card detection GPIOs must be set up in board-specific logic. + * (2) any card detection PIOs must be set up in board-specific logic. */ - sam_configgpio(GPIO_MCI0_DA0); /* Data 0 of Slot A */ - sam_configgpio(GPIO_MCI0_DA1); /* Data 1 of Slot A */ - sam_configgpio(GPIO_MCI0_DA2); /* Data 2 of Slot A */ - sam_configgpio(GPIO_MCI0_DA3); /* Data 3 of Slot A */ - sam_configgpio(GPIO_MCI0_CK); /* SD clock */ - sam_configgpio(GPIO_MCI0_CDA); /* Command/Response */ + sam_configpio(PIO_MCI0_DA0); /* Data 0 of Slot A */ + sam_configpio(PIO_MCI0_DA1); /* Data 1 of Slot A */ + sam_configpio(PIO_MCI0_DA2); /* Data 2 of Slot A */ + sam_configpio(PIO_MCI0_DA3); /* Data 3 of Slot A */ + sam_configpio(PIO_MCI0_CK); /* SD clock */ + sam_configpio(PIO_MCI0_CDA); /* Command/Response */ /* Enable the HSMCI0 peripheral clock. This really should be done in * sam_enable (as well as disabling peripheal clocks in sam_disable(). @@ -2742,17 +2742,17 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno) priv->base = SAM_HSMCI1_VBASE; priv->hsmci = 1; - /* Configure GPIOs for 4-bit, wide-bus operation. NOTE: (1) the chip + /* Configure PIOs for 4-bit, wide-bus operation. NOTE: (1) the chip * is capable of 8-bit wide bus operation but D4-D7 are not configured, - * (2) any card detection GPIOs must be set up in board-specific logic. + * (2) any card detection PIOs must be set up in board-specific logic. */ - sam_configgpio(GPIO_MCI1_DA0); /* Data 0 of Slot A */ - sam_configgpio(GPIO_MCI1_DA1); /* Data 1 of Slot A */ - sam_configgpio(GPIO_MCI1_DA2); /* Data 2 of Slot A */ - sam_configgpio(GPIO_MCI1_DA3); /* Data 3 of Slot A */ - sam_configgpio(GPIO_MCI1_CK); /* SD clock */ - sam_configgpio(GPIO_MCI1_CDA); /* Command/Response */ + sam_configpio(PIO_MCI1_DA0); /* Data 0 of Slot A */ + sam_configpio(PIO_MCI1_DA1); /* Data 1 of Slot A */ + sam_configpio(PIO_MCI1_DA2); /* Data 2 of Slot A */ + sam_configpio(PIO_MCI1_DA3); /* Data 3 of Slot A */ + sam_configpio(PIO_MCI1_CK); /* SD clock */ + sam_configpio(PIO_MCI1_CDA); /* Command/Response */ /* Enable the HSMCI1 peripheral clock This really should be done in * sam_enable (as well as disabling peripheal clocks in sam_disable(). @@ -2779,17 +2779,17 @@ FAR struct sdio_dev_s *sdio_initialize(int slotno) priv->base = SAM_HSMCI2_VBASE; priv->hsmci = 2; - /* Configure GPIOs for 4-bit, wide-bus operation. NOTE: (1) the chip + /* Configure PIOs for 4-bit, wide-bus operation. NOTE: (1) the chip * is capable of 8-bit wide bus operation but D4-D7 are not configured, - * (2) any card detection GPIOs must be set up in board-specific logic. + * (2) any card detection PIOs must be set up in board-specific logic. */ - sam_configgpio(GPIO_MCI2_DA0); /* Data 0 of Slot A */ - sam_configgpio(GPIO_MCI2_DA1); /* Data 1 of Slot A */ - sam_configgpio(GPIO_MCI2_DA2); /* Data 2 of Slot A */ - sam_configgpio(GPIO_MCI1_DA3); /* Data 3 of Slot A */ - sam_configgpio(GPIO_MCI2_DA3); /* SD clock */ - sam_configgpio(GPIO_MCI2_CDA); /* Command/Response */ + sam_configpio(PIO_MCI2_DA0); /* Data 0 of Slot A */ + sam_configpio(PIO_MCI2_DA1); /* Data 1 of Slot A */ + sam_configpio(PIO_MCI2_DA2); /* Data 2 of Slot A */ + sam_configpio(PIO_MCI1_DA3); /* Data 3 of Slot A */ + sam_configpio(PIO_MCI2_DA3); /* SD clock */ + sam_configpio(PIO_MCI2_CDA); /* Command/Response */ /* Enable the HSMCI2 peripheral clock This really should be done in * sam_enable (as well as disabling peripheal clocks in sam_disable(). diff --git a/nuttx/arch/arm/src/sama5/sam_irq.c b/nuttx/arch/arm/src/sama5/sam_irq.c index 986e5d018..a7c642e21 100644 --- a/nuttx/arch/arm/src/sama5/sam_irq.c +++ b/nuttx/arch/arm/src/sama5/sam_irq.c @@ -50,8 +50,8 @@ #include "os_internal.h" #include "up_internal.h" -#ifdef CONFIG_PIO_IRQ -# include "sam_gpio.h" +#ifdef CONFIG_SAMA5_PIO_IRQ +# include "sam_pio.h" #endif #include "chip/sam_aic.h" @@ -317,7 +317,7 @@ void up_irqinitialize(void) * PIO pins. */ -#ifdef CONFIG_PIO_IRQ +#ifdef CONFIG_SAMA5_PIO_IRQ sam_pioirqinitialize(); #endif @@ -426,7 +426,7 @@ void up_disable_irq(int irq) sam_dumpaic("disable", irq); irqrestore(flags); } -#ifdef CONFIG_PIO_IRQ +#ifdef CONFIG_SAMA5_PIO_IRQ else { /* Maybe it is a (derived) PIO IRQ */ @@ -465,7 +465,7 @@ void up_enable_irq(int irq) sam_dumpaic("enable", irq); irqrestore(flags); } -#ifdef CONFIG_PIO_IRQ +#ifdef CONFIG_SAMA5_PIO_IRQ else { /* Maybe it is a (derived) PIO IRQ */ diff --git a/nuttx/arch/arm/src/sama5/sam_lowputc.c b/nuttx/arch/arm/src/sama5/sam_lowputc.c index 0283c18df..3154fa80c 100644 --- a/nuttx/arch/arm/src/sama5/sam_lowputc.c +++ b/nuttx/arch/arm/src/sama5/sam_lowputc.c @@ -47,7 +47,7 @@ #include "up_internal.h" #include "up_arch.h" -#include "sam_gpio.h" +#include "sam_pio.h" #include "sam_periphclks.h" #include "sam_lowputc.h" @@ -292,56 +292,56 @@ void sam_lowsetup(void) /* Configure UART pins for all selected UART/USARTs */ #ifdef CONFIG_SAMA5_UART0 - (void)sam_configgpio(GPIO_UART0_RXD); - (void)sam_configgpio(GPIO_UART0_TXD); + (void)sam_configpio(PIO_UART0_RXD); + (void)sam_configpio(PIO_UART0_TXD); #endif #ifdef CONFIG_SAMA5_UART1 - (void)sam_configgpio(GPIO_UART1_RXD); - (void)sam_configgpio(GPIO_UART1_TXD); + (void)sam_configpio(PIO_UART1_RXD); + (void)sam_configpio(PIO_UART1_TXD); #endif #ifdef CONFIG_SAMA5_USART0 - (void)sam_configgpio(GPIO_USART0_RXD); - (void)sam_configgpio(GPIO_USART0_TXD); + (void)sam_configpio(PIO_USART0_RXD); + (void)sam_configpio(PIO_USART0_TXD); #ifdef CONFIG_USART0_OFLOWCONTROL - (void)sam_configgpio(GPIO_USART0_CTS); + (void)sam_configpio(PIO_USART0_CTS); #endif #ifdef CONFIG_USART0_IFLOWCONTROL - (void)sam_configgpio(GPIO_USART0_RTS); + (void)sam_configpio(PIO_USART0_RTS); #endif #endif #ifdef CONFIG_SAMA5_USART1 - (void)sam_configgpio(GPIO_USART1_RXD); - (void)sam_configgpio(GPIO_USART1_TXD); + (void)sam_configpio(PIO_USART1_RXD); + (void)sam_configpio(PIO_USART1_TXD); #ifdef CONFIG_USART1_OFLOWCONTROL - (void)sam_configgpio(GPIO_USART1_CTS); + (void)sam_configpio(PIO_USART1_CTS); #endif #ifdef CONFIG_USART1_IFLOWCONTROL - (void)sam_configgpio(GPIO_USART1_RTS); + (void)sam_configpio(PIO_USART1_RTS); #endif #endif #ifdef CONFIG_SAMA5_USART2 - (void)sam_configgpio(GPIO_USART2_RXD); - (void)sam_configgpio(GPIO_USART2_TXD); + (void)sam_configpio(PIO_USART2_RXD); + (void)sam_configpio(PIO_USART2_TXD); #ifdef CONFIG_USART2_OFLOWCONTROL - (void)sam_configgpio(GPIO_USART2_CTS); + (void)sam_configpio(PIO_USART2_CTS); #endif #ifdef CONFIG_USART2_IFLOWCONTROL - (void)sam_configgpio(GPIO_USART2_RTS); + (void)sam_configpio(PIO_USART2_RTS); #endif #endif #ifdef CONFIG_SAMA5_USART3 - (void)sam_configgpio(GPIO_USART3_RXD); - (void)sam_configgpio(GPIO_USART3_TXD); + (void)sam_configpio(PIO_USART3_RXD); + (void)sam_configpio(PIO_USART3_TXD); #ifdef CONFIG_USART3_OFLOWCONTROL - (void)sam_configgpio(GPIO_USART3_CTS); + (void)sam_configpio(PIO_USART3_CTS); #endif #ifdef CONFIG_USART3_IFLOWCONTROL - (void)sam_configgpio(GPIO_USART3_RTS); + (void)sam_configpio(PIO_USART3_RTS); #endif #endif diff --git a/nuttx/arch/arm/src/sama5/sam_pio.c b/nuttx/arch/arm/src/sama5/sam_pio.c new file mode 100644 index 000000000..3f313b2ae --- /dev/null +++ b/nuttx/arch/arm/src/sama5/sam_pio.c @@ -0,0 +1,547 @@ +/**************************************************************************** + * arch/arm/src/sama5/sam_pio.c + * General Purpose Input/Output (PIO) logic for the SAMA5 + * + * Copyright (C) 2013 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include + +#include "up_internal.h" +#include "up_arch.h" + +#include "chip.h" +#include "sam_pio.h" +#include "chip/sam_pio.h" + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#ifdef CONFIG_DEBUG_GPIO +static const char g_portchar[4] = { 'A', 'B', 'C', 'D' }; +#endif + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ +/**************************************************************************** + * Name: sam_piobase + * + * Description: + * Return the base address of the PIO register set + * + ****************************************************************************/ + +static inline uintptr_t sam_piobase(pio_pinset_t cfgset) +{ + int port = (cfgset & PIO_PORT_MASK) >> PIO_PORT_SHIFT; + return SAM_PION_VBASE(port); +} + +/**************************************************************************** + * Name: sam_piopin + * + * Description: + * Returun the base address of the PIO register set + * + ****************************************************************************/ + +static inline int sam_piopin(pio_pinset_t cfgset) +{ + return 1 << ((cfgset & PIO_PIN_MASK) >> PIO_PIN_SHIFT); +} + +/**************************************************************************** + * Name: sam_configinput + * + * Description: + * Configure a PIO input pin based on bit-encoded description of the pin. + * + ****************************************************************************/ + +static inline int sam_configinput(uintptr_t base, uint32_t pin, + pio_pinset_t cfgset) +{ +#if defined(PIO_HAVE_SCHMITT) || defined(PIO_HAVE_DRIVE) + uint32_t regval; +#endif +#if defined(PIO_HAVE_DRIVE) + uint32_t offset; + uint32_t mask; + uint32_t drive; + int shift; +#endif + + /* Disable interrupts on the pin */ + + putreg32(pin, base + SAM_PIO_IDR_OFFSET); + + /* Enable/disable the pull-up as requested */ + + if ((cfgset & PIO_CFG_PULLUP) != 0) + { + putreg32(pin, base + SAM_PIO_PUER_OFFSET); + } + else + { + putreg32(pin, base + SAM_PIO_PUDR_OFFSET); + } + +#ifdef PIO_HAVE_PULLDOWN + /* Enable/disable the pull-down as requested */ + + if ((cfgset & PIO_CFG_PULLDOWN) != 0) + { + putreg32(pin, base + SAM_PIO_PPDER_OFFSET); + } + else + { + putreg32(pin, base + SAM_PIO_PPDDR_OFFSET); + } +#endif + + /* Check if filtering should be enabled */ + + if ((cfgset & PIO_CFG_DEGLITCH) != 0) + { + putreg32(pin, base + SAM_PIO_IFER_OFFSET); + } + else + { + putreg32(pin, base + SAM_PIO_IFDR_OFFSET); + } + +#ifdef PIO_HAVE_SCHMITT + /* Enable/disable the Schmitt trigger */ + + regval = getreg32(base + SAM_PIO_SCHMITT_OFFSET); + if ((cfgset & PIO_CFG_PULLDOWN) != 0) + { + regval |= pin; + } + else + { + regval &= ~pin; + } + putreg32(regval, base + SAM_PIO_SCHMITT_OFFSET); +#endif + +#ifdef PIO_HAVE_DRIVE + /* Configure drive strength */ + + drive = (cfgset & PIO_DRIVE_MASK) >> PIO_DRIVE_SHIFT; + if (pin < 32) + { + offset = SAM_PIO_DRIVER1_OFFSET; + mask = PIO_DRIVER1_LINE_MASK(pin); + shift = PIO_DRIVER1_LINE_SHIFT(pin); + } + else + { + offset = SAM_PIO_DRIVER2_OFFSET; + mask = PIO_DRIVER2_LINE_MASK(pin); + shift = PIO_DRIVER2_LINE_SHIFT(pin); + } + + regval = getreg32(base + offset); + regval &= ~mask; + regval |= drive << shift; + putreg32(regval, base + offset); +#endif + + /* Configure the pin as an input and enable the PIO function */ + + putreg32(pin, base + SAM_PIO_ODR_OFFSET); + putreg32(pin, base + SAM_PIO_PER_OFFSET); + + /* To-Do: If DEGLITCH is selected, need to configure DIFSR, SCIFSR, and + * IFDGSR registers. This would probably best be done with + * another, new API... perhaps sam_configfilter() + */ + + return OK; +} + +/**************************************************************************** + * Name: sam_configoutput + * + * Description: + * Configure a PIO output pin based on bit-encoded description of the pin. + * + ****************************************************************************/ + +static inline int sam_configoutput(uintptr_t base, uint32_t pin, + pio_pinset_t cfgset) +{ + /* Disable interrupts on the pin */ + + putreg32(pin, base + SAM_PIO_IDR_OFFSET); + + /* Enable/disable the pull-up as requested */ + + if ((cfgset & PIO_CFG_PULLUP) != 0) + { + putreg32(pin, base + SAM_PIO_PUER_OFFSET); + } + else + { + putreg32(pin, base + SAM_PIO_PUDR_OFFSET); + } + +#ifdef PIO_HAVE_PULLDOWN + /* Enable/disable the pull-down as requested */ + + if ((cfgset & PIO_CFG_PULLDOWN) != 0) + { + putreg32(pin, base + SAM_PIO_PPDER_OFFSET); + } + else + { + putreg32(pin, base + SAM_PIO_PPDDR_OFFSET); + } +#endif + + /* Enable the open drain driver if requrested */ + + if ((cfgset & PIO_CFG_OPENDRAIN) != 0) + { + putreg32(pin, base + SAM_PIO_MDER_OFFSET); + } + else + { + putreg32(pin, base + SAM_PIO_MDDR_OFFSET); + } + + /* Set default value */ + + if ((cfgset & PIO_OUTPUT_SET) != 0) + { + putreg32(pin, base + SAM_PIO_SODR_OFFSET); + } + else + { + putreg32(pin, base + SAM_PIO_CODR_OFFSET); + } + + /* Configure the pin as an output and enable the PIO function */ + + putreg32(pin, base + SAM_PIO_OER_OFFSET); + putreg32(pin, base + SAM_PIO_PER_OFFSET); + return OK; +} + +/**************************************************************************** + * Name: sam_configperiph + * + * Description: + * Configure a PIO pin driven by a peripheral A or B signal based on + * bit-encoded description of the pin. + * + ****************************************************************************/ + +static inline int sam_configperiph(uintptr_t base, uint32_t pin, + pio_pinset_t cfgset) +{ + uint32_t regval; + + /* Disable interrupts on the pin */ + + putreg32(pin, base + SAM_PIO_IDR_OFFSET); + + /* Enable/disable the pull-up as requested */ + + if ((cfgset & PIO_CFG_PULLUP) != 0) + { + putreg32(pin, base + SAM_PIO_PUER_OFFSET); + } + else + { + putreg32(pin, base + SAM_PIO_PUDR_OFFSET); + } + +#ifdef PIO_HAVE_PULLDOWN + /* Enable/disable the pull-down as requested */ + + if ((cfgset & PIO_CFG_PULLDOWN) != 0) + { + putreg32(pin, base + SAM_PIO_PPDER_OFFSET); + } + else + { + putreg32(pin, base + SAM_PIO_PPDDR_OFFSET); + } +#endif + +#ifdef PIO_HAVE_PERIPHCD + /* Configure pin, depending upon the peripheral A, B, C or D + * + * PERIPHA: ABCDSR1[n] = 0 ABCDSR2[n] = 0 + * PERIPHB: ABCDSR1[n] = 1 ABCDSR2[n] = 0 + * PERIPHC: ABCDSR1[n] = 0 ABCDSR2[n] = 1 + * PERIPHD: ABCDSR1[n] = 1 ABCDSR2[n] = 1 + */ + + regval = getreg32(base + SAM_PIO_ABCDSR1_OFFSET); + if ((cfgset & PIO_MODE_MASK) == PIO_PERIPHA || + (cfgset & PIO_MODE_MASK) == PIO_PERIPHC) + { + regval &= ~pin; + } + else + { + regval |= pin; + } + putreg32(regval, base + SAM_PIO_ABCDSR1_OFFSET); + + regval = getreg32(base + SAM_PIO_ABCDSR2_OFFSET); + if ((cfgset & PIO_MODE_MASK) == PIO_PERIPHA || + (cfgset & PIO_MODE_MASK) == PIO_PERIPHB) + { + regval &= ~pin; + } + else + { + regval |= pin; + } + putreg32(regval, base + SAM_PIO_ABCDSR2_OFFSET); + +#else + /* Configure pin, depending upon the peripheral A or B: + * + * PERIPHA: ABSR[n] = 0 + * PERIPHB: ABSR[n] = 1 + */ + + regval = getreg32(base + SAM_PIO_ABSR_OFFSET); + if ((cfgset & PIO_MODE_MASK) == PIO_PERIPHA) + { + regval &= ~pin; + } + else + { + regval |= pin; + } + putreg32(regval, base + SAM_PIO_ABSR_OFFSET); +#endif + + /* Disable PIO functionality */ + + putreg32(pin, base + SAM_PIO_PDR_OFFSET); + return OK; +} + +/**************************************************************************** + * Global Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: sam_configpio + * + * Description: + * Configure a PIO pin based on bit-encoded description of the pin. + * + ****************************************************************************/ + +int sam_configpio(pio_pinset_t cfgset) +{ + uintptr_t base = sam_piobase(cfgset); + uint32_t pin = sam_piopin(cfgset); + irqstate_t flags; + int ret; + + /* Disable interrupts to prohibit re-entrance. */ + + flags = irqsave(); + + /* Enable writing to PIO registers */ + + putreg32(PIO_WPMR_WPKEY, base + SAM_PIO_WPMR_OFFSET); + + /* Handle the pin configuration according to pin type */ + + switch (cfgset & PIO_MODE_MASK) + { + case PIO_INPUT: + ret = sam_configinput(base, pin, cfgset); + break; + + case PIO_OUTPUT: + ret = sam_configoutput(base, pin, cfgset); + break; + + case PIO_PERIPHA: + case PIO_PERIPHB: +#ifdef PIO_HAVE_PERIPHCD + case PIO_PERIPHC: + case PIO_PERIPHD: +#endif + ret = sam_configperiph(base, pin, cfgset); + break; + + default: + ret = -EINVAL; + break; + } + + /* Disable writing to PIO registers */ + + putreg32(PIO_WPMR_WPEN | PIO_WPMR_WPKEY, base + SAM_PIO_WPMR_OFFSET); + irqrestore(flags); + + return ret; +} + +/**************************************************************************** + * Name: sam_piowrite + * + * Description: + * Write one or zero to the selected PIO pin + * + ****************************************************************************/ + +void sam_piowrite(pio_pinset_t pinset, bool value) +{ + uintptr_t base = sam_piobase(pinset); + uint32_t pin = sam_piopin(pinset); + + if (value) + { + putreg32(pin, base + SAM_PIO_SODR_OFFSET); + } + else + { + putreg32(pin, base + SAM_PIO_CODR_OFFSET); + } +} + +/**************************************************************************** + * Name: sam_pioread + * + * Description: + * Read one or zero from the selected PIO pin + * + ****************************************************************************/ + +bool sam_pioread(pio_pinset_t pinset) +{ + uintptr_t base = sam_piobase(pinset); + uint32_t pin = sam_piopin(pinset); + uint32_t regval; + + if ((pinset & PIO_MODE_MASK) == PIO_OUTPUT) + { + regval = getreg32(base + SAM_PIO_ODSR_OFFSET); + } + else + { + regval = getreg32(base + SAM_PIO_PDSR_OFFSET); + } + + return (regval & pin) != 0; +} + +/************************************************************************************ + * Function: sam_dumppio + * + * Description: + * Dump all PIO registers associated with the base address of the provided pinset. + * + ************************************************************************************/ + +#ifdef CONFIG_DEBUG_GPIO +int sam_dumppio(uint32_t pinset, const char *msg) +{ + irqstate_t flags; + uintptr_t base; + unsigned int pin; + unsigned int port; + + /* Get the base address associated with the PIO port */ + + pin = sam_piopin(pinset); + port = (pinset & PIO_PORT_MASK) >> PIO_PORT_SHIFT; + base = SAM_PION_BASE(port); + + /* The following requires exclusive access to the PIO registers */ + + flags = irqsave(); + lldbg("PIO%c pinset: %08x base: %08x -- %s\n", + g_portchar[port], pinset, base, msg); + lldbg(" PSR: %08x OSR: %08x IFSR: %08x ODSR: %08x\n", + getreg32(base + SAM_PIO_PSR_OFFSET), getreg32(base + SAM_PIO_OSR_OFFSET), + getreg32(base + SAM_PIO_IFSR_OFFSET), getreg32(base + SAM_PIO_ODSR_OFFSET)); + lldbg(" PDSR: %08x IMR: %08x ISR: %08x MDSR: %08x\n", + getreg32(base + SAM_PIO_PDSR_OFFSET), getreg32(base + SAM_PIO_IMR_OFFSET), + getreg32(base + SAM_PIO_ISR_OFFSET), getreg32(base + SAM_PIO_MDSR_OFFSET)); + lldbg(" ABCDSR: %08x %08x IFSCSR: %08x PPDSR: %08x\n", + getreg32(base + SAM_PIO_ABCDSR1_OFFSET), getreg32(base + SAM_PIO_ABCDSR2_OFFSET), + getreg32(base + SAM_PIO_IFSCSR_OFFSET), getreg32(base + SAM_PIOC_PPDSR)); + lldbg(" PUSR: %08x SCDR: %08x OWSR: %08x AIMMR: %08x\n", + getreg32(base + SAM_PIO_PUSR_OFFSET), getreg32(base + SAM_PIO_SCDR_OFFSET), + getreg32(base + SAM_PIO_OWSR_OFFSET), getreg32(base + SAM_PIO_AIMMR_OFFSET)); + lldbg(" ESR: %08x LSR: %08x ELSR: %08x FELLSR: %08x\n", + getreg32(base + SAM_PIO_ESR_OFFSET), getreg32(base + SAM_PIO_LSR_OFFSET), + getreg32(base + SAM_PIO_ELSR_OFFSET), getreg32(base + SAM_PIO_FELLSR_OFFSET)); + lldbg(" FRLHSR: %08x LOCKSR: %08x WPMR: %08x WPSR: %08x\n", + getreg32(base + SAM_PIO_FRLHSR_OFFSET), getreg32(base + SAM_PIO_LOCKSR_OFFSET), + getreg32(base + SAM_PIO_WPMR_OFFSET), getreg32(base + SAM_PIO_WPSR_OFFSET)); + lldbg(" PCMR: %08x PCIMR: %08x PCISR: %08x PCRHR: %08x\n", + getreg32(base + SAM_PIO_PCMR_OFFSET), getreg32(base + SAM_PIO_PCIMR_OFFSET), + getreg32(base + SAM_PIO_PCISR_OFFSET), getreg32(base + SAM_PIO_PCRHR_OFFSET)); + lldbg("SCHMITT: %08x\n", + getreg32(base + SAM_PIO_SCHMITT_OFFSET)); + irqrestore(flags); + return OK; +} +#endif + diff --git a/nuttx/arch/arm/src/sama5/sam_pio.h b/nuttx/arch/arm/src/sama5/sam_pio.h new file mode 100644 index 000000000..e09f9a21c --- /dev/null +++ b/nuttx/arch/arm/src/sama5/sam_pio.h @@ -0,0 +1,339 @@ +/************************************************************************************ + * arch/arm/src/sama5/sam_pio.h + * Parallel Input/Output (PIO) definitions for the SAM4S + * + * Copyright (C) 2013 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_SAMA5_SAM_PIO_H +#define __ARCH_ARM_SRC_SAMA5_SAM_PIO_H + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +#include +#include + +/************************************************************************************ + * Definitions + ************************************************************************************/ +/* Configuration ********************************************************************/ + +#undef CONFIG_SAMA5_PIO_IRQ +#if defined(CONFIG_SAMA5_PIOA_IRQ) || defined(CONFIG_SAMA5_PIOB_IRQ) || \ + defined(CONFIG_SAMA5_PIOC_IRQ) || defined(CONFIG_SAMA5_PIOD_IRQ) || \ + defined(CONFIG_SAMA5_PIOD_IRQ) +# define CONFIG_SAMA5_PIO_IRQ 1 +#endif + +#ifndef CONFIG_DEBUG +# undef CONFIG_DEBUG_GPIO +#endif + +#define PIO_HAVE_PULLDOWN 1 +#define PIO_HAVE_PERIPHCD 1 +#define PIO_HAVE_SCHMITT 1 +#define PIO_HAVE_DRIVE 1 + +/* Bit-encoded input to sam_configpio() ********************************************/ + +/* 32-bit Encoding: + * + * ..MM MCCC CCDD IIIV PPPB BBBB + */ + +/* Input/Output mode: + * + * ..MM M... .... .... .... .... + */ + +#define PIO_MODE_SHIFT (19) /* Bits 19-21: PIO mode */ +#define PIO_MODE_MASK (7 << PIO_MODE_SHIFT) +# define PIO_INPUT (0 << PIO_MODE_SHIFT) /* Input */ +# define PIO_OUTPUT (1 << PIO_MODE_SHIFT) /* Output */ +# define PIO_PERIPHA (2 << PIO_MODE_SHIFT) /* Controlled by periph A signal */ +# define PIO_PERIPHB (3 << PIO_MODE_SHIFT) /* Controlled by periph B signal */ +# define PIO_PERIPHC (4 << PIO_MODE_SHIFT) /* Controlled by periph C signal */ +# define PIO_PERIPHD (5 << PIO_MODE_SHIFT) /* Controlled by periph D signal */ + +/* These bits set the configuration of the pin: + * NOTE: No definitions for parallel capture mode + * + * .... .CCC CC.. .... .... .... + */ + +#define PIO_CFG_SHIFT (14) /* Bits 14-18: PIO configuration bits */ +#define PIO_CFG_MASK (31 << PIO_CFG_SHIFT) +# define PIO_CFG_DEFAULT (0 << PIO_CFG_SHIFT) /* Default, no attribute */ +# define PIO_CFG_PULLUP (1 << PIO_CFG_SHIFT) /* Bit 11: Internal pull-up */ +# define PIO_CFG_PULLDOWN (2 << PIO_CFG_SHIFT) /* Bit 11: Internal pull-down */ +# define PIO_CFG_DEGLITCH (4 << PIO_CFG_SHIFT) /* Bit 12: Internal glitch filter */ +# define PIO_CFG_OPENDRAIN (8 << PIO_CFG_SHIFT) /* Bit 13: Open drain */ +# define PIO_CFG_SCHMITT (16 << PIO_CFG_SHIFT) /* Bit 13: Schmitt trigger */ + +/* Drive Strength: + * + * .... .... ..DD .... .... .... + */ + +#define PIO_DRIVE_SHIFT (12) /* Bits 12-13: Drive strength */ +#define PIO_DRIVE_MASK (7 << PIO_DRIVE_SHIFT) +# define PIO_DRIVE_LOW (0 << PIO_DRIVE_SHIFT) +# define PIO_DRIVE_MEDIUM (2 << PIO_DRIVE_SHIFT) +# define PIO_DRIVE_HIGH (3 << PIO_DRIVE_SHIFT) + +/* Additional interrupt modes: + * + * .... .... .... III. .... .... + */ + +#define PIO_INT_SHIFT (9) /* Bits 9-11: PIO interrupt bits */ +#define PIO_INT_MASK (7 << PIO_INT_SHIFT) +# define _PIO_INT_AIM (1 << 10) /* Bit 10: Additional Interrupt modes */ +# define _PIO_INT_LEVEL (1 << 9) /* Bit 9: Level detection interrupt */ +# define _PIO_INT_EDGE (0) /* (vs. Edge detection interrupt) */ +# define _PIO_INT_RH (1 << 8) /* Bit 9: Rising edge/High level detection interrupt */ +# define _PIO_INT_FL (0) /* (vs. Falling edge/Low level detection interrupt) */ + +# define PIO_INT_HIGHLEVEL (_PIO_INT_AIM | _PIO_INT_LEVEL | _PIO_INT_RH) +# define PIO_INT_LOWLEVEL (_PIO_INT_AIM | _PIO_INT_LEVEL | _PIO_INT_FL) +# define PIO_INT_RISING (_PIO_INT_AIM | _PIO_INT_EDGE | _PIO_INT_RH) +# define PIO_INT_FALLING (_PIO_INT_AIM | _PIO_INT_EDGE | _PIO_INT_FL) +# define PIO_INT_BOTHEDGES (0) + +/* If the pin is an PIO output, then this identifies the initial output value: + * + * .... .... .... ...V .... .... + */ + +#define PIO_OUTPUT_SET (1 << 8) /* Bit 8: Inital value of output */ +#define PIO_OUTPUT_CLEAR (0) + +/* This identifies the PIO port: + * + * .... .... .... .... PPP. .... + */ + +#define PIO_PORT_SHIFT (5) /* Bit 5-7: Port number */ +#define PIO_PORT_MASK (7 << PIO_PORT_SHIFT) +# define PIO_PORT_PIOA (0 << PIO_PORT_SHIFT) +# define PIO_PORT_PIOB (1 << PIO_PORT_SHIFT) +# define PIO_PORT_PIOC (2 << PIO_PORT_SHIFT) +# define PIO_PORT_PIOD (3 << PIO_PORT_SHIFT) +# define PIO_PORT_PIOE (4 << PIO_PORT_SHIFT) + +/* This identifies the bit in the port: + * + * .... .... .... .... ...B BBBB + */ + +#define PIO_PIN_SHIFT (0) /* Bits 0-4: PIO number: 0-31 */ +#define PIO_PIN_MASK (31 << PIO_PIN_SHIFT) +#define PIO_PIN0 (0 << PIO_PIN_SHIFT) +#define PIO_PIN1 (1 << PIO_PIN_SHIFT) +#define PIO_PIN2 (2 << PIO_PIN_SHIFT) +#define PIO_PIN3 (3 << PIO_PIN_SHIFT) +#define PIO_PIN4 (4 << PIO_PIN_SHIFT) +#define PIO_PIN5 (5 << PIO_PIN_SHIFT) +#define PIO_PIN6 (6 << PIO_PIN_SHIFT) +#define PIO_PIN7 (7 << PIO_PIN_SHIFT) +#define PIO_PIN8 (8 << PIO_PIN_SHIFT) +#define PIO_PIN9 (9 << PIO_PIN_SHIFT) +#define PIO_PIN10 (10 << PIO_PIN_SHIFT) +#define PIO_PIN11 (11 << PIO_PIN_SHIFT) +#define PIO_PIN12 (12 << PIO_PIN_SHIFT) +#define PIO_PIN13 (13 << PIO_PIN_SHIFT) +#define PIO_PIN14 (14 << PIO_PIN_SHIFT) +#define PIO_PIN15 (15 << PIO_PIN_SHIFT) +#define PIO_PIN16 (16 << PIO_PIN_SHIFT) +#define PIO_PIN17 (17 << PIO_PIN_SHIFT) +#define PIO_PIN18 (18 << PIO_PIN_SHIFT) +#define PIO_PIN19 (19 << PIO_PIN_SHIFT) +#define PIO_PIN20 (20 << PIO_PIN_SHIFT) +#define PIO_PIN21 (21 << PIO_PIN_SHIFT) +#define PIO_PIN22 (22 << PIO_PIN_SHIFT) +#define PIO_PIN23 (23 << PIO_PIN_SHIFT) +#define PIO_PIN24 (24 << PIO_PIN_SHIFT) +#define PIO_PIN25 (25 << PIO_PIN_SHIFT) +#define PIO_PIN26 (26 << PIO_PIN_SHIFT) +#define PIO_PIN27 (27 << PIO_PIN_SHIFT) +#define PIO_PIN28 (28 << PIO_PIN_SHIFT) +#define PIO_PIN29 (29 << PIO_PIN_SHIFT) +#define PIO_PIN30 (30 << PIO_PIN_SHIFT) +#define PIO_PIN31 (31 << PIO_PIN_SHIFT) + +/************************************************************************************ + * Public Types + ************************************************************************************/ + +/* Must be big enough to hold the 32-bit encoding */ + +typedef uint32_t pio_pinset_t; + +/************************************************************************************ + * Inline Functions + ************************************************************************************/ + +#ifndef __ASSEMBLY__ + +/************************************************************************************ + * Public Data + ************************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/************************************************************************************ + * Public Function Prototypes + ************************************************************************************/ + +/************************************************************************************ + * Name: sam_pioirqinitialize + * + * Description: + * Initialize logic to support a second level of interrupt decoding for PIO pins. + * + ************************************************************************************/ + +#ifdef CONFIG_SAMA5_PIO_IRQ +void sam_pioirqinitialize(void); +#else +# define sam_pioirqinitialize() +#endif + +/************************************************************************************ + * Name: sam_configpio + * + * Description: + * Configure a PIO pin based on bit-encoded description of the pin. + * + ************************************************************************************/ + +int sam_configpio(pio_pinset_t cfgset); + +/************************************************************************************ + * Name: sam_piowrite + * + * Description: + * Write one or zero to the selected PIO pin + * + ************************************************************************************/ + +void sam_piowrite(pio_pinset_t pinset, bool value); + +/************************************************************************************ + * Name: sam_pioread + * + * Description: + * Read one or zero from the selected PIO pin + * + ************************************************************************************/ + +bool sam_pioread(pio_pinset_t pinset); + +/************************************************************************************ + * Name: sam_pioirq + * + * Description: + * Configure an interrupt for the specified PIO pin. + * + ************************************************************************************/ + +#ifdef CONFIG_SAMA5_PIO_IRQ +void sam_pioirq(pio_pinset_t pinset); +#else +# define sam_pioirq(pinset) +#endif + +/************************************************************************************ + * Name: sam_pioirqenable + * + * Description: + * Enable the interrupt for specified PIO IRQ + * + ************************************************************************************/ + +#ifdef CONFIG_SAMA5_PIO_IRQ +void sam_pioirqenable(int irq); +#else +# define sam_pioirqenable(irq) +#endif + +/************************************************************************************ + * Name: sam_pioirqdisable + * + * Description: + * Disable the interrupt for specified PIO IRQ + * + ************************************************************************************/ + +#ifdef CONFIG_SAMA5_PIO_IRQ +void sam_pioirqdisable(int irq); +#else +# define sam_pioirqdisable(irq) +#endif + +/************************************************************************************ + * Function: sam_dumppio + * + * Description: + * Dump all PIO registers associated with the base address of the provided pinset. + * + ************************************************************************************/ + +#ifdef CONFIG_DEBUG_GPIO +int sam_dumppio(uint32_t pinset, const char *msg); +#else +# define sam_dumppio(p,m) +#endif + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __ARCH_ARM_SRC_SAMA5_SAM_PIO_H */ diff --git a/nuttx/arch/arm/src/sama5/sam_pioirq.c b/nuttx/arch/arm/src/sama5/sam_pioirq.c new file mode 100644 index 000000000..f80dcdc56 --- /dev/null +++ b/nuttx/arch/arm/src/sama5/sam_pioirq.c @@ -0,0 +1,462 @@ +/**************************************************************************** + * arch/arm/src/sama5/sam_pioirq.c + * + * Copyright (C) 2013 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "up_arch.h" +#include "up_internal.h" + +#include "sam_pio.h" +#include "sam_periphclks.h" +#include "chip/sam_pio.h" +#include "chip/sam_pmc.h" + +#ifdef CONFIG_SAMA5_PIO_IRQ + +/**************************************************************************** + * Private Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: sam_piobase + * + * Description: + * Return the base address of the PIO register set + * + ****************************************************************************/ + +static inline uint32_t sam_piobase(pio_pinset_t pinset) +{ + int port = (pinset & PIO_PORT_MASK) >> PIO_PORT_SHIFT; + return SAM_PION_VBASE(port >> PIO_PORT_SHIFT); +} + +/**************************************************************************** + * Name: sam_piopin + * + * Description: + * Returun the base address of the PIO register set + * + ****************************************************************************/ + +static inline int sam_piopin(pio_pinset_t pinset) +{ + return 1 << ((pinset & PIO_PIN_MASK) >> PIO_PIN_SHIFT); +} + +/**************************************************************************** + * Name: sam_irqbase + * + * Description: + * Return pio information associated with this IRQ + * + ****************************************************************************/ + +static int sam_irqbase(int irq, uint32_t *base, int *pin) +{ + if (irq >= SAM_IRQ_NINT) + { +#ifdef CONFIG_SAMA5_PIOA_IRQ + if (irq <= SAM_IRQ_PA31) + { + *base = SAM_PIOA_VBASE; + *pin = irq - SAM_IRQ_PA0; + return OK; + } +#endif +#ifdef CONFIG_SAMA5_PIOB_IRQ + if (irq <= SAM_IRQ_PB31) + { + *base = SAM_PIOB_VBASE; + *pin = irq - SAM_IRQ_PB0; + return OK; + } +#endif +#ifdef CONFIG_SAMA5_PIOC_IRQ + if (irq <= SAM_IRQ_PC31) + { + *base = SAM_PIOC_VBASE; + *pin = irq - SAM_IRQ_PC0; + return OK; + } +#endif +#ifdef CONFIG_SAMA5_PIOD_IRQ + if (irq <= SAM_IRQ_PD31) + { + *base = SAM_PIOD_VBASE; + *pin = irq - SAM_IRQ_PD0; + return OK; + } +#endif +#ifdef CONFIG_SAMA5_PIOE_IRQ + if (irq <= SAM_IRQ_PE31) + { + *base = SAM_PIOE_VBASE; + *pin = irq - SAM_IRQ_PE0; + return OK; + } +#endif +#ifdef CONFIG_SAMA5_PIOF_IRQ + if (irq <= SAM_IRQ_PF31) + { + *base = SAM_PIOF_VBASE; + *pin = irq - SAM_IRQ_PF0; + return OK; + } +#endif + } + + return -EINVAL; +} + +/**************************************************************************** + * Name: sam_pioa/b/cinterrupt + * + * Description: + * Receive PIOA/B/C interrupts + * + ****************************************************************************/ + +static int sam_piointerrupt(uint32_t base, int irq0, void *context) +{ + uint32_t pending; + uint32_t bit; + int irq; + + pending = getreg32(base + SAM_PIO_ISR_OFFSET) & getreg32(base + SAM_PIO_IMR_OFFSET); + for (bit = 1, irq = irq0; pending != 0; bit <<= 1, irq++) + { + if ((pending & bit) != 0) + { + /* Re-deliver the IRQ (recurses! We got here from irq_dispatch!) */ + + irq_dispatch(irq, context); + + /* Remove this from the set of pending interrupts */ + + pending &= ~bit; + } + } + return OK; +} + +#ifdef CONFIG_SAMA5_PIOA_IRQ +static int sam_pioainterrupt(int irq, void *context) +{ + return sam_piointerrupt(SAM_PIOA_VBASE, SAM_IRQ_PA0, context); +} +#endif + +#ifdef CONFIG_SAMA5_PIOB_IRQ +static int sam_piobinterrupt(int irq, void *context) +{ + return sam_piointerrupt(SAM_PIOB_VBASE, SAM_IRQ_PB0, context); +} +#endif + +#ifdef CONFIG_SAMA5_PIOC_IRQ +static int sam_piocinterrupt(int irq, void *context) +{ + return sam_piointerrupt(SAM_PIOC_VBASE, SAM_IRQ_PC0, context); +} +#endif + +#ifdef CONFIG_SAMA5_PIOD_IRQ +static int sam_piodinterrupt(int irq, void *context) +{ + return sam_piointerrupt(SAM_PIOD_VBASE, SAM_IRQ_PD0, context); +} +#endif + +#ifdef CONFIG_SAMA5_PIOE_IRQ +static int sam_pioeinterrupt(int irq, void *context) +{ + return sam_piointerrupt(SAM_PIOE_VBASE, SAM_IRQ_PE0, context); +} +#endif + +#ifdef CONFIG_SAMA5_PIOF_IRQ +static int sam_piofinterrupt(int irq, void *context) +{ + return sam_piointerrupt(SAM_PIOF_VBASE, SAM_IRQ_PF0, context); +} +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: sam_pioirqinitialize + * + * Description: + * Initialize logic to support a second level of interrupt decoding for + * PIO pins. + * + ****************************************************************************/ + +void sam_pioirqinitialize(void) +{ + /* Configure PIOA interrupts */ + +#ifdef CONFIG_SAMA5_PIOA_IRQ + /* Enable PIOA clocking */ + + sam_pioa_enableclk(); + + /* Clear and disable all PIOA interrupts */ + + (void)getreg32(SAM_PIOA_ISR); + putreg32(0xffffffff, SAM_PIOA_IDR); + + /* Attach and enable the PIOA IRQ */ + + (void)irq_attach(SAM_IRQ_PIOA, sam_pioainterrupt); + up_enable_irq(SAM_IRQ_PIOA); +#endif + + /* Configure PIOB interrupts */ + +#ifdef CONFIG_SAMA5_PIOB_IRQ + /* Enable PIOB clocking */ + + sam_piob_enableclk(); + + /* Clear and disable all PIOB interrupts */ + + (void)getreg32(SAM_PIOB_ISR); + putreg32(0xffffffff, SAM_PIOB_IDR); + + /* Attach and enable the PIOB IRQ */ + + (void)irq_attach(SAM_IRQ_PIOB, sam_piobinterrupt); + up_enable_irq(SAM_IRQ_PIOB); +#endif + + /* Configure PIOC interrupts */ + +#ifdef CONFIG_SAMA5_PIOC_IRQ + /* Enable PIOC clocking */ + + sam_pioc_enableclk(); + + /* Clear and disable all PIOC interrupts */ + + (void)getreg32(SAM_PIOC_ISR); + putreg32(0xffffffff, SAM_PIOC_IDR); + + /* Attach and enable the PIOC IRQ */ + + (void)irq_attach(SAM_IRQ_PIOC, sam_piocinterrupt); + up_enable_irq(SAM_IRQ_PIOC); +#endif + + /* Configure PIOD interrupts */ + +#ifdef CONFIG_SAMA5_PIOD_IRQ + /* Enable PIOD clocking */ + + sam_piod_enableclk(); + + /* Clear and disable all PIOD interrupts */ + + (void)getreg32(SAM_PIOD_ISR); + putreg32(0xffffffff, SAM_PIOD_IDR); + + /* Attach and enable the PIOC IRQ */ + + (void)irq_attach(SAM_IRQ_PIOD, sam_piodinterrupt); + up_enable_irq(SAM_IRQ_PIOD); +#endif + + /* Configure PIOE interrupts */ + +#ifdef CONFIG_SAMA5_PIOE_IRQ + /* Enable PIOE clocking */ + + sam_pioe_enableclk(); + + /* Clear and disable all PIOE interrupts */ + + (void)getreg32(SAM_PIOE_ISR); + putreg32(0xffffffff, SAM_PIOE_IDR); + + /* Attach and enable the PIOE IRQ */ + + (void)irq_attach(SAM_IRQ_PIOE, sam_pioeinterrupt); + up_enable_irq(SAM_IRQ_PIOE); +#endif + + /* Configure PIOF interrupts */ + +#ifdef CONFIG_SAMA5_PIOF_IRQ + /* Enable PIOF clocking */ + + sam_piof_enableclk(); + + /* Clear and disable all PIOF interrupts */ + + (void)getreg32(SAM_PIOF_ISR); + putreg32(0xffffffff, SAM_PIOF_IDR); + + /* Attach and enable the PIOF IRQ */ + + (void)irq_attach(SAM_IRQ_PIOF, sam_piofinterrupt); + up_enable_irq(SAM_IRQ_PIOF); +#endif +} + +/************************************************************************************ + * Name: sam_pioirq + * + * Description: + * Configure an interrupt for the specified PIO pin. + * + ************************************************************************************/ + +void sam_pioirq(pio_pinset_t pinset) +{ + uint32_t base = sam_piobase(pinset); + int pin = sam_piopin(pinset); + + /* Are any additional interrupt modes selected? */ + + if ((pinset & _PIO_INT_AIM) != 0) + { + /* Yes.. Enable additional interrupt mode */ + + putreg32(pin, base + SAM_PIO_AIMER_OFFSET); + + /* Level or edge detected interrupt? */ + + if ((pinset & _PIO_INT_LEVEL) != 0) + { + putreg32(pin, base + SAM_PIO_LSR_OFFSET); /* Level */ + } + else + { + putreg32(pin, base + SAM_PIO_ESR_OFFSET); /* Edge */ + } + + /* High level/rising edge or low level /falling edge? */ + + if ((pinset & _PIO_INT_RH) != 0) + { + putreg32(pin, base + SAM_PIO_REHLSR_OFFSET); /* High level/Rising edge */ + } + else + { + putreg32(pin, base + SAM_PIO_FELLSR_OFFSET); /* Low level/Falling edge */ + } + } + else + { + /* No.. Disable additional interrupt mode */ + + putreg32(pin, base + SAM_PIO_AIMDR_OFFSET); + } +} + +/************************************************************************************ + * Name: sam_pioirqenable + * + * Description: + * Enable the interrupt for specified PIO IRQ + * + ************************************************************************************/ + +void sam_pioirqenable(int irq) +{ + uint32_t base; + int pin; + + if (sam_irqbase(irq, &base, &pin) == OK) + { + /* Clear (all) pending interrupts and enable this pin interrupt */ + + //(void)getreg32(base + SAM_PIO_ISR_OFFSET); + putreg32((1 << pin), base + SAM_PIO_IER_OFFSET); + } +} + +/************************************************************************************ + * Name: sam_pioirqdisable + * + * Description: + * Disable the interrupt for specified PIO IRQ + * + ************************************************************************************/ + +void sam_pioirqdisable(int irq) +{ + uint32_t base; + int pin; + + if (sam_irqbase(irq, &base, &pin) == OK) + { + /* Disable this pin interrupt */ + + putreg32((1 << pin), base + SAM_PIO_IDR_OFFSET); + } +} + +#endif /* CONFIG_SAMA5_PIO_IRQ */ diff --git a/nuttx/arch/arm/src/sama5/sam_serial.c b/nuttx/arch/arm/src/sama5/sam_serial.c index 017584c4f..ebf1e4166 100644 --- a/nuttx/arch/arm/src/sama5/sam_serial.c +++ b/nuttx/arch/arm/src/sama5/sam_serial.c @@ -1122,7 +1122,7 @@ static bool up_txempty(struct uart_dev_s *dev) void sam_earlyserialinit(void) { - /* NOTE: All GPIO configuration for the USARTs was performed in + /* NOTE: All PIO configuration for the USARTs was performed in * sam_lowsetup */ diff --git a/nuttx/arch/arm/src/sama5/sam_spi.c b/nuttx/arch/arm/src/sama5/sam_spi.c index 3199680b5..53122e959 100644 --- a/nuttx/arch/arm/src/sama5/sam_spi.c +++ b/nuttx/arch/arm/src/sama5/sam_spi.c @@ -60,7 +60,7 @@ #include "up_arch.h" #include "chip.h" -#include "sam_gpio.h" +#include "sam_pio.h" #include "sam_spi.h" #include "sam_periphclks.h" #include "chip/sam_pmc.h" @@ -602,9 +602,9 @@ static int spi_lock(struct spi_dev_s *dev, bool lock) * may be only stubs. * * An alternative way to program the PIO chip select pins is as normal - * GPIO outputs. In that case, the automatic control of the CS pins is + * PIO outputs. 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. */ @@ -1171,9 +1171,9 @@ struct spi_dev_s *up_spiinitialize(int port) * select pins must be selected by board-specific logic. */ - sam_configgpio(GPIO_SPI0_MISO); - sam_configgpio(GPIO_SPI0_MOSI); - sam_configgpio(GPIO_SPI0_SPCK); + sam_configpio(PIO_SPI0_MISO); + sam_configpio(PIO_SPI0_MOSI); + sam_configpio(PIO_SPI0_SPCK); } #endif #if defined(CONFIG_SAMA5_SPI0) && defined(CONFIG_SAMA5_SPI1) @@ -1187,9 +1187,9 @@ struct spi_dev_s *up_spiinitialize(int port) * select pins must be selected by board-specific logic. */ - sam_configgpio(GPIO_SPI1_MISO); - sam_configgpio(GPIO_SPI1_MOSI); - sam_configgpio(GPIO_SPI1_SPCK); + sam_configpio(PIO_SPI1_MISO); + sam_configpio(PIO_SPI1_MOSI); + sam_configpio(PIO_SPI1_SPCK); } #endif diff --git a/nuttx/arch/arm/src/sama5/sam_spi.h b/nuttx/arch/arm/src/sama5/sam_spi.h index 615104774..bb8c5398a 100644 --- a/nuttx/arch/arm/src/sama5/sam_spi.h +++ b/nuttx/arch/arm/src/sama5/sam_spi.h @@ -122,10 +122,10 @@ extern "C" * 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 @@ enum spi_dev_e; * 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: @@ -207,7 +207,7 @@ uint8_t sam_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid); * may be configured to use 9-bit data transfers with the 9th bit * indicating command or data. That same hardware may be configurable, * instead, to use 8-bit data but to require an additional, board- - * specific GPIO control to distinguish command and data. This function + * specific PIO control to distinguish command and data. This function * would be needed in that latter case. * * Input Parameters: 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 +#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 #include -#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 #include +#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 -#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 -- cgit v1.2.3