2009-05-14 22:50:43 +02:00
|
|
|
/****************************************************************************
|
2014-03-08 20:29:09 +01:00
|
|
|
* arch/arm/src/tiva/tiva_gpioirq.c
|
2009-05-14 22:50:43 +02:00
|
|
|
*
|
2014-03-08 20:29:09 +01:00
|
|
|
* Copyright (C) 2009-2010, 2012, 2014 Gregory Nutt. All rights reserved.
|
2012-02-08 18:17:18 +01:00
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
2009-05-14 22:50:43 +02:00
|
|
|
*
|
|
|
|
* 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 <nuttx/config.h>
|
|
|
|
|
2009-12-16 21:05:51 +01:00
|
|
|
#include <stdint.h>
|
2009-05-14 22:50:43 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
#include <arch/irq.h>
|
|
|
|
|
|
|
|
#include "up_arch.h"
|
2014-08-08 22:31:15 +02:00
|
|
|
#include "irq/irq.h"
|
2013-01-08 20:27:38 +01:00
|
|
|
|
2014-03-08 20:29:09 +01:00
|
|
|
#include "tiva_gpio.h"
|
2009-05-14 22:50:43 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
2009-12-16 21:05:51 +01:00
|
|
|
* Pre-processor Definitions
|
2009-05-14 22:50:43 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* A table of handlers for each GPIO interrupt */
|
|
|
|
|
|
|
|
static FAR xcpt_t g_gpioirqvector[NR_GPIO_IRQS];
|
|
|
|
|
|
|
|
/* A table that maps a GPIO group to a GPIO base address. Overly complicated
|
2010-08-12 04:40:16 +02:00
|
|
|
* because we support disabling interrupt support for arbitrary ports. This
|
|
|
|
* must carefully match the IRQ numbers assigned in arch/arm/include/lm3s/irq.h
|
2009-05-14 22:50:43 +02:00
|
|
|
*/
|
|
|
|
|
2013-03-02 01:11:43 +01:00
|
|
|
static const uintptr_t g_gpiobase[] =
|
2009-05-14 22:50:43 +02:00
|
|
|
{
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOA_IRQS
|
|
|
|
TIVA_GPIOA_BASE
|
2013-03-02 01:11:43 +01:00
|
|
|
#else
|
|
|
|
0
|
2009-05-14 22:50:43 +02:00
|
|
|
#endif
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOB_IRQS
|
|
|
|
, TIVA_GPIOB_BASE
|
2009-05-14 22:50:43 +02:00
|
|
|
#endif
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOC_IRQS
|
|
|
|
, TIVA_GPIOC_BASE
|
2009-05-14 22:50:43 +02:00
|
|
|
#endif
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOD_IRQS
|
|
|
|
, TIVA_GPIOD_BASE
|
2009-05-14 22:50:43 +02:00
|
|
|
#endif
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOE_IRQS
|
|
|
|
, TIVA_GPIOE_BASE
|
2009-05-14 22:50:43 +02:00
|
|
|
#endif
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOF_IRQS
|
|
|
|
, TIVA_GPIOF_BASE
|
2009-05-14 22:50:43 +02:00
|
|
|
#endif
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOG_IRQS
|
|
|
|
, TIVA_GPIOG_BASE
|
2009-05-14 22:50:43 +02:00
|
|
|
#endif
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOH_IRQS
|
|
|
|
, TIVA_GPIOH_BASE
|
2009-05-14 22:50:43 +02:00
|
|
|
#endif
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOJ_IRQS
|
|
|
|
, TIVA_GPIOJ_BASE
|
2010-08-12 03:49:25 +02:00
|
|
|
#endif
|
2009-05-14 22:50:43 +02:00
|
|
|
};
|
2010-08-12 04:40:16 +02:00
|
|
|
|
2013-03-02 01:11:43 +01:00
|
|
|
#define GPIO_NADDRS (sizeof(g_gpiobase)/sizeof(uintptr_t))
|
2009-05-14 22:50:43 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2014-03-08 20:29:09 +01:00
|
|
|
* Name: tiva_gpiobaseaddress
|
2009-05-14 22:50:43 +02:00
|
|
|
*
|
2010-08-12 04:40:16 +02:00
|
|
|
* Input:
|
|
|
|
* gpioirq - A pin number in the range of 0 to NR_GPIO_IRQS.
|
|
|
|
*
|
2009-05-14 22:50:43 +02:00
|
|
|
* Description:
|
|
|
|
* Given a GPIO enumeration value, return the base address of the
|
2010-08-12 04:40:16 +02:00
|
|
|
* associated GPIO registers. NOTE that range checking was provided by
|
|
|
|
* callee
|
2009-05-14 22:50:43 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-03-08 20:29:09 +01:00
|
|
|
static uintptr_t tiva_gpiobaseaddress(unsigned int gpioirq)
|
2009-05-14 22:50:43 +02:00
|
|
|
{
|
2010-08-12 04:40:16 +02:00
|
|
|
unsigned int ndx = gpioirq >> 3;
|
|
|
|
if (ndx < GPIO_NADDRS)
|
2010-08-12 03:49:25 +02:00
|
|
|
{
|
2010-08-12 04:40:16 +02:00
|
|
|
return g_gpiobase[ndx];
|
2010-08-12 03:49:25 +02:00
|
|
|
}
|
2013-03-02 01:11:43 +01:00
|
|
|
|
2010-08-12 03:49:25 +02:00
|
|
|
return 0;
|
2009-05-14 22:50:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2014-03-08 20:29:09 +01:00
|
|
|
* Name: tiva_gpio*handler
|
2009-05-14 22:50:43 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Handle interrupts on each enabled GPIO port
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-03-08 20:29:09 +01:00
|
|
|
static int tiva_gpiohandler(uint32_t regbase, int irqbase, void *context)
|
2009-05-14 22:50:43 +02:00
|
|
|
{
|
2009-12-16 21:05:51 +01:00
|
|
|
uint32_t mis;
|
2009-05-14 22:50:43 +02:00
|
|
|
int irq;
|
|
|
|
int pin;
|
|
|
|
|
|
|
|
/* Handle each pending GPIO interrupt. "The GPIO MIS register is the masked
|
|
|
|
* interrupt status register. Bits read High in GPIO MIS reflect the status
|
|
|
|
* of input lines triggering an interrupt. Bits read as Low indicate that
|
|
|
|
* either no interrupt has been generated, or the interrupt is masked."
|
|
|
|
*/
|
|
|
|
|
2014-03-08 22:50:26 +01:00
|
|
|
mis = getreg32(regbase + TIVA_GPIO_MIS_OFFSET) & 0xff;
|
2009-05-14 22:50:43 +02:00
|
|
|
|
|
|
|
/* Clear all GPIO interrupts that we are going to process. "The GPIO ICR
|
|
|
|
* register is the interrupt clear register. Writing a 1 to a bit in this
|
|
|
|
* register clears the corresponding interrupt edge detection logic register.
|
|
|
|
* Writing a 0 has no effect."
|
|
|
|
*/
|
|
|
|
|
2014-03-08 22:50:26 +01:00
|
|
|
putreg32(mis, regbase + TIVA_GPIO_ICR_OFFSET);
|
2009-05-14 22:50:43 +02:00
|
|
|
|
|
|
|
/* Now process each IRQ pending in the MIS */
|
|
|
|
|
|
|
|
for (pin = 0; pin < 8 && mis != 0; pin++, mis >>= 1)
|
|
|
|
{
|
|
|
|
if ((mis & 1) != 0)
|
|
|
|
{
|
|
|
|
irq = irqbase + pin;
|
|
|
|
g_gpioirqvector[irq - NR_IRQS](irq, context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOA_IRQS
|
2014-03-08 20:29:09 +01:00
|
|
|
static int tiva_gpioahandler(int irq, FAR void *context)
|
2009-05-14 22:50:43 +02:00
|
|
|
{
|
2014-03-08 22:50:26 +01:00
|
|
|
return tiva_gpiohandler(TIVA_GPIOA_BASE, TIVA_IRQ_GPIOA_0, context);
|
2009-05-14 22:50:43 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOB_IRQS
|
2014-03-08 20:29:09 +01:00
|
|
|
static int tiva_gpiobhandler(int irq, FAR void *context)
|
2009-05-14 22:50:43 +02:00
|
|
|
{
|
2014-03-08 22:50:26 +01:00
|
|
|
return tiva_gpiohandler(TIVA_GPIOB_BASE, TIVA_IRQ_GPIOB_0, context);
|
2009-05-14 22:50:43 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOC_IRQS
|
2014-03-08 20:29:09 +01:00
|
|
|
static int tiva_gpiochandler(int irq, FAR void *context)
|
2009-05-14 22:50:43 +02:00
|
|
|
{
|
2014-03-08 22:50:26 +01:00
|
|
|
return tiva_gpiohandler(TIVA_GPIOC_BASE, TIVA_IRQ_GPIOC_0, context);
|
2009-05-14 22:50:43 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOD_IRQS
|
2014-03-08 20:29:09 +01:00
|
|
|
static int tiva_gpiodhandler(int irq, FAR void *context)
|
2009-05-14 22:50:43 +02:00
|
|
|
{
|
2014-03-08 22:50:26 +01:00
|
|
|
return tiva_gpiohandler(TIVA_GPIOD_BASE, TIVA_IRQ_GPIOD_0, context);
|
2009-05-14 22:50:43 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOE_IRQS
|
2014-03-08 20:29:09 +01:00
|
|
|
static int tiva_gpioehandler(int irq, FAR void *context)
|
2009-05-14 22:50:43 +02:00
|
|
|
{
|
2014-03-08 22:50:26 +01:00
|
|
|
return tiva_gpiohandler(TIVA_GPIOE_BASE, TIVA_IRQ_GPIOE_0, context);
|
2009-05-14 22:50:43 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOF_IRQS
|
2014-03-08 20:29:09 +01:00
|
|
|
static int tiva_gpiofhandler(int irq, FAR void *context)
|
2009-05-14 22:50:43 +02:00
|
|
|
{
|
2014-03-08 22:50:26 +01:00
|
|
|
return tiva_gpiohandler(TIVA_GPIOF_BASE, TIVA_IRQ_GPIOF_0, context);
|
2009-05-14 22:50:43 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOG_IRQS
|
2014-03-08 20:29:09 +01:00
|
|
|
static int tiva_gpioghandler(int irq, FAR void *context)
|
2009-05-14 22:50:43 +02:00
|
|
|
{
|
2014-03-08 22:50:26 +01:00
|
|
|
return tiva_gpiohandler(TIVA_GPIOG_BASE, TIVA_IRQ_GPIOG_0, context);
|
2009-05-14 22:50:43 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOH_IRQS
|
2014-03-08 20:29:09 +01:00
|
|
|
static int tiva_gpiohhandler(int irq, FAR void *context)
|
2009-05-14 22:50:43 +02:00
|
|
|
{
|
2014-03-08 22:50:26 +01:00
|
|
|
return tiva_gpiohandler(TIVA_GPIOH_BASE, TIVA_IRQ_GPIOH_0, context);
|
2009-05-14 22:50:43 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOJ_IRQS
|
2014-03-08 20:29:09 +01:00
|
|
|
static int tiva_gpiojhandler(int irq, FAR void *context)
|
2010-08-13 06:29:10 +02:00
|
|
|
{
|
2014-03-08 22:50:26 +01:00
|
|
|
return tiva_gpiohandler(TIVA_GPIOJ_BASE, TIVA_IRQ_GPIOJ_0, context);
|
2010-08-13 06:29:10 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-05-14 22:50:43 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: gpio_irqinitialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Initialize all vectors to the unexpected interrupt handler
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int gpio_irqinitialize(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Point all interrupt vectors to the unexpected interrupt */
|
|
|
|
|
|
|
|
for (i = 0; i < NR_GPIO_IRQS; i++)
|
|
|
|
{
|
|
|
|
g_gpioirqvector[i] = irq_unexpected_isr;
|
|
|
|
}
|
|
|
|
|
2010-08-12 04:48:34 +02:00
|
|
|
/* Then attach each GPIO interrupt handlers and enable corresponding GPIO
|
|
|
|
* interrupts
|
|
|
|
*/
|
2009-05-14 22:50:43 +02:00
|
|
|
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOA_IRQS
|
|
|
|
irq_attach(TIVA_IRQ_GPIOA, tiva_gpioahandler);
|
|
|
|
up_enable_irq(TIVA_IRQ_GPIOA);
|
2009-05-14 22:50:43 +02:00
|
|
|
#endif
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOB_IRQS
|
|
|
|
irq_attach(TIVA_IRQ_GPIOB, tiva_gpiobhandler);
|
|
|
|
up_enable_irq(TIVA_IRQ_GPIOB);
|
2009-05-14 22:50:43 +02:00
|
|
|
#endif
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOC_IRQS
|
|
|
|
irq_attach(TIVA_IRQ_GPIOC, tiva_gpiochandler);
|
|
|
|
up_enable_irq(TIVA_IRQ_GPIOC);
|
2009-05-14 22:50:43 +02:00
|
|
|
#endif
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOD_IRQS
|
|
|
|
irq_attach(TIVA_IRQ_GPIOD, tiva_gpiodhandler);
|
|
|
|
up_enable_irq(TIVA_IRQ_GPIOD);
|
2009-05-14 22:50:43 +02:00
|
|
|
#endif
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOE_IRQS
|
|
|
|
irq_attach(TIVA_IRQ_GPIOE, tiva_gpioehandler);
|
|
|
|
up_enable_irq(TIVA_IRQ_GPIOE);
|
2009-05-14 22:50:43 +02:00
|
|
|
#endif
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOF_IRQS
|
|
|
|
irq_attach(TIVA_IRQ_GPIOF, tiva_gpiofhandler);
|
|
|
|
up_enable_irq(TIVA_IRQ_GPIOF);
|
2009-05-14 22:50:43 +02:00
|
|
|
#endif
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOG_IRQS
|
|
|
|
irq_attach(TIVA_IRQ_GPIOG, tiva_gpioghandler);
|
|
|
|
up_enable_irq(TIVA_IRQ_GPIOG);
|
2009-05-14 22:50:43 +02:00
|
|
|
#endif
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOH_IRQS
|
|
|
|
irq_attach(TIVA_IRQ_GPIOH, tiva_gpiohhandler);
|
|
|
|
up_enable_irq(TIVA_IRQ_GPIOH);
|
2010-08-12 04:48:34 +02:00
|
|
|
#endif
|
2014-03-08 22:50:26 +01:00
|
|
|
#ifndef CONFIG_TIVA_DISABLE_GPIOJ_IRQS
|
|
|
|
irq_attach(TIVA_IRQ_GPIOJ, tiva_gpiojhandler);
|
|
|
|
up_enable_irq(TIVA_IRQ_GPIOJ);
|
2009-05-14 22:50:43 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: gpio_irqattach
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Attach in GPIO interrupt to the provide 'isr'
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int gpio_irqattach(int irq, xcpt_t isr)
|
|
|
|
{
|
|
|
|
irqstate_t flags;
|
|
|
|
int gpioirq = irq - NR_IRQS;
|
|
|
|
int ret = ERROR;
|
|
|
|
|
|
|
|
if ((unsigned)gpioirq < NR_GPIO_IRQS)
|
|
|
|
{
|
|
|
|
flags = irqsave();
|
|
|
|
|
|
|
|
/* If the new ISR is NULL, then the ISR is being detached.
|
|
|
|
* In this case, disable the ISR and direct any interrupts
|
|
|
|
* to the unexpected interrupt handler.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (isr == NULL)
|
|
|
|
{
|
|
|
|
#ifndef CONFIG_ARCH_NOINTC
|
|
|
|
gpio_irqdisable(gpioirq);
|
|
|
|
#endif
|
|
|
|
isr = irq_unexpected_isr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save the new ISR in the table. */
|
|
|
|
|
|
|
|
g_irqvector[gpioirq] = isr;
|
|
|
|
irqrestore(flags);
|
|
|
|
ret = OK;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: gpio_irqenable
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Enable the GPIO IRQ specified by 'irq'
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void gpio_irqenable(int irq)
|
|
|
|
{
|
|
|
|
irqstate_t flags;
|
|
|
|
int gpioirq = irq - NR_IRQS;
|
2013-03-02 01:11:43 +01:00
|
|
|
uintptr_t base;
|
2009-12-16 21:05:51 +01:00
|
|
|
uint32_t regval;
|
2009-05-14 22:50:43 +02:00
|
|
|
int pin;
|
|
|
|
|
|
|
|
if ((unsigned)gpioirq < NR_GPIO_IRQS)
|
|
|
|
{
|
|
|
|
/* Get the base address of the GPIO module associated with this IRQ */
|
|
|
|
|
2014-03-08 20:29:09 +01:00
|
|
|
base = tiva_gpiobaseaddress(gpioirq);
|
2010-05-07 06:20:12 +02:00
|
|
|
DEBUGASSERT(base != 0);
|
2009-05-14 22:50:43 +02:00
|
|
|
pin = (1 << (gpioirq & 7));
|
|
|
|
|
|
|
|
/* Disable the GPIO interrupt. "The GPIO IM register is the interrupt
|
|
|
|
* mask register. Bits set to High in GPIO IM allow the corresponding
|
|
|
|
* pins to trigger their individual interrupts and the combined GPIO INTR
|
|
|
|
* line. Clearing a bit disables interrupt triggering on that pin. All
|
|
|
|
* bits are cleared by a reset.
|
|
|
|
*/
|
|
|
|
|
|
|
|
flags = irqsave();
|
2014-03-08 22:50:26 +01:00
|
|
|
regval = getreg32(base + TIVA_GPIO_IM_OFFSET);
|
2009-05-14 22:50:43 +02:00
|
|
|
regval |= pin;
|
2014-03-08 22:50:26 +01:00
|
|
|
putreg32(regval, base + TIVA_GPIO_IM_OFFSET);
|
2009-05-14 22:50:43 +02:00
|
|
|
irqrestore(flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: gpio_irqdisable
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Disable the GPIO IRQ specified by 'irq'
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
void gpio_irqdisable(int irq)
|
|
|
|
{
|
|
|
|
irqstate_t flags;
|
|
|
|
int gpioirq = irq - NR_IRQS;
|
2013-03-02 01:11:43 +01:00
|
|
|
uintptr_t base;
|
2009-12-16 21:05:51 +01:00
|
|
|
uint32_t regval;
|
2009-05-14 22:50:43 +02:00
|
|
|
int pin;
|
|
|
|
|
|
|
|
if ((unsigned)gpioirq < NR_GPIO_IRQS)
|
|
|
|
{
|
|
|
|
/* Get the base address of the GPIO module associated with this IRQ */
|
|
|
|
|
2014-03-08 20:29:09 +01:00
|
|
|
base = tiva_gpiobaseaddress(gpioirq);
|
2010-08-13 05:45:51 +02:00
|
|
|
DEBUGASSERT(base != 0);
|
2009-05-14 22:50:43 +02:00
|
|
|
pin = (1 << (gpioirq & 7));
|
|
|
|
|
|
|
|
/* Disable the GPIO interrupt. "The GPIO IM register is the interrupt
|
|
|
|
* mask register. Bits set to High in GPIO IM allow the corresponding
|
|
|
|
* pins to trigger their individual interrupts and the combined GPIO INTR
|
|
|
|
* line. Clearing a bit disables interrupt triggering on that pin. All
|
|
|
|
* bits are cleared by a reset.
|
|
|
|
*/
|
|
|
|
|
|
|
|
flags = irqsave();
|
2014-03-08 22:50:26 +01:00
|
|
|
regval = getreg32(base + TIVA_GPIO_IM_OFFSET);
|
2009-05-14 22:50:43 +02:00
|
|
|
regval &= ~pin;
|
2014-03-08 22:50:26 +01:00
|
|
|
putreg32(regval, base + TIVA_GPIO_IM_OFFSET);
|
2009-05-14 22:50:43 +02:00
|
|
|
irqrestore(flags);
|
|
|
|
}
|
|
|
|
}
|