Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
m480_gpio.h
00001 /**************************************************************************//** 00002 * @file GPIO.h 00003 * @version V3.00 00004 * @brief M480 series GPIO driver header file 00005 * 00006 * @copyright (C) 2016 Nuvoton Technology Corp. All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without modification, 00009 * are permitted provided that the following conditions are met: 00010 * 1. Redistributions of source code must retain the above copyright notice, 00011 * this list of conditions and the following disclaimer. 00012 * 2. Redistributions in binary form must reproduce the above copyright notice, 00013 * this list of conditions and the following disclaimer in the documentation 00014 * and/or other materials provided with the distribution. 00015 * 3. Neither the name of Nuvoton Technology Corp. nor the names of its contributors 00016 * may be used to endorse or promote products derived from this software 00017 * without specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00020 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00021 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00022 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00023 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00024 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00025 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00026 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00027 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00028 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 ******************************************************************************/ 00030 #ifndef __GPIO_H__ 00031 #define __GPIO_H__ 00032 00033 00034 #ifdef __cplusplus 00035 extern "C" 00036 { 00037 #endif 00038 00039 /** @addtogroup Standard_Driver Standard Driver 00040 @{ 00041 */ 00042 00043 /** @addtogroup GPIO_Driver GPIO Driver 00044 @{ 00045 */ 00046 00047 /** @addtogroup GPIO_EXPORTED_CONSTANTS GPIO Exported Constants 00048 @{ 00049 */ 00050 00051 00052 #define GPIO_PIN_MAX 16UL /*!< Specify Maximum Pins of Each GPIO Port \hideinitializer */ 00053 00054 00055 /*---------------------------------------------------------------------------------------------------------*/ 00056 /* GPIO_MODE Constant Definitions */ 00057 /*---------------------------------------------------------------------------------------------------------*/ 00058 #define GPIO_MODE_INPUT 0x0UL /*!< Input Mode \hideinitializer */ 00059 #define GPIO_MODE_OUTPUT 0x1UL /*!< Output Mode \hideinitializer */ 00060 #define GPIO_MODE_OPEN_DRAIN 0x2UL /*!< Open-Drain Mode \hideinitializer */ 00061 #define GPIO_MODE_QUASI 0x3UL /*!< Quasi-bidirectional Mode \hideinitializer */ 00062 00063 00064 /*---------------------------------------------------------------------------------------------------------*/ 00065 /* GPIO Interrupt Type Constant Definitions */ 00066 /*---------------------------------------------------------------------------------------------------------*/ 00067 #define GPIO_INT_RISING 0x00010000UL /*!< Interrupt enable by Input Rising Edge \hideinitializer */ 00068 #define GPIO_INT_FALLING 0x00000001UL /*!< Interrupt enable by Input Falling Edge \hideinitializer */ 00069 #define GPIO_INT_BOTH_EDGE 0x00010001UL /*!< Interrupt enable by both Rising Edge and Falling Edge \hideinitializer */ 00070 #define GPIO_INT_HIGH 0x01010000UL /*!< Interrupt enable by Level-High \hideinitializer */ 00071 #define GPIO_INT_LOW 0x01000001UL /*!< Interrupt enable by Level-Level \hideinitializer */ 00072 00073 00074 /*---------------------------------------------------------------------------------------------------------*/ 00075 /* GPIO_INTTYPE Constant Definitions */ 00076 /*---------------------------------------------------------------------------------------------------------*/ 00077 #define GPIO_INTTYPE_EDGE 0UL /*!< GPIO_INTTYPE Setting for Edge Trigger Mode \hideinitializer */ 00078 #define GPIO_INTTYPE_LEVEL 1UL /*!< GPIO_INTTYPE Setting for Edge Level Mode \hideinitializer */ 00079 00080 /*---------------------------------------------------------------------------------------------------------*/ 00081 /* GPIO Slew Rate Type Constant Definitions */ 00082 /*---------------------------------------------------------------------------------------------------------*/ 00083 #define GPIO_SLEWCTL_NORMAL 0x0UL /*!< GPIO slew setting for normal Mode \hideinitializer */ 00084 #define GPIO_SLEWCTL_HIGH 0x1UL /*!< GPIO slew setting for high Mode \hideinitializer */ 00085 #define GPIO_SLEWCTL_FAST 0x2UL /*!< GPIO slew setting for fast Mode \hideinitializer */ 00086 00087 /*---------------------------------------------------------------------------------------------------------*/ 00088 /* GPIO Pull-up And Pull-down Type Constant Definitions */ 00089 /*---------------------------------------------------------------------------------------------------------*/ 00090 #define GPIO_PUSEL_DISABLE 0x0UL /*!< GPIO PUSEL setting for Disable Mode \hideinitializer */ 00091 #define GPIO_PUSEL_PULL_UP 0x1UL /*!< GPIO PUSEL setting for Pull-up Mode \hideinitializer */ 00092 #define GPIO_PUSEL_PULL_DOWN 0x2UL /*!< GPIO PUSEL setting for Pull-down Mode \hideinitializer */ 00093 00094 00095 /*---------------------------------------------------------------------------------------------------------*/ 00096 /* GPIO_DBCTL Constant Definitions */ 00097 /*---------------------------------------------------------------------------------------------------------*/ 00098 #define GPIO_DBCTL_ICLK_ON 0x00000020UL /*!< GPIO_DBCTL setting for all IO pins edge detection circuit is always active after reset \hideinitializer */ 00099 #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 \hideinitializer */ 00100 00101 #define GPIO_DBCTL_DBCLKSRC_LIRC 0x00000010UL /*!< GPIO_DBCTL setting for de-bounce counter clock source is the internal 10 kHz \hideinitializer */ 00102 #define GPIO_DBCTL_DBCLKSRC_HCLK 0x00000000UL /*!< GPIO_DBCTL setting for de-bounce counter clock source is the HCLK \hideinitializer */ 00103 00104 #define GPIO_DBCTL_DBCLKSEL_1 0x00000000UL /*!< GPIO_DBCTL setting for sampling cycle = 1 clocks \hideinitializer */ 00105 #define GPIO_DBCTL_DBCLKSEL_2 0x00000001UL /*!< GPIO_DBCTL setting for sampling cycle = 2 clocks \hideinitializer */ 00106 #define GPIO_DBCTL_DBCLKSEL_4 0x00000002UL /*!< GPIO_DBCTL setting for sampling cycle = 4 clocks \hideinitializer */ 00107 #define GPIO_DBCTL_DBCLKSEL_8 0x00000003UL /*!< GPIO_DBCTL setting for sampling cycle = 8 clocks \hideinitializer */ 00108 #define GPIO_DBCTL_DBCLKSEL_16 0x00000004UL /*!< GPIO_DBCTL setting for sampling cycle = 16 clocks \hideinitializer */ 00109 #define GPIO_DBCTL_DBCLKSEL_32 0x00000005UL /*!< GPIO_DBCTL setting for sampling cycle = 32 clocks \hideinitializer */ 00110 #define GPIO_DBCTL_DBCLKSEL_64 0x00000006UL /*!< GPIO_DBCTL setting for sampling cycle = 64 clocks \hideinitializer */ 00111 #define GPIO_DBCTL_DBCLKSEL_128 0x00000007UL /*!< GPIO_DBCTL setting for sampling cycle = 128 clocks \hideinitializer */ 00112 #define GPIO_DBCTL_DBCLKSEL_256 0x00000008UL /*!< GPIO_DBCTL setting for sampling cycle = 256 clocks \hideinitializer */ 00113 #define GPIO_DBCTL_DBCLKSEL_512 0x00000009UL /*!< GPIO_DBCTL setting for sampling cycle = 512 clocks \hideinitializer */ 00114 #define GPIO_DBCTL_DBCLKSEL_1024 0x0000000AUL /*!< GPIO_DBCTL setting for sampling cycle = 1024 clocks \hideinitializer */ 00115 #define GPIO_DBCTL_DBCLKSEL_2048 0x0000000BUL /*!< GPIO_DBCTL setting for sampling cycle = 2048 clocks \hideinitializer */ 00116 #define GPIO_DBCTL_DBCLKSEL_4096 0x0000000CUL /*!< GPIO_DBCTL setting for sampling cycle = 4096 clocks \hideinitializer */ 00117 #define GPIO_DBCTL_DBCLKSEL_8192 0x0000000DUL /*!< GPIO_DBCTL setting for sampling cycle = 8192 clocks \hideinitializer */ 00118 #define GPIO_DBCTL_DBCLKSEL_16384 0x0000000EUL /*!< GPIO_DBCTL setting for sampling cycle = 16384 clocks \hideinitializer */ 00119 #define GPIO_DBCTL_DBCLKSEL_32768 0x0000000FUL /*!< GPIO_DBCTL setting for sampling cycle = 32768 clocks \hideinitializer */ 00120 00121 00122 /* Define GPIO Pin Data Input/Output. It could be used to control each I/O pin by pin address mapping. 00123 Example 1: 00124 00125 PA0 = 1; 00126 00127 It is used to set GPIO PA.0 to high; 00128 00129 Example 2: 00130 00131 if (PA0) 00132 PA0 = 0; 00133 00134 If GPIO PA.0 pin status is high, then set GPIO PA.0 data output to low. 00135 */ 00136 #define GPIO_PIN_DATA(port, pin) (*((volatile uint32_t *)((GPIO_PIN_DATA_BASE+(0x40*(port))) + ((pin)<<2)))) /*!< Pin Data Input/Output \hideinitializer */ 00137 #define PA0 GPIO_PIN_DATA(0, 0 ) /*!< Specify PA.0 Pin Data Input/Output \hideinitializer */ 00138 #define PA1 GPIO_PIN_DATA(0, 1 ) /*!< Specify PA.1 Pin Data Input/Output \hideinitializer */ 00139 #define PA2 GPIO_PIN_DATA(0, 2 ) /*!< Specify PA.2 Pin Data Input/Output \hideinitializer */ 00140 #define PA3 GPIO_PIN_DATA(0, 3 ) /*!< Specify PA.3 Pin Data Input/Output \hideinitializer */ 00141 #define PA4 GPIO_PIN_DATA(0, 4 ) /*!< Specify PA.4 Pin Data Input/Output \hideinitializer */ 00142 #define PA5 GPIO_PIN_DATA(0, 5 ) /*!< Specify PA.5 Pin Data Input/Output \hideinitializer */ 00143 #define PA6 GPIO_PIN_DATA(0, 6 ) /*!< Specify PA.6 Pin Data Input/Output \hideinitializer */ 00144 #define PA7 GPIO_PIN_DATA(0, 7 ) /*!< Specify PA.7 Pin Data Input/Output \hideinitializer */ 00145 #define PA8 GPIO_PIN_DATA(0, 8 ) /*!< Specify PA.8 Pin Data Input/Output \hideinitializer */ 00146 #define PA9 GPIO_PIN_DATA(0, 9 ) /*!< Specify PA.9 Pin Data Input/Output \hideinitializer */ 00147 #define PA10 GPIO_PIN_DATA(0, 10) /*!< Specify PA.10 Pin Data Input/Output \hideinitializer */ 00148 #define PA11 GPIO_PIN_DATA(0, 11) /*!< Specify PA.11 Pin Data Input/Output \hideinitializer */ 00149 #define PA12 GPIO_PIN_DATA(0, 12) /*!< Specify PA.12 Pin Data Input/Output \hideinitializer */ 00150 #define PA13 GPIO_PIN_DATA(0, 13) /*!< Specify PA.13 Pin Data Input/Output \hideinitializer */ 00151 #define PA14 GPIO_PIN_DATA(0, 14) /*!< Specify PA.14 Pin Data Input/Output \hideinitializer */ 00152 #define PA15 GPIO_PIN_DATA(0, 15) /*!< Specify PA.15 Pin Data Input/Output \hideinitializer */ 00153 #define PB0 GPIO_PIN_DATA(1, 0 ) /*!< Specify PB.0 Pin Data Input/Output \hideinitializer */ 00154 #define PB1 GPIO_PIN_DATA(1, 1 ) /*!< Specify PB.1 Pin Data Input/Output \hideinitializer */ 00155 #define PB2 GPIO_PIN_DATA(1, 2 ) /*!< Specify PB.2 Pin Data Input/Output \hideinitializer */ 00156 #define PB3 GPIO_PIN_DATA(1, 3 ) /*!< Specify PB.3 Pin Data Input/Output \hideinitializer */ 00157 #define PB4 GPIO_PIN_DATA(1, 4 ) /*!< Specify PB.4 Pin Data Input/Output \hideinitializer */ 00158 #define PB5 GPIO_PIN_DATA(1, 5 ) /*!< Specify PB.5 Pin Data Input/Output \hideinitializer */ 00159 #define PB6 GPIO_PIN_DATA(1, 6 ) /*!< Specify PB.6 Pin Data Input/Output \hideinitializer */ 00160 #define PB7 GPIO_PIN_DATA(1, 7 ) /*!< Specify PB.7 Pin Data Input/Output \hideinitializer */ 00161 #define PB8 GPIO_PIN_DATA(1, 8 ) /*!< Specify PB.8 Pin Data Input/Output \hideinitializer */ 00162 #define PB9 GPIO_PIN_DATA(1, 9 ) /*!< Specify PB.9 Pin Data Input/Output \hideinitializer */ 00163 #define PB10 GPIO_PIN_DATA(1, 10) /*!< Specify PB.10 Pin Data Input/Output \hideinitializer */ 00164 #define PB11 GPIO_PIN_DATA(1, 11) /*!< Specify PB.11 Pin Data Input/Output \hideinitializer */ 00165 #define PB12 GPIO_PIN_DATA(1, 12) /*!< Specify PB.12 Pin Data Input/Output \hideinitializer */ 00166 #define PB13 GPIO_PIN_DATA(1, 13) /*!< Specify PB.13 Pin Data Input/Output \hideinitializer */ 00167 #define PB14 GPIO_PIN_DATA(1, 14) /*!< Specify PB.14 Pin Data Input/Output \hideinitializer */ 00168 #define PB15 GPIO_PIN_DATA(1, 15) /*!< Specify PB.15 Pin Data Input/Output \hideinitializer */ 00169 #define PC0 GPIO_PIN_DATA(2, 0 ) /*!< Specify PC.0 Pin Data Input/Output \hideinitializer */ 00170 #define PC1 GPIO_PIN_DATA(2, 1 ) /*!< Specify PC.1 Pin Data Input/Output \hideinitializer */ 00171 #define PC2 GPIO_PIN_DATA(2, 2 ) /*!< Specify PC.2 Pin Data Input/Output \hideinitializer */ 00172 #define PC3 GPIO_PIN_DATA(2, 3 ) /*!< Specify PC.3 Pin Data Input/Output \hideinitializer */ 00173 #define PC4 GPIO_PIN_DATA(2, 4 ) /*!< Specify PC.4 Pin Data Input/Output \hideinitializer */ 00174 #define PC5 GPIO_PIN_DATA(2, 5 ) /*!< Specify PC.5 Pin Data Input/Output \hideinitializer */ 00175 #define PC6 GPIO_PIN_DATA(2, 6 ) /*!< Specify PC.6 Pin Data Input/Output \hideinitializer */ 00176 #define PC7 GPIO_PIN_DATA(2, 7 ) /*!< Specify PC.7 Pin Data Input/Output \hideinitializer */ 00177 #define PC8 GPIO_PIN_DATA(2, 8 ) /*!< Specify PC.8 Pin Data Input/Output \hideinitializer */ 00178 #define PC9 GPIO_PIN_DATA(2, 9 ) /*!< Specify PC.9 Pin Data Input/Output \hideinitializer */ 00179 #define PC10 GPIO_PIN_DATA(2, 10) /*!< Specify PC.10 Pin Data Input/Output \hideinitializer */ 00180 #define PC11 GPIO_PIN_DATA(2, 11) /*!< Specify PC.11 Pin Data Input/Output \hideinitializer */ 00181 #define PC12 GPIO_PIN_DATA(2, 12) /*!< Specify PC.12 Pin Data Input/Output \hideinitializer */ 00182 #define PC13 GPIO_PIN_DATA(2, 13) /*!< Specify PC.13 Pin Data Input/Output \hideinitializer */ 00183 #define PC14 GPIO_PIN_DATA(2, 14) /*!< Specify PC.14 Pin Data Input/Output \hideinitializer */ 00184 #define PD0 GPIO_PIN_DATA(3, 0 ) /*!< Specify PD.0 Pin Data Input/Output \hideinitializer */ 00185 #define PD1 GPIO_PIN_DATA(3, 1 ) /*!< Specify PD.1 Pin Data Input/Output \hideinitializer */ 00186 #define PD2 GPIO_PIN_DATA(3, 2 ) /*!< Specify PD.2 Pin Data Input/Output \hideinitializer */ 00187 #define PD3 GPIO_PIN_DATA(3, 3 ) /*!< Specify PD.3 Pin Data Input/Output \hideinitializer */ 00188 #define PD4 GPIO_PIN_DATA(3, 4 ) /*!< Specify PD.4 Pin Data Input/Output \hideinitializer */ 00189 #define PD5 GPIO_PIN_DATA(3, 5 ) /*!< Specify PD.5 Pin Data Input/Output \hideinitializer */ 00190 #define PD6 GPIO_PIN_DATA(3, 6 ) /*!< Specify PD.6 Pin Data Input/Output \hideinitializer */ 00191 #define PD7 GPIO_PIN_DATA(3, 7 ) /*!< Specify PD.7 Pin Data Input/Output \hideinitializer */ 00192 #define PD8 GPIO_PIN_DATA(3, 8 ) /*!< Specify PD.8 Pin Data Input/Output \hideinitializer */ 00193 #define PD9 GPIO_PIN_DATA(3, 9 ) /*!< Specify PD.9 Pin Data Input/Output \hideinitializer */ 00194 #define PD10 GPIO_PIN_DATA(3, 10) /*!< Specify PD.10 Pin Data Input/Output \hideinitializer */ 00195 #define PD11 GPIO_PIN_DATA(3, 11) /*!< Specify PD.11 Pin Data Input/Output \hideinitializer */ 00196 #define PD12 GPIO_PIN_DATA(3, 12) /*!< Specify PD.12 Pin Data Input/Output \hideinitializer */ 00197 #define PD13 GPIO_PIN_DATA(3, 13) /*!< Specify PD.13 Pin Data Input/Output \hideinitializer */ 00198 #define PD14 GPIO_PIN_DATA(3, 14) /*!< Specify PD.14 Pin Data Input/Output \hideinitializer */ 00199 #define PE0 GPIO_PIN_DATA(4, 0 ) /*!< Specify PE.0 Pin Data Input/Output \hideinitializer */ 00200 #define PE1 GPIO_PIN_DATA(4, 1 ) /*!< Specify PE.1 Pin Data Input/Output \hideinitializer */ 00201 #define PE2 GPIO_PIN_DATA(4, 2 ) /*!< Specify PE.2 Pin Data Input/Output \hideinitializer */ 00202 #define PE3 GPIO_PIN_DATA(4, 3 ) /*!< Specify PE.3 Pin Data Input/Output \hideinitializer */ 00203 #define PE4 GPIO_PIN_DATA(4, 4 ) /*!< Specify PE.4 Pin Data Input/Output \hideinitializer */ 00204 #define PE5 GPIO_PIN_DATA(4, 5 ) /*!< Specify PE.5 Pin Data Input/Output \hideinitializer */ 00205 #define PE6 GPIO_PIN_DATA(4, 6 ) /*!< Specify PE.6 Pin Data Input/Output \hideinitializer */ 00206 #define PE7 GPIO_PIN_DATA(4, 7 ) /*!< Specify PE.7 Pin Data Input/Output \hideinitializer */ 00207 #define PE8 GPIO_PIN_DATA(4, 8 ) /*!< Specify PE.8 Pin Data Input/Output \hideinitializer */ 00208 #define PE9 GPIO_PIN_DATA(4, 9 ) /*!< Specify PE.9 Pin Data Input/Output \hideinitializer */ 00209 #define PE10 GPIO_PIN_DATA(4, 10) /*!< Specify PE.10 Pin Data Input/Output \hideinitializer */ 00210 #define PE11 GPIO_PIN_DATA(4, 11) /*!< Specify PE.11 Pin Data Input/Output \hideinitializer */ 00211 #define PE12 GPIO_PIN_DATA(4, 12) /*!< Specify PE.12 Pin Data Input/Output \hideinitializer */ 00212 #define PE13 GPIO_PIN_DATA(4, 13) /*!< Specify PE.13 Pin Data Input/Output \hideinitializer */ 00213 #define PE14 GPIO_PIN_DATA(4, 14) /*!< Specify PE.14 Pin Data Input/Output \hideinitializer */ 00214 #define PE15 GPIO_PIN_DATA(4, 15) /*!< Specify PE.15 Pin Data Input/Output \hideinitializer */ 00215 #define PF0 GPIO_PIN_DATA(5, 0 ) /*!< Specify PF.0 Pin Data Input/Output \hideinitializer */ 00216 #define PF1 GPIO_PIN_DATA(5, 1 ) /*!< Specify PF.1 Pin Data Input/Output \hideinitializer */ 00217 #define PF2 GPIO_PIN_DATA(5, 2 ) /*!< Specify PF.2 Pin Data Input/Output \hideinitializer */ 00218 #define PF3 GPIO_PIN_DATA(5, 3 ) /*!< Specify PF.3 Pin Data Input/Output \hideinitializer */ 00219 #define PF4 GPIO_PIN_DATA(5, 4 ) /*!< Specify PF.4 Pin Data Input/Output \hideinitializer */ 00220 #define PF5 GPIO_PIN_DATA(5, 5 ) /*!< Specify PF.5 Pin Data Input/Output \hideinitializer */ 00221 #define PF6 GPIO_PIN_DATA(5, 6 ) /*!< Specify PF.6 Pin Data Input/Output \hideinitializer */ 00222 #define PF7 GPIO_PIN_DATA(5, 7 ) /*!< Specify PF.7 Pin Data Input/Output \hideinitializer */ 00223 #define PF8 GPIO_PIN_DATA(5, 8 ) /*!< Specify PF.8 Pin Data Input/Output \hideinitializer */ 00224 #define PF9 GPIO_PIN_DATA(5, 9 ) /*!< Specify PF.9 Pin Data Input/Output \hideinitializer */ 00225 #define PF10 GPIO_PIN_DATA(5, 10) /*!< Specify PF.10 Pin Data Input/Output \hideinitializer */ 00226 #define PF11 GPIO_PIN_DATA(5, 11) /*!< Specify PF.11 Pin Data Input/Output \hideinitializer */ 00227 #define PG0 GPIO_PIN_DATA(6, 0 ) /*!< Specify PG.0 Pin Data Input/Output \hideinitializer */ 00228 #define PG1 GPIO_PIN_DATA(6, 1 ) /*!< Specify PG.1 Pin Data Input/Output \hideinitializer */ 00229 #define PG2 GPIO_PIN_DATA(6, 2 ) /*!< Specify PG.2 Pin Data Input/Output \hideinitializer */ 00230 #define PG3 GPIO_PIN_DATA(6, 3 ) /*!< Specify PG.3 Pin Data Input/Output \hideinitializer */ 00231 #define PG4 GPIO_PIN_DATA(6, 4 ) /*!< Specify PG.4 Pin Data Input/Output \hideinitializer */ 00232 #define PG5 GPIO_PIN_DATA(6, 5 ) /*!< Specify PG.5 Pin Data Input/Output \hideinitializer */ 00233 #define PG6 GPIO_PIN_DATA(6, 6 ) /*!< Specify PG.6 Pin Data Input/Output \hideinitializer */ 00234 #define PG7 GPIO_PIN_DATA(6, 7 ) /*!< Specify PG.7 Pin Data Input/Output \hideinitializer */ 00235 #define PG8 GPIO_PIN_DATA(6, 8 ) /*!< Specify PG.8 Pin Data Input/Output \hideinitializer */ 00236 #define PG9 GPIO_PIN_DATA(6, 9 ) /*!< Specify PG.9 Pin Data Input/Output \hideinitializer */ 00237 #define PG10 GPIO_PIN_DATA(6, 10) /*!< Specify PG.10 Pin Data Input/Output \hideinitializer */ 00238 #define PG11 GPIO_PIN_DATA(6, 11) /*!< Specify PG.11 Pin Data Input/Output \hideinitializer */ 00239 #define PG12 GPIO_PIN_DATA(6, 12) /*!< Specify PG.12 Pin Data Input/Output \hideinitializer */ 00240 #define PG13 GPIO_PIN_DATA(6, 13) /*!< Specify PG.13 Pin Data Input/Output \hideinitializer */ 00241 #define PG14 GPIO_PIN_DATA(6, 14) /*!< Specify PG.14 Pin Data Input/Output \hideinitializer */ 00242 #define PG15 GPIO_PIN_DATA(6, 15) /*!< Specify PG.15 Pin Data Input/Output \hideinitializer */ 00243 #define PH0 GPIO_PIN_DATA(7, 0 ) /*!< Specify PH.0 Pin Data Input/Output \hideinitializer */ 00244 #define PH1 GPIO_PIN_DATA(7, 1 ) /*!< Specify PH.1 Pin Data Input/Output \hideinitializer */ 00245 #define PH2 GPIO_PIN_DATA(7, 2 ) /*!< Specify PH.2 Pin Data Input/Output \hideinitializer */ 00246 #define PH3 GPIO_PIN_DATA(7, 3 ) /*!< Specify PH.3 Pin Data Input/Output \hideinitializer */ 00247 #define PH4 GPIO_PIN_DATA(7, 4 ) /*!< Specify PH.4 Pin Data Input/Output \hideinitializer */ 00248 #define PH5 GPIO_PIN_DATA(7, 5 ) /*!< Specify PH.5 Pin Data Input/Output \hideinitializer */ 00249 #define PH6 GPIO_PIN_DATA(7, 6 ) /*!< Specify PH.6 Pin Data Input/Output \hideinitializer */ 00250 #define PH7 GPIO_PIN_DATA(7, 7 ) /*!< Specify PH.7 Pin Data Input/Output \hideinitializer */ 00251 #define PH8 GPIO_PIN_DATA(7, 8 ) /*!< Specify PH.8 Pin Data Input/Output \hideinitializer */ 00252 #define PH9 GPIO_PIN_DATA(7, 9 ) /*!< Specify PH.9 Pin Data Input/Output \hideinitializer */ 00253 #define PH10 GPIO_PIN_DATA(7, 10) /*!< Specify PH.10 Pin Data Input/Output \hideinitializer */ 00254 #define PH11 GPIO_PIN_DATA(7, 11) /*!< Specify PH.11 Pin Data Input/Output \hideinitializer */ 00255 00256 00257 /*@}*/ /* end of group GPIO_EXPORTED_CONSTANTS */ 00258 00259 00260 /** @addtogroup GPIO_EXPORTED_FUNCTIONS GPIO Exported Functions 00261 @{ 00262 */ 00263 00264 /** 00265 * @brief Clear GPIO Pin Interrupt Flag 00266 * 00267 * @param[in] port GPIO port. It could be It could be PA, PB, PC, PD, PE, PF, PG or PH. 00268 * @param[in] u32PinMask The single or multiple pins of specified GPIO port. 00269 * It could be BIT0 ~ BIT15 for PA, PB, PC, PD, PF and PH GPIO port. 00270 * It could be BIT0 ~ BIT13 for PE GPIO port. 00271 * It could be BIT0 ~ BIT11 for PG GPIO port. 00272 * 00273 * @return None 00274 * 00275 * @details Clear the interrupt status of specified GPIO pin. 00276 * \hideinitializer 00277 */ 00278 #define GPIO_CLR_INT_FLAG(port, u32PinMask) ((port)->INTSRC = (u32PinMask)) 00279 00280 /** 00281 * @brief Disable Pin De-bounce Function 00282 * 00283 * @param[in] port GPIO port. It could be It could be PA, PB, PC, PD, PE, PF, PG or PH. 00284 * @param[in] u32PinMask The single or multiple pins of specified GPIO port. 00285 * It could be BIT0 ~ BIT15 for PA, PB, PC, PD, PF and PH GPIO port. 00286 * It could be BIT0 ~ BIT13 for PE GPIO port. 00287 * It could be BIT0 ~ BIT11 for PG GPIO port. 00288 * 00289 * @return None 00290 * 00291 * @details Disable the interrupt de-bounce function of specified GPIO pin. 00292 * \hideinitializer 00293 */ 00294 #define GPIO_DISABLE_DEBOUNCE(port, u32PinMask) ((port)->DBEN &= ~(u32PinMask)) 00295 00296 /** 00297 * @brief Enable Pin De-bounce Function 00298 * 00299 * @param[in] port GPIO port. It could be It could be PA, PB, PC, PD, PE, PF, PG or PH. 00300 * @param[in] u32PinMask The single or multiple pins of specified GPIO port. 00301 * It could be BIT0 ~ BIT15 for PA, PB, PC, PD, PF and PH GPIO port. 00302 * It could be BIT0 ~ BIT13 for PE GPIO port. 00303 * It could be BIT0 ~ BIT11 for PG GPIO port. 00304 * @return None 00305 * 00306 * @details Enable the interrupt de-bounce function of specified GPIO pin. 00307 * \hideinitializer 00308 */ 00309 #define GPIO_ENABLE_DEBOUNCE(port, u32PinMask) ((port)->DBEN |= (u32PinMask)) 00310 00311 /** 00312 * @brief Disable I/O Digital Input Path 00313 * 00314 * @param[in] port GPIO port. It could be It could be PA, PB, PC, PD, PE, PF, PG or PH. 00315 * @param[in] u32PinMask The single or multiple pins of specified GPIO port. 00316 * It could be BIT0 ~ BIT15 for PA, PB, PC, PD, PF and PH GPIO port. 00317 * It could be BIT0 ~ BIT13 for PE GPIO port. 00318 * It could be BIT0 ~ BIT11 for PG GPIO port. 00319 * 00320 * @return None 00321 * 00322 * @details Disable I/O digital input path of specified GPIO pin. 00323 * \hideinitializer 00324 */ 00325 #define GPIO_DISABLE_DIGITAL_PATH(port, u32PinMask) ((port)->DINOFF |= ((u32PinMask)<<16)) 00326 00327 /** 00328 * @brief Enable I/O Digital Input Path 00329 * 00330 * @param[in] port GPIO port. It could be It could be PA, PB, PC, PD, PE, PF, PG or PH. 00331 * @param[in] u32PinMask The single or multiple pins of specified GPIO port. 00332 * It could be BIT0 ~ BIT15 for PA, PB, PC, PD, PF and PH GPIO port. 00333 * It could be BIT0 ~ BIT13 for PE GPIO port. 00334 * It could be BIT0 ~ BIT11 for PG GPIO port. 00335 * 00336 * @return None 00337 * 00338 * @details Enable I/O digital input path of specified GPIO pin. 00339 * \hideinitializer 00340 */ 00341 #define GPIO_ENABLE_DIGITAL_PATH(port, u32PinMask) ((port)->DINOFF &= ~((u32PinMask)<<16)) 00342 00343 /** 00344 * @brief Disable I/O DOUT mask 00345 * 00346 * @param[in] port GPIO port. It could be It could be PA, PB, PC, PD, PE, PF, PG or PH. 00347 * @param[in] u32PinMask The single or multiple pins of specified GPIO port. 00348 * It could be BIT0 ~ BIT15 for PA, PB, PC, PD, PF and PH GPIO port. 00349 * It could be BIT0 ~ BIT13 for PE GPIO port. 00350 * It could be BIT0 ~ BIT11 for PG GPIO port. 00351 * 00352 * @return None 00353 * 00354 * @details Disable I/O DOUT mask of specified GPIO pin. 00355 * \hideinitializer 00356 */ 00357 #define GPIO_DISABLE_DOUT_MASK(port, u32PinMask) ((port)->DATMSK &= ~(u32PinMask)) 00358 00359 /** 00360 * @brief Enable I/O DOUT mask 00361 * 00362 * @param[in] port GPIO port. It could be It could be PA, PB, PC, PD, PE, PF, PG or PH. 00363 * @param[in] u32PinMask The single or multiple pins of specified GPIO port. 00364 * It could be BIT0 ~ BIT15 for PA, PB, PC, PD, PF and PH GPIO port. 00365 * It could be BIT0 ~ BIT13 for PE GPIO port. 00366 * It could be BIT0 ~ BIT11 for PG GPIO port. 00367 * 00368 * @return None 00369 * 00370 * @details Enable I/O DOUT mask of specified GPIO pin. 00371 * \hideinitializer 00372 */ 00373 #define GPIO_ENABLE_DOUT_MASK(port, u32PinMask) ((port)->DATMSK |= (u32PinMask)) 00374 00375 /** 00376 * @brief Get GPIO Pin Interrupt Flag 00377 * 00378 * @param[in] port GPIO port. It could be It could be PA, PB, PC, PD, PE, PF, PG or PH. 00379 * @param[in] u32PinMask The single or multiple pins of specified GPIO port. 00380 * It could be BIT0 ~ BIT15 for PA, PB, PC, PD, PF and PH GPIO port. 00381 * It could be BIT0 ~ BIT13 for PE GPIO port. 00382 * It could be BIT0 ~ BIT11 for PG GPIO port. 00383 * 00384 * @retval 0 No interrupt at specified GPIO pin 00385 * @retval 1 The specified GPIO pin generate an interrupt 00386 * 00387 * @details Get the interrupt status of specified GPIO pin. 00388 * \hideinitializer 00389 */ 00390 #define GPIO_GET_INT_FLAG(port, u32PinMask) ((port)->INTSRC & (u32PinMask)) 00391 00392 /** 00393 * @brief Set De-bounce Sampling Cycle Time 00394 * 00395 * @param[in] u32ClkSrc The de-bounce counter clock source. It could be GPIO_DBCTL_DBCLKSRC_HCLK or GPIO_DBCTL_DBCLKSRC_LIRC. 00396 * @param[in] u32ClkSel The de-bounce sampling cycle selection. It could be 00397 * - \ref GPIO_DBCTL_DBCLKSEL_1 00398 * - \ref GPIO_DBCTL_DBCLKSEL_2 00399 * - \ref GPIO_DBCTL_DBCLKSEL_4 00400 * - \ref GPIO_DBCTL_DBCLKSEL_8 00401 * - \ref GPIO_DBCTL_DBCLKSEL_16 00402 * - \ref GPIO_DBCTL_DBCLKSEL_32 00403 * - \ref GPIO_DBCTL_DBCLKSEL_64 00404 * - \ref GPIO_DBCTL_DBCLKSEL_128 00405 * - \ref GPIO_DBCTL_DBCLKSEL_256 00406 * - \ref GPIO_DBCTL_DBCLKSEL_512 00407 * - \ref GPIO_DBCTL_DBCLKSEL_1024 00408 * - \ref GPIO_DBCTL_DBCLKSEL_2048 00409 * - \ref GPIO_DBCTL_DBCLKSEL_4096 00410 * - \ref GPIO_DBCTL_DBCLKSEL_8192 00411 * - \ref GPIO_DBCTL_DBCLKSEL_16384 00412 * - \ref GPIO_DBCTL_DBCLKSEL_32768 00413 * 00414 * @return None 00415 * 00416 * @details Set the interrupt de-bounce sampling cycle time based on the debounce counter clock source. \n 00417 * Example: _GPIO_SET_DEBOUNCE_TIME(GPIO_DBCTL_DBCLKSRC_LIRC, GPIO_DBCTL_DBCLKSEL_4). \n 00418 * It's meaning the De-debounce counter clock source is internal 10 KHz and sampling cycle selection is 4. \n 00419 * Then the target de-bounce sampling cycle time is (4)*(1/(10*1000)) s = 4*0.0001 s = 400 us, 00420 * and system will sampling interrupt input once per 00 us. 00421 * \hideinitializer 00422 */ 00423 #define GPIO_SET_DEBOUNCE_TIME(u32ClkSrc, u32ClkSel) (GPIO->DBCTL = (GPIO_DBCTL_ICLKON_Msk | (u32ClkSrc) | (u32ClkSel))) 00424 00425 /** 00426 * @brief Get GPIO Port IN Data 00427 * 00428 * @param[in] port GPIO port. It could be It could be PA, PB, PC, PD, PE, PF, PG or PH. 00429 * 00430 * @return The specified port data 00431 * 00432 * @details Get the PIN register of specified GPIO port. 00433 * \hideinitializer 00434 */ 00435 #define GPIO_GET_IN_DATA(port) ((port)->PIN) 00436 00437 /** 00438 * @brief Set GPIO Port OUT Data 00439 * 00440 * @param[in] port GPIO port. It could be It could be PA, PB, PC, PD, PE, PF, PG or PH. 00441 * @param[in] u32Data GPIO port data. 00442 * 00443 * @return None 00444 * 00445 * @details Set the Data into specified GPIO port. 00446 * \hideinitializer 00447 */ 00448 #define GPIO_SET_OUT_DATA(port, u32Data) ((port)->DOUT = (u32Data)) 00449 00450 /** 00451 * @brief Toggle Specified GPIO pin 00452 * 00453 * @param[in] u32Pin Pxy 00454 * 00455 * @return None 00456 * 00457 * @details Toggle the specified GPIO pint. 00458 * \hideinitializer 00459 */ 00460 #define GPIO_TOGGLE(u32Pin) ((u32Pin) ^= 1) 00461 00462 00463 /** 00464 * @brief Enable External GPIO interrupt 00465 * 00466 * @param[in] port GPIO port. It could be It could be PA, PB, PC, PD, PE, PF, PG or PH. 00467 * @param[in] u32Pin The pin of specified GPIO port. 00468 * It could be 0 ~ 15 for PA, PB, PC, PD, PF and PH GPIO port. 00469 * It could be 0 ~ 13 for PE GPIO port. 00470 * It could be 0 ~ 11 for PG GPIO port. 00471 * @param[in] u32IntAttribs The interrupt attribute of specified GPIO pin. It could be \n 00472 * GPIO_INT_RISING, GPIO_INT_FALLING, GPIO_INT_BOTH_EDGE, GPIO_INT_HIGH, GPIO_INT_LOW. 00473 * 00474 * @return None 00475 * 00476 * @details This function is used to enable specified GPIO pin interrupt. 00477 * \hideinitializer 00478 */ 00479 #define GPIO_EnableEINT GPIO_EnableInt 00480 00481 /** 00482 * @brief Disable External GPIO interrupt 00483 * 00484 * @param[in] port GPIO port. It could be It could be PA, PB, PC, PD, PE, PF, PG or PH. 00485 * @param[in] u32Pin The pin of specified GPIO port. 00486 * It could be 0 ~ 15 for PA, PB, PC, PD, PF and PH GPIO port. 00487 * It could be 0 ~ 13 for PE GPIO port. 00488 * It could be 0 ~ 11 for PG GPIO port. 00489 * 00490 * @return None 00491 * 00492 * @details This function is used to enable specified GPIO pin interrupt. 00493 * \hideinitializer 00494 */ 00495 #define GPIO_DisableEINT GPIO_DisableInt 00496 00497 00498 void GPIO_SetMode(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode); 00499 void GPIO_EnableInt(GPIO_T *port, uint32_t u32Pin, uint32_t u32IntAttribs); 00500 void GPIO_DisableInt(GPIO_T *port, uint32_t u32Pin); 00501 void GPIO_SetSlewCtl(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode); 00502 void GPIO_SetPullCtl(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode); 00503 00504 00505 /*@}*/ /* end of group GPIO_EXPORTED_FUNCTIONS */ 00506 00507 /*@}*/ /* end of group GPIO_Driver */ 00508 00509 /*@}*/ /* end of group Standard_Driver */ 00510 00511 00512 #ifdef __cplusplus 00513 } 00514 #endif 00515 00516 #endif /* __GPIO_H__ */ 00517 00518 /*** (C) COPYRIGHT 2013~2016 Nuvoton Technology Corp. ***/
Generated on Tue Jul 12 2022 15:37:20 by
1.7.2