Date: March 20, 2011 This library is created from "LPC17xx CMSIS-Compliant Standard Peripheral Firmware Driver Library (GNU, Keil, IAR) (Jan 28, 2011)", available from NXP's website, under "All microcontrollers support documents" [[http://ics.nxp.com/support/documents/microcontrollers/?type=software]] You will need to follow [[/projects/libraries/svn/mbed/trunk/LPC1768/LPC17xx.h]] while using this library Examples provided here [[/users/frank26080115/programs/LPC1700CMSIS_Examples/]] The beautiful thing is that NXP does not place copyright protection on any of the files in here Only a few modifications are made to make it compile with the mbed online compiler, I fixed some warnings as well. This is untested as of March 20, 2011 Forum post about this library: [[/forum/mbed/topic/2030/]]

Committer:
frank26080115
Date:
Sun Mar 20 18:45:15 2011 +0000
Revision:
0:84d7747641aa

        

Who changed what in which revision?

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