2 * @brief GPIO Registers and Functions
\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_001_H_
\r
33 #define __GPIO_001_H_
\r
35 #include "sys_config.h"
\r
42 /** @defgroup IP_GPIO_001 IP: GPIO register block and driver
\r
43 * @ingroup IP_Drivers
\r
48 * @brief GPIO port register block structure
\r
50 typedef struct { /*!< GPIO_PORT Structure */
\r
51 __IO uint8_t B[128][32]; /*!< Offset 0x0000: Byte pin registers ports 0 to n; pins PIOn_0 to PIOn_31 */
\r
52 __IO uint32_t W[32][32]; /*!< Offset 0x1000: Word pin registers port 0 to n */
\r
53 __IO uint32_t DIR[32]; /*!< Offset 0x2000: Direction registers port n */
\r
54 __IO uint32_t MASK[32]; /*!< Offset 0x2080: Mask register port n */
\r
55 __IO uint32_t PIN[32]; /*!< Offset 0x2100: Portpin register port n */
\r
56 __IO uint32_t MPIN[32]; /*!< Offset 0x2180: Masked port register port n */
\r
57 __IO uint32_t SET[32]; /*!< Offset 0x2200: Write: Set register for port n Read: output bits for port n */
\r
58 __O uint32_t CLR[32]; /*!< Offset 0x2280: Clear port n */
\r
59 __O uint32_t NOT[32]; /*!< Offset 0x2300: Toggle port n */
\r
63 * @brief Initialize GPIO block
\r
64 * @param pGPIO : The Base Address of the GPIO block
\r
67 STATIC INLINE void IP_GPIO_Init(IP_GPIO_001_T *pGPIO)
\r
71 * @brief Set a GPIO port/bit state
\r
72 * @param pGPIO : The Base Address of the GPIO block
\r
73 * @param Port : GPIO port to set
\r
74 * @param Bit : GPIO bit to set
\r
75 * @param Setting : true for high, false for low
\r
78 STATIC INLINE void IP_GPIO_WritePortBit(IP_GPIO_001_T *pGPIO, uint32_t Port, uint8_t Bit, bool Setting)
\r
80 pGPIO->B[Port][Bit] = Setting;
\r
84 * @brief Set a GPIO direction
\r
85 * @param pGPIO : The Base Address of the GPIO block
\r
86 * @param Port : GPIO port to set
\r
87 * @param Bit : GPIO bit to set
\r
88 * @param Setting : true for output, false for input
\r
91 STATIC INLINE void IP_GPIO_WriteDirBit(IP_GPIO_001_T *pGPIO, uint32_t Port, uint8_t Bit, bool Setting)
\r
94 pGPIO->DIR[Port] |= 1UL << Bit;
\r
97 pGPIO->DIR[Port] &= ~(1UL << Bit);
\r
102 * @brief Read a GPIO state
\r
103 * @param pGPIO : The Base Address of the GPIO block
\r
104 * @param Port : GPIO port to read
\r
105 * @param Bit : GPIO bit to read
\r
106 * @return true of the GPIO is high, false if low
\r
108 STATIC INLINE bool IP_GPIO_ReadPortBit(IP_GPIO_001_T *pGPIO, uint32_t Port, uint8_t Bit)
\r
110 return (bool) pGPIO->B[Port][Bit];
\r
114 * @brief Read a GPIO direction (out or in)
\r
115 * @param pGPIO : The Base Address of the GPIO block
\r
116 * @param Port : GPIO port to read
\r
117 * @param Bit : GPIO bit to read
\r
118 * @return true of the GPIO is an output, false if input
\r
120 STATIC INLINE bool IP_GPIO_ReadDirBit(IP_GPIO_001_T *pGPIO, uint32_t Port, uint8_t Bit)
\r
122 return (bool) (((pGPIO->DIR[Port]) >> Bit) & 1);
\r
133 #endif /* __GPIO_001_H_ */
\r