2 * @brief LPC18xx/43xx GPIO driver
\r
5 * Copyright(C) NXP Semiconductors, 2012
\r
6 * All rights reserved.
\r
9 * Software that is described herein is for illustrative purposes only
\r
10 * which provides customers with programming information regarding the
\r
11 * LPC products. This software is supplied "AS IS" without any warranties of
\r
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
\r
13 * all warranties, express or implied, including all implied warranties of
\r
14 * merchantability, fitness for a particular purpose and non-infringement of
\r
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
\r
16 * or liability for the use of the software, conveys no license or rights under any
\r
17 * patent, copyright, mask work right, or any other intellectual property rights in
\r
18 * or to any products. NXP Semiconductors reserves the right to make changes
\r
19 * in the software without notification. NXP Semiconductors also makes no
\r
20 * representation or warranty that such application will be suitable for the
\r
21 * specified use without further testing or modification.
\r
24 * Permission to use, copy, modify, and distribute this software and its
\r
25 * documentation is hereby granted, under NXP Semiconductors' and its
\r
26 * licensor's relevant copyrights in the software, without fee, provided that it
\r
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
\r
28 * copyright, permission, and disclaimer notice must appear in all copies of
\r
32 #ifndef __GPIO_18XX_43XX_H_
\r
33 #define __GPIO_18XX_43XX_H_
\r
39 /** @defgroup GPIO_18XX_43XX CHIP: LPC18xx/43xx GPIO Driver
\r
40 * @ingroup CHIP_18XX_43XX_Drivers
\r
45 * @brief Initialize GPIO block
\r
46 * @param pGPIO : The base of GPIO peripheral on the chip
\r
49 STATIC INLINE void Chip_GPIO_Init(LPC_GPIO_T *pGPIO)
\r
51 IP_GPIO_Init(pGPIO);
\r
55 * @brief Set a GPIO port/bit state
\r
56 * @param pGPIO : The base of GPIO peripheral on the chip
\r
57 * @param port : GPIO port to set
\r
58 * @param bit : GPIO bit to set
\r
59 * @param setting : true for high, false for low
\r
62 STATIC INLINE void Chip_GPIO_WritePortBit(LPC_GPIO_T *pGPIO, uint32_t port, uint8_t bit, bool setting)
\r
64 IP_GPIO_WritePortBit(pGPIO, port, bit, setting);
\r
68 * @brief Seta GPIO direction
\r
69 * @param pGPIO : The base of GPIO peripheral on the chip
\r
70 * @param port : GPIO port to set
\r
71 * @param bit : GPIO bit to set
\r
72 * @param setting : true for output, false for input
\r
75 STATIC INLINE void Chip_GPIO_WriteDirBit(LPC_GPIO_T *pGPIO, uint32_t port, uint8_t bit, bool setting)
\r
77 IP_GPIO_WriteDirBit(pGPIO, port, bit, setting);
\r
81 * @brief Read a GPIO state
\r
82 * @param pGPIO : The base of GPIO peripheral on the chip
\r
83 * @param port : GPIO port to read
\r
84 * @param bit : GPIO bit to read
\r
85 * @return true of the GPIO is high, false if low
\r
87 STATIC INLINE bool Chip_GPIO_ReadPortBit(LPC_GPIO_T *pGPIO, uint32_t port, uint8_t bit)
\r
89 return IP_GPIO_ReadPortBit(pGPIO, port, bit);
\r
93 * @brief Read a GPIO direction (out or in)
\r
94 * @param pGPIO : The base of GPIO peripheral on the chip
\r
95 * @param port : GPIO port to read
\r
96 * @param bit : GPIO bit to read
\r
97 * @return true of the GPIO is an output, false if input
\r
99 STATIC INLINE bool Chip_GPIO_ReadDirBit(LPC_GPIO_T *pGPIO, uint32_t port, uint8_t bit)
\r
101 return IP_GPIO_ReadDirBit(pGPIO, port, bit);
\r
105 * @brief Enable GPIO Interrupt
\r
106 * @param pGPIOPinInt : The base of GPIO pin interrupt peripheral on the chip
\r
107 * @param portNum : GPIO port number interrupt, should be: 0 to 7
\r
108 * @param bitValue : GPIO bit to enable (Not used)
\r
109 * @param intMode : Interrupt mode, should be:
\r
110 * 0: Rising edge interrupt mode
\r
111 * 1: Falling edge interrupt mode
\r
112 * 2: Active-High interrupt mode
\r
113 * 3: Active-Low interrupt mode
\r
116 STATIC INLINE void Chip_GPIO_IntCmd(LPC_GPIOPININT_T* pGPIOPinInt, uint8_t portNum, uint8_t bitValue, IP_GPIOPININT_MODE_T intMode)
\r
118 IP_GPIOPININT_IntCmd(pGPIOPinInt, portNum, intMode);
\r
122 * @brief Get GPIO Interrupt Status
\r
123 * @param pGPIOPinInt : The base of GPIO pin interrupt peripheral on the chip
\r
124 * @param portNum : GPIO port number interrupt, should be: 0 to 7
\r
125 * @param pinNum : GPIO pin to check (Not used)
\r
126 * @param intMode : Interrupt mode (Not used)
\r
127 * @return true if interrupt is pending, otherwise false
\r
129 STATIC INLINE bool Chip_GPIO_IntGetStatus(LPC_GPIOPININT_T* pGPIOPinInt, uint8_t portNum, uint8_t pinNum, uint8_t intMode)
\r
131 return IP_GPIOPININT_IntGetStatus(pGPIOPinInt, portNum);
\r
135 * @brief Clear GPIO Interrupt (Edge interrupt cases only)
\r
136 * @param pGPIOPinInt : The base of GPIO pin interrupt peripheral on the chip
\r
137 * @param portNum : GPIO port number interrupt, should be: 0 to 7
\r
138 * @param bitValue : GPIO bit to clear (Not used)
\r
141 STATIC INLINE void Chip_GPIO_IntClear(LPC_GPIOPININT_T* pGPIOPinInt, uint8_t portNum, uint8_t bitValue)
\r
143 IP_GPIOPININT_IntClear(pGPIOPinInt, portNum);
\r
147 * @brief GPIO Group Interrupt Pin Initialization
\r
148 * @param pGPIOGPINT : Pointer to GPIOIR register block
\r
149 * @param PortComb : GPIO group combined enable, should be: 0 (OR functionality) and 1 (AND functionality)
\r
150 * @param PortTrigger : GPIO group interrupt trigger, should be: 0 (Edge-triggered) 1 (Level triggered)
\r
153 STATIC INLINE void Chip_GPIOGP_IntInit(IP_GPIOGROUPINT_001_T *pGPIOGPINT, uint8_t PortComb, uint8_t PortTrigger)
\r
155 IP_GPIOGP_IntInit(pGPIOGPINT, PortComb, PortTrigger);
\r
159 * @brief GPIO Group Interrupt Pin Add to Group
\r
160 * @param pGPIOGPINT : Pointer to GPIOIR register block
\r
161 * @param PortNum : GPIO port number, should be 0 to 7
\r
162 * @param PinNum : GPIO pin number, should be 0 to 31
\r
163 * @param ActiveMode : GPIO active mode, should be 0 (active LOW) and 1 (active HIGH)
\r
166 STATIC INLINE void Chip_GPIOGP_IntPinAdd(IP_GPIOGROUPINT_001_T *pGPIOGPINT,
\r
171 IP_GPIOGP_IntPinAdd(pGPIOGPINT, PortNum, PinNum, ActiveMode);
\r
175 * @brief GPIO Group Interrupt Pin Remove from Group
\r
176 * @param pGPIOGPINT : Pointer to GPIOIR register block
\r
177 * @param PortNum : GPIO port number, should be 0 to 7
\r
178 * @param PinNum : GPIO pin number, should be 0 to 31
\r
181 STATIC INLINE void Chip_GPIOGP_IntPinRemove(IP_GPIOGROUPINT_001_T *pGPIOGPINT, uint8_t PortNum, uint8_t PinNum)
\r
183 IP_GPIOGP_IntPinRemove(pGPIOGPINT, PortNum, PinNum);
\r
187 * @brief Get GPIO Group Interrupt Get Status
\r
188 * @param pGPIOGPINT : Pointer to GPIOIR register block
\r
189 * @return true if interrupt is pending, otherwise false
\r
191 STATIC INLINE bool Chip_GPIOGP_IntGetStatus(IP_GPIOGROUPINT_001_T *pGPIOGPINT)
\r
193 return IP_GPIOGP_IntGetStatus(pGPIOGPINT);
\r
197 * @brief Clear GPIO Group Interrupt
\r
198 * @param pGPIOGPINT : Pointer to GPIOIR register block
\r
201 STATIC INLINE void Chip_GPIOGP_IntClear(IP_GPIOGROUPINT_001_T *pGPIOGPINT)
\r
203 IP_GPIOGP_IntClear(pGPIOGPINT);
\r
207 * @brief Set Direction for a GPIO port
\r
208 * @param pGPIO : The base of GPIO peripheral on the chip
\r
209 * @param portNum : Port Number
\r
210 * @param bitValue : GPIO bit to set
\r
211 * @param out : Direction value, 0 = input, !0 = output
\r
213 * @note Bits set to '0' are not altered.
\r
215 void Chip_GPIO_SetDir(LPC_GPIO_T *pGPIO, uint8_t portNum, uint32_t bitValue, uint8_t out);
\r
218 * @brief Set Direction for a GPIO port
\r
219 * @param pGPIO : The base of GPIO peripheral on the chip
\r
220 * @param portNum : Port Number
\r
221 * @param bitValue : GPIO bit to set
\r
222 * @param out : Direction value, 0 = input, !0 = output
\r
224 * @note Bits set to '0' are not altered.
\r
226 STATIC INLINE void Chip_FIO_SetDir(LPC_GPIO_T *pGPIO, uint8_t portNum, uint32_t bitValue, uint8_t out)
\r
228 /* Same with Chip_GPIO_SetDir() */
\r
229 Chip_GPIO_SetDir(pGPIO, portNum, bitValue, out);
\r
233 * @brief Set a GPIO port/bit to the high state
\r
234 * @param pGPIO : The base of GPIO peripheral on the chip
\r
235 * @param portNum : Port number
\r
236 * @param bitValue : Bit(s) in the port to set high
\r
238 * @note Any bit set as a '0' will not have it's state changed. This only
\r
239 * applies to ports configured as an output.
\r
241 STATIC INLINE void Chip_FIO_SetValue(LPC_GPIO_T *pGPIO, uint8_t portNum, uint32_t bitValue)
\r
243 /* Same with GPIO_SetValue() */
\r
244 pGPIO->SET[portNum] = bitValue;
\r
248 * @brief Set a GPIO port/bit to the low state
\r
249 * @param pGPIO : The base of GPIO peripheral on the chip
\r
250 * @param portNum : Port number
\r
251 * @param bitValue : Bit(s) in the port to set low
\r
253 * @note Any bit set as a '0' will not have it's state changed. This only
\r
254 * applies to ports configured as an output.
\r
256 STATIC INLINE void Chip_FIO_ClearValue(LPC_GPIO_T *pGPIO, uint8_t portNum, uint32_t bitValue)
\r
258 /* Same with GPIO_ClearValue() */
\r
259 pGPIO->CLR[portNum] = bitValue;
\r
263 * @brief Read current bit states for the selected port
\r
264 * @param pGPIO : The base of GPIO peripheral on the chip
\r
265 * @param portNum : Port number to read
\r
266 * @return Current value of GPIO port
\r
267 * @note The current states of the bits for the port are read, regardless of
\r
268 * whether the GPIO port bits are input or output.
\r
270 STATIC INLINE uint32_t Chip_FIO_ReadValue(LPC_GPIO_T *pGPIO, uint8_t portNum)
\r
272 /* Same with GPIO_ReadValue() */
\r
273 return pGPIO->PIN[portNum];
\r
277 * @brief Set a GPIO port/bit to the high state
\r
278 * @param pGPIO : The base of GPIO peripheral on the chip
\r
279 * @param portNum : Port number
\r
280 * @param bitValue : Bit(s) in the port to set high
\r
282 * @note Any bit set as a '0' will not have it's state changed. This only
\r
283 * applies to ports configured as an output.
\r
285 STATIC INLINE void Chip_GPIO_SetValue(LPC_GPIO_T *pGPIO, uint8_t portNum, uint32_t bitValue)
\r
287 pGPIO->SET[portNum] = bitValue;
\r
291 * @brief Set a GPIO port/bit to the low state
\r
292 * @param pGPIO : The base of GPIO peripheral on the chip
\r
293 * @param portNum : Port number
\r
294 * @param bitValue : Bit(s) in the port to set low
\r
296 * @note Any bit set as a '0' will not have it's state changed. This only
\r
297 * applies to ports configured as an output.
\r
299 STATIC INLINE void Chip_GPIO_ClearValue(LPC_GPIO_T *pGPIO, uint8_t portNum, uint32_t bitValue)
\r
301 pGPIO->CLR[portNum] = bitValue;
\r
305 * @brief Read current bit states for the selected port
\r
306 * @param pGPIO : The base of GPIO peripheral on the chip
\r
307 * @param portNum : Port number to read
\r
308 * @return Current value of GPIO port
\r
309 * @note The current states of the bits for the port are read, regardless of
\r
310 * whether the GPIO port bits are input or output.
\r
312 STATIC INLINE uint32_t Chip_GPIO_ReadValue(LPC_GPIO_T *pGPIO, uint8_t portNum)
\r
314 return pGPIO->PIN[portNum];
\r
325 #endif /* __GPIO_18XX_43XX_H_ */
\r