The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
<>
Date:
Thu Oct 27 16:45:56 2016 +0100
Revision:
128:9bcdf88f62b0
Parent:
113:f141b2784e32
Child:
139:856d2700e60b
Release 128 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

2966: Add kw24 support https://github.com/ARMmbed/mbed-os/pull/2966
3068: MultiTech mDot - clean up PeripheralPins.c and add new pin names https://github.com/ARMmbed/mbed-os/pull/3068
3089: Kinetis HAL: Remove clock initialization code from serial and ticker https://github.com/ARMmbed/mbed-os/pull/3089
2943: [NRF5] NVIC_SetVector functionality https://github.com/ARMmbed/mbed-os/pull/2943
2938: InterruptIn changes in NCS36510 HAL. https://github.com/ARMmbed/mbed-os/pull/2938
3108: Fix sleep function for NRF52. https://github.com/ARMmbed/mbed-os/pull/3108
3076: STM32F1: Correct timer master value reading https://github.com/ARMmbed/mbed-os/pull/3076
3085: Add LOWPOWERTIMER capability for NUCLEO_F303ZE https://github.com/ARMmbed/mbed-os/pull/3085
3046: [BEETLE] Update BLE stack on Beetle board https://github.com/ARMmbed/mbed-os/pull/3046
3122: [Silicon Labs] Update of Silicon Labs HAL https://github.com/ARMmbed/mbed-os/pull/3122
3022: OnSemi RAM usage fix https://github.com/ARMmbed/mbed-os/pull/3022
3121: STM32F3: Correct UART4 and UART5 defines when using DEVICE_SERIAL_ASYNCH https://github.com/ARMmbed/mbed-os/pull/3121
3142: Targets- NUMAKER_PFM_NUC47216 remove mbed 2 https://github.com/ARMmbed/mbed-os/pull/3142

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 98:8ab26030e058 1 /***************************************************************************//**
Kojto 98:8ab26030e058 2 * @file em_gpio.h
Kojto 98:8ab26030e058 3 * @brief General Purpose IO (GPIO) peripheral API
<> 128:9bcdf88f62b0 4 * @version 5.0.0
Kojto 98:8ab26030e058 5 *******************************************************************************
Kojto 98:8ab26030e058 6 * @section License
<> 128:9bcdf88f62b0 7 * <b>Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com</b>
Kojto 98:8ab26030e058 8 *******************************************************************************
Kojto 98:8ab26030e058 9 *
Kojto 98:8ab26030e058 10 * Permission is granted to anyone to use this software for any purpose,
Kojto 98:8ab26030e058 11 * including commercial applications, and to alter it and redistribute it
Kojto 98:8ab26030e058 12 * freely, subject to the following restrictions:
Kojto 98:8ab26030e058 13 *
Kojto 98:8ab26030e058 14 * 1. The origin of this software must not be misrepresented; you must not
Kojto 98:8ab26030e058 15 * claim that you wrote the original software.
Kojto 98:8ab26030e058 16 * 2. Altered source versions must be plainly marked as such, and must not be
Kojto 98:8ab26030e058 17 * misrepresented as being the original software.
Kojto 98:8ab26030e058 18 * 3. This notice may not be removed or altered from any source distribution.
Kojto 98:8ab26030e058 19 *
Kojto 98:8ab26030e058 20 * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
Kojto 98:8ab26030e058 21 * obligation to support this Software. Silicon Labs is providing the
Kojto 98:8ab26030e058 22 * Software "AS IS", with no express or implied warranties of any kind,
Kojto 98:8ab26030e058 23 * including, but not limited to, any implied warranties of merchantability
Kojto 98:8ab26030e058 24 * or fitness for any particular purpose or warranties against infringement
Kojto 98:8ab26030e058 25 * of any proprietary rights of a third party.
Kojto 98:8ab26030e058 26 *
Kojto 98:8ab26030e058 27 * Silicon Labs will not be liable for any consequential, incidental, or
Kojto 98:8ab26030e058 28 * special damages, or any other relief, or for any claim by any third party,
Kojto 98:8ab26030e058 29 * arising from your use of this Software.
Kojto 98:8ab26030e058 30 *
Kojto 98:8ab26030e058 31 ******************************************************************************/
Kojto 98:8ab26030e058 32
Kojto 98:8ab26030e058 33
<> 128:9bcdf88f62b0 34 #ifndef EM_GPIO_H
<> 128:9bcdf88f62b0 35 #define EM_GPIO_H
Kojto 98:8ab26030e058 36
Kojto 98:8ab26030e058 37 #include "em_device.h"
Kojto 98:8ab26030e058 38 #if defined(GPIO_COUNT) && (GPIO_COUNT > 0)
Kojto 98:8ab26030e058 39
Kojto 98:8ab26030e058 40 #include <stdbool.h>
Kojto 113:f141b2784e32 41 #include "em_bus.h"
Kojto 98:8ab26030e058 42 #include "em_assert.h"
Kojto 98:8ab26030e058 43
Kojto 98:8ab26030e058 44 #ifdef __cplusplus
Kojto 98:8ab26030e058 45 extern "C" {
Kojto 98:8ab26030e058 46 #endif
Kojto 98:8ab26030e058 47
Kojto 98:8ab26030e058 48 /***************************************************************************//**
<> 128:9bcdf88f62b0 49 * @addtogroup emlib
Kojto 98:8ab26030e058 50 * @{
Kojto 98:8ab26030e058 51 ******************************************************************************/
Kojto 98:8ab26030e058 52
Kojto 98:8ab26030e058 53 /***************************************************************************//**
Kojto 98:8ab26030e058 54 * @addtogroup GPIO
Kojto 98:8ab26030e058 55 * @{
Kojto 98:8ab26030e058 56 ******************************************************************************/
Kojto 98:8ab26030e058 57
Kojto 98:8ab26030e058 58 /*******************************************************************************
Kojto 113:f141b2784e32 59 ******************************* DEFINES ***********************************
Kojto 113:f141b2784e32 60 ******************************************************************************/
Kojto 113:f141b2784e32 61
Kojto 113:f141b2784e32 62 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
Kojto 113:f141b2784e32 63 #if defined( _EFM32_TINY_FAMILY ) || defined( _EFM32_ZERO_FAMILY )
Kojto 113:f141b2784e32 64
Kojto 113:f141b2784e32 65 #define _GPIO_PORT_A_PIN_COUNT 14
Kojto 113:f141b2784e32 66 #define _GPIO_PORT_B_PIN_COUNT 10
Kojto 113:f141b2784e32 67 #define _GPIO_PORT_C_PIN_COUNT 16
Kojto 113:f141b2784e32 68 #define _GPIO_PORT_D_PIN_COUNT 9
Kojto 113:f141b2784e32 69 #define _GPIO_PORT_E_PIN_COUNT 12
Kojto 113:f141b2784e32 70 #define _GPIO_PORT_F_PIN_COUNT 6
Kojto 113:f141b2784e32 71
Kojto 113:f141b2784e32 72 #define _GPIO_PORT_A_PIN_MASK 0xF77F
Kojto 113:f141b2784e32 73 #define _GPIO_PORT_B_PIN_MASK 0x79F8
Kojto 113:f141b2784e32 74 #define _GPIO_PORT_C_PIN_MASK 0xFFFF
Kojto 113:f141b2784e32 75 #define _GPIO_PORT_D_PIN_MASK 0x01FF
Kojto 113:f141b2784e32 76 #define _GPIO_PORT_E_PIN_MASK 0xFFF0
Kojto 113:f141b2784e32 77 #define _GPIO_PORT_F_PIN_MASK 0x003F
Kojto 113:f141b2784e32 78
Kojto 113:f141b2784e32 79 #elif defined( _EFM32_HAPPY_FAMILY )
Kojto 113:f141b2784e32 80
Kojto 113:f141b2784e32 81 #define _GPIO_PORT_A_PIN_COUNT 6
Kojto 113:f141b2784e32 82 #define _GPIO_PORT_B_PIN_COUNT 5
Kojto 113:f141b2784e32 83 #define _GPIO_PORT_C_PIN_COUNT 12
Kojto 113:f141b2784e32 84 #define _GPIO_PORT_D_PIN_COUNT 4
Kojto 113:f141b2784e32 85 #define _GPIO_PORT_E_PIN_COUNT 4
Kojto 113:f141b2784e32 86 #define _GPIO_PORT_F_PIN_COUNT 6
Kojto 113:f141b2784e32 87
Kojto 113:f141b2784e32 88 #define _GPIO_PORT_A_PIN_MASK 0x0707
Kojto 113:f141b2784e32 89 #define _GPIO_PORT_B_PIN_MASK 0x6980
Kojto 113:f141b2784e32 90 #define _GPIO_PORT_C_PIN_MASK 0xEF1F
Kojto 113:f141b2784e32 91 #define _GPIO_PORT_D_PIN_MASK 0x00F0
Kojto 113:f141b2784e32 92 #define _GPIO_PORT_E_PIN_MASK 0x3C00
Kojto 113:f141b2784e32 93 #define _GPIO_PORT_F_PIN_MASK 0x003F
Kojto 113:f141b2784e32 94
Kojto 113:f141b2784e32 95 #elif defined( _EFM32_GIANT_FAMILY ) \
Kojto 113:f141b2784e32 96 || defined( _EFM32_WONDER_FAMILY )
Kojto 113:f141b2784e32 97
Kojto 113:f141b2784e32 98 #define _GPIO_PORT_A_PIN_COUNT 16
Kojto 113:f141b2784e32 99 #define _GPIO_PORT_B_PIN_COUNT 16
Kojto 113:f141b2784e32 100 #define _GPIO_PORT_C_PIN_COUNT 16
Kojto 113:f141b2784e32 101 #define _GPIO_PORT_D_PIN_COUNT 16
Kojto 113:f141b2784e32 102 #define _GPIO_PORT_E_PIN_COUNT 16
Kojto 113:f141b2784e32 103 #define _GPIO_PORT_F_PIN_COUNT 13
Kojto 113:f141b2784e32 104
Kojto 113:f141b2784e32 105 #define _GPIO_PORT_A_PIN_MASK 0xFFFF
Kojto 113:f141b2784e32 106 #define _GPIO_PORT_B_PIN_MASK 0xFFFF
Kojto 113:f141b2784e32 107 #define _GPIO_PORT_C_PIN_MASK 0xFFFF
Kojto 113:f141b2784e32 108 #define _GPIO_PORT_D_PIN_MASK 0xFFFF
Kojto 113:f141b2784e32 109 #define _GPIO_PORT_E_PIN_MASK 0xFFFF
Kojto 113:f141b2784e32 110 #define _GPIO_PORT_F_PIN_MASK 0x1FFF
Kojto 113:f141b2784e32 111
Kojto 113:f141b2784e32 112 #elif defined( _EFM32_GECKO_FAMILY )
Kojto 113:f141b2784e32 113
Kojto 113:f141b2784e32 114 #define _GPIO_PORT_A_PIN_COUNT 16
Kojto 113:f141b2784e32 115 #define _GPIO_PORT_B_PIN_COUNT 16
Kojto 113:f141b2784e32 116 #define _GPIO_PORT_C_PIN_COUNT 16
Kojto 113:f141b2784e32 117 #define _GPIO_PORT_D_PIN_COUNT 16
Kojto 113:f141b2784e32 118 #define _GPIO_PORT_E_PIN_COUNT 16
Kojto 113:f141b2784e32 119 #define _GPIO_PORT_F_PIN_COUNT 10
Kojto 113:f141b2784e32 120
Kojto 113:f141b2784e32 121 #define _GPIO_PORT_A_PIN_MASK 0xFFFF
Kojto 113:f141b2784e32 122 #define _GPIO_PORT_B_PIN_MASK 0xFFFF
Kojto 113:f141b2784e32 123 #define _GPIO_PORT_C_PIN_MASK 0xFFFF
Kojto 113:f141b2784e32 124 #define _GPIO_PORT_D_PIN_MASK 0xFFFF
Kojto 113:f141b2784e32 125 #define _GPIO_PORT_E_PIN_MASK 0xFFFF
Kojto 113:f141b2784e32 126 #define _GPIO_PORT_F_PIN_MASK 0x03FF
Kojto 113:f141b2784e32 127
Kojto 113:f141b2784e32 128 #elif defined( _EFR32_MIGHTY_FAMILY ) \
Kojto 113:f141b2784e32 129 || defined( _EFR32_BLUE_FAMILY ) \
Kojto 113:f141b2784e32 130 || defined( _EFR32_FLEX_FAMILY ) \
Kojto 113:f141b2784e32 131 || defined( _EFR32_ZAPPY_FAMILY )
Kojto 113:f141b2784e32 132
Kojto 113:f141b2784e32 133 #define _GPIO_PORT_A_PIN_COUNT 6
Kojto 113:f141b2784e32 134 #define _GPIO_PORT_B_PIN_COUNT 5
Kojto 113:f141b2784e32 135 #define _GPIO_PORT_C_PIN_COUNT 6
<> 128:9bcdf88f62b0 136 #define _GPIO_PORT_D_PIN_COUNT 6
Kojto 113:f141b2784e32 137 #define _GPIO_PORT_E_PIN_COUNT 0
Kojto 113:f141b2784e32 138 #define _GPIO_PORT_F_PIN_COUNT 8
Kojto 113:f141b2784e32 139
Kojto 113:f141b2784e32 140 #define _GPIO_PORT_A_PIN_MASK 0x003F
Kojto 113:f141b2784e32 141 #define _GPIO_PORT_B_PIN_MASK 0xF800
Kojto 113:f141b2784e32 142 #define _GPIO_PORT_C_PIN_MASK 0x0FC0
<> 128:9bcdf88f62b0 143 #define _GPIO_PORT_D_PIN_MASK 0xFC00
Kojto 113:f141b2784e32 144 #define _GPIO_PORT_E_PIN_MASK 0x0000
Kojto 113:f141b2784e32 145 #define _GPIO_PORT_F_PIN_MASK 0x00FF
Kojto 113:f141b2784e32 146
Kojto 113:f141b2784e32 147 #elif defined( _EFM32_PEARL_FAMILY ) \
Kojto 113:f141b2784e32 148 || defined( _EFM32_JADE_FAMILY )
Kojto 113:f141b2784e32 149
Kojto 113:f141b2784e32 150 #define _GPIO_PORT_A_PIN_COUNT 6
Kojto 113:f141b2784e32 151 #define _GPIO_PORT_B_PIN_COUNT 5
Kojto 113:f141b2784e32 152 #define _GPIO_PORT_C_PIN_COUNT 6
Kojto 113:f141b2784e32 153 #define _GPIO_PORT_D_PIN_COUNT 7
Kojto 113:f141b2784e32 154 #define _GPIO_PORT_E_PIN_COUNT 0
Kojto 113:f141b2784e32 155 #define _GPIO_PORT_F_PIN_COUNT 8
Kojto 113:f141b2784e32 156
Kojto 113:f141b2784e32 157 #define _GPIO_PORT_A_PIN_MASK 0x003F
Kojto 113:f141b2784e32 158 #define _GPIO_PORT_B_PIN_MASK 0xF800
Kojto 113:f141b2784e32 159 #define _GPIO_PORT_C_PIN_MASK 0x0FC0
Kojto 113:f141b2784e32 160 #define _GPIO_PORT_D_PIN_MASK 0xFE00
Kojto 113:f141b2784e32 161 #define _GPIO_PORT_E_PIN_MASK 0x0000
Kojto 113:f141b2784e32 162 #define _GPIO_PORT_F_PIN_MASK 0x00FF
Kojto 113:f141b2784e32 163
Kojto 113:f141b2784e32 164 #else
Kojto 113:f141b2784e32 165 #warning "Port and pin masks are not defined for this family."
Kojto 113:f141b2784e32 166 #endif
Kojto 113:f141b2784e32 167
Kojto 113:f141b2784e32 168 #if defined( _GPIO_PORT_G_PIN_COUNT ) && defined( _GPIO_PORT_H_PIN_COUNT )
Kojto 113:f141b2784e32 169 #define _GPIO_PORT_SIZE(port) ( \
Kojto 113:f141b2784e32 170 (port) == 0 ? _GPIO_PORT_A_PIN_COUNT : \
Kojto 113:f141b2784e32 171 (port) == 1 ? _GPIO_PORT_B_PIN_COUNT : \
Kojto 113:f141b2784e32 172 (port) == 2 ? _GPIO_PORT_C_PIN_COUNT : \
Kojto 113:f141b2784e32 173 (port) == 3 ? _GPIO_PORT_D_PIN_COUNT : \
Kojto 113:f141b2784e32 174 (port) == 4 ? _GPIO_PORT_E_PIN_COUNT : \
Kojto 113:f141b2784e32 175 (port) == 5 ? _GPIO_PORT_F_PIN_COUNT : \
Kojto 113:f141b2784e32 176 (port) == 6 ? _GPIO_PORT_G_PIN_COUNT : \
Kojto 113:f141b2784e32 177 (port) == 7 ? _GPIO_PORT_H_PIN_COUNT : \
Kojto 113:f141b2784e32 178 0)
Kojto 113:f141b2784e32 179 #else
Kojto 113:f141b2784e32 180 #define _GPIO_PORT_SIZE(port) ( \
Kojto 113:f141b2784e32 181 (port) == 0 ? _GPIO_PORT_A_PIN_COUNT : \
Kojto 113:f141b2784e32 182 (port) == 1 ? _GPIO_PORT_B_PIN_COUNT : \
Kojto 113:f141b2784e32 183 (port) == 2 ? _GPIO_PORT_C_PIN_COUNT : \
Kojto 113:f141b2784e32 184 (port) == 3 ? _GPIO_PORT_D_PIN_COUNT : \
Kojto 113:f141b2784e32 185 (port) == 4 ? _GPIO_PORT_E_PIN_COUNT : \
Kojto 113:f141b2784e32 186 (port) == 5 ? _GPIO_PORT_F_PIN_COUNT : \
Kojto 113:f141b2784e32 187 0)
Kojto 113:f141b2784e32 188 #endif
Kojto 113:f141b2784e32 189
Kojto 113:f141b2784e32 190 #if defined( _GPIO_PORT_G_PIN_MASK ) && defined( _GPIO_PORT_H_PIN_MASK )
Kojto 113:f141b2784e32 191 #define _GPIO_PORT_MASK(port) ( \
Kojto 113:f141b2784e32 192 (port) == 0 ? _GPIO_PORT_A_PIN_MASK : \
Kojto 113:f141b2784e32 193 (port) == 1 ? _GPIO_PORT_B_PIN_MASK : \
Kojto 113:f141b2784e32 194 (port) == 2 ? _GPIO_PORT_C_PIN_MASK : \
Kojto 113:f141b2784e32 195 (port) == 3 ? _GPIO_PORT_D_PIN_MASK : \
Kojto 113:f141b2784e32 196 (port) == 4 ? _GPIO_PORT_E_PIN_MASK : \
Kojto 113:f141b2784e32 197 (port) == 5 ? _GPIO_PORT_F_PIN_MASK : \
Kojto 113:f141b2784e32 198 (port) == 6 ? _GPIO_PORT_G_PIN_MASK : \
Kojto 113:f141b2784e32 199 (port) == 7 ? _GPIO_PORT_H_PIN_MASK : \
Kojto 113:f141b2784e32 200 0)
Kojto 113:f141b2784e32 201 #else
Kojto 113:f141b2784e32 202 #define _GPIO_PORT_MASK(port) ( \
Kojto 113:f141b2784e32 203 (port) == 0 ? _GPIO_PORT_A_PIN_MASK : \
Kojto 113:f141b2784e32 204 (port) == 1 ? _GPIO_PORT_B_PIN_MASK : \
Kojto 113:f141b2784e32 205 (port) == 2 ? _GPIO_PORT_C_PIN_MASK : \
Kojto 113:f141b2784e32 206 (port) == 3 ? _GPIO_PORT_D_PIN_MASK : \
Kojto 113:f141b2784e32 207 (port) == 4 ? _GPIO_PORT_E_PIN_MASK : \
Kojto 113:f141b2784e32 208 (port) == 5 ? _GPIO_PORT_F_PIN_MASK : \
Kojto 113:f141b2784e32 209 0)
Kojto 113:f141b2784e32 210 #endif
Kojto 113:f141b2784e32 211
Kojto 113:f141b2784e32 212 /** Validation of port and pin */
Kojto 113:f141b2784e32 213 #define GPIO_PORT_VALID(port) ( _GPIO_PORT_MASK(port) )
Kojto 113:f141b2784e32 214 #define GPIO_PORT_PIN_VALID(port, pin) ((( _GPIO_PORT_MASK(port)) >> (pin)) & 0x1 )
Kojto 113:f141b2784e32 215
<> 128:9bcdf88f62b0 216 #if defined(_GPIO_EXTIPINSELL_MASK)
<> 128:9bcdf88f62b0 217 /** Validation of interrupt number and pin */
<> 128:9bcdf88f62b0 218 #define GPIO_INTNO_PIN_VALID(intNo, pin) \
<> 128:9bcdf88f62b0 219 ((intNo & ~_GPIO_EXTIPINSELL_EXTIPINSEL0_MASK) \
<> 128:9bcdf88f62b0 220 == (pin & ~_GPIO_EXTIPINSELL_EXTIPINSEL0_MASK))
<> 128:9bcdf88f62b0 221 #endif
<> 128:9bcdf88f62b0 222
Kojto 113:f141b2784e32 223 /** Highest GPIO pin number */
Kojto 113:f141b2784e32 224 #define GPIO_PIN_MAX 15
Kojto 113:f141b2784e32 225
Kojto 113:f141b2784e32 226 /** Highest GPIO port number */
<> 128:9bcdf88f62b0 227 #if defined( _GPIO_PORT_J_PIN_COUNT )
<> 128:9bcdf88f62b0 228 #define GPIO_PORT_MAX 9
<> 128:9bcdf88f62b0 229 #elif defined( _GPIO_PORT_I_PIN_COUNT )
<> 128:9bcdf88f62b0 230 #define GPIO_PORT_MAX 8
<> 128:9bcdf88f62b0 231 #elif defined( _GPIO_PORT_H_PIN_COUNT )
Kojto 113:f141b2784e32 232 #define GPIO_PORT_MAX 7
<> 128:9bcdf88f62b0 233 #elif defined( _GPIO_PORT_G_PIN_COUNT )
<> 128:9bcdf88f62b0 234 #define GPIO_PORT_MAX 6
<> 128:9bcdf88f62b0 235 #elif defined( _GPIO_PORT_F_PIN_COUNT )
<> 128:9bcdf88f62b0 236 #define GPIO_PORT_MAX 5
Kojto 113:f141b2784e32 237 #else
<> 128:9bcdf88f62b0 238 #error "Max GPIO port number is undefined for this part."
Kojto 113:f141b2784e32 239 #endif
<> 128:9bcdf88f62b0 240
<> 128:9bcdf88f62b0 241 /** Highest EXT GPIO interrupt number */
<> 128:9bcdf88f62b0 242 #define GPIO_EXTINTNO_MAX 15
<> 128:9bcdf88f62b0 243
Kojto 113:f141b2784e32 244 /** @endcond */
Kojto 113:f141b2784e32 245
Kojto 113:f141b2784e32 246 /*******************************************************************************
Kojto 98:8ab26030e058 247 ******************************** ENUMS ************************************
Kojto 98:8ab26030e058 248 ******************************************************************************/
Kojto 98:8ab26030e058 249
Kojto 113:f141b2784e32 250 /** GPIO ports ids. */
Kojto 98:8ab26030e058 251 typedef enum
Kojto 98:8ab26030e058 252 {
Kojto 113:f141b2784e32 253 #if ( _GPIO_PORT_A_PIN_COUNT > 0 )
Kojto 113:f141b2784e32 254 gpioPortA = 0,
Kojto 113:f141b2784e32 255 #endif
Kojto 113:f141b2784e32 256 #if ( _GPIO_PORT_B_PIN_COUNT > 0 )
Kojto 113:f141b2784e32 257 gpioPortB = 1,
Kojto 113:f141b2784e32 258 #endif
Kojto 113:f141b2784e32 259 #if ( _GPIO_PORT_C_PIN_COUNT > 0 )
Kojto 113:f141b2784e32 260 gpioPortC = 2,
Kojto 113:f141b2784e32 261 #endif
Kojto 113:f141b2784e32 262 #if ( _GPIO_PORT_D_PIN_COUNT > 0 )
Kojto 113:f141b2784e32 263 gpioPortD = 3,
Kojto 113:f141b2784e32 264 #endif
Kojto 113:f141b2784e32 265 #if ( _GPIO_PORT_E_PIN_COUNT > 0 )
Kojto 113:f141b2784e32 266 gpioPortE = 4,
Kojto 113:f141b2784e32 267 #endif
Kojto 113:f141b2784e32 268 #if ( _GPIO_PORT_F_PIN_COUNT > 0 )
Kojto 113:f141b2784e32 269 gpioPortF = 5
Kojto 113:f141b2784e32 270 #endif
Kojto 113:f141b2784e32 271 #if defined( _GPIO_PORT_G_PIN_COUNT ) && ( _GPIO_PORT_G_PIN_COUNT > 0 )
Kojto 113:f141b2784e32 272 gpioPortG = 6
Kojto 113:f141b2784e32 273 #endif
Kojto 113:f141b2784e32 274 #if defined( _GPIO_PORT_H_PIN_COUNT ) && ( _GPIO_PORT_H_PIN_COUNT > 0 )
Kojto 113:f141b2784e32 275 gpioPortH = 7
Kojto 113:f141b2784e32 276 #endif
Kojto 98:8ab26030e058 277 } GPIO_Port_TypeDef;
Kojto 98:8ab26030e058 278
Kojto 113:f141b2784e32 279 #if defined( _GPIO_P_CTRL_DRIVEMODE_MASK )
Kojto 98:8ab26030e058 280 /** GPIO drive mode. */
Kojto 98:8ab26030e058 281 typedef enum
Kojto 98:8ab26030e058 282 {
Kojto 98:8ab26030e058 283 /** Default 6mA */
Kojto 98:8ab26030e058 284 gpioDriveModeStandard = GPIO_P_CTRL_DRIVEMODE_STANDARD,
Kojto 98:8ab26030e058 285 /** 0.5 mA */
Kojto 98:8ab26030e058 286 gpioDriveModeLowest = GPIO_P_CTRL_DRIVEMODE_LOWEST,
Kojto 98:8ab26030e058 287 /** 20 mA */
Kojto 98:8ab26030e058 288 gpioDriveModeHigh = GPIO_P_CTRL_DRIVEMODE_HIGH,
Kojto 98:8ab26030e058 289 /** 2 mA */
Kojto 98:8ab26030e058 290 gpioDriveModeLow = GPIO_P_CTRL_DRIVEMODE_LOW
Kojto 98:8ab26030e058 291 } GPIO_DriveMode_TypeDef;
Kojto 113:f141b2784e32 292 #endif
Kojto 98:8ab26030e058 293
Kojto 113:f141b2784e32 294 #if defined( _GPIO_P_CTRL_DRIVESTRENGTH_MASK ) && defined( _GPIO_P_CTRL_DRIVESTRENGTHALT_MASK )
Kojto 113:f141b2784e32 295 /** GPIO drive strength. */
Kojto 113:f141b2784e32 296 typedef enum
Kojto 113:f141b2784e32 297 {
Kojto 113:f141b2784e32 298 /** GPIO weak 1mA and alternate function weak 1mA */
Kojto 113:f141b2784e32 299 gpioDriveStrengthWeakAlternateWeak = GPIO_P_CTRL_DRIVESTRENGTH_WEAK | GPIO_P_CTRL_DRIVESTRENGTHALT_WEAK,
Kojto 113:f141b2784e32 300
Kojto 113:f141b2784e32 301 /** GPIO weak 1mA and alternate function strong 10mA */
Kojto 113:f141b2784e32 302 gpioDriveStrengthWeakAlternateStrong = GPIO_P_CTRL_DRIVESTRENGTH_WEAK | GPIO_P_CTRL_DRIVESTRENGTHALT_STRONG,
Kojto 113:f141b2784e32 303
Kojto 113:f141b2784e32 304 /** GPIO strong 10mA and alternate function weak 1mA */
Kojto 113:f141b2784e32 305 gpioDriveStrengthStrongAlternateWeak = GPIO_P_CTRL_DRIVESTRENGTH_STRONG | GPIO_P_CTRL_DRIVESTRENGTHALT_WEAK,
Kojto 113:f141b2784e32 306
Kojto 113:f141b2784e32 307 /** GPIO strong 10mA and alternate function strong 10mA */
Kojto 113:f141b2784e32 308 gpioDriveStrengthStrongAlternateStrong = GPIO_P_CTRL_DRIVESTRENGTH_STRONG | GPIO_P_CTRL_DRIVESTRENGTHALT_STRONG,
Kojto 113:f141b2784e32 309 } GPIO_DriveStrength_TypeDef;
<> 128:9bcdf88f62b0 310
<> 128:9bcdf88f62b0 311 /* Deprecated enums */
Kojto 113:f141b2784e32 312 #define gpioDriveStrengthStrong gpioDriveStrengthStrongAlternateStrong
Kojto 113:f141b2784e32 313 #define gpioDriveStrengthWeak gpioDriveStrengthWeakAlternateWeak
Kojto 113:f141b2784e32 314 #endif
Kojto 113:f141b2784e32 315
Kojto 113:f141b2784e32 316 /** Pin mode. For more details on each mode, please refer to the
Kojto 98:8ab26030e058 317 * reference manual. */
Kojto 98:8ab26030e058 318 typedef enum
Kojto 98:8ab26030e058 319 {
Kojto 98:8ab26030e058 320 /** Input disabled. Pullup if DOUT is set. */
Kojto 98:8ab26030e058 321 gpioModeDisabled = _GPIO_P_MODEL_MODE0_DISABLED,
Kojto 98:8ab26030e058 322 /** Input enabled. Filter if DOUT is set */
Kojto 98:8ab26030e058 323 gpioModeInput = _GPIO_P_MODEL_MODE0_INPUT,
Kojto 98:8ab26030e058 324 /** Input enabled. DOUT determines pull direction */
Kojto 98:8ab26030e058 325 gpioModeInputPull = _GPIO_P_MODEL_MODE0_INPUTPULL,
Kojto 98:8ab26030e058 326 /** Input enabled with filter. DOUT determines pull direction */
Kojto 98:8ab26030e058 327 gpioModeInputPullFilter = _GPIO_P_MODEL_MODE0_INPUTPULLFILTER,
Kojto 98:8ab26030e058 328 /** Push-pull output */
Kojto 98:8ab26030e058 329 gpioModePushPull = _GPIO_P_MODEL_MODE0_PUSHPULL,
Kojto 113:f141b2784e32 330 #if defined( _GPIO_P_MODEL_MODE0_PUSHPULLDRIVE )
Kojto 98:8ab26030e058 331 /** Push-pull output with drive-strength set by DRIVEMODE */
Kojto 98:8ab26030e058 332 gpioModePushPullDrive = _GPIO_P_MODEL_MODE0_PUSHPULLDRIVE,
Kojto 113:f141b2784e32 333 #endif
Kojto 113:f141b2784e32 334 #if defined( _GPIO_P_MODEL_MODE0_PUSHPULLALT )
Kojto 113:f141b2784e32 335 /** Push-pull using alternate control */
Kojto 113:f141b2784e32 336 gpioModePushPullAlternate = _GPIO_P_MODEL_MODE0_PUSHPULLALT,
Kojto 113:f141b2784e32 337 #endif
Kojto 98:8ab26030e058 338 /** Wired-or output */
Kojto 113:f141b2784e32 339 gpioModeWiredOr = _GPIO_P_MODEL_MODE0_WIREDOR,
Kojto 98:8ab26030e058 340 /** Wired-or output with pull-down */
Kojto 113:f141b2784e32 341 gpioModeWiredOrPullDown = _GPIO_P_MODEL_MODE0_WIREDORPULLDOWN,
Kojto 98:8ab26030e058 342 /** Open-drain output */
Kojto 113:f141b2784e32 343 gpioModeWiredAnd = _GPIO_P_MODEL_MODE0_WIREDAND,
Kojto 98:8ab26030e058 344 /** Open-drain output with filter */
Kojto 113:f141b2784e32 345 gpioModeWiredAndFilter = _GPIO_P_MODEL_MODE0_WIREDANDFILTER,
Kojto 98:8ab26030e058 346 /** Open-drain output with pullup */
Kojto 113:f141b2784e32 347 gpioModeWiredAndPullUp = _GPIO_P_MODEL_MODE0_WIREDANDPULLUP,
Kojto 98:8ab26030e058 348 /** Open-drain output with filter and pullup */
Kojto 113:f141b2784e32 349 gpioModeWiredAndPullUpFilter = _GPIO_P_MODEL_MODE0_WIREDANDPULLUPFILTER,
Kojto 113:f141b2784e32 350 #if defined( _GPIO_P_MODEL_MODE0_WIREDANDDRIVE )
Kojto 98:8ab26030e058 351 /** Open-drain output with drive-strength set by DRIVEMODE */
Kojto 113:f141b2784e32 352 gpioModeWiredAndDrive = _GPIO_P_MODEL_MODE0_WIREDANDDRIVE,
Kojto 98:8ab26030e058 353 /** Open-drain output with filter and drive-strength set by DRIVEMODE */
Kojto 113:f141b2784e32 354 gpioModeWiredAndDriveFilter = _GPIO_P_MODEL_MODE0_WIREDANDDRIVEFILTER,
Kojto 98:8ab26030e058 355 /** Open-drain output with pullup and drive-strength set by DRIVEMODE */
Kojto 113:f141b2784e32 356 gpioModeWiredAndDrivePullUp = _GPIO_P_MODEL_MODE0_WIREDANDDRIVEPULLUP,
Kojto 98:8ab26030e058 357 /** Open-drain output with filter, pullup and drive-strength set by DRIVEMODE */
Kojto 113:f141b2784e32 358 gpioModeWiredAndDrivePullUpFilter = _GPIO_P_MODEL_MODE0_WIREDANDDRIVEPULLUPFILTER
Kojto 113:f141b2784e32 359 #endif
Kojto 113:f141b2784e32 360 #if defined( _GPIO_P_MODEL_MODE0_WIREDANDALT )
Kojto 113:f141b2784e32 361 /** Open-drain output using alternate control */
Kojto 113:f141b2784e32 362 gpioModeWiredAndAlternate = _GPIO_P_MODEL_MODE0_WIREDANDALT,
Kojto 113:f141b2784e32 363 /** Open-drain output using alternate control with filter */
Kojto 113:f141b2784e32 364 gpioModeWiredAndAlternateFilter = _GPIO_P_MODEL_MODE0_WIREDANDALTFILTER,
Kojto 113:f141b2784e32 365 /** Open-drain output using alternate control with pullup */
Kojto 113:f141b2784e32 366 gpioModeWiredAndAlternatePullUp = _GPIO_P_MODEL_MODE0_WIREDANDALTPULLUP,
Kojto 113:f141b2784e32 367 /** Open-drain output uisng alternate control with filter and pullup */
Kojto 113:f141b2784e32 368 gpioModeWiredAndAlternatePullUpFilter = _GPIO_P_MODEL_MODE0_WIREDANDALTPULLUPFILTER,
Kojto 113:f141b2784e32 369 #endif
Kojto 98:8ab26030e058 370 } GPIO_Mode_TypeDef;
Kojto 98:8ab26030e058 371
Kojto 98:8ab26030e058 372 /*******************************************************************************
Kojto 98:8ab26030e058 373 ***************************** PROTOTYPES **********************************
Kojto 98:8ab26030e058 374 ******************************************************************************/
Kojto 98:8ab26030e058 375
Kojto 98:8ab26030e058 376 void GPIO_DbgLocationSet(unsigned int location);
Kojto 98:8ab26030e058 377
Kojto 98:8ab26030e058 378 /***************************************************************************//**
Kojto 98:8ab26030e058 379 * @brief
Kojto 98:8ab26030e058 380 * Enable/disable serial wire clock pin.
Kojto 98:8ab26030e058 381 *
Kojto 98:8ab26030e058 382 * @note
Kojto 98:8ab26030e058 383 * Disabling SWDClk will disable the debug interface, which may result in
Kojto 98:8ab26030e058 384 * a lockout if done early in startup (before debugger is able to halt core).
Kojto 98:8ab26030e058 385 *
Kojto 98:8ab26030e058 386 * @param[in] enable
Kojto 98:8ab26030e058 387 * @li false - disable serial wire clock.
Kojto 98:8ab26030e058 388 * @li true - enable serial wire clock (default after reset).
Kojto 98:8ab26030e058 389 ******************************************************************************/
Kojto 98:8ab26030e058 390 __STATIC_INLINE void GPIO_DbgSWDClkEnable(bool enable)
Kojto 98:8ab26030e058 391 {
Kojto 113:f141b2784e32 392 #if defined( _GPIO_ROUTE_SWCLKPEN_MASK )
Kojto 113:f141b2784e32 393 BUS_RegBitWrite(&(GPIO->ROUTE), _GPIO_ROUTE_SWCLKPEN_SHIFT, enable);
Kojto 113:f141b2784e32 394 #elif defined( _GPIO_ROUTEPEN_SWCLKTCKPEN_MASK )
Kojto 113:f141b2784e32 395 BUS_RegBitWrite(&(GPIO->ROUTEPEN), _GPIO_ROUTEPEN_SWCLKTCKPEN_SHIFT, enable);
Kojto 113:f141b2784e32 396 #else
Kojto 113:f141b2784e32 397 #warning "ROUTE enable for SWCLK pin is not defined."
Kojto 113:f141b2784e32 398 #endif
Kojto 98:8ab26030e058 399 }
Kojto 98:8ab26030e058 400
Kojto 98:8ab26030e058 401 /***************************************************************************//**
Kojto 98:8ab26030e058 402 * @brief
Kojto 113:f141b2784e32 403 * Enable/disable serial wire data I/O pin.
Kojto 98:8ab26030e058 404 *
Kojto 98:8ab26030e058 405 * @note
Kojto 98:8ab26030e058 406 * Disabling SWDClk will disable the debug interface, which may result in
Kojto 98:8ab26030e058 407 * a lockout if done early in startup (before debugger is able to halt core).
Kojto 98:8ab26030e058 408 *
Kojto 98:8ab26030e058 409 * @param[in] enable
Kojto 98:8ab26030e058 410 * @li false - disable serial wire data pin.
Kojto 98:8ab26030e058 411 * @li true - enable serial wire data pin (default after reset).
Kojto 98:8ab26030e058 412 ******************************************************************************/
Kojto 98:8ab26030e058 413 __STATIC_INLINE void GPIO_DbgSWDIOEnable(bool enable)
Kojto 98:8ab26030e058 414 {
Kojto 113:f141b2784e32 415 #if defined( _GPIO_ROUTE_SWDIOPEN_MASK )
Kojto 113:f141b2784e32 416 BUS_RegBitWrite(&(GPIO->ROUTE), _GPIO_ROUTE_SWDIOPEN_SHIFT, enable);
Kojto 113:f141b2784e32 417 #elif defined( _GPIO_ROUTEPEN_SWDIOTMSPEN_MASK )
Kojto 113:f141b2784e32 418 BUS_RegBitWrite(&(GPIO->ROUTEPEN), _GPIO_ROUTEPEN_SWDIOTMSPEN_SHIFT, enable);
Kojto 113:f141b2784e32 419 #else
Kojto 113:f141b2784e32 420 #warning "ROUTE enable for SWDIO pin is not defined."
Kojto 113:f141b2784e32 421 #endif
Kojto 98:8ab26030e058 422 }
Kojto 98:8ab26030e058 423
Kojto 113:f141b2784e32 424 #if defined( _GPIO_ROUTE_SWOPEN_MASK ) || defined( _GPIO_ROUTEPEN_SWVPEN_MASK )
Kojto 98:8ab26030e058 425 /***************************************************************************//**
Kojto 98:8ab26030e058 426 * @brief
Kojto 98:8ab26030e058 427 * Enable/Disable serial wire output pin.
Kojto 98:8ab26030e058 428 *
Kojto 98:8ab26030e058 429 * @note
Kojto 98:8ab26030e058 430 * Enabling this pin is not sufficient to fully enable serial wire output
Kojto 98:8ab26030e058 431 * which is also dependent on issues outside the GPIO module. Please refer to
Kojto 98:8ab26030e058 432 * DBG_SWOEnable().
Kojto 98:8ab26030e058 433 *
Kojto 98:8ab26030e058 434 * @param[in] enable
Kojto 98:8ab26030e058 435 * @li false - disable serial wire viewer pin (default after reset).
Kojto 98:8ab26030e058 436 * @li true - enable serial wire viewer pin.
Kojto 98:8ab26030e058 437 ******************************************************************************/
Kojto 98:8ab26030e058 438 __STATIC_INLINE void GPIO_DbgSWOEnable(bool enable)
Kojto 98:8ab26030e058 439 {
Kojto 113:f141b2784e32 440 #if defined( _GPIO_ROUTE_SWOPEN_MASK )
Kojto 113:f141b2784e32 441 BUS_RegBitWrite(&(GPIO->ROUTE), _GPIO_ROUTE_SWOPEN_SHIFT, enable);
Kojto 113:f141b2784e32 442 #elif defined( _GPIO_ROUTEPEN_SWVPEN_MASK )
Kojto 113:f141b2784e32 443 BUS_RegBitWrite(&(GPIO->ROUTEPEN), _GPIO_ROUTEPEN_SWVPEN_SHIFT, enable);
Kojto 113:f141b2784e32 444 #else
Kojto 113:f141b2784e32 445 #warning "ROUTE enable for SWO/SWV pin is not defined."
Kojto 113:f141b2784e32 446 #endif
Kojto 98:8ab26030e058 447 }
Kojto 98:8ab26030e058 448 #endif
Kojto 98:8ab26030e058 449
Kojto 113:f141b2784e32 450 #if defined (_GPIO_P_CTRL_DRIVEMODE_MASK)
Kojto 98:8ab26030e058 451 void GPIO_DriveModeSet(GPIO_Port_TypeDef port, GPIO_DriveMode_TypeDef mode);
Kojto 113:f141b2784e32 452 #endif
Kojto 98:8ab26030e058 453
Kojto 113:f141b2784e32 454 #if defined( _GPIO_P_CTRL_DRIVESTRENGTH_MASK )
Kojto 113:f141b2784e32 455 void GPIO_DriveStrengthSet(GPIO_Port_TypeDef port, GPIO_DriveStrength_TypeDef strength);
Kojto 113:f141b2784e32 456 #endif
Kojto 98:8ab26030e058 457
Kojto 98:8ab26030e058 458 # if defined( _GPIO_EM4WUEN_MASK )
Kojto 98:8ab26030e058 459 /**************************************************************************//**
Kojto 98:8ab26030e058 460 * @brief
Kojto 98:8ab26030e058 461 * Disable GPIO pin wake-up from EM4.
Kojto 98:8ab26030e058 462 *
Kojto 98:8ab26030e058 463 * @param[in] pinmask
Kojto 98:8ab26030e058 464 * Bitmask containing the bitwise logic OR of which GPIO pin(s) to disable.
Kojto 98:8ab26030e058 465 * Refer to Reference Manuals for pinmask to GPIO port/pin mapping.
Kojto 98:8ab26030e058 466 *****************************************************************************/
Kojto 98:8ab26030e058 467 __STATIC_INLINE void GPIO_EM4DisablePinWakeup(uint32_t pinmask)
Kojto 98:8ab26030e058 468 {
Kojto 98:8ab26030e058 469 EFM_ASSERT((pinmask & ~_GPIO_EM4WUEN_MASK) == 0);
Kojto 98:8ab26030e058 470
Kojto 98:8ab26030e058 471 GPIO->EM4WUEN &= ~pinmask;
Kojto 98:8ab26030e058 472 }
Kojto 98:8ab26030e058 473 #endif
Kojto 98:8ab26030e058 474
<> 128:9bcdf88f62b0 475 # if defined( _GPIO_EM4WUEN_MASK )
<> 128:9bcdf88f62b0 476 void GPIO_EM4EnablePinWakeup(uint32_t pinmask, uint32_t polaritymask);
<> 128:9bcdf88f62b0 477 #endif
Kojto 98:8ab26030e058 478
<> 128:9bcdf88f62b0 479 #if defined( _GPIO_EM4WUCAUSE_MASK ) || defined( _GPIO_IF_EM4WU_MASK )
Kojto 98:8ab26030e058 480 /**************************************************************************//**
Kojto 98:8ab26030e058 481 * @brief
Kojto 98:8ab26030e058 482 * Check which GPIO pin(s) that caused a wake-up from EM4.
Kojto 98:8ab26030e058 483 *
Kojto 98:8ab26030e058 484 * @return
Kojto 98:8ab26030e058 485 * Bitmask containing the bitwise logic OR of which GPIO pin(s) caused the
Kojto 98:8ab26030e058 486 * wake-up. Refer to Reference Manuals for pinmask to GPIO port/pin mapping.
Kojto 98:8ab26030e058 487 *****************************************************************************/
Kojto 98:8ab26030e058 488 __STATIC_INLINE uint32_t GPIO_EM4GetPinWakeupCause(void)
Kojto 98:8ab26030e058 489 {
Kojto 113:f141b2784e32 490 #if defined( _GPIO_EM4WUCAUSE_MASK )
Kojto 98:8ab26030e058 491 return GPIO->EM4WUCAUSE & _GPIO_EM4WUCAUSE_MASK;
Kojto 113:f141b2784e32 492 #else
<> 128:9bcdf88f62b0 493 return GPIO->IF & _GPIO_IF_EM4WU_MASK;
Kojto 113:f141b2784e32 494 #endif
Kojto 98:8ab26030e058 495 }
Kojto 98:8ab26030e058 496 #endif
Kojto 98:8ab26030e058 497
Kojto 113:f141b2784e32 498 #if defined( GPIO_CTRL_EM4RET ) || defined( _EMU_EM4CTRL_EM4IORETMODE_MASK )
Kojto 98:8ab26030e058 499 /**************************************************************************//**
Kojto 98:8ab26030e058 500 * @brief
Kojto 98:8ab26030e058 501 * Enable GPIO pin retention of output enable, output value, pull enable and
Kojto 98:8ab26030e058 502 * pull direction in EM4.
<> 128:9bcdf88f62b0 503 *
Kojto 113:f141b2784e32 504 * @note
<> 128:9bcdf88f62b0 505 * For platform 2 parts, EMU_EM4Init() and EMU_UnlatchPinRetention() offers
Kojto 113:f141b2784e32 506 * more pin retention features. This function implements the EM4EXIT retention
Kojto 113:f141b2784e32 507 * mode on platform 2.
Kojto 98:8ab26030e058 508 *
Kojto 98:8ab26030e058 509 * @param[in] enable
Kojto 98:8ab26030e058 510 * @li true - enable EM4 pin retention.
Kojto 98:8ab26030e058 511 * @li false - disable EM4 pin retention.
Kojto 98:8ab26030e058 512 *****************************************************************************/
Kojto 98:8ab26030e058 513 __STATIC_INLINE void GPIO_EM4SetPinRetention(bool enable)
Kojto 98:8ab26030e058 514 {
Kojto 98:8ab26030e058 515 if (enable)
Kojto 98:8ab26030e058 516 {
Kojto 113:f141b2784e32 517 #if defined( GPIO_CTRL_EM4RET )
Kojto 98:8ab26030e058 518 GPIO->CTRL |= GPIO_CTRL_EM4RET;
Kojto 113:f141b2784e32 519 #else
Kojto 113:f141b2784e32 520 EMU->EM4CTRL = (EMU->EM4CTRL & ~_EMU_EM4CTRL_EM4IORETMODE_MASK)
Kojto 113:f141b2784e32 521 | EMU_EM4CTRL_EM4IORETMODE_EM4EXIT;
Kojto 113:f141b2784e32 522 #endif
Kojto 98:8ab26030e058 523 }
Kojto 98:8ab26030e058 524 else
Kojto 98:8ab26030e058 525 {
Kojto 113:f141b2784e32 526 #if defined( GPIO_CTRL_EM4RET )
Kojto 98:8ab26030e058 527 GPIO->CTRL &= ~GPIO_CTRL_EM4RET;
Kojto 113:f141b2784e32 528 #else
Kojto 113:f141b2784e32 529 EMU->EM4CTRL = (EMU->EM4CTRL & ~_EMU_EM4CTRL_EM4IORETMODE_MASK)
Kojto 113:f141b2784e32 530 | EMU_EM4CTRL_EM4IORETMODE_DISABLE;
Kojto 113:f141b2784e32 531 #endif
Kojto 98:8ab26030e058 532 }
Kojto 98:8ab26030e058 533 }
Kojto 98:8ab26030e058 534 #endif
Kojto 98:8ab26030e058 535
<> 128:9bcdf88f62b0 536 void GPIO_ExtIntConfig(GPIO_Port_TypeDef port,
<> 128:9bcdf88f62b0 537 unsigned int pin,
<> 128:9bcdf88f62b0 538 unsigned int intNo,
<> 128:9bcdf88f62b0 539 bool risingEdge,
<> 128:9bcdf88f62b0 540 bool fallingEdge,
<> 128:9bcdf88f62b0 541 bool enable);
Kojto 98:8ab26030e058 542
Kojto 98:8ab26030e058 543 /***************************************************************************//**
Kojto 98:8ab26030e058 544 * @brief
Kojto 98:8ab26030e058 545 * Enable/disable input sensing.
Kojto 98:8ab26030e058 546 *
Kojto 98:8ab26030e058 547 * @details
Kojto 98:8ab26030e058 548 * Disabling input sensing if not used, can save some energy consumption.
Kojto 98:8ab26030e058 549 *
Kojto 98:8ab26030e058 550 * @param[in] val
Kojto 98:8ab26030e058 551 * Bitwise logic OR of one or more of:
Kojto 98:8ab26030e058 552 * @li GPIO_INSENSE_INT - interrupt input sensing.
Kojto 98:8ab26030e058 553 * @li GPIO_INSENSE_PRS - peripheral reflex system input sensing.
Kojto 98:8ab26030e058 554 *
Kojto 98:8ab26030e058 555 * @param[in] mask
Kojto 113:f141b2784e32 556 * Mask containing bitwise logic OR of bits similar as for @p val used to
Kojto 113:f141b2784e32 557 * indicate which input sense options to disable/enable.
Kojto 98:8ab26030e058 558 ******************************************************************************/
Kojto 98:8ab26030e058 559 __STATIC_INLINE void GPIO_InputSenseSet(uint32_t val, uint32_t mask)
Kojto 98:8ab26030e058 560 {
Kojto 98:8ab26030e058 561 GPIO->INSENSE = (GPIO->INSENSE & ~mask) | (val & mask);
Kojto 98:8ab26030e058 562 }
Kojto 98:8ab26030e058 563
Kojto 98:8ab26030e058 564 /***************************************************************************//**
Kojto 98:8ab26030e058 565 * @brief
Kojto 98:8ab26030e058 566 * Clear one or more pending GPIO interrupts.
Kojto 98:8ab26030e058 567 *
Kojto 98:8ab26030e058 568 * @param[in] flags
Kojto 98:8ab26030e058 569 * Bitwise logic OR of GPIO interrupt sources to clear.
Kojto 98:8ab26030e058 570 ******************************************************************************/
Kojto 98:8ab26030e058 571 __STATIC_INLINE void GPIO_IntClear(uint32_t flags)
Kojto 98:8ab26030e058 572 {
Kojto 98:8ab26030e058 573 GPIO->IFC = flags;
Kojto 98:8ab26030e058 574 }
Kojto 98:8ab26030e058 575
Kojto 98:8ab26030e058 576 /***************************************************************************//**
Kojto 98:8ab26030e058 577 * @brief
Kojto 98:8ab26030e058 578 * Disable one or more GPIO interrupts.
Kojto 98:8ab26030e058 579 *
Kojto 98:8ab26030e058 580 * @param[in] flags
Kojto 98:8ab26030e058 581 * GPIO interrupt sources to disable.
Kojto 98:8ab26030e058 582 ******************************************************************************/
Kojto 98:8ab26030e058 583 __STATIC_INLINE void GPIO_IntDisable(uint32_t flags)
Kojto 98:8ab26030e058 584 {
Kojto 98:8ab26030e058 585 GPIO->IEN &= ~flags;
Kojto 98:8ab26030e058 586 }
Kojto 98:8ab26030e058 587
Kojto 98:8ab26030e058 588 /***************************************************************************//**
Kojto 98:8ab26030e058 589 * @brief
Kojto 98:8ab26030e058 590 * Enable one or more GPIO interrupts.
Kojto 98:8ab26030e058 591 *
Kojto 98:8ab26030e058 592 * @note
Kojto 98:8ab26030e058 593 * Depending on the use, a pending interrupt may already be set prior to
Kojto 98:8ab26030e058 594 * enabling the interrupt. Consider using GPIO_IntClear() prior to enabling
Kojto 98:8ab26030e058 595 * if such a pending interrupt should be ignored.
Kojto 98:8ab26030e058 596 *
Kojto 98:8ab26030e058 597 * @param[in] flags
Kojto 98:8ab26030e058 598 * GPIO interrupt sources to enable.
Kojto 98:8ab26030e058 599 ******************************************************************************/
Kojto 98:8ab26030e058 600 __STATIC_INLINE void GPIO_IntEnable(uint32_t flags)
Kojto 98:8ab26030e058 601 {
Kojto 98:8ab26030e058 602 GPIO->IEN |= flags;
Kojto 98:8ab26030e058 603 }
Kojto 98:8ab26030e058 604
Kojto 98:8ab26030e058 605 /***************************************************************************//**
Kojto 98:8ab26030e058 606 * @brief
Kojto 98:8ab26030e058 607 * Get pending GPIO interrupts.
Kojto 98:8ab26030e058 608 *
Kojto 98:8ab26030e058 609 * @return
Kojto 98:8ab26030e058 610 * GPIO interrupt sources pending.
Kojto 98:8ab26030e058 611 ******************************************************************************/
Kojto 98:8ab26030e058 612 __STATIC_INLINE uint32_t GPIO_IntGet(void)
Kojto 98:8ab26030e058 613 {
Kojto 113:f141b2784e32 614 return GPIO->IF;
Kojto 98:8ab26030e058 615 }
Kojto 98:8ab26030e058 616
Kojto 98:8ab26030e058 617 /***************************************************************************//**
Kojto 98:8ab26030e058 618 * @brief
Kojto 98:8ab26030e058 619 * Get enabled and pending GPIO interrupt flags.
Kojto 98:8ab26030e058 620 * Useful for handling more interrupt sources in the same interrupt handler.
Kojto 98:8ab26030e058 621 *
Kojto 98:8ab26030e058 622 * @note
Kojto 98:8ab26030e058 623 * Interrupt flags are not cleared by the use of this function.
Kojto 98:8ab26030e058 624 *
Kojto 98:8ab26030e058 625 * @return
Kojto 98:8ab26030e058 626 * Pending and enabled GPIO interrupt sources.
Kojto 98:8ab26030e058 627 * The return value is the bitwise AND combination of
Kojto 98:8ab26030e058 628 * - the OR combination of enabled interrupt sources in GPIO_IEN register
Kojto 98:8ab26030e058 629 * and
Kojto 98:8ab26030e058 630 * - the OR combination of valid interrupt flags in GPIO_IF register.
Kojto 98:8ab26030e058 631 ******************************************************************************/
Kojto 98:8ab26030e058 632 __STATIC_INLINE uint32_t GPIO_IntGetEnabled(void)
Kojto 98:8ab26030e058 633 {
Kojto 98:8ab26030e058 634 uint32_t tmp;
Kojto 98:8ab26030e058 635
Kojto 98:8ab26030e058 636 /* Store GPIO->IEN in temporary variable in order to define explicit order
Kojto 98:8ab26030e058 637 * of volatile accesses. */
Kojto 98:8ab26030e058 638 tmp = GPIO->IEN;
Kojto 98:8ab26030e058 639
Kojto 98:8ab26030e058 640 /* Bitwise AND of pending and enabled interrupts */
Kojto 98:8ab26030e058 641 return GPIO->IF & tmp;
Kojto 98:8ab26030e058 642 }
Kojto 98:8ab26030e058 643
Kojto 98:8ab26030e058 644 /**************************************************************************//**
Kojto 98:8ab26030e058 645 * @brief
Kojto 98:8ab26030e058 646 * Set one or more pending GPIO interrupts from SW.
Kojto 98:8ab26030e058 647 *
Kojto 98:8ab26030e058 648 * @param[in] flags
Kojto 98:8ab26030e058 649 * GPIO interrupt sources to set to pending.
Kojto 98:8ab26030e058 650 *****************************************************************************/
Kojto 98:8ab26030e058 651 __STATIC_INLINE void GPIO_IntSet(uint32_t flags)
Kojto 98:8ab26030e058 652 {
Kojto 98:8ab26030e058 653 GPIO->IFS = flags;
Kojto 98:8ab26030e058 654 }
Kojto 98:8ab26030e058 655
Kojto 98:8ab26030e058 656 /***************************************************************************//**
Kojto 98:8ab26030e058 657 * @brief
Kojto 98:8ab26030e058 658 * Locks the GPIO configuration.
Kojto 98:8ab26030e058 659 ******************************************************************************/
Kojto 98:8ab26030e058 660 __STATIC_INLINE void GPIO_Lock(void)
Kojto 98:8ab26030e058 661 {
Kojto 98:8ab26030e058 662 GPIO->LOCK = GPIO_LOCK_LOCKKEY_LOCK;
Kojto 98:8ab26030e058 663 }
Kojto 98:8ab26030e058 664
Kojto 98:8ab26030e058 665 /***************************************************************************//**
Kojto 98:8ab26030e058 666 * @brief
Kojto 98:8ab26030e058 667 * Read the pad value for a single pin in a GPIO port.
Kojto 98:8ab26030e058 668 *
Kojto 98:8ab26030e058 669 * @param[in] port
Kojto 98:8ab26030e058 670 * The GPIO port to access.
Kojto 98:8ab26030e058 671 *
Kojto 98:8ab26030e058 672 * @param[in] pin
Kojto 98:8ab26030e058 673 * The pin number to read.
Kojto 98:8ab26030e058 674 *
Kojto 98:8ab26030e058 675 * @return
Kojto 98:8ab26030e058 676 * The pin value, 0 or 1.
Kojto 98:8ab26030e058 677 ******************************************************************************/
Kojto 113:f141b2784e32 678 __STATIC_INLINE unsigned int GPIO_PinInGet(GPIO_Port_TypeDef port,
Kojto 113:f141b2784e32 679 unsigned int pin)
Kojto 98:8ab26030e058 680 {
Kojto 113:f141b2784e32 681 EFM_ASSERT(GPIO_PORT_PIN_VALID(port, pin));
Kojto 113:f141b2784e32 682 return BUS_RegBitRead(&GPIO->P[port].DIN, pin);
Kojto 98:8ab26030e058 683 }
Kojto 98:8ab26030e058 684
<> 128:9bcdf88f62b0 685 GPIO_Mode_TypeDef GPIO_PinModeGet(GPIO_Port_TypeDef port,
<> 128:9bcdf88f62b0 686 unsigned int pin);
<> 128:9bcdf88f62b0 687
<> 128:9bcdf88f62b0 688 void GPIO_PinModeSet(GPIO_Port_TypeDef port,
<> 128:9bcdf88f62b0 689 unsigned int pin,
<> 128:9bcdf88f62b0 690 GPIO_Mode_TypeDef mode,
<> 128:9bcdf88f62b0 691 unsigned int out);
Kojto 98:8ab26030e058 692
Kojto 98:8ab26030e058 693 /***************************************************************************//**
Kojto 98:8ab26030e058 694 * @brief
Kojto 98:8ab26030e058 695 * Set a single pin in GPIO data out port register to 0.
Kojto 98:8ab26030e058 696 *
Kojto 98:8ab26030e058 697 * @note
Kojto 98:8ab26030e058 698 * In order for the setting to take effect on the output pad, the pin must
Kojto 98:8ab26030e058 699 * have been configured properly. If not, it will take effect whenever the
Kojto 98:8ab26030e058 700 * pin has been properly configured.
Kojto 98:8ab26030e058 701 *
Kojto 98:8ab26030e058 702 * @param[in] port
Kojto 98:8ab26030e058 703 * The GPIO port to access.
Kojto 98:8ab26030e058 704 *
Kojto 98:8ab26030e058 705 * @param[in] pin
Kojto 98:8ab26030e058 706 * The pin to set.
Kojto 98:8ab26030e058 707 ******************************************************************************/
Kojto 98:8ab26030e058 708 __STATIC_INLINE void GPIO_PinOutClear(GPIO_Port_TypeDef port, unsigned int pin)
Kojto 98:8ab26030e058 709 {
Kojto 113:f141b2784e32 710 EFM_ASSERT(GPIO_PORT_PIN_VALID(port, pin));
Kojto 113:f141b2784e32 711 #if defined( _GPIO_P_DOUTCLR_MASK )
Kojto 98:8ab26030e058 712 GPIO->P[port].DOUTCLR = 1 << pin;
Kojto 113:f141b2784e32 713 #else
Kojto 113:f141b2784e32 714 BUS_RegBitWrite(&GPIO->P[port].DOUT, pin, 0);
Kojto 113:f141b2784e32 715 #endif
Kojto 98:8ab26030e058 716 }
Kojto 98:8ab26030e058 717
Kojto 98:8ab26030e058 718 /***************************************************************************//**
Kojto 98:8ab26030e058 719 * @brief
Kojto 98:8ab26030e058 720 * Get current setting for a pin in a GPIO port data out register.
Kojto 98:8ab26030e058 721 *
Kojto 98:8ab26030e058 722 * @param[in] port
Kojto 98:8ab26030e058 723 * The GPIO port to access.
Kojto 98:8ab26030e058 724 *
Kojto 98:8ab26030e058 725 * @param[in] pin
Kojto 98:8ab26030e058 726 * The pin to get setting for.
Kojto 98:8ab26030e058 727 *
Kojto 98:8ab26030e058 728 * @return
Kojto 98:8ab26030e058 729 * The DOUT setting for the requested pin, 0 or 1.
Kojto 98:8ab26030e058 730 ******************************************************************************/
Kojto 113:f141b2784e32 731 __STATIC_INLINE unsigned int GPIO_PinOutGet(GPIO_Port_TypeDef port,
Kojto 113:f141b2784e32 732 unsigned int pin)
Kojto 98:8ab26030e058 733 {
Kojto 113:f141b2784e32 734 EFM_ASSERT(GPIO_PORT_PIN_VALID(port, pin));
Kojto 113:f141b2784e32 735 return BUS_RegBitRead(&GPIO->P[port].DOUT, pin);
Kojto 98:8ab26030e058 736 }
Kojto 98:8ab26030e058 737
Kojto 98:8ab26030e058 738 /***************************************************************************//**
Kojto 98:8ab26030e058 739 * @brief
Kojto 98:8ab26030e058 740 * Set a single pin in GPIO data out register to 1.
Kojto 98:8ab26030e058 741 *
Kojto 98:8ab26030e058 742 * @note
Kojto 98:8ab26030e058 743 * In order for the setting to take effect on the output pad, the pin must
Kojto 98:8ab26030e058 744 * have been configured properly. If not, it will take effect whenever the
Kojto 98:8ab26030e058 745 * pin has been properly configured.
Kojto 98:8ab26030e058 746 *
Kojto 98:8ab26030e058 747 * @param[in] port
Kojto 98:8ab26030e058 748 * The GPIO port to access.
Kojto 98:8ab26030e058 749 *
Kojto 98:8ab26030e058 750 * @param[in] pin
Kojto 98:8ab26030e058 751 * The pin to set.
Kojto 98:8ab26030e058 752 ******************************************************************************/
Kojto 98:8ab26030e058 753 __STATIC_INLINE void GPIO_PinOutSet(GPIO_Port_TypeDef port, unsigned int pin)
Kojto 98:8ab26030e058 754 {
Kojto 113:f141b2784e32 755 EFM_ASSERT(GPIO_PORT_PIN_VALID(port, pin));
Kojto 113:f141b2784e32 756 #if defined( _GPIO_P_DOUTSET_MASK )
Kojto 98:8ab26030e058 757 GPIO->P[port].DOUTSET = 1 << pin;
Kojto 113:f141b2784e32 758 #else
Kojto 113:f141b2784e32 759 BUS_RegBitWrite(&GPIO->P[port].DOUT, pin, 1);
Kojto 113:f141b2784e32 760 #endif
Kojto 98:8ab26030e058 761 }
Kojto 98:8ab26030e058 762
Kojto 98:8ab26030e058 763 /***************************************************************************//**
Kojto 98:8ab26030e058 764 * @brief
Kojto 98:8ab26030e058 765 * Toggle a single pin in GPIO port data out register.
Kojto 98:8ab26030e058 766 *
Kojto 98:8ab26030e058 767 * @note
Kojto 98:8ab26030e058 768 * In order for the setting to take effect on the output pad, the pin must
Kojto 98:8ab26030e058 769 * have been configured properly. If not, it will take effect whenever the
Kojto 98:8ab26030e058 770 * pin has been properly configured.
Kojto 98:8ab26030e058 771 *
Kojto 98:8ab26030e058 772 * @param[in] port
Kojto 98:8ab26030e058 773 * The GPIO port to access.
Kojto 98:8ab26030e058 774 *
Kojto 98:8ab26030e058 775 * @param[in] pin
Kojto 98:8ab26030e058 776 * The pin to toggle.
Kojto 98:8ab26030e058 777 ******************************************************************************/
Kojto 98:8ab26030e058 778 __STATIC_INLINE void GPIO_PinOutToggle(GPIO_Port_TypeDef port, unsigned int pin)
Kojto 98:8ab26030e058 779 {
Kojto 113:f141b2784e32 780 EFM_ASSERT(GPIO_PORT_PIN_VALID(port, pin));
Kojto 98:8ab26030e058 781
Kojto 98:8ab26030e058 782 GPIO->P[port].DOUTTGL = 1 << pin;
Kojto 98:8ab26030e058 783 }
Kojto 98:8ab26030e058 784
Kojto 98:8ab26030e058 785 /***************************************************************************//**
Kojto 98:8ab26030e058 786 * @brief
Kojto 98:8ab26030e058 787 * Read the pad values for GPIO port.
Kojto 98:8ab26030e058 788 *
Kojto 98:8ab26030e058 789 * @param[in] port
Kojto 98:8ab26030e058 790 * The GPIO port to access.
Kojto 98:8ab26030e058 791 ******************************************************************************/
Kojto 98:8ab26030e058 792 __STATIC_INLINE uint32_t GPIO_PortInGet(GPIO_Port_TypeDef port)
Kojto 98:8ab26030e058 793 {
Kojto 98:8ab26030e058 794 EFM_ASSERT(GPIO_PORT_VALID(port));
Kojto 98:8ab26030e058 795
Kojto 113:f141b2784e32 796 return GPIO->P[port].DIN;
Kojto 98:8ab26030e058 797 }
Kojto 98:8ab26030e058 798
Kojto 98:8ab26030e058 799 /***************************************************************************//**
Kojto 98:8ab26030e058 800 * @brief
Kojto 98:8ab26030e058 801 * Set bits in DOUT register for a port to 0.
Kojto 98:8ab26030e058 802 *
Kojto 98:8ab26030e058 803 * @note
Kojto 98:8ab26030e058 804 * In order for the setting to take effect on the output pad, the pin must
Kojto 98:8ab26030e058 805 * have been configured properly. If not, it will take effect whenever the
Kojto 98:8ab26030e058 806 * pin has been properly configured.
Kojto 98:8ab26030e058 807 *
Kojto 98:8ab26030e058 808 * @param[in] port
Kojto 98:8ab26030e058 809 * The GPIO port to access.
Kojto 98:8ab26030e058 810 *
Kojto 98:8ab26030e058 811 * @param[in] pins
Kojto 98:8ab26030e058 812 * Bit mask for bits to clear in DOUT register.
Kojto 98:8ab26030e058 813 ******************************************************************************/
Kojto 98:8ab26030e058 814 __STATIC_INLINE void GPIO_PortOutClear(GPIO_Port_TypeDef port, uint32_t pins)
Kojto 98:8ab26030e058 815 {
Kojto 98:8ab26030e058 816 EFM_ASSERT(GPIO_PORT_VALID(port));
Kojto 113:f141b2784e32 817 #if defined( _GPIO_P_DOUTCLR_MASK )
Kojto 113:f141b2784e32 818 GPIO->P[port].DOUTCLR = pins;
Kojto 113:f141b2784e32 819 #else
Kojto 113:f141b2784e32 820 BUS_RegMaskedClear(&GPIO->P[port].DOUT, pins);
Kojto 113:f141b2784e32 821 #endif
Kojto 98:8ab26030e058 822 }
Kojto 98:8ab26030e058 823
Kojto 98:8ab26030e058 824 /***************************************************************************//**
Kojto 98:8ab26030e058 825 * @brief
Kojto 98:8ab26030e058 826 * Get current setting for a GPIO port data out register.
Kojto 98:8ab26030e058 827 *
Kojto 98:8ab26030e058 828 * @param[in] port
Kojto 98:8ab26030e058 829 * The GPIO port to access.
Kojto 98:8ab26030e058 830 *
Kojto 98:8ab26030e058 831 * @return
Kojto 98:8ab26030e058 832 * The data out setting for the requested port.
Kojto 98:8ab26030e058 833 ******************************************************************************/
Kojto 98:8ab26030e058 834 __STATIC_INLINE uint32_t GPIO_PortOutGet(GPIO_Port_TypeDef port)
Kojto 98:8ab26030e058 835 {
Kojto 98:8ab26030e058 836 EFM_ASSERT(GPIO_PORT_VALID(port));
Kojto 98:8ab26030e058 837
Kojto 113:f141b2784e32 838 return GPIO->P[port].DOUT;
Kojto 98:8ab26030e058 839 }
Kojto 98:8ab26030e058 840
Kojto 98:8ab26030e058 841 /***************************************************************************//**
Kojto 98:8ab26030e058 842 * @brief
Kojto 98:8ab26030e058 843 * Set bits GPIO data out register to 1.
Kojto 98:8ab26030e058 844 *
Kojto 98:8ab26030e058 845 * @note
Kojto 98:8ab26030e058 846 * In order for the setting to take effect on the respective output pads, the
Kojto 98:8ab26030e058 847 * pins must have been configured properly. If not, it will take effect
Kojto 98:8ab26030e058 848 * whenever the pin has been properly configured.
Kojto 98:8ab26030e058 849 *
Kojto 98:8ab26030e058 850 * @param[in] port
Kojto 98:8ab26030e058 851 * The GPIO port to access.
Kojto 98:8ab26030e058 852 *
Kojto 98:8ab26030e058 853 * @param[in] pins
Kojto 98:8ab26030e058 854 * Bit mask for bits to set to 1 in DOUT register.
Kojto 98:8ab26030e058 855 ******************************************************************************/
Kojto 98:8ab26030e058 856 __STATIC_INLINE void GPIO_PortOutSet(GPIO_Port_TypeDef port, uint32_t pins)
Kojto 98:8ab26030e058 857 {
Kojto 98:8ab26030e058 858 EFM_ASSERT(GPIO_PORT_VALID(port));
Kojto 113:f141b2784e32 859 #if defined( _GPIO_P_DOUTSET_MASK )
Kojto 113:f141b2784e32 860 GPIO->P[port].DOUTSET = pins;
Kojto 113:f141b2784e32 861 #else
Kojto 113:f141b2784e32 862 BUS_RegMaskedSet(&GPIO->P[port].DOUT, pins);
Kojto 113:f141b2784e32 863 #endif
Kojto 98:8ab26030e058 864 }
Kojto 98:8ab26030e058 865
Kojto 98:8ab26030e058 866 /***************************************************************************//**
Kojto 98:8ab26030e058 867 * @brief
Kojto 98:8ab26030e058 868 * Set GPIO port data out register.
Kojto 98:8ab26030e058 869 *
Kojto 98:8ab26030e058 870 * @note
Kojto 98:8ab26030e058 871 * In order for the setting to take effect on the respective output pads, the
Kojto 98:8ab26030e058 872 * pins must have been configured properly. If not, it will take effect
Kojto 98:8ab26030e058 873 * whenever the pin has been properly configured.
Kojto 98:8ab26030e058 874 *
Kojto 98:8ab26030e058 875 * @param[in] port
Kojto 98:8ab26030e058 876 * The GPIO port to access.
Kojto 98:8ab26030e058 877 *
Kojto 98:8ab26030e058 878 * @param[in] val
Kojto 98:8ab26030e058 879 * Value to write to port data out register.
Kojto 98:8ab26030e058 880 *
Kojto 98:8ab26030e058 881 * @param[in] mask
Kojto 98:8ab26030e058 882 * Mask indicating which bits to modify.
Kojto 98:8ab26030e058 883 ******************************************************************************/
Kojto 113:f141b2784e32 884 __STATIC_INLINE void GPIO_PortOutSetVal(GPIO_Port_TypeDef port,
Kojto 113:f141b2784e32 885 uint32_t val,
Kojto 113:f141b2784e32 886 uint32_t mask)
Kojto 98:8ab26030e058 887 {
Kojto 98:8ab26030e058 888 EFM_ASSERT(GPIO_PORT_VALID(port));
Kojto 98:8ab26030e058 889
Kojto 98:8ab26030e058 890 GPIO->P[port].DOUT = (GPIO->P[port].DOUT & ~mask) | (val & mask);
Kojto 98:8ab26030e058 891 }
Kojto 98:8ab26030e058 892
Kojto 98:8ab26030e058 893 /***************************************************************************//**
Kojto 98:8ab26030e058 894 * @brief
Kojto 113:f141b2784e32 895 * Toggle pins in GPIO port data out register.
Kojto 98:8ab26030e058 896 *
Kojto 98:8ab26030e058 897 * @note
Kojto 98:8ab26030e058 898 * In order for the setting to take effect on the output pad, the pin must
Kojto 98:8ab26030e058 899 * have been configured properly. If not, it will take effect whenever the
Kojto 98:8ab26030e058 900 * pin has been properly configured.
Kojto 98:8ab26030e058 901 *
Kojto 98:8ab26030e058 902 * @param[in] port
Kojto 98:8ab26030e058 903 * The GPIO port to access.
Kojto 98:8ab26030e058 904 *
Kojto 98:8ab26030e058 905 * @param[in] pins
Kojto 98:8ab26030e058 906 * Bitmask with pins to toggle.
Kojto 98:8ab26030e058 907 ******************************************************************************/
Kojto 98:8ab26030e058 908 __STATIC_INLINE void GPIO_PortOutToggle(GPIO_Port_TypeDef port, uint32_t pins)
Kojto 98:8ab26030e058 909 {
Kojto 98:8ab26030e058 910 EFM_ASSERT(GPIO_PORT_VALID(port));
Kojto 98:8ab26030e058 911
Kojto 113:f141b2784e32 912 GPIO->P[port].DOUTTGL = pins;
Kojto 98:8ab26030e058 913 }
Kojto 98:8ab26030e058 914
<> 128:9bcdf88f62b0 915 #if defined(_GPIO_P_CTRL_SLEWRATE_MASK)
<> 128:9bcdf88f62b0 916 /***************************************************************************//**
<> 128:9bcdf88f62b0 917 * @brief
<> 128:9bcdf88f62b0 918 * Set slewrate for pins on a GPIO port.
<> 128:9bcdf88f62b0 919 *
<> 128:9bcdf88f62b0 920 * @param[in] port
<> 128:9bcdf88f62b0 921 * The GPIO port to configure.
<> 128:9bcdf88f62b0 922 *
<> 128:9bcdf88f62b0 923 * @param[in] slewrate
<> 128:9bcdf88f62b0 924 * The slewrate to configure for pins on this GPIO port.
<> 128:9bcdf88f62b0 925 *
<> 128:9bcdf88f62b0 926 * @param[in] slewrateAlt
<> 128:9bcdf88f62b0 927 * The slewrate to configure for pins using alternate modes on this GPIO port.
<> 128:9bcdf88f62b0 928 ******************************************************************************/
<> 128:9bcdf88f62b0 929 __STATIC_INLINE void GPIO_SlewrateSet(GPIO_Port_TypeDef port,
<> 128:9bcdf88f62b0 930 uint32_t slewrate,
<> 128:9bcdf88f62b0 931 uint32_t slewrateAlt)
<> 128:9bcdf88f62b0 932 {
<> 128:9bcdf88f62b0 933 EFM_ASSERT(GPIO_PORT_VALID(port));
<> 128:9bcdf88f62b0 934 EFM_ASSERT(slewrate <= (_GPIO_P_CTRL_SLEWRATE_MASK
<> 128:9bcdf88f62b0 935 >> _GPIO_P_CTRL_SLEWRATE_SHIFT));
<> 128:9bcdf88f62b0 936 EFM_ASSERT(slewrateAlt <= (_GPIO_P_CTRL_SLEWRATEALT_MASK
<> 128:9bcdf88f62b0 937 >> _GPIO_P_CTRL_SLEWRATEALT_SHIFT));
<> 128:9bcdf88f62b0 938
<> 128:9bcdf88f62b0 939 GPIO->P[port].CTRL = (GPIO->P[port].CTRL
<> 128:9bcdf88f62b0 940 & ~(_GPIO_P_CTRL_SLEWRATE_MASK
<> 128:9bcdf88f62b0 941 | _GPIO_P_CTRL_SLEWRATEALT_MASK))
<> 128:9bcdf88f62b0 942 | (slewrate << _GPIO_P_CTRL_SLEWRATE_SHIFT)
<> 128:9bcdf88f62b0 943 | (slewrateAlt << _GPIO_P_CTRL_SLEWRATEALT_SHIFT);
<> 128:9bcdf88f62b0 944 }
<> 128:9bcdf88f62b0 945 #endif
Kojto 98:8ab26030e058 946
Kojto 98:8ab26030e058 947 /***************************************************************************//**
Kojto 98:8ab26030e058 948 * @brief
Kojto 98:8ab26030e058 949 * Unlocks the GPIO configuration.
Kojto 98:8ab26030e058 950 ******************************************************************************/
Kojto 98:8ab26030e058 951 __STATIC_INLINE void GPIO_Unlock(void)
Kojto 98:8ab26030e058 952 {
Kojto 98:8ab26030e058 953 GPIO->LOCK = GPIO_LOCK_LOCKKEY_UNLOCK;
Kojto 98:8ab26030e058 954 }
Kojto 98:8ab26030e058 955
<> 128:9bcdf88f62b0 956 /*******************************************************************************
<> 128:9bcdf88f62b0 957 *********************** DEPRECATED PROTOTYPES *****************************
<> 128:9bcdf88f62b0 958 *********************** (will be removed) *****************************
<> 128:9bcdf88f62b0 959 ******************************************************************************/
<> 128:9bcdf88f62b0 960
<> 128:9bcdf88f62b0 961 /***************************************************************************//**
<> 128:9bcdf88f62b0 962 * @brief
<> 128:9bcdf88f62b0 963 * Configure GPIO interrupt.
<> 128:9bcdf88f62b0 964 *
<> 128:9bcdf88f62b0 965 * @details
<> 128:9bcdf88f62b0 966 * If reconfiguring a GPIO interrupt that is already enabled, it is generally
<> 128:9bcdf88f62b0 967 * recommended to disable it first, see GPIO_Disable().
<> 128:9bcdf88f62b0 968 *
<> 128:9bcdf88f62b0 969 * The actual GPIO interrupt handler must be in place before enabling the
<> 128:9bcdf88f62b0 970 * interrupt.
<> 128:9bcdf88f62b0 971 *
<> 128:9bcdf88f62b0 972 * Notice that any pending interrupt for the selected pin is cleared by this
<> 128:9bcdf88f62b0 973 * function.
<> 128:9bcdf88f62b0 974 *
<> 128:9bcdf88f62b0 975 * @deprecated
<> 128:9bcdf88f62b0 976 * Deprecated function. New code should use @ref GPIO_ExtIntConfig().
<> 128:9bcdf88f62b0 977 *
<> 128:9bcdf88f62b0 978 * @note
<> 128:9bcdf88f62b0 979 * A certain pin number can only be associated with one port. Ie, if GPIO
<> 128:9bcdf88f62b0 980 * interrupt 1 is assigned to port A/pin 1, then it is not possible to use
<> 128:9bcdf88f62b0 981 * pin 1 from any other ports for interrupts. Please refer to the reference
<> 128:9bcdf88f62b0 982 * manual. On devices which implement GPIO_EXTIPINSEL registers a more
<> 128:9bcdf88f62b0 983 * flexible approach is possible, refer to @ref GPIO_ExtIntConfig().
<> 128:9bcdf88f62b0 984 *
<> 128:9bcdf88f62b0 985 * @param[in] port
<> 128:9bcdf88f62b0 986 * The port to associate with @p pin.
<> 128:9bcdf88f62b0 987 *
<> 128:9bcdf88f62b0 988 * @param[in] pin
<> 128:9bcdf88f62b0 989 * The pin number on the port ( == GPIO EXTI interrupt number).
<> 128:9bcdf88f62b0 990 *
<> 128:9bcdf88f62b0 991 * @param[in] risingEdge
<> 128:9bcdf88f62b0 992 * Set to true if interrupts shall be enabled on rising edge, otherwise false.
<> 128:9bcdf88f62b0 993 *
<> 128:9bcdf88f62b0 994 * @param[in] fallingEdge
<> 128:9bcdf88f62b0 995 * Set to true if interrupts shall be enabled on falling edge, otherwise false.
<> 128:9bcdf88f62b0 996 *
<> 128:9bcdf88f62b0 997 * @param[in] enable
<> 128:9bcdf88f62b0 998 * Set to true if interrupt shall be enabled after configuration completed,
<> 128:9bcdf88f62b0 999 * false to leave disabled. See GPIO_IntDisable() and GPIO_IntEnable().
<> 128:9bcdf88f62b0 1000 ******************************************************************************/
<> 128:9bcdf88f62b0 1001 __STATIC_INLINE void GPIO_IntConfig(GPIO_Port_TypeDef port,
<> 128:9bcdf88f62b0 1002 unsigned int pin,
<> 128:9bcdf88f62b0 1003 bool risingEdge,
<> 128:9bcdf88f62b0 1004 bool fallingEdge,
<> 128:9bcdf88f62b0 1005 bool enable)
<> 128:9bcdf88f62b0 1006 {
<> 128:9bcdf88f62b0 1007 GPIO_ExtIntConfig(port, pin, pin, risingEdge, fallingEdge, enable);
<> 128:9bcdf88f62b0 1008 }
<> 128:9bcdf88f62b0 1009
Kojto 98:8ab26030e058 1010 /** @} (end addtogroup GPIO) */
<> 128:9bcdf88f62b0 1011 /** @} (end addtogroup emlib) */
Kojto 98:8ab26030e058 1012
Kojto 98:8ab26030e058 1013 #ifdef __cplusplus
Kojto 98:8ab26030e058 1014 }
Kojto 98:8ab26030e058 1015 #endif
Kojto 98:8ab26030e058 1016
Kojto 98:8ab26030e058 1017 #endif /* defined(GPIO_COUNT) && (GPIO_COUNT > 0) */
<> 128:9bcdf88f62b0 1018 #endif /* EM_GPIO_H */