From c5169b092a7ac62a95431f4de33436e24adac5d5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 13 Jun 2013 18:53:14 -0600 Subject: [PATCH] SAM3/4S GPIO interrupt changes --- arch/arm/src/sam34/sam3u_gpio.h | 25 +++++++++++++++---------- arch/arm/src/sam34/sam_gpioirq.c | 6 +++--- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/arch/arm/src/sam34/sam3u_gpio.h b/arch/arm/src/sam34/sam3u_gpio.h index 84f5430567..74716bb3ab 100644 --- a/arch/arm/src/sam34/sam3u_gpio.h +++ b/arch/arm/src/sam34/sam3u_gpio.h @@ -56,7 +56,7 @@ /* 16-bit Encoding: * - * MMCC CII. VPPB BBBB + * MMCC CIII VPPB BBBB */ /* Input/Output mode: @@ -85,17 +85,22 @@ /* Additional interrupt modes: * - * .... .II. .... .... + * .... .III .... .... */ -#define GPIO_INT_SHIFT (9) /* Bits 9-10: GPIO interrupt bits */ -#define GPIO_INT_MASK (3 << GPIO_INT_SHIFT) -# define GPIO_INT_LEVEL (1 << 10) /* Bit 10: Level detection interrupt */ -# define GPIO_INT_EDGE (0) /* (vs. Edge detection interrupt) */ -# define GPIO_INT_HIGHLEVEL (1 << 9) /* Bit 9: High level detection interrupt */ -# define GPIO_INT_LOWLEVEL (0) /* (vs. Low level detection interrupt) */ -# define GPIO_INT_RISING (1 << 9) /* Bit 9: Rising edge detection interrupt */ -# define GPIO_INT_FALLING (0) /* (vs. Falling edge detection interrupt) */ +#define GPIO_INT_SHIFT (8) /* Bits 8-10: 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: * diff --git a/arch/arm/src/sam34/sam_gpioirq.c b/arch/arm/src/sam34/sam_gpioirq.c index b7c7ead278..11ea34aa66 100644 --- a/arch/arm/src/sam34/sam_gpioirq.c +++ b/arch/arm/src/sam34/sam_gpioirq.c @@ -280,7 +280,7 @@ void sam_gpioirq(uint16_t pinset) /* Are any additional interrupt modes selected? */ - if ((pinset & GPIO_INT_MASK) != 0) + if ((pinset & _GIO_INT_AIM) != 0) { /* Yes.. Enable additional interrupt mode */ @@ -288,7 +288,7 @@ void sam_gpioirq(uint16_t pinset) /* Level or edge detected interrupt? */ - if ((pinset & GPIO_INT_LEVEL) != 0) + if ((pinset & _GPIO_INT_LEVEL) != 0) { putreg32(pin, base + SAM_PIO_LSR_OFFSET); /* Level */ } @@ -299,7 +299,7 @@ void sam_gpioirq(uint16_t pinset) /* High level/rising edge or low level /falling edge? */ - if ((pinset & GPIO_INT_HIGHLEVEL) != 0) + if ((pinset & _GPIO_INT_RH) != 0) { putreg32(pin, base + SAM_PIO_REHLSR_OFFSET); /* High level/Rising edge */ }