2012-09-13 20:32:24 +02:00
|
|
|
/************************************************************************************
|
2019-07-11 18:50:00 +02:00
|
|
|
* arch/arm/src/lpc17xx_40xx/lpc17_40_gpio.h
|
2012-09-13 20:32:24 +02:00
|
|
|
*
|
2013-01-18 20:16:44 +01:00
|
|
|
* Copyright (C) 2010, 2013 Gregory Nutt. All rights reserved.
|
2012-09-13 20:32:24 +02:00
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
************************************************************************************/
|
|
|
|
|
2019-07-11 18:50:00 +02:00
|
|
|
#ifndef __ARCH_ARM_SRC_LPC17XX_40XX_LPC17_40_GPIO_H
|
|
|
|
#define __ARCH_ARM_SRC_LPC17XX_40XX_LPC17_40_GPIO_H
|
2012-09-13 20:32:24 +02:00
|
|
|
|
|
|
|
/************************************************************************************
|
|
|
|
* Included Files
|
|
|
|
************************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2013-01-18 20:16:44 +01:00
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
# include <stdint.h>
|
2013-02-13 18:29:28 +01:00
|
|
|
# include <stdbool.h>
|
2013-01-18 20:16:44 +01:00
|
|
|
#endif
|
|
|
|
|
2019-07-11 18:50:00 +02:00
|
|
|
#include <arch/lpc17xx_40xx/chip.h>
|
2013-01-18 21:25:32 +01:00
|
|
|
|
2019-07-11 18:50:00 +02:00
|
|
|
#include "hardware/lpc17_40_gpio.h"
|
|
|
|
#include "hardware/lpc17_40_pinconn.h"
|
|
|
|
#include "hardware/lpc17_40_pinconfig.h"
|
2012-09-13 20:32:24 +02:00
|
|
|
|
2019-07-11 18:50:00 +02:00
|
|
|
/* Include the GPIO definitions for the selected LPC17xx/LPC40xx family. */
|
2012-09-13 20:32:24 +02:00
|
|
|
|
2013-01-18 21:25:32 +01:00
|
|
|
#if defined(LPC176x)
|
2013-04-04 01:47:43 +02:00
|
|
|
# include "lpc176x_gpio.h"
|
2019-07-11 18:50:00 +02:00
|
|
|
#elif defined(LPC178x_40xx)
|
|
|
|
# include "lpc178x_40xx_gpio.h"
|
2013-01-18 21:25:32 +01:00
|
|
|
#else
|
2019-07-11 18:50:00 +02:00
|
|
|
# error "Unrecognized LPC17xx/LPC40xx family"
|
2013-01-18 21:25:32 +01:00
|
|
|
#endif
|
|
|
|
|
2012-09-13 20:32:24 +02:00
|
|
|
/************************************************************************************
|
2013-04-04 01:47:43 +02:00
|
|
|
* Pre-processor Definitions
|
2012-09-13 20:32:24 +02:00
|
|
|
************************************************************************************/
|
|
|
|
|
2013-04-04 01:47:43 +02:00
|
|
|
/************************************************************************************
|
|
|
|
* Public Types
|
|
|
|
************************************************************************************/
|
2013-01-18 21:25:32 +01:00
|
|
|
|
2012-09-13 20:32:24 +02:00
|
|
|
/************************************************************************************
|
|
|
|
* Public Data
|
|
|
|
************************************************************************************/
|
|
|
|
|
2013-01-18 20:16:44 +01:00
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
#define EXTERN extern "C"
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
2019-07-11 18:50:00 +02:00
|
|
|
/* These tables have global scope only because they are shared between lpc17_40_gpio.c,
|
|
|
|
* lpc17_40_gpioint.c, and lpc17_40_gpiodbg.c
|
2013-01-18 20:16:44 +01:00
|
|
|
*/
|
|
|
|
|
2019-07-11 18:50:00 +02:00
|
|
|
#ifdef CONFIG_LPC17_40_GPIOIRQ
|
2013-01-18 20:16:44 +01:00
|
|
|
EXTERN uint64_t g_intedge0;
|
|
|
|
EXTERN uint64_t g_intedge2;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
EXTERN const uint32_t g_fiobase[GPIO_NPORTS];
|
|
|
|
EXTERN const uint32_t g_intbase[GPIO_NPORTS];
|
|
|
|
|
|
|
|
/****************************************************************************
|
2012-09-13 20:32:24 +02:00
|
|
|
* Public Functions
|
2013-01-18 20:16:44 +01:00
|
|
|
****************************************************************************/
|
|
|
|
|
2013-01-18 21:25:32 +01:00
|
|
|
/************************************************************************************
|
2019-07-11 18:50:00 +02:00
|
|
|
* Name: lpc17_40_gpioirqinitialize
|
2013-01-18 21:25:32 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Initialize logic to support a second level of interrupt decoding for GPIO pins.
|
|
|
|
*
|
|
|
|
************************************************************************************/
|
|
|
|
|
2019-07-11 18:50:00 +02:00
|
|
|
#ifdef CONFIG_LPC17_40_GPIOIRQ
|
|
|
|
void lpc17_40_gpioirqinitialize(void);
|
2013-01-18 21:25:32 +01:00
|
|
|
#else
|
2019-07-11 18:50:00 +02:00
|
|
|
# define lpc17_40_gpioirqinitialize()
|
2013-01-18 21:25:32 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/************************************************************************************
|
2019-07-11 18:50:00 +02:00
|
|
|
* Name: lpc17_40_configgpio
|
2013-01-18 21:25:32 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Configure a GPIO pin based on bit-encoded description of the pin.
|
|
|
|
*
|
|
|
|
************************************************************************************/
|
|
|
|
|
2019-07-11 18:50:00 +02:00
|
|
|
int lpc17_40_configgpio(lpc17_40_pinset_t cfgset);
|
2013-01-18 21:25:32 +01:00
|
|
|
|
|
|
|
/************************************************************************************
|
2019-07-11 18:50:00 +02:00
|
|
|
* Name: lpc17_40_gpiowrite
|
2013-01-18 21:25:32 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Write one or zero to the selected GPIO pin
|
|
|
|
*
|
|
|
|
************************************************************************************/
|
|
|
|
|
2019-07-11 18:50:00 +02:00
|
|
|
void lpc17_40_gpiowrite(lpc17_40_pinset_t pinset, bool value);
|
2013-01-18 21:25:32 +01:00
|
|
|
|
|
|
|
/************************************************************************************
|
2019-07-11 18:50:00 +02:00
|
|
|
* Name: lpc17_40_gpioread
|
2013-01-18 21:25:32 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Read one or zero from the selected GPIO pin
|
|
|
|
*
|
|
|
|
************************************************************************************/
|
|
|
|
|
2019-07-11 18:50:00 +02:00
|
|
|
bool lpc17_40_gpioread(lpc17_40_pinset_t pinset);
|
2013-01-18 21:25:32 +01:00
|
|
|
|
|
|
|
/************************************************************************************
|
2019-07-11 18:50:00 +02:00
|
|
|
* Name: lpc17_40_gpioirqenable
|
2013-01-18 21:25:32 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Enable the interrupt for specified GPIO IRQ
|
|
|
|
*
|
|
|
|
************************************************************************************/
|
|
|
|
|
2019-07-11 18:50:00 +02:00
|
|
|
#ifdef CONFIG_LPC17_40_GPIOIRQ
|
|
|
|
void lpc17_40_gpioirqenable(int irq);
|
2013-01-18 21:25:32 +01:00
|
|
|
#else
|
2019-07-11 18:50:00 +02:00
|
|
|
# define lpc17_40_gpioirqenable(irq)
|
2013-01-18 21:25:32 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/************************************************************************************
|
2019-07-11 18:50:00 +02:00
|
|
|
* Name: lpc17_40_gpioirqdisable
|
2013-01-18 21:25:32 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Disable the interrupt for specified GPIO IRQ
|
|
|
|
*
|
|
|
|
************************************************************************************/
|
|
|
|
|
2019-07-11 18:50:00 +02:00
|
|
|
#ifdef CONFIG_LPC17_40_GPIOIRQ
|
|
|
|
void lpc17_40_gpioirqdisable(int irq);
|
2013-01-18 21:25:32 +01:00
|
|
|
#else
|
2019-07-11 18:50:00 +02:00
|
|
|
# define lpc17_40_gpioirqdisable(irq)
|
2013-01-18 21:25:32 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/************************************************************************************
|
2019-07-11 18:50:00 +02:00
|
|
|
* Function: lpc17_40_dumpgpio
|
2013-01-18 21:25:32 +01:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Dump all GPIO registers associated with the base address of the provided pinset.
|
|
|
|
*
|
|
|
|
************************************************************************************/
|
|
|
|
|
2016-06-15 17:20:23 +02:00
|
|
|
#ifdef CONFIG_DEBUG_GPIO_INFO
|
2019-07-11 18:50:00 +02:00
|
|
|
int lpc17_40_dumpgpio(lpc17_40_pinset_t pinset, const char *msg);
|
2013-01-18 21:25:32 +01:00
|
|
|
#else
|
2019-07-11 18:50:00 +02:00
|
|
|
# define lpc17_40_dumpgpio(p,m)
|
2013-01-18 21:25:32 +01:00
|
|
|
#endif
|
|
|
|
|
2013-01-18 20:16:44 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* __ASSEMBLY__ */
|
2012-09-13 20:32:24 +02:00
|
|
|
|
2019-07-11 18:50:00 +02:00
|
|
|
#endif /* __ARCH_ARM_SRC_LPC17XX_40XX_LPC17_40_GPIO_H */
|