1 /**************************************************************************//** 2 * @file GPIO.h 3 * @version V3.0 4 * @brief M2351 series General Purpose I/O (GPIO) driver header file 5 * 6 * @copyright SPDX-License-Identifier: Apache-2.0 7 * @copyright Copyright (C) 2016-2020 Nuvoton Technology Corp. All rights reserved. 8 ******************************************************************************/ 9 #ifndef __GPIO_H__ 10 #define __GPIO_H__ 11 12 #ifdef __cplusplus 13 extern "C" 14 { 15 #endif 16 17 18 /** @addtogroup Standard_Driver Standard Driver 19 @{ 20 */ 21 22 /** @addtogroup GPIO_Driver GPIO Driver 23 @{ 24 */ 25 26 /** @addtogroup GPIO_EXPORTED_CONSTANTS GPIO Exported Constants 27 @{ 28 */ 29 30 #define GPIO_PIN_MAX 16UL /*!< Specify Maximum Pins of Each GPIO Port */ 31 32 33 /*---------------------------------------------------------------------------------------------------------*/ 34 /* GPIO_MODE Constant Definitions */ 35 /*---------------------------------------------------------------------------------------------------------*/ 36 #define GPIO_MODE_INPUT 0x0UL /*!< Input Mode */ 37 #define GPIO_MODE_OUTPUT 0x1UL /*!< Output Mode */ 38 #define GPIO_MODE_OPEN_DRAIN 0x2UL /*!< Open-Drain Mode */ 39 #define GPIO_MODE_QUASI 0x3UL /*!< Quasi-bidirectional Mode */ 40 41 42 /*---------------------------------------------------------------------------------------------------------*/ 43 /* GPIO Interrupt Type Constant Definitions */ 44 /*---------------------------------------------------------------------------------------------------------*/ 45 #define GPIO_INT_RISING 0x00010000UL /*!< Interrupt enable by Input Rising Edge */ 46 #define GPIO_INT_FALLING 0x00000001UL /*!< Interrupt enable by Input Falling Edge */ 47 #define GPIO_INT_BOTH_EDGE 0x00010001UL /*!< Interrupt enable by both Rising Edge and Falling Edge */ 48 #define GPIO_INT_HIGH 0x01010000UL /*!< Interrupt enable by Level-High */ 49 #define GPIO_INT_LOW 0x01000001UL /*!< Interrupt enable by Level-Level */ 50 51 52 /*---------------------------------------------------------------------------------------------------------*/ 53 /* GPIO_INTTYPE Constant Definitions */ 54 /*---------------------------------------------------------------------------------------------------------*/ 55 #define GPIO_INTTYPE_EDGE 0UL /*!< GPIO_INTTYPE Setting for Edge Trigger Mode */ 56 #define GPIO_INTTYPE_LEVEL 1UL /*!< GPIO_INTTYPE Setting for Edge Level Mode */ 57 58 59 /*---------------------------------------------------------------------------------------------------------*/ 60 /* GPIO Slew Rate Type Constant Definitions */ 61 /*---------------------------------------------------------------------------------------------------------*/ 62 #define GPIO_SLEWCTL_NORMAL 0x0UL /*!< GPIO slew setting for normal Mode */ 63 #define GPIO_SLEWCTL_HIGH 0x1UL /*!< GPIO slew setting for high Mode */ 64 #define GPIO_SLEWCTL_FAST 0x2UL /*!< GPIO slew setting for fast Mode */ 65 66 67 /*---------------------------------------------------------------------------------------------------------*/ 68 /* GPIO Pull-up And Pull-down Type Constant Definitions */ 69 /*---------------------------------------------------------------------------------------------------------*/ 70 #define GPIO_PUSEL_DISABLE 0x0UL /*!< GPIO PUSEL setting for Disable Mode */ 71 #define GPIO_PUSEL_PULL_UP 0x1UL /*!< GPIO PUSEL setting for Pull-up Mode */ 72 #define GPIO_PUSEL_PULL_DOWN 0x2UL /*!< GPIO PUSEL setting for Pull-down Mode */ 73 74 75 /*---------------------------------------------------------------------------------------------------------*/ 76 /* GPIO_DBCTL Constant Definitions */ 77 /*---------------------------------------------------------------------------------------------------------*/ 78 #define GPIO_DBCTL_ICLK_ON 0x00000020UL /*!< GPIO_DBCTL setting for all IO pins edge detection circuit is always active after reset */ 79 #define GPIO_DBCTL_ICLK_OFF 0x00000000UL /*!< GPIO_DBCTL setting for edge detection circuit is active only if IO pin corresponding GPIOx_IEN bit is set to 1 */ 80 81 #define GPIO_DBCTL_DBCLKSRC_LIRC 0x00000010UL /*!< GPIO_DBCTL setting for de-bounce counter clock source is the internal 10 kHz */ 82 #define GPIO_DBCTL_DBCLKSRC_HCLK 0x00000000UL /*!< GPIO_DBCTL setting for de-bounce counter clock source is the HCLK */ 83 84 #define GPIO_DBCTL_DBCLKSEL_1 0x00000000UL /*!< GPIO_DBCTL setting for sampling cycle = 1 clocks */ 85 #define GPIO_DBCTL_DBCLKSEL_2 0x00000001UL /*!< GPIO_DBCTL setting for sampling cycle = 2 clocks */ 86 #define GPIO_DBCTL_DBCLKSEL_4 0x00000002UL /*!< GPIO_DBCTL setting for sampling cycle = 4 clocks */ 87 #define GPIO_DBCTL_DBCLKSEL_8 0x00000003UL /*!< GPIO_DBCTL setting for sampling cycle = 8 clocks */ 88 #define GPIO_DBCTL_DBCLKSEL_16 0x00000004UL /*!< GPIO_DBCTL setting for sampling cycle = 16 clocks */ 89 #define GPIO_DBCTL_DBCLKSEL_32 0x00000005UL /*!< GPIO_DBCTL setting for sampling cycle = 32 clocks */ 90 #define GPIO_DBCTL_DBCLKSEL_64 0x00000006UL /*!< GPIO_DBCTL setting for sampling cycle = 64 clocks */ 91 #define GPIO_DBCTL_DBCLKSEL_128 0x00000007UL /*!< GPIO_DBCTL setting for sampling cycle = 128 clocks */ 92 #define GPIO_DBCTL_DBCLKSEL_256 0x00000008UL /*!< GPIO_DBCTL setting for sampling cycle = 256 clocks */ 93 #define GPIO_DBCTL_DBCLKSEL_512 0x00000009UL /*!< GPIO_DBCTL setting for sampling cycle = 512 clocks */ 94 #define GPIO_DBCTL_DBCLKSEL_1024 0x0000000AUL /*!< GPIO_DBCTL setting for sampling cycle = 1024 clocks */ 95 #define GPIO_DBCTL_DBCLKSEL_2048 0x0000000BUL /*!< GPIO_DBCTL setting for sampling cycle = 2048 clocks */ 96 #define GPIO_DBCTL_DBCLKSEL_4096 0x0000000CUL /*!< GPIO_DBCTL setting for sampling cycle = 4096 clocks */ 97 #define GPIO_DBCTL_DBCLKSEL_8192 0x0000000DUL /*!< GPIO_DBCTL setting for sampling cycle = 8192 clocks */ 98 #define GPIO_DBCTL_DBCLKSEL_16384 0x0000000EUL /*!< GPIO_DBCTL setting for sampling cycle = 16384 clocks */ 99 #define GPIO_DBCTL_DBCLKSEL_32768 0x0000000FUL /*!< GPIO_DBCTL setting for sampling cycle = 32768 clocks */ 100 101 102 /** Define GPIO Pin Data Input/Output. It could be used to control each I/O pin by pin address mapping. 103 * Example 1: 104 * 105 * PA0 = 1; 106 * 107 * It is used to set PA.0 to high; 108 * 109 * Example 2: 110 * 111 * if (PA0) 112 * PA0 = 0; 113 * 114 * If PA.0 pin status is high, then set PA.0 data output to low. 115 */ 116 #if defined (SCU_INIT_IONSSET_VAL) && (SCU_INIT_IONSSET_VAL & BIT0 ) 117 # define PA_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+NS_OFFSET+(0x40*(port))) + ((pin)<<2)))) 118 #else 119 # define PA_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+(0x40*(port))) + ((pin)<<2)))) 120 #endif 121 #define PA0 PA_PIN_DATA(0, 0 ) /*!< Specify PA.0 Pin Data Input/Output */ 122 #define PA1 PA_PIN_DATA(0, 1 ) /*!< Specify PA.1 Pin Data Input/Output */ 123 #define PA2 PA_PIN_DATA(0, 2 ) /*!< Specify PA.2 Pin Data Input/Output */ 124 #define PA3 PA_PIN_DATA(0, 3 ) /*!< Specify PA.3 Pin Data Input/Output */ 125 #define PA4 PA_PIN_DATA(0, 4 ) /*!< Specify PA.4 Pin Data Input/Output */ 126 #define PA5 PA_PIN_DATA(0, 5 ) /*!< Specify PA.5 Pin Data Input/Output */ 127 #define PA6 PA_PIN_DATA(0, 6 ) /*!< Specify PA.6 Pin Data Input/Output */ 128 #define PA7 PA_PIN_DATA(0, 7 ) /*!< Specify PA.7 Pin Data Input/Output */ 129 #define PA8 PA_PIN_DATA(0, 8 ) /*!< Specify PA.8 Pin Data Input/Output */ 130 #define PA9 PA_PIN_DATA(0, 9 ) /*!< Specify PA.9 Pin Data Input/Output */ 131 #define PA10 PA_PIN_DATA(0, 10) /*!< Specify PA.10 Pin Data Input/Output */ 132 #define PA11 PA_PIN_DATA(0, 11) /*!< Specify PA.11 Pin Data Input/Output */ 133 #define PA12 PA_PIN_DATA(0, 12) /*!< Specify PA.12 Pin Data Input/Output */ 134 #define PA13 PA_PIN_DATA(0, 13) /*!< Specify PA.13 Pin Data Input/Output */ 135 #define PA14 PA_PIN_DATA(0, 14) /*!< Specify PA.14 Pin Data Input/Output */ 136 #define PA15 PA_PIN_DATA(0, 15) /*!< Specify PA.15 Pin Data Input/Output */ 137 138 #if defined (SCU_INIT_IONSSET_VAL) && (SCU_INIT_IONSSET_VAL & BIT1 ) 139 # define PB_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+NS_OFFSET+(0x40*(port))) + ((pin)<<2)))) 140 #else 141 # define PB_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+(0x40*(port))) + ((pin)<<2)))) 142 #endif 143 #define PB0 PB_PIN_DATA(1, 0 ) /*!< Specify PB.0 Pin Data Input/Output */ 144 #define PB1 PB_PIN_DATA(1, 1 ) /*!< Specify PB.1 Pin Data Input/Output */ 145 #define PB2 PB_PIN_DATA(1, 2 ) /*!< Specify PB.2 Pin Data Input/Output */ 146 #define PB3 PB_PIN_DATA(1, 3 ) /*!< Specify PB.3 Pin Data Input/Output */ 147 #define PB4 PB_PIN_DATA(1, 4 ) /*!< Specify PB.4 Pin Data Input/Output */ 148 #define PB5 PB_PIN_DATA(1, 5 ) /*!< Specify PB.5 Pin Data Input/Output */ 149 #define PB6 PB_PIN_DATA(1, 6 ) /*!< Specify PB.6 Pin Data Input/Output */ 150 #define PB7 PB_PIN_DATA(1, 7 ) /*!< Specify PB.7 Pin Data Input/Output */ 151 #define PB8 PB_PIN_DATA(1, 8 ) /*!< Specify PB.8 Pin Data Input/Output */ 152 #define PB9 PB_PIN_DATA(1, 9 ) /*!< Specify PB.9 Pin Data Input/Output */ 153 #define PB10 PB_PIN_DATA(1, 10) /*!< Specify PB.10 Pin Data Input/Output */ 154 #define PB11 PB_PIN_DATA(1, 11) /*!< Specify PB.11 Pin Data Input/Output */ 155 #define PB12 PB_PIN_DATA(1, 12) /*!< Specify PB.12 Pin Data Input/Output */ 156 #define PB13 PB_PIN_DATA(1, 13) /*!< Specify PB.13 Pin Data Input/Output */ 157 #define PB14 PB_PIN_DATA(1, 14) /*!< Specify PB.14 Pin Data Input/Output */ 158 #define PB15 PB_PIN_DATA(1, 15) /*!< Specify PB.15 Pin Data Input/Output */ 159 160 #if defined (SCU_INIT_IONSSET_VAL) && (SCU_INIT_IONSSET_VAL & BIT2 ) 161 # define PC_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+NS_OFFSET+(0x40*(port))) + ((pin)<<2)))) 162 #else 163 # define PC_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+(0x40*(port))) + ((pin)<<2)))) 164 #endif 165 #define PC0 PC_PIN_DATA(2, 0 ) /*!< Specify PC.0 Pin Data Input/Output */ 166 #define PC1 PC_PIN_DATA(2, 1 ) /*!< Specify PC.1 Pin Data Input/Output */ 167 #define PC2 PC_PIN_DATA(2, 2 ) /*!< Specify PC.2 Pin Data Input/Output */ 168 #define PC3 PC_PIN_DATA(2, 3 ) /*!< Specify PC.3 Pin Data Input/Output */ 169 #define PC4 PC_PIN_DATA(2, 4 ) /*!< Specify PC.4 Pin Data Input/Output */ 170 #define PC5 PC_PIN_DATA(2, 5 ) /*!< Specify PC.5 Pin Data Input/Output */ 171 #define PC6 PC_PIN_DATA(2, 6 ) /*!< Specify PC.6 Pin Data Input/Output */ 172 #define PC7 PC_PIN_DATA(2, 7 ) /*!< Specify PC.7 Pin Data Input/Output */ 173 #define PC8 PC_PIN_DATA(2, 8 ) /*!< Specify PC.8 Pin Data Input/Output */ 174 #define PC9 PC_PIN_DATA(2, 9 ) /*!< Specify PC.9 Pin Data Input/Output */ 175 #define PC10 PC_PIN_DATA(2, 10) /*!< Specify PC.10 Pin Data Input/Output */ 176 #define PC11 PC_PIN_DATA(2, 11) /*!< Specify PC.11 Pin Data Input/Output */ 177 #define PC12 PC_PIN_DATA(2, 12) /*!< Specify PC.12 Pin Data Input/Output */ 178 #define PC13 PC_PIN_DATA(2, 13) /*!< Specify PC.13 Pin Data Input/Output */ 179 180 #if defined (SCU_INIT_IONSSET_VAL) && (SCU_INIT_IONSSET_VAL & BIT3 ) 181 # define PD_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+NS_OFFSET+(0x40*(port))) + ((pin)<<2)))) 182 #else 183 # define PD_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+(0x40*(port))) + ((pin)<<2)))) 184 #endif 185 #define PD0 PD_PIN_DATA(3, 0 ) /*!< Specify PD.0 Pin Data Input/Output */ 186 #define PD1 PD_PIN_DATA(3, 1 ) /*!< Specify PD.1 Pin Data Input/Output */ 187 #define PD2 PD_PIN_DATA(3, 2 ) /*!< Specify PD.2 Pin Data Input/Output */ 188 #define PD3 PD_PIN_DATA(3, 3 ) /*!< Specify PD.3 Pin Data Input/Output */ 189 #define PD4 PD_PIN_DATA(3, 4 ) /*!< Specify PD.4 Pin Data Input/Output */ 190 #define PD5 PD_PIN_DATA(3, 5 ) /*!< Specify PD.5 Pin Data Input/Output */ 191 #define PD6 PD_PIN_DATA(3, 6 ) /*!< Specify PD.6 Pin Data Input/Output */ 192 #define PD7 PD_PIN_DATA(3, 7 ) /*!< Specify PD.7 Pin Data Input/Output */ 193 #define PD8 PD_PIN_DATA(3, 8 ) /*!< Specify PD.8 Pin Data Input/Output */ 194 #define PD9 PD_PIN_DATA(3, 9 ) /*!< Specify PD.9 Pin Data Input/Output */ 195 #define PD10 PD_PIN_DATA(3, 10) /*!< Specify PD.10 Pin Data Input/Output */ 196 #define PD11 PD_PIN_DATA(3, 11) /*!< Specify PD.11 Pin Data Input/Output */ 197 #define PD12 PD_PIN_DATA(3, 12) /*!< Specify PD.12 Pin Data Input/Output */ 198 #define PD13 PD_PIN_DATA(3, 13) /*!< Specify PD.13 Pin Data Input/Output */ 199 #define PD14 PD_PIN_DATA(3, 14) /*!< Specify PD.14 Pin Data Input/Output */ 200 201 #if defined (SCU_INIT_IONSSET_VAL) && (SCU_INIT_IONSSET_VAL & BIT4 ) 202 # define PE_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+NS_OFFSET+(0x40*(port))) + ((pin)<<2)))) 203 #else 204 # define PE_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+(0x40*(port))) + ((pin)<<2)))) 205 #endif 206 #define PE0 PE_PIN_DATA(4, 0 ) /*!< Specify PE.0 Pin Data Input/Output */ 207 #define PE1 PE_PIN_DATA(4, 1 ) /*!< Specify PE.1 Pin Data Input/Output */ 208 #define PE2 PE_PIN_DATA(4, 2 ) /*!< Specify PE.2 Pin Data Input/Output */ 209 #define PE3 PE_PIN_DATA(4, 3 ) /*!< Specify PE.3 Pin Data Input/Output */ 210 #define PE4 PE_PIN_DATA(4, 4 ) /*!< Specify PE.4 Pin Data Input/Output */ 211 #define PE5 PE_PIN_DATA(4, 5 ) /*!< Specify PE.5 Pin Data Input/Output */ 212 #define PE6 PE_PIN_DATA(4, 6 ) /*!< Specify PE.6 Pin Data Input/Output */ 213 #define PE7 PE_PIN_DATA(4, 7 ) /*!< Specify PE.7 Pin Data Input/Output */ 214 #define PE8 PE_PIN_DATA(4, 8 ) /*!< Specify PE.8 Pin Data Input/Output */ 215 #define PE9 PE_PIN_DATA(4, 9 ) /*!< Specify PE.9 Pin Data Input/Output */ 216 #define PE10 PE_PIN_DATA(4, 10) /*!< Specify PE.10 Pin Data Input/Output */ 217 #define PE11 PE_PIN_DATA(4, 11) /*!< Specify PE.11 Pin Data Input/Output */ 218 #define PE12 PE_PIN_DATA(4, 12) /*!< Specify PE.12 Pin Data Input/Output */ 219 #define PE13 PE_PIN_DATA(4, 13) /*!< Specify PE.13 Pin Data Input/Output */ 220 #define PE14 PE_PIN_DATA(4, 14) /*!< Specify PE.14 Pin Data Input/Output */ 221 #define PE15 PE_PIN_DATA(4, 15) /*!< Specify PE.15 Pin Data Input/Output */ 222 223 #if defined (SCU_INIT_IONSSET_VAL) && (SCU_INIT_IONSSET_VAL & BIT5 ) 224 # define PF_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+NS_OFFSET+(0x40*(port))) + ((pin)<<2)))) 225 #else 226 # define PF_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+(0x40*(port))) + ((pin)<<2)))) 227 #endif 228 #define PF0 PF_PIN_DATA(5, 0 ) /*!< Specify PF.0 Pin Data Input/Output */ 229 #define PF1 PF_PIN_DATA(5, 1 ) /*!< Specify PF.1 Pin Data Input/Output */ 230 #define PF2 PF_PIN_DATA(5, 2 ) /*!< Specify PF.2 Pin Data Input/Output */ 231 #define PF3 PF_PIN_DATA(5, 3 ) /*!< Specify PF.3 Pin Data Input/Output */ 232 #define PF4 PF_PIN_DATA(5, 4 ) /*!< Specify PF.4 Pin Data Input/Output */ 233 #define PF5 PF_PIN_DATA(5, 5 ) /*!< Specify PF.5 Pin Data Input/Output */ 234 #define PF6 PF_PIN_DATA(5, 6 ) /*!< Specify PF.6 Pin Data Input/Output */ 235 #define PF7 PF_PIN_DATA(5, 7 ) /*!< Specify PF.7 Pin Data Input/Output */ 236 #define PF8 PF_PIN_DATA(5, 8 ) /*!< Specify PF.8 Pin Data Input/Output */ 237 #define PF9 PF_PIN_DATA(5, 9 ) /*!< Specify PF.9 Pin Data Input/Output */ 238 #define PF10 PF_PIN_DATA(5, 10) /*!< Specify PF.10 Pin Data Input/Output */ 239 #define PF11 PF_PIN_DATA(5, 11) /*!< Specify PF.11 Pin Data Input/Output */ 240 241 #if defined (SCU_INIT_IONSSET_VAL) && (SCU_INIT_IONSSET_VAL & BIT6 ) 242 # define PG_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+NS_OFFSET+(0x40*(port))) + ((pin)<<2)))) 243 #else 244 # define PG_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+(0x40*(port))) + ((pin)<<2)))) 245 #endif 246 #define PG2 PG_PIN_DATA(6, 2 ) /*!< Specify PG.2 Pin Data Input/Output */ 247 #define PG3 PG_PIN_DATA(6, 3 ) /*!< Specify PG.3 Pin Data Input/Output */ 248 #define PG4 PG_PIN_DATA(6, 4 ) /*!< Specify PG.4 Pin Data Input/Output */ 249 #define PG9 PG_PIN_DATA(6, 9 ) /*!< Specify PG.9 Pin Data Input/Output */ 250 #define PG10 PG_PIN_DATA(6, 10) /*!< Specify PG.10 Pin Data Input/Output */ 251 #define PG11 PG_PIN_DATA(6, 11) /*!< Specify PG.11 Pin Data Input/Output */ 252 #define PG12 PG_PIN_DATA(6, 12) /*!< Specify PG.12 Pin Data Input/Output */ 253 #define PG13 PG_PIN_DATA(6, 13) /*!< Specify PG.13 Pin Data Input/Output */ 254 #define PG14 PG_PIN_DATA(6, 14) /*!< Specify PG.14 Pin Data Input/Output */ 255 #define PG15 PG_PIN_DATA(6, 15) /*!< Specify PG.15 Pin Data Input/Output */ 256 257 #if defined (SCU_INIT_IONSSET_VAL) && (SCU_INIT_IONSSET_VAL & BIT7 ) 258 # define PH_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+NS_OFFSET+(0x40*(port))) + ((pin)<<2)))) 259 #else 260 # define PH_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+(0x40*(port))) + ((pin)<<2)))) 261 #endif 262 #define PH4 PH_PIN_DATA(7, 4 ) /*!< Specify PH.4 Pin Data Input/Output */ 263 #define PH5 PH_PIN_DATA(7, 5 ) /*!< Specify PH.5 Pin Data Input/Output */ 264 #define PH6 PH_PIN_DATA(7, 6 ) /*!< Specify PH.6 Pin Data Input/Output */ 265 #define PH7 PH_PIN_DATA(7, 7 ) /*!< Specify PH.7 Pin Data Input/Output */ 266 #define PH8 PH_PIN_DATA(7, 8 ) /*!< Specify PH.8 Pin Data Input/Output */ 267 #define PH9 PH_PIN_DATA(7, 9 ) /*!< Specify PH.9 Pin Data Input/Output */ 268 #define PH10 PH_PIN_DATA(7, 10) /*!< Specify PH.10 Pin Data Input/Output */ 269 #define PH11 PH_PIN_DATA(7, 11) /*!< Specify PH.11 Pin Data Input/Output */ 270 271 /* GPIO bit definitions for secure */ 272 #define GPIO_PIN_DATA_S(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+(0x40*(port))) + ((pin)<<2)))) 273 #define PA0_S GPIO_PIN_DATA_S(0, 0 ) /*!< Specify PA.0 Pin Data Input/Output */ 274 #define PA1_S GPIO_PIN_DATA_S(0, 1 ) /*!< Specify PA.1 Pin Data Input/Output */ 275 #define PA2_S GPIO_PIN_DATA_S(0, 2 ) /*!< Specify PA.2 Pin Data Input/Output */ 276 #define PA3_S GPIO_PIN_DATA_S(0, 3 ) /*!< Specify PA.3 Pin Data Input/Output */ 277 #define PA4_S GPIO_PIN_DATA_S(0, 4 ) /*!< Specify PA.4 Pin Data Input/Output */ 278 #define PA5_S GPIO_PIN_DATA_S(0, 5 ) /*!< Specify PA.5 Pin Data Input/Output */ 279 #define PA6_S GPIO_PIN_DATA_S(0, 6 ) /*!< Specify PA.6 Pin Data Input/Output */ 280 #define PA7_S GPIO_PIN_DATA_S(0, 7 ) /*!< Specify PA.7 Pin Data Input/Output */ 281 #define PA8_S GPIO_PIN_DATA_S(0, 8 ) /*!< Specify PA.8 Pin Data Input/Output */ 282 #define PA9_S GPIO_PIN_DATA_S(0, 9 ) /*!< Specify PA.9 Pin Data Input/Output */ 283 #define PA10_S GPIO_PIN_DATA_S(0, 10) /*!< Specify PA.10 Pin Data Input/Output */ 284 #define PA11_S GPIO_PIN_DATA_S(0, 11) /*!< Specify PA.11 Pin Data Input/Output */ 285 #define PA12_S GPIO_PIN_DATA_S(0, 12) /*!< Specify PA.12 Pin Data Input/Output */ 286 #define PA13_S GPIO_PIN_DATA_S(0, 13) /*!< Specify PA.13 Pin Data Input/Output */ 287 #define PA14_S GPIO_PIN_DATA_S(0, 14) /*!< Specify PA.14 Pin Data Input/Output */ 288 #define PA15_S GPIO_PIN_DATA_S(0, 15) /*!< Specify PA.15 Pin Data Input/Output */ 289 #define PB0_S GPIO_PIN_DATA_S(1, 0 ) /*!< Specify PB.0 Pin Data Input/Output */ 290 #define PB1_S GPIO_PIN_DATA_S(1, 1 ) /*!< Specify PB.1 Pin Data Input/Output */ 291 #define PB2_S GPIO_PIN_DATA_S(1, 2 ) /*!< Specify PB.2 Pin Data Input/Output */ 292 #define PB3_S GPIO_PIN_DATA_S(1, 3 ) /*!< Specify PB.3 Pin Data Input/Output */ 293 #define PB4_S GPIO_PIN_DATA_S(1, 4 ) /*!< Specify PB.4 Pin Data Input/Output */ 294 #define PB5_S GPIO_PIN_DATA_S(1, 5 ) /*!< Specify PB.5 Pin Data Input/Output */ 295 #define PB6_S GPIO_PIN_DATA_S(1, 6 ) /*!< Specify PB.6 Pin Data Input/Output */ 296 #define PB7_S GPIO_PIN_DATA_S(1, 7 ) /*!< Specify PB.7 Pin Data Input/Output */ 297 #define PB8_S GPIO_PIN_DATA_S(1, 8 ) /*!< Specify PB.8 Pin Data Input/Output */ 298 #define PB9_S GPIO_PIN_DATA_S(1, 9 ) /*!< Specify PB.9 Pin Data Input/Output */ 299 #define PB10_S GPIO_PIN_DATA_S(1, 10) /*!< Specify PB.10 Pin Data Input/Output */ 300 #define PB11_S GPIO_PIN_DATA_S(1, 11) /*!< Specify PB.11 Pin Data Input/Output */ 301 #define PB12_S GPIO_PIN_DATA_S(1, 12) /*!< Specify PB.12 Pin Data Input/Output */ 302 #define PB13_S GPIO_PIN_DATA_S(1, 13) /*!< Specify PB.13 Pin Data Input/Output */ 303 #define PB14_S GPIO_PIN_DATA_S(1, 14) /*!< Specify PB.14 Pin Data Input/Output */ 304 #define PB15_S GPIO_PIN_DATA_S(1, 15) /*!< Specify PB.15 Pin Data Input/Output */ 305 #define PC0_S GPIO_PIN_DATA_S(2, 0 ) /*!< Specify PC.0 Pin Data Input/Output */ 306 #define PC1_S GPIO_PIN_DATA_S(2, 1 ) /*!< Specify PC.1 Pin Data Input/Output */ 307 #define PC2_S GPIO_PIN_DATA_S(2, 2 ) /*!< Specify PC.2 Pin Data Input/Output */ 308 #define PC3_S GPIO_PIN_DATA_S(2, 3 ) /*!< Specify PC.3 Pin Data Input/Output */ 309 #define PC4_S GPIO_PIN_DATA_S(2, 4 ) /*!< Specify PC.4 Pin Data Input/Output */ 310 #define PC5_S GPIO_PIN_DATA_S(2, 5 ) /*!< Specify PC.5 Pin Data Input/Output */ 311 #define PC6_S GPIO_PIN_DATA_S(2, 6 ) /*!< Specify PC.6 Pin Data Input/Output */ 312 #define PC7_S GPIO_PIN_DATA_S(2, 7 ) /*!< Specify PC.7 Pin Data Input/Output */ 313 #define PC8_S GPIO_PIN_DATA_S(2, 8 ) /*!< Specify PC.8 Pin Data Input/Output */ 314 #define PC9_S GPIO_PIN_DATA_S(2, 9 ) /*!< Specify PC.9 Pin Data Input/Output */ 315 #define PC10_S GPIO_PIN_DATA_S(2, 10) /*!< Specify PC.10 Pin Data Input/Output */ 316 #define PC11_S GPIO_PIN_DATA_S(2, 11) /*!< Specify PC.11 Pin Data Input/Output */ 317 #define PC12_S GPIO_PIN_DATA_S(2, 12) /*!< Specify PC.12 Pin Data Input/Output */ 318 #define PC13_S GPIO_PIN_DATA_S(2, 13) /*!< Specify PC.13 Pin Data Input/Output */ 319 #define PD0_S GPIO_PIN_DATA_S(3, 0 ) /*!< Specify PD.0 Pin Data Input/Output */ 320 #define PD1_S GPIO_PIN_DATA_S(3, 1 ) /*!< Specify PD.1 Pin Data Input/Output */ 321 #define PD2_S GPIO_PIN_DATA_S(3, 2 ) /*!< Specify PD.2 Pin Data Input/Output */ 322 #define PD3_S GPIO_PIN_DATA_S(3, 3 ) /*!< Specify PD.3 Pin Data Input/Output */ 323 #define PD4_S GPIO_PIN_DATA_S(3, 4 ) /*!< Specify PD.4 Pin Data Input/Output */ 324 #define PD5_S GPIO_PIN_DATA_S(3, 5 ) /*!< Specify PD.5 Pin Data Input/Output */ 325 #define PD6_S GPIO_PIN_DATA_S(3, 6 ) /*!< Specify PD.6 Pin Data Input/Output */ 326 #define PD7_S GPIO_PIN_DATA_S(3, 7 ) /*!< Specify PD.7 Pin Data Input/Output */ 327 #define PD8_S GPIO_PIN_DATA_S(3, 8 ) /*!< Specify PD.8 Pin Data Input/Output */ 328 #define PD9_S GPIO_PIN_DATA_S(3, 9 ) /*!< Specify PD.9 Pin Data Input/Output */ 329 #define PD10_S GPIO_PIN_DATA_S(3, 10) /*!< Specify PD.10 Pin Data Input/Output */ 330 #define PD11_S GPIO_PIN_DATA_S(3, 11) /*!< Specify PD.11 Pin Data Input/Output */ 331 #define PD12_S GPIO_PIN_DATA_S(3, 12) /*!< Specify PD.12 Pin Data Input/Output */ 332 #define PD13_S GPIO_PIN_DATA_S(3, 13) /*!< Specify PD.13 Pin Data Input/Output */ 333 #define PD14_S GPIO_PIN_DATA_S(3, 14) /*!< Specify PD.14 Pin Data Input/Output */ 334 #define PE0_S GPIO_PIN_DATA_S(4, 0 ) /*!< Specify PE.0 Pin Data Input/Output */ 335 #define PE1_S GPIO_PIN_DATA_S(4, 1 ) /*!< Specify PE.1 Pin Data Input/Output */ 336 #define PE2_S GPIO_PIN_DATA_S(4, 2 ) /*!< Specify PE.2 Pin Data Input/Output */ 337 #define PE3_S GPIO_PIN_DATA_S(4, 3 ) /*!< Specify PE.3 Pin Data Input/Output */ 338 #define PE4_S GPIO_PIN_DATA_S(4, 4 ) /*!< Specify PE.4 Pin Data Input/Output */ 339 #define PE5_S GPIO_PIN_DATA_S(4, 5 ) /*!< Specify PE.5 Pin Data Input/Output */ 340 #define PE6_S GPIO_PIN_DATA_S(4, 6 ) /*!< Specify PE.6 Pin Data Input/Output */ 341 #define PE7_S GPIO_PIN_DATA_S(4, 7 ) /*!< Specify PE.7 Pin Data Input/Output */ 342 #define PE8_S GPIO_PIN_DATA_S(4, 8 ) /*!< Specify PE.8 Pin Data Input/Output */ 343 #define PE9_S GPIO_PIN_DATA_S(4, 9 ) /*!< Specify PE.9 Pin Data Input/Output */ 344 #define PE10_S GPIO_PIN_DATA_S(4, 10) /*!< Specify PE.10 Pin Data Input/Output */ 345 #define PE11_S GPIO_PIN_DATA_S(4, 11) /*!< Specify PE.11 Pin Data Input/Output */ 346 #define PE12_S GPIO_PIN_DATA_S(4, 12) /*!< Specify PE.12 Pin Data Input/Output */ 347 #define PE13_S GPIO_PIN_DATA_S(4, 13) /*!< Specify PE.13 Pin Data Input/Output */ 348 #define PE14_S GPIO_PIN_DATA_S(4, 14) /*!< Specify PE.14 Pin Data Input/Output */ 349 #define PE15_S GPIO_PIN_DATA_S(4, 15) /*!< Specify PE.15 Pin Data Input/Output */ 350 #define PF0_S GPIO_PIN_DATA_S(5, 0 ) /*!< Specify PF.0 Pin Data Input/Output */ 351 #define PF1_S GPIO_PIN_DATA_S(5, 1 ) /*!< Specify PF.1 Pin Data Input/Output */ 352 #define PF2_S GPIO_PIN_DATA_S(5, 2 ) /*!< Specify PF.2 Pin Data Input/Output */ 353 #define PF3_S GPIO_PIN_DATA_S(5, 3 ) /*!< Specify PF.3 Pin Data Input/Output */ 354 #define PF4_S GPIO_PIN_DATA_S(5, 4 ) /*!< Specify PF.4 Pin Data Input/Output */ 355 #define PF5_S GPIO_PIN_DATA_S(5, 5 ) /*!< Specify PF.5 Pin Data Input/Output */ 356 #define PF6_S GPIO_PIN_DATA_S(5, 6 ) /*!< Specify PF.6 Pin Data Input/Output */ 357 #define PF7_S GPIO_PIN_DATA_S(5, 7 ) /*!< Specify PF.7 Pin Data Input/Output */ 358 #define PF8_S GPIO_PIN_DATA_S(5, 8 ) /*!< Specify PF.8 Pin Data Input/Output */ 359 #define PF9_S GPIO_PIN_DATA_S(5, 9 ) /*!< Specify PF.9 Pin Data Input/Output */ 360 #define PF10_S GPIO_PIN_DATA_S(5, 10) /*!< Specify PF.10 Pin Data Input/Output */ 361 #define PF11_S GPIO_PIN_DATA_S(5, 11) /*!< Specify PF.11 Pin Data Input/Output */ 362 #define PG2_S GPIO_PIN_DATA_S(6, 2 ) /*!< Specify PG.2 Pin Data Input/Output */ 363 #define PG3_S GPIO_PIN_DATA_S(6, 3 ) /*!< Specify PG.3 Pin Data Input/Output */ 364 #define PG4_S GPIO_PIN_DATA_S(6, 4 ) /*!< Specify PG.4 Pin Data Input/Output */ 365 #define PG9_S GPIO_PIN_DATA_S(6, 9 ) /*!< Specify PG.9 Pin Data Input/Output */ 366 #define PG10_S GPIO_PIN_DATA_S(6, 10) /*!< Specify PG.10 Pin Data Input/Output */ 367 #define PG11_S GPIO_PIN_DATA_S(6, 11) /*!< Specify PG.11 Pin Data Input/Output */ 368 #define PG12_S GPIO_PIN_DATA_S(6, 12) /*!< Specify PG.12 Pin Data Input/Output */ 369 #define PG13_S GPIO_PIN_DATA_S(6, 13) /*!< Specify PG.13 Pin Data Input/Output */ 370 #define PG14_S GPIO_PIN_DATA_S(6, 14) /*!< Specify PG.14 Pin Data Input/Output */ 371 #define PG15_S GPIO_PIN_DATA_S(6, 15) /*!< Specify PG.15 Pin Data Input/Output */ 372 #define PH4_S GPIO_PIN_DATA_S(7, 4 ) /*!< Specify PH.4 Pin Data Input/Output */ 373 #define PH5_S GPIO_PIN_DATA_S(7, 5 ) /*!< Specify PH.5 Pin Data Input/Output */ 374 #define PH6_S GPIO_PIN_DATA_S(7, 6 ) /*!< Specify PH.6 Pin Data Input/Output */ 375 #define PH7_S GPIO_PIN_DATA_S(7, 7 ) /*!< Specify PH.7 Pin Data Input/Output */ 376 #define PH8_S GPIO_PIN_DATA_S(7, 8 ) /*!< Specify PH.8 Pin Data Input/Output */ 377 #define PH9_S GPIO_PIN_DATA_S(7, 9 ) /*!< Specify PH.9 Pin Data Input/Output */ 378 #define PH10_S GPIO_PIN_DATA_S(7, 10) /*!< Specify PH.10 Pin Data Input/Output */ 379 #define PH11_S GPIO_PIN_DATA_S(7, 11) /*!< Specify PH.11 Pin Data Input/Output */ 380 381 /* GPIO bit definitions for non-secure */ 382 #define GPIO_PIN_DATA_NS(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+NS_OFFSET+(0x40*(port))) + ((pin)<<2)))) 383 #define PA0_NS GPIO_PIN_DATA_NS(0, 0 ) /*!< Specify PA.0 Pin Data Input/Output */ 384 #define PA1_NS GPIO_PIN_DATA_NS(0, 1 ) /*!< Specify PA.1 Pin Data Input/Output */ 385 #define PA2_NS GPIO_PIN_DATA_NS(0, 2 ) /*!< Specify PA.2 Pin Data Input/Output */ 386 #define PA3_NS GPIO_PIN_DATA_NS(0, 3 ) /*!< Specify PA.3 Pin Data Input/Output */ 387 #define PA4_NS GPIO_PIN_DATA_NS(0, 4 ) /*!< Specify PA.4 Pin Data Input/Output */ 388 #define PA5_NS GPIO_PIN_DATA_NS(0, 5 ) /*!< Specify PA.5 Pin Data Input/Output */ 389 #define PA6_NS GPIO_PIN_DATA_NS(0, 6 ) /*!< Specify PA.6 Pin Data Input/Output */ 390 #define PA7_NS GPIO_PIN_DATA_NS(0, 7 ) /*!< Specify PA.7 Pin Data Input/Output */ 391 #define PA8_NS GPIO_PIN_DATA_NS(0, 8 ) /*!< Specify PA.8 Pin Data Input/Output */ 392 #define PA9_NS GPIO_PIN_DATA_NS(0, 9 ) /*!< Specify PA.9 Pin Data Input/Output */ 393 #define PA10_NS GPIO_PIN_DATA_NS(0, 10) /*!< Specify PA.10 Pin Data Input/Output */ 394 #define PA11_NS GPIO_PIN_DATA_NS(0, 11) /*!< Specify PA.11 Pin Data Input/Output */ 395 #define PA12_NS GPIO_PIN_DATA_NS(0, 12) /*!< Specify PA.12 Pin Data Input/Output */ 396 #define PA13_NS GPIO_PIN_DATA_NS(0, 13) /*!< Specify PA.13 Pin Data Input/Output */ 397 #define PA14_NS GPIO_PIN_DATA_NS(0, 14) /*!< Specify PA.14 Pin Data Input/Output */ 398 #define PA15_NS GPIO_PIN_DATA_NS(0, 15) /*!< Specify PA.15 Pin Data Input/Output */ 399 #define PB0_NS GPIO_PIN_DATA_NS(1, 0 ) /*!< Specify PB.0 Pin Data Input/Output */ 400 #define PB1_NS GPIO_PIN_DATA_NS(1, 1 ) /*!< Specify PB.1 Pin Data Input/Output */ 401 #define PB2_NS GPIO_PIN_DATA_NS(1, 2 ) /*!< Specify PB.2 Pin Data Input/Output */ 402 #define PB3_NS GPIO_PIN_DATA_NS(1, 3 ) /*!< Specify PB.3 Pin Data Input/Output */ 403 #define PB4_NS GPIO_PIN_DATA_NS(1, 4 ) /*!< Specify PB.4 Pin Data Input/Output */ 404 #define PB5_NS GPIO_PIN_DATA_NS(1, 5 ) /*!< Specify PB.5 Pin Data Input/Output */ 405 #define PB6_NS GPIO_PIN_DATA_NS(1, 6 ) /*!< Specify PB.6 Pin Data Input/Output */ 406 #define PB7_NS GPIO_PIN_DATA_NS(1, 7 ) /*!< Specify PB.7 Pin Data Input/Output */ 407 #define PB8_NS GPIO_PIN_DATA_NS(1, 8 ) /*!< Specify PB.8 Pin Data Input/Output */ 408 #define PB9_NS GPIO_PIN_DATA_NS(1, 9 ) /*!< Specify PB.9 Pin Data Input/Output */ 409 #define PB10_NS GPIO_PIN_DATA_NS(1, 10) /*!< Specify PB.10 Pin Data Input/Output */ 410 #define PB11_NS GPIO_PIN_DATA_NS(1, 11) /*!< Specify PB.11 Pin Data Input/Output */ 411 #define PB12_NS GPIO_PIN_DATA_NS(1, 12) /*!< Specify PB.12 Pin Data Input/Output */ 412 #define PB13_NS GPIO_PIN_DATA_NS(1, 13) /*!< Specify PB.13 Pin Data Input/Output */ 413 #define PB14_NS GPIO_PIN_DATA_NS(1, 14) /*!< Specify PB.14 Pin Data Input/Output */ 414 #define PB15_NS GPIO_PIN_DATA_NS(1, 15) /*!< Specify PB.15 Pin Data Input/Output */ 415 #define PC0_NS GPIO_PIN_DATA_NS(2, 0 ) /*!< Specify PC.0 Pin Data Input/Output */ 416 #define PC1_NS GPIO_PIN_DATA_NS(2, 1 ) /*!< Specify PC.1 Pin Data Input/Output */ 417 #define PC2_NS GPIO_PIN_DATA_NS(2, 2 ) /*!< Specify PC.2 Pin Data Input/Output */ 418 #define PC3_NS GPIO_PIN_DATA_NS(2, 3 ) /*!< Specify PC.3 Pin Data Input/Output */ 419 #define PC4_NS GPIO_PIN_DATA_NS(2, 4 ) /*!< Specify PC.4 Pin Data Input/Output */ 420 #define PC5_NS GPIO_PIN_DATA_NS(2, 5 ) /*!< Specify PC.5 Pin Data Input/Output */ 421 #define PC6_NS GPIO_PIN_DATA_NS(2, 6 ) /*!< Specify PC.6 Pin Data Input/Output */ 422 #define PC7_NS GPIO_PIN_DATA_NS(2, 7 ) /*!< Specify PC.7 Pin Data Input/Output */ 423 #define PC8_NS GPIO_PIN_DATA_NS(2, 8 ) /*!< Specify PC.8 Pin Data Input/Output */ 424 #define PC9_NS GPIO_PIN_DATA_NS(2, 9 ) /*!< Specify PC.9 Pin Data Input/Output */ 425 #define PC10_NS GPIO_PIN_DATA_NS(2, 10) /*!< Specify PC.10 Pin Data Input/Output */ 426 #define PC11_NS GPIO_PIN_DATA_NS(2, 11) /*!< Specify PC.11 Pin Data Input/Output */ 427 #define PC12_NS GPIO_PIN_DATA_NS(2, 12) /*!< Specify PC.12 Pin Data Input/Output */ 428 #define PC13_NS GPIO_PIN_DATA_NS(2, 13) /*!< Specify PC.13 Pin Data Input/Output */ 429 #define PD0_NS GPIO_PIN_DATA_NS(3, 0 ) /*!< Specify PD.0 Pin Data Input/Output */ 430 #define PD1_NS GPIO_PIN_DATA_NS(3, 1 ) /*!< Specify PD.1 Pin Data Input/Output */ 431 #define PD2_NS GPIO_PIN_DATA_NS(3, 2 ) /*!< Specify PD.2 Pin Data Input/Output */ 432 #define PD3_NS GPIO_PIN_DATA_NS(3, 3 ) /*!< Specify PD.3 Pin Data Input/Output */ 433 #define PD4_NS GPIO_PIN_DATA_NS(3, 4 ) /*!< Specify PD.4 Pin Data Input/Output */ 434 #define PD5_NS GPIO_PIN_DATA_NS(3, 5 ) /*!< Specify PD.5 Pin Data Input/Output */ 435 #define PD6_NS GPIO_PIN_DATA_NS(3, 6 ) /*!< Specify PD.6 Pin Data Input/Output */ 436 #define PD7_NS GPIO_PIN_DATA_NS(3, 7 ) /*!< Specify PD.7 Pin Data Input/Output */ 437 #define PD8_NS GPIO_PIN_DATA_NS(3, 8 ) /*!< Specify PD.8 Pin Data Input/Output */ 438 #define PD9_NS GPIO_PIN_DATA_NS(3, 9 ) /*!< Specify PD.9 Pin Data Input/Output */ 439 #define PD10_NS GPIO_PIN_DATA_NS(3, 10) /*!< Specify PD.10 Pin Data Input/Output */ 440 #define PD11_NS GPIO_PIN_DATA_NS(3, 11) /*!< Specify PD.11 Pin Data Input/Output */ 441 #define PD12_NS GPIO_PIN_DATA_NS(3, 12) /*!< Specify PD.12 Pin Data Input/Output */ 442 #define PD13_NS GPIO_PIN_DATA_NS(3, 13) /*!< Specify PD.13 Pin Data Input/Output */ 443 #define PD14_NS GPIO_PIN_DATA_NS(3, 14) /*!< Specify PD.14 Pin Data Input/Output */ 444 #define PE0_NS GPIO_PIN_DATA_NS(4, 0 ) /*!< Specify PE.0 Pin Data Input/Output */ 445 #define PE1_NS GPIO_PIN_DATA_NS(4, 1 ) /*!< Specify PE.1 Pin Data Input/Output */ 446 #define PE2_NS GPIO_PIN_DATA_NS(4, 2 ) /*!< Specify PE.2 Pin Data Input/Output */ 447 #define PE3_NS GPIO_PIN_DATA_NS(4, 3 ) /*!< Specify PE.3 Pin Data Input/Output */ 448 #define PE4_NS GPIO_PIN_DATA_NS(4, 4 ) /*!< Specify PE.4 Pin Data Input/Output */ 449 #define PE5_NS GPIO_PIN_DATA_NS(4, 5 ) /*!< Specify PE.5 Pin Data Input/Output */ 450 #define PE6_NS GPIO_PIN_DATA_NS(4, 6 ) /*!< Specify PE.6 Pin Data Input/Output */ 451 #define PE7_NS GPIO_PIN_DATA_NS(4, 7 ) /*!< Specify PE.7 Pin Data Input/Output */ 452 #define PE8_NS GPIO_PIN_DATA_NS(4, 8 ) /*!< Specify PE.8 Pin Data Input/Output */ 453 #define PE9_NS GPIO_PIN_DATA_NS(4, 9 ) /*!< Specify PE.9 Pin Data Input/Output */ 454 #define PE10_NS GPIO_PIN_DATA_NS(4, 10) /*!< Specify PE.10 Pin Data Input/Output */ 455 #define PE11_NS GPIO_PIN_DATA_NS(4, 11) /*!< Specify PE.11 Pin Data Input/Output */ 456 #define PE12_NS GPIO_PIN_DATA_NS(4, 12) /*!< Specify PE.12 Pin Data Input/Output */ 457 #define PE13_NS GPIO_PIN_DATA_NS(4, 13) /*!< Specify PE.13 Pin Data Input/Output */ 458 #define PE14_NS GPIO_PIN_DATA_NS(4, 14) /*!< Specify PE.14 Pin Data Input/Output */ 459 #define PE15_NS GPIO_PIN_DATA_NS(4, 15) /*!< Specify PE.15 Pin Data Input/Output */ 460 #define PF0_NS GPIO_PIN_DATA_NS(5, 0 ) /*!< Specify PF.0 Pin Data Input/Output */ 461 #define PF1_NS GPIO_PIN_DATA_NS(5, 1 ) /*!< Specify PF.1 Pin Data Input/Output */ 462 #define PF2_NS GPIO_PIN_DATA_NS(5, 2 ) /*!< Specify PF.2 Pin Data Input/Output */ 463 #define PF3_NS GPIO_PIN_DATA_NS(5, 3 ) /*!< Specify PF.3 Pin Data Input/Output */ 464 #define PF4_NS GPIO_PIN_DATA_NS(5, 4 ) /*!< Specify PF.4 Pin Data Input/Output */ 465 #define PF5_NS GPIO_PIN_DATA_NS(5, 5 ) /*!< Specify PF.5 Pin Data Input/Output */ 466 #define PF6_NS GPIO_PIN_DATA_NS(5, 6 ) /*!< Specify PF.6 Pin Data Input/Output */ 467 #define PF7_NS GPIO_PIN_DATA_NS(5, 7 ) /*!< Specify PF.7 Pin Data Input/Output */ 468 #define PF8_NS GPIO_PIN_DATA_NS(5, 8 ) /*!< Specify PF.8 Pin Data Input/Output */ 469 #define PF9_NS GPIO_PIN_DATA_NS(5, 9 ) /*!< Specify PF.9 Pin Data Input/Output */ 470 #define PF10_NS GPIO_PIN_DATA_NS(5, 10) /*!< Specify PF.10 Pin Data Input/Output */ 471 #define PF11_NS GPIO_PIN_DATA_NS(5, 11) /*!< Specify PF.11 Pin Data Input/Output */ 472 #define PG2_NS GPIO_PIN_DATA_NS(6, 2 ) /*!< Specify PG.2 Pin Data Input/Output */ 473 #define PG3_NS GPIO_PIN_DATA_NS(6, 3 ) /*!< Specify PG.3 Pin Data Input/Output */ 474 #define PG4_NS GPIO_PIN_DATA_NS(6, 4 ) /*!< Specify PG.4 Pin Data Input/Output */ 475 #define PG9_NS GPIO_PIN_DATA_NS(6, 9 ) /*!< Specify PG.9 Pin Data Input/Output */ 476 #define PG10_NS GPIO_PIN_DATA_NS(6, 10) /*!< Specify PG.10 Pin Data Input/Output */ 477 #define PG11_NS GPIO_PIN_DATA_NS(6, 11) /*!< Specify PG.11 Pin Data Input/Output */ 478 #define PG12_NS GPIO_PIN_DATA_NS(6, 12) /*!< Specify PG.12 Pin Data Input/Output */ 479 #define PG13_NS GPIO_PIN_DATA_NS(6, 13) /*!< Specify PG.13 Pin Data Input/Output */ 480 #define PG14_NS GPIO_PIN_DATA_NS(6, 14) /*!< Specify PG.14 Pin Data Input/Output */ 481 #define PG15_NS GPIO_PIN_DATA_NS(6, 15) /*!< Specify PG.15 Pin Data Input/Output */ 482 #define PH4_NS GPIO_PIN_DATA_NS(7, 4 ) /*!< Specify PH.4 Pin Data Input/Output */ 483 #define PH5_NS GPIO_PIN_DATA_NS(7, 5 ) /*!< Specify PH.5 Pin Data Input/Output */ 484 #define PH6_NS GPIO_PIN_DATA_NS(7, 6 ) /*!< Specify PH.6 Pin Data Input/Output */ 485 #define PH7_NS GPIO_PIN_DATA_NS(7, 7 ) /*!< Specify PH.7 Pin Data Input/Output */ 486 #define PH8_NS GPIO_PIN_DATA_NS(7, 8 ) /*!< Specify PH.8 Pin Data Input/Output */ 487 #define PH9_NS GPIO_PIN_DATA_NS(7, 9 ) /*!< Specify PH.9 Pin Data Input/Output */ 488 #define PH10_NS GPIO_PIN_DATA_NS(7, 10) /*!< Specify PH.10 Pin Data Input/Output */ 489 #define PH11_NS GPIO_PIN_DATA_NS(7, 11) /*!< Specify PH.11 Pin Data Input/Output */ 490 491 /*@}*/ /* end of group GPIO_EXPORTED_CONSTANTS */ 492 493 494 /** @addtogroup GPIO_EXPORTED_FUNCTIONS GPIO Exported Functions 495 @{ 496 */ 497 498 /** 499 * @brief Clear GPIO Pin Interrupt Flag 500 * 501 * @param[in] port GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH. 502 * @param[in] u32PinMask The single or multiple pins of specified GPIO port. \n 503 * It could be BIT0 ~ BIT15 for PA, PB, PC, PD and PF. \n 504 * It could be BIT0 ~ BIT13 for PE. \n 505 * It could be BIT1 ~ BIT5, BIT7 ~ BIT12 for PG. 506 * 507 * @return None 508 * 509 * @details Clear the interrupt status of specified GPIO pin. 510 */ 511 #define GPIO_CLR_INT_FLAG(port, u32PinMask) ((port)->INTSRC = (u32PinMask)) 512 513 /** 514 * @brief Disable Pin De-bounce Function 515 * 516 * @param[in] port GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH. 517 * @param[in] u32PinMask The single or multiple pins of specified GPIO port. \n 518 * It could be BIT0 ~ BIT15 for PA, PB and PE. \n 519 * It could be BIT0 ~ BIT13 for PC. \n 520 * It could be BIT0 ~ BIT14 for PD. \n 521 * It could be BIT0 ~ BIT11 for PF. \n 522 * It could be BIT2 ~ BIT3, BIT9 ~ BIT15 for PG. \n 523 * It could be BIT4 ~ BIT11 for PH. 524 * 525 * @return None 526 * 527 * @details Disable the interrupt de-bounce function of specified GPIO pin. 528 */ 529 #define GPIO_DISABLE_DEBOUNCE(port, u32PinMask) ((port)->DBEN &= ~(u32PinMask)) 530 531 /** 532 * @brief Enable Pin De-bounce Function 533 * 534 * @param[in] port GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH. 535 * @param[in] u32PinMask The single or multiple pins of specified GPIO port. \n 536 * It could be BIT0 ~ BIT15 for PA, PB and PE. \n 537 * It could be BIT0 ~ BIT13 for PC. \n 538 * It could be BIT0 ~ BIT14 for PD. \n 539 * It could be BIT0 ~ BIT11 for PF. \n 540 * It could be BIT2 ~ BIT3, BIT9 ~ BIT15 for PG. \n 541 * It could be BIT4 ~ BIT11 for PH. 542 * @return None 543 * 544 * @details Enable the interrupt de-bounce function of specified GPIO pin. 545 */ 546 #define GPIO_ENABLE_DEBOUNCE(port, u32PinMask) ((port)->DBEN |= (u32PinMask)) 547 548 /** 549 * @brief Disable I/O Digital Input Path 550 * 551 * @param[in] port GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH. 552 * @param[in] u32PinMask The single or multiple pins of specified GPIO port. \n 553 * It could be BIT0 ~ BIT15 for PA, PB and PE. \n 554 * It could be BIT0 ~ BIT13 for PC. \n 555 * It could be BIT0 ~ BIT14 for PD. \n 556 * It could be BIT0 ~ BIT11 for PF. \n 557 * It could be BIT2 ~ BIT3, BIT9 ~ BIT15 for PG. \n 558 * It could be BIT4 ~ BIT11 for PH. 559 * 560 * @return None 561 * 562 * @details Disable I/O digital input path of specified GPIO pin. 563 */ 564 #define GPIO_DISABLE_DIGITAL_PATH(port, u32PinMask) ((port)->DINOFF |= ((u32PinMask)<<16)) 565 566 /** 567 * @brief Enable I/O Digital Input Path 568 * 569 * @param[in] port GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH. 570 * @param[in] u32PinMask The single or multiple pins of specified GPIO port. \n 571 * It could be BIT0 ~ BIT15 for PA, PB and PE. \n 572 * It could be BIT0 ~ BIT13 for PC. \n 573 * It could be BIT0 ~ BIT14 for PD. \n 574 * It could be BIT0 ~ BIT11 for PF. \n 575 * It could be BIT2 ~ BIT3, BIT9 ~ BIT15 for PG. \n 576 * It could be BIT4 ~ BIT11 for PH. 577 * 578 * @return None 579 * 580 * @details Enable I/O digital input path of specified GPIO pin. 581 */ 582 #define GPIO_ENABLE_DIGITAL_PATH(port, u32PinMask) ((port)->DINOFF &= ~((u32PinMask)<<16)) 583 584 /** 585 * @brief Disable I/O DOUT mask 586 * 587 * @param[in] port GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH. 588 * @param[in] u32PinMask The single or multiple pins of specified GPIO port. \n 589 * It could be BIT0 ~ BIT15 for PA, PB and PE. \n 590 * It could be BIT0 ~ BIT13 for PC. \n 591 * It could be BIT0 ~ BIT14 for PD. \n 592 * It could be BIT0 ~ BIT11 for PF. \n 593 * It could be BIT2 ~ BIT3, BIT9 ~ BIT15 for PG. \n 594 * It could be BIT4 ~ BIT11 for PH. 595 * 596 * @return None 597 * 598 * @details Disable I/O DOUT mask of specified GPIO pin. 599 */ 600 #define GPIO_DISABLE_DOUT_MASK(port, u32PinMask) ((port)->DATMSK &= ~(u32PinMask)) 601 602 /** 603 * @brief Enable I/O DOUT mask 604 * 605 * @param[in] port GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH. 606 * @param[in] u32PinMask The single or multiple pins of specified GPIO port. \n 607 * It could be BIT0 ~ BIT15 for PA, PB and PE. \n 608 * It could be BIT0 ~ BIT13 for PC. \n 609 * It could be BIT0 ~ BIT14 for PD. \n 610 * It could be BIT0 ~ BIT11 for PF. \n 611 * It could be BIT2 ~ BIT3, BIT9 ~ BIT15 for PG. \n 612 * It could be BIT4 ~ BIT11 for PH. 613 * 614 * @return None 615 * 616 * @details Enable I/O DOUT mask of specified GPIO pin. 617 */ 618 #define GPIO_ENABLE_DOUT_MASK(port, u32PinMask) ((port)->DATMSK |= (u32PinMask)) 619 620 /** 621 * @brief Get GPIO Pin Interrupt Flag 622 * 623 * @param[in] port GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH. 624 * @param[in] u32PinMask The single or multiple pins of specified GPIO port. \n 625 * It could be BIT0 ~ BIT15 for PA, PB and PE. \n 626 * It could be BIT0 ~ BIT13 for PC. \n 627 * It could be BIT0 ~ BIT14 for PD. \n 628 * It could be BIT0 ~ BIT11 for PF. \n 629 * It could be BIT2 ~ BIT3, BIT9 ~ BIT15 for PG. \n 630 * It could be BIT4 ~ BIT11 for PH. 631 * 632 * @retval 0 No interrupt at specified GPIO pin 633 * @retval 1 The specified GPIO pin generate an interrupt 634 * 635 * @details Get the interrupt status of specified GPIO pin. 636 */ 637 #define GPIO_GET_INT_FLAG(port, u32PinMask) ((port)->INTSRC & (u32PinMask)) 638 639 /** 640 * @brief Set De-bounce Sampling Cycle Time 641 * 642 * @param[in] port GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH. 643 * @param[in] u32ClkSrc The de-bounce counter clock source. It could be GPIO_DBCTL_DBCLKSRC_HCLK or GPIO_DBCTL_DBCLKSRC_LIRC. 644 * @param[in] u32ClkSel The de-bounce sampling cycle selection. It could be 645 * - \ref GPIO_DBCTL_DBCLKSEL_1 646 * - \ref GPIO_DBCTL_DBCLKSEL_2 647 * - \ref GPIO_DBCTL_DBCLKSEL_4 648 * - \ref GPIO_DBCTL_DBCLKSEL_8 649 * - \ref GPIO_DBCTL_DBCLKSEL_16 650 * - \ref GPIO_DBCTL_DBCLKSEL_32 651 * - \ref GPIO_DBCTL_DBCLKSEL_64 652 * - \ref GPIO_DBCTL_DBCLKSEL_128 653 * - \ref GPIO_DBCTL_DBCLKSEL_256 654 * - \ref GPIO_DBCTL_DBCLKSEL_512 655 * - \ref GPIO_DBCTL_DBCLKSEL_1024 656 * - \ref GPIO_DBCTL_DBCLKSEL_2048 657 * - \ref GPIO_DBCTL_DBCLKSEL_4096 658 * - \ref GPIO_DBCTL_DBCLKSEL_8192 659 * - \ref GPIO_DBCTL_DBCLKSEL_16384 660 * - \ref GPIO_DBCTL_DBCLKSEL_32768 661 * 662 * @return None 663 * 664 * @details Set the interrupt de-bounce sampling cycle time based on the debounce counter clock source. \n 665 * Example: _GPIO_SET_DEBOUNCE_TIME(PA, GPIO_DBCTL_DBCLKSRC_LIRC, GPIO_DBCTL_DBCLKSEL_4). \n 666 * It's meaning the De-debounce counter clock source is internal 10 KHz and sampling cycle selection is 4. \n 667 * Then the target de-bounce sampling cycle time is (4)*(1/(10*1000)) s = 4*0.0001 s = 400 us, 668 * and system will sampling interrupt input once per 400 us. 669 */ 670 #define GPIO_SET_DEBOUNCE_TIME(port, u32ClkSrc, u32ClkSel) ((port)->DBCTL = (GPIO_DBCTL_ICLKON_Msk | (u32ClkSrc) | (u32ClkSel))) 671 672 /** 673 * @brief Get GPIO Port IN Data 674 * 675 * @param[in] port GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH. 676 * 677 * @return The specified port data 678 * 679 * @details Get the PIN register of specified GPIO port. 680 */ 681 #define GPIO_GET_IN_DATA(port) ((port)->PIN) 682 683 /** 684 * @brief Set GPIO Port OUT Data 685 * 686 * @param[in] port GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH. 687 * @param[in] u32Data GPIO port data. 688 * 689 * @return None 690 * 691 * @details Set the Data into specified GPIO port. 692 */ 693 #define GPIO_SET_OUT_DATA(port, u32Data) ((port)->DOUT = (u32Data)) 694 695 /** 696 * @brief Toggle Specified GPIO pin 697 * 698 * @param[in] u32Pin Pxy 699 * 700 * @return None 701 * 702 * @details Toggle the specified GPIO pint. 703 */ 704 #define GPIO_TOGGLE(u32Pin) ((u32Pin) ^= 1) 705 706 707 /** 708 * @brief Enable External GPIO interrupt 709 * 710 * @param[in] port GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH. 711 * @param[in] u32Pin The pin of specified GPIO port. \n 712 * It could be 0 ~ 15 for PA, PB and PE. \n 713 * It could be 0 ~ 13 for PC GPIO port. \n 714 * It could be 0 ~ 14 for PD GPIO port. \n 715 * It could be 0 ~ 11 for PF GPIO port. \n 716 * It could be 2 ~ 4, 9 ~ 15 for PG GPIO port. \n 717 * It could be 4 ~ 11 for PH GPIO port. 718 * @param[in] u32IntAttribs The interrupt attribute of specified GPIO pin. It could be 719 * - \ref GPIO_INT_RISING 720 * - \ref GPIO_INT_FALLING 721 * - \ref GPIO_INT_BOTH_EDGE 722 * - \ref GPIO_INT_HIGH 723 * - \ref GPIO_INT_LOW 724 * 725 * @return None 726 * 727 * @details This function is used to enable specified GPIO pin interrupt. 728 */ 729 #define GPIO_EnableEINT GPIO_EnableInt 730 731 /** 732 * @brief Disable External GPIO interrupt 733 * 734 * @param[in] port GPIO port. It could be PA, PB, PC, PD, PE, PF, PG or PH. 735 * @param[in] u32Pin The pin of specified GPIO port. \n 736 * It could be 0 ~ 15 for PA, PB and PE. \n 737 * It could be 0 ~ 13 for PC GPIO port. \n 738 * It could be 0 ~ 14 for PD GPIO port. \n 739 * It could be 0 ~ 11 for PF GPIO port. \n 740 * It could be 2 ~ 4, 9 ~ 15 for PG GPIO port. \n 741 * It could be 4 ~ 11 for PH GPIO port. 742 * 743 * @return None 744 * 745 * @details This function is used to enable specified GPIO pin interrupt. 746 */ 747 #define GPIO_DisableEINT GPIO_DisableInt 748 749 750 void GPIO_SetMode(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode); 751 void GPIO_EnableInt(GPIO_T *port, uint32_t u32Pin, uint32_t u32IntAttribs); 752 void GPIO_DisableInt(GPIO_T *port, uint32_t u32Pin); 753 void GPIO_SetSlewCtl(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode); 754 void GPIO_SetPullCtl(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode); 755 756 757 /*@}*/ /* end of group GPIO_EXPORTED_FUNCTIONS */ 758 759 /*@}*/ /* end of group GPIO_Driver */ 760 761 /*@}*/ /* end of group Standard_Driver */ 762 763 #ifdef __cplusplus 764 } 765 #endif 766 767 #endif /* __GPIO_H__ */ 768 769