1 /**********************************************************************
\r
2 * $Id$ lpc18xx_gpio.h 2011-06-02
\r
4 * @file lpc18xx_gpio.h
\r
5 * @brief Contains all macro definitions and function prototypes
\r
6 * support for GPIO firmware library on LPC18xx
\r
8 * @date 02. June. 2011
\r
9 * @author NXP MCU SW Application Team
\r
11 * Copyright(C) 2011, NXP Semiconductor
\r
12 * All rights reserved.
\r
14 ***********************************************************************
\r
15 * Software that is described herein is for illustrative purposes only
\r
16 * which provides customers with programming information regarding the
\r
17 * products. This software is supplied "AS IS" without any warranties.
\r
18 * NXP Semiconductors assumes no responsibility or liability for the
\r
19 * use of the software, conveys no license or title under any patent,
\r
20 * copyright, or mask work right to the product. NXP Semiconductors
\r
21 * reserves the right to make changes in the software without
\r
22 * notification. NXP Semiconductors also make no representation or
\r
23 * warranty that such application will be suitable for the specified
\r
24 * use without further testing or modification.
\r
25 **********************************************************************/
\r
27 /* Peripheral group ----------------------------------------------------------- */
\r
28 /** @defgroup GPIO GPIO (General Purpose I/O)
\r
29 * @ingroup LPC1800CMSIS_FwLib_Drivers
\r
33 #ifndef LPC18XX_GPIO_H_
\r
34 #define LPC18XX_GPIO_H_
\r
36 /* Includes ------------------------------------------------------------------- */
\r
37 #include "LPC18xx.h"
\r
38 #include "lpc_types.h"
\r
46 /* Public Macros -------------------------------------------------------------- */
\r
47 /** @defgroup GPIO_Public_Macros GPIO Public Macros
\r
51 /** General LPC GPIO Base */
\r
52 #define LPC_GPIO_BASE LPC_GPIO0_BASE
\r
53 /** Fast GPIO port 0 byte accessible definition */
\r
54 #define GPIO0_Byte ((GPIO_Byte_TypeDef *)(LPC_GPIO_BASE+0x00))
\r
55 /** Fast GPIO port 1 byte accessible definition */
\r
56 #define GPIO1_Byte ((GPIO_Byte_TypeDef *)(LPC_GPIO_BASE+0x20))
\r
57 /** Fast GPIO port 2 byte accessible definition */
\r
58 #define GPIO2_Byte ((GPIO_Byte_TypeDef *)(LPC_GPIO_BASE+0x40))
\r
59 /** Fast GPIO port 3 byte accessible definition */
\r
60 #define GPIO3_Byte ((GPIO_Byte_TypeDef *)(LPC_GPIO_BASE+0x60))
\r
61 /** Fast GPIO port 4 byte accessible definition */
\r
62 #define GPIO4_Byte ((GPIO_Byte_TypeDef *)(LPC_GPIO_BASE+0x80))
\r
65 /** Fast GPIO port 0 half-word accessible definition */
\r
66 #define GPIO0_HalfWord ((GPIO_HalfWord_TypeDef *)(LPC_GPIO_BASE+0x00))
\r
67 /** Fast GPIO port 1 half-word accessible definition */
\r
68 #define GPIO1_HalfWord ((GPIO_HalfWord_TypeDef *)(LPC_GPIO_BASE+0x20))
\r
69 /** Fast GPIO port 2 half-word accessible definition */
\r
70 #define GPIO2_HalfWord ((GPIO_HalfWord_TypeDef *)(LPC_GPIO_BASE+0x40))
\r
71 /** Fast GPIO port 3 half-word accessible definition */
\r
72 #define GPIO3_HalfWord ((GPIO_HalfWord_TypeDef *)(LPC_GPIO_BASE+0x60))
\r
73 /** Fast GPIO port 4 half-word accessible definition */
\r
74 #define GPIO4_HalfWord ((GPIO_HalfWord_TypeDef *)(LPC_GPIO_BASE+0x80))
\r
81 /* Public Types --------------------------------------------------------------- */
\r
82 /** @defgroup GPIO_Public_Types GPIO Public Types
\r
87 * @brief Fast GPIO port byte type definition
\r
91 __IO uint8_t FIODIR[4]; /**< FIO direction register in byte-align */
\r
92 uint32_t RESERVED0[3]; /**< Reserved */
\r
93 __IO uint8_t FIOMASK[4]; /**< FIO mask register in byte-align */
\r
94 __IO uint8_t FIOPIN[4]; /**< FIO pin register in byte align */
\r
95 __IO uint8_t FIOSET[4]; /**< FIO set register in byte-align */
\r
96 __O uint8_t FIOCLR[4]; /**< FIO clear register in byte-align */
\r
97 } GPIO_Byte_TypeDef;
\r
101 * @brief Fast GPIO port half-word type definition
\r
105 __IO uint16_t FIODIRL; /**< FIO direction register lower halfword part */
\r
106 __IO uint16_t FIODIRU; /**< FIO direction register upper halfword part */
\r
107 uint32_t RESERVED0[3]; /**< Reserved */
\r
108 __IO uint16_t FIOMASKL; /**< FIO mask register lower halfword part */
\r
109 __IO uint16_t FIOMASKU; /**< FIO mask register upper halfword part */
\r
110 __IO uint16_t FIOPINL; /**< FIO pin register lower halfword part */
\r
111 __IO uint16_t FIOPINU; /**< FIO pin register upper halfword part */
\r
112 __IO uint16_t FIOSETL; /**< FIO set register lower halfword part */
\r
113 __IO uint16_t FIOSETU; /**< FIO set register upper halfword part */
\r
114 __O uint16_t FIOCLRL; /**< FIO clear register lower halfword part */
\r
115 __O uint16_t FIOCLRU; /**< FIO clear register upper halfword part */
\r
116 } GPIO_HalfWord_TypeDef;
\r
124 /* Public Functions ----------------------------------------------------------- */
\r
125 /** @defgroup GPIO_Public_Functions GPIO Public Functions
\r
129 /* GPIO style ------------------------------- */
\r
130 void GPIO_SetDir(uint8_t portNum, uint32_t bitValue, uint8_t dir);
\r
131 void GPIO_SetValue(uint8_t portNum, uint32_t bitValue);
\r
132 void GPIO_ClearValue(uint8_t portNum, uint32_t bitValue);
\r
133 uint32_t GPIO_ReadValue(uint8_t portNum);
\r
136 void GPIO_IntCmd(uint8_t portNum, uint32_t bitValue, uint8_t edgeState);
\r
137 FunctionalState GPIO_GetIntStatus(uint8_t portNum, uint32_t pinNum, uint8_t edgeState);
\r
138 void GPIO_ClearInt(uint8_t portNum, uint32_t bitValue);
\r
142 /* FIO (word-accessible) style ------------------------------- */
\r
143 void FIO_SetDir(uint8_t portNum, uint32_t bitValue, uint8_t dir);
\r
144 void FIO_SetValue(uint8_t portNum, uint32_t bitValue);
\r
145 void FIO_ClearValue(uint8_t portNum, uint32_t bitValue);
\r
146 uint32_t FIO_ReadValue(uint8_t portNum);
\r
147 void FIO_SetMask(uint8_t portNum, uint32_t bitValue, uint8_t maskValue);
\r
150 void FIO_IntCmd(uint8_t portNum, uint32_t bitValue, uint8_t edgeState);
\r
151 FunctionalState FIO_GetIntStatus(uint8_t portNum, uint32_t pinNum, uint8_t edgeState);
\r
152 void FIO_ClearInt(uint8_t portNum, uint32_t pinNum);
\r
156 /* FIO (halfword-accessible) style ------------------------------- */
\r
157 void FIO_HalfWordSetDir(uint8_t portNum, uint8_t halfwordNum, uint16_t bitValue, uint8_t dir);
\r
158 void FIO_HalfWordSetMask(uint8_t portNum, uint8_t halfwordNum, uint16_t bitValue, uint8_t maskValue);
\r
159 void FIO_HalfWordSetValue(uint8_t portNum, uint8_t halfwordNum, uint16_t bitValue);
\r
160 void FIO_HalfWordClearValue(uint8_t portNum, uint8_t halfwordNum, uint16_t bitValue);
\r
161 uint16_t FIO_HalfWordReadValue(uint8_t portNum, uint8_t halfwordNum);
\r
164 /* FIO (byte-accessible) style ------------------------------- */
\r
165 void FIO_ByteSetDir(uint8_t portNum, uint8_t byteNum, uint8_t bitValue, uint8_t dir);
\r
166 void FIO_ByteSetMask(uint8_t portNum, uint8_t byteNum, uint8_t bitValue, uint8_t maskValue);
\r
167 void FIO_ByteSetValue(uint8_t portNum, uint8_t byteNum, uint8_t bitValue);
\r
168 void FIO_ByteClearValue(uint8_t portNum, uint8_t byteNum, uint8_t bitValue);
\r
169 uint8_t FIO_ByteReadValue(uint8_t portNum, uint8_t byteNum);
\r
180 #endif /* LPC18XX_GPIO_H_ */
\r
186 /* --------------------------------- End Of File ------------------------------ */
\r