uc-sdk
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
lpc17xx_gpio.h
Go to the documentation of this file.
1 /***********************************************************************/
21 /* Peripheral group ----------------------------------------------------------- */
27 #ifndef LPC17XX_GPIO_H_
28 #define LPC17XX_GPIO_H_
29 
30 /* Includes ------------------------------------------------------------------- */
31 #include "LPC17xx.h"
32 #include "lpc_types.h"
33 
34 
35 #ifdef __cplusplus
36 extern "C"
37 {
38 #endif
39 
40 /* Public Macros -------------------------------------------------------------- */
46 #define GPIO0_Byte ((GPIO_Byte_TypeDef *)(LPC_GPIO0_BASE))
47 
48 #define GPIO1_Byte ((GPIO_Byte_TypeDef *)(LPC_GPIO1_BASE))
49 
50 #define GPIO2_Byte ((GPIO_Byte_TypeDef *)(LPC_GPIO2_BASE))
51 
52 #define GPIO3_Byte ((GPIO_Byte_TypeDef *)(LPC_GPIO3_BASE))
53 
54 #define GPIO4_Byte ((GPIO_Byte_TypeDef *)(LPC_GPIO4_BASE))
55 
56 
58 #define GPIO0_HalfWord ((GPIO_HalfWord_TypeDef *)(LPC_GPIO0_BASE))
59 
60 #define GPIO1_HalfWord ((GPIO_HalfWord_TypeDef *)(LPC_GPIO1_BASE))
61 
62 #define GPIO2_HalfWord ((GPIO_HalfWord_TypeDef *)(LPC_GPIO2_BASE))
63 
64 #define GPIO3_HalfWord ((GPIO_HalfWord_TypeDef *)(LPC_GPIO3_BASE))
65 
66 #define GPIO4_HalfWord ((GPIO_HalfWord_TypeDef *)(LPC_GPIO4_BASE))
67 
72 /* Public Types --------------------------------------------------------------- */
80 typedef struct {
81  __IO uint8_t FIODIR[4];
82  uint32_t RESERVED0[3];
83  __IO uint8_t FIOMASK[4];
84  __IO uint8_t FIOPIN[4];
85  __IO uint8_t FIOSET[4];
86  __O uint8_t FIOCLR[4];
88 
89 
93 typedef struct {
94  __IO uint16_t FIODIRL;
95  __IO uint16_t FIODIRU;
96  uint32_t RESERVED0[3];
97  __IO uint16_t FIOMASKL;
98  __IO uint16_t FIOMASKU;
99  __IO uint16_t FIOPINL;
100  __IO uint16_t FIOPINU;
101  __IO uint16_t FIOSETL;
102  __IO uint16_t FIOSETU;
103  __O uint16_t FIOCLRL;
104  __O uint16_t FIOCLRU;
106 
112 /* Public Functions ----------------------------------------------------------- */
117 /* GPIO style ------------------------------- */
118 void GPIO_SetDir(uint8_t portNum, uint32_t bitValue, uint8_t dir);
119 void GPIO_SetValue(uint8_t portNum, uint32_t bitValue);
120 void GPIO_ClearValue(uint8_t portNum, uint32_t bitValue);
121 uint32_t GPIO_ReadValue(uint8_t portNum);
122 void GPIO_IntCmd(uint8_t portNum, uint32_t bitValue, uint8_t edgeState);
123 FunctionalState GPIO_GetIntStatus(uint8_t portNum, uint32_t pinNum, uint8_t edgeState);
124 void GPIO_ClearInt(uint8_t portNum, uint32_t bitValue);
125 
126 /* FIO (word-accessible) style ------------------------------- */
127 void FIO_SetDir(uint8_t portNum, uint32_t bitValue, uint8_t dir);
128 void FIO_SetValue(uint8_t portNum, uint32_t bitValue);
129 void FIO_ClearValue(uint8_t portNum, uint32_t bitValue);
130 uint32_t FIO_ReadValue(uint8_t portNum);
131 void FIO_SetMask(uint8_t portNum, uint32_t bitValue, uint8_t maskValue);
132 void FIO_IntCmd(uint8_t portNum, uint32_t bitValue, uint8_t edgeState);
133 FunctionalState FIO_GetIntStatus(uint8_t portNum, uint32_t pinNum, uint8_t edgeState);
134 void FIO_ClearInt(uint8_t portNum, uint32_t pinNum);
135 
136 /* FIO (halfword-accessible) style ------------------------------- */
137 void FIO_HalfWordSetDir(uint8_t portNum, uint8_t halfwordNum, uint16_t bitValue, uint8_t dir);
138 void FIO_HalfWordSetMask(uint8_t portNum, uint8_t halfwordNum, uint16_t bitValue, uint8_t maskValue);
139 void FIO_HalfWordSetValue(uint8_t portNum, uint8_t halfwordNum, uint16_t bitValue);
140 void FIO_HalfWordClearValue(uint8_t portNum, uint8_t halfwordNum, uint16_t bitValue);
141 uint16_t FIO_HalfWordReadValue(uint8_t portNum, uint8_t halfwordNum);
142 
143 /* FIO (byte-accessible) style ------------------------------- */
144 void FIO_ByteSetDir(uint8_t portNum, uint8_t byteNum, uint8_t bitValue, uint8_t dir);
145 void FIO_ByteSetMask(uint8_t portNum, uint8_t byteNum, uint8_t bitValue, uint8_t maskValue);
146 void FIO_ByteSetValue(uint8_t portNum, uint8_t byteNum, uint8_t bitValue);
147 void FIO_ByteClearValue(uint8_t portNum, uint8_t byteNum, uint8_t bitValue);
148 uint8_t FIO_ByteReadValue(uint8_t portNum, uint8_t byteNum);
149 
155 #ifdef __cplusplus
156 }
157 #endif
158 
159 #endif /* LPC17XX_GPIO_H_ */
160 
165 /* --------------------------------- End Of File ------------------------------ */