lpc-field

Template project for programming NXP's LPC1768 MCUs
git clone git://git.mdnr.space/lpc-field
Log | Files | Refs | README | LICENSE

lpc17xx_gpio.h (7147B)


      1 /**********************************************************************
      2 * $Id$		lpc17xx_gpio.h				2010-06-18
      3 *//**
      4 * @file		lpc17xx_gpio.h
      5 * @brief	Contains all macro definitions and function prototypes
      6 * 			support for GPDMA firmware library on LPC17xx
      7 * @version	3.0
      8 * @date		18. June. 2010
      9 * @author	NXP MCU SW Application Team
     10 *
     11 * Copyright(C) 2010, NXP Semiconductor
     12 * All rights reserved.
     13 *
     14 ***********************************************************************
     15 * Software that is described herein is for illustrative purposes only
     16 * which provides customers with programming information regarding the
     17 * products. This software is supplied "AS IS" without any warranties.
     18 * NXP Semiconductors assumes no responsibility or liability for the
     19 * use of the software, conveys no license or title under any patent,
     20 * copyright, or mask work right to the product. NXP Semiconductors
     21 * reserves the right to make changes in the software without
     22 * notification. NXP Semiconductors also make no representation or
     23 * warranty that such application will be suitable for the specified
     24 * use without further testing or modification.
     25 * Permission to use, copy, modify, and distribute this software and its
     26 * documentation is hereby granted, under NXP Semiconductors'
     27 * relevant copyright in the software, without fee, provided that it
     28 * is used in conjunction with NXP Semiconductors microcontrollers.  This
     29 * copyright, permission, and disclaimer notice must appear in all copies of
     30 * this code.
     31 **********************************************************************/
     32 
     33 /* Peripheral group ----------------------------------------------------------- */
     34 /** @defgroup GPIO GPIO (General Purpose Input/Output)
     35  * @ingroup LPC1700CMSIS_FwLib_Drivers
     36  * @{
     37  */
     38 
     39 #ifndef LPC17XX_GPIO_H_
     40 #define LPC17XX_GPIO_H_
     41 
     42 /* Includes ------------------------------------------------------------------- */
     43 #include "LPC17xx.h"
     44 #include "lpc_types.h"
     45 
     46 
     47 #ifdef __cplusplus
     48 extern "C"
     49 {
     50 #endif
     51 
     52 /* Public Macros -------------------------------------------------------------- */
     53 /** @defgroup GPIO_Public_Macros GPIO Public Macros
     54  * @{
     55  */
     56 
     57 /** Fast GPIO port 0 byte accessible definition */
     58 #define GPIO0_Byte	((GPIO_Byte_TypeDef *)(LPC_GPIO0_BASE))
     59 /** Fast GPIO port 1 byte accessible definition */
     60 #define GPIO1_Byte	((GPIO_Byte_TypeDef *)(LPC_GPIO1_BASE))
     61 /** Fast GPIO port 2 byte accessible definition */
     62 #define GPIO2_Byte	((GPIO_Byte_TypeDef *)(LPC_GPIO2_BASE))
     63 /** Fast GPIO port 3 byte accessible definition */
     64 #define GPIO3_Byte	((GPIO_Byte_TypeDef *)(LPC_GPIO3_BASE))
     65 /** Fast GPIO port 4 byte accessible definition */
     66 #define GPIO4_Byte	((GPIO_Byte_TypeDef *)(LPC_GPIO4_BASE))
     67 
     68 
     69 /** Fast GPIO port 0 half-word accessible definition */
     70 #define GPIO0_HalfWord	((GPIO_HalfWord_TypeDef *)(LPC_GPIO0_BASE))
     71 /** Fast GPIO port 1 half-word accessible definition */
     72 #define GPIO1_HalfWord	((GPIO_HalfWord_TypeDef *)(LPC_GPIO1_BASE))
     73 /** Fast GPIO port 2 half-word accessible definition */
     74 #define GPIO2_HalfWord	((GPIO_HalfWord_TypeDef *)(LPC_GPIO2_BASE))
     75 /** Fast GPIO port 3 half-word accessible definition */
     76 #define GPIO3_HalfWord	((GPIO_HalfWord_TypeDef *)(LPC_GPIO3_BASE))
     77 /** Fast GPIO port 4 half-word accessible definition */
     78 #define GPIO4_HalfWord	((GPIO_HalfWord_TypeDef *)(LPC_GPIO4_BASE))
     79 
     80 /**
     81  * @}
     82  */
     83 
     84 /* Public Types --------------------------------------------------------------- */
     85 /** @defgroup GPIO_Public_Types GPIO Public Types
     86  * @{
     87  */
     88 
     89 /**
     90  * @brief Fast GPIO port byte type definition
     91  */
     92 typedef struct {
     93 	__IO uint8_t FIODIR[4];		/**< FIO direction register in byte-align */
     94 	   uint32_t RESERVED0[3];	/**< Reserved */
     95 	__IO uint8_t FIOMASK[4];	/**< FIO mask register in byte-align */
     96 	__IO uint8_t FIOPIN[4];		/**< FIO pin register in byte align */
     97 	__IO uint8_t FIOSET[4];		/**< FIO set register in byte-align */
     98 	__O  uint8_t FIOCLR[4];		/**< FIO clear register in byte-align */
     99 } GPIO_Byte_TypeDef;
    100 
    101 
    102 /**
    103  * @brief Fast GPIO port half-word type definition
    104  */
    105 typedef struct {
    106 	__IO uint16_t FIODIRL;		/**< FIO direction register lower halfword part */
    107 	__IO uint16_t FIODIRU;		/**< FIO direction register upper halfword part */
    108 	   uint32_t RESERVED0[3];	/**< Reserved */
    109 	__IO uint16_t FIOMASKL;		/**< FIO mask register lower halfword part */
    110 	__IO uint16_t FIOMASKU;		/**< FIO mask register upper halfword part */
    111 	__IO uint16_t FIOPINL;		/**< FIO pin register lower halfword part */
    112 	__IO uint16_t FIOPINU;		/**< FIO pin register upper halfword part */
    113 	__IO uint16_t FIOSETL;		/**< FIO set register lower halfword part */
    114 	__IO uint16_t FIOSETU;		/**< FIO set register upper halfword part */
    115 	__O  uint16_t FIOCLRL;		/**< FIO clear register lower halfword part */
    116 	__O  uint16_t FIOCLRU;		/**< FIO clear register upper halfword part */
    117 } GPIO_HalfWord_TypeDef;
    118 
    119 /**
    120  * @}
    121  */
    122 
    123 
    124 /* Public Functions ----------------------------------------------------------- */
    125 /** @defgroup GPIO_Public_Functions GPIO Public Functions
    126  * @{
    127  */
    128 
    129 /* GPIO style ------------------------------- */
    130 void GPIO_SetDir(uint8_t portNum, uint32_t bitValue, uint8_t dir);
    131 void GPIO_SetValue(uint8_t portNum, uint32_t bitValue);
    132 void GPIO_ClearValue(uint8_t portNum, uint32_t bitValue);
    133 uint32_t GPIO_ReadValue(uint8_t portNum);
    134 void GPIO_IntCmd(uint8_t portNum, uint32_t bitValue, uint8_t edgeState);
    135 FunctionalState GPIO_GetIntStatus(uint8_t portNum, uint32_t pinNum, uint8_t edgeState);
    136 void GPIO_ClearInt(uint8_t portNum, uint32_t bitValue);
    137 
    138 /* FIO (word-accessible) style ------------------------------- */
    139 void FIO_SetDir(uint8_t portNum, uint32_t bitValue, uint8_t dir);
    140 void FIO_SetValue(uint8_t portNum, uint32_t bitValue);
    141 void FIO_ClearValue(uint8_t portNum, uint32_t bitValue);
    142 uint32_t FIO_ReadValue(uint8_t portNum);
    143 void FIO_SetMask(uint8_t portNum, uint32_t bitValue, uint8_t maskValue);
    144 void FIO_IntCmd(uint8_t portNum, uint32_t bitValue, uint8_t edgeState);
    145 FunctionalState FIO_GetIntStatus(uint8_t portNum, uint32_t pinNum, uint8_t edgeState);
    146 void FIO_ClearInt(uint8_t portNum, uint32_t pinNum);
    147 
    148 /* FIO (halfword-accessible) style ------------------------------- */
    149 void FIO_HalfWordSetDir(uint8_t portNum, uint8_t halfwordNum, uint16_t bitValue, uint8_t dir);
    150 void FIO_HalfWordSetMask(uint8_t portNum, uint8_t halfwordNum, uint16_t bitValue, uint8_t maskValue);
    151 void FIO_HalfWordSetValue(uint8_t portNum, uint8_t halfwordNum, uint16_t bitValue);
    152 void FIO_HalfWordClearValue(uint8_t portNum, uint8_t halfwordNum, uint16_t bitValue);
    153 uint16_t FIO_HalfWordReadValue(uint8_t portNum, uint8_t halfwordNum);
    154 
    155 /* FIO (byte-accessible) style ------------------------------- */
    156 void FIO_ByteSetDir(uint8_t portNum, uint8_t byteNum, uint8_t bitValue, uint8_t dir);
    157 void FIO_ByteSetMask(uint8_t portNum, uint8_t byteNum, uint8_t bitValue, uint8_t maskValue);
    158 void FIO_ByteSetValue(uint8_t portNum, uint8_t byteNum, uint8_t bitValue);
    159 void FIO_ByteClearValue(uint8_t portNum, uint8_t byteNum, uint8_t bitValue);
    160 uint8_t FIO_ByteReadValue(uint8_t portNum, uint8_t byteNum);
    161 
    162 /**
    163  * @}
    164  */
    165 
    166 
    167 #ifdef __cplusplus
    168 }
    169 #endif
    170 
    171 #endif /* LPC17XX_GPIO_H_ */
    172 
    173 /**
    174  * @}
    175  */
    176 
    177 /* --------------------------------- End Of File ------------------------------ */