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:
Kojto
Date:
Wed Apr 29 10:16:23 2015 +0100
Revision:
98:8ab26030e058
Child:
113:f141b2784e32
Release 98 of the mbed library

Changes:
- Silabs new targets (Giant, Zero, Happy, Leopard, Wonder Geckos)
- Asynchronous SPI, I2C, Serial
- LowPower classes
- Nordic - nordic SDK v8.0 update
- Teensy - gcc arm fix for startup
- Nucleo F411 - usb freq fix

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
Kojto 98:8ab26030e058 4 * @version 3.20.12
Kojto 98:8ab26030e058 5 *******************************************************************************
Kojto 98:8ab26030e058 6 * @section License
Kojto 98:8ab26030e058 7 * <b>(C) Copyright 2014 Silicon Labs, 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
Kojto 98:8ab26030e058 34 #ifndef __SILICON_LABS_EM_GPIO_H_
Kojto 98:8ab26030e058 35 #define __SILICON_LABS_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 98:8ab26030e058 41 #include "em_bitband.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 /***************************************************************************//**
Kojto 98:8ab26030e058 49 * @addtogroup EM_Library
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 98:8ab26030e058 59 ******************************** ENUMS ************************************
Kojto 98:8ab26030e058 60 ******************************************************************************/
Kojto 98:8ab26030e058 61
Kojto 98:8ab26030e058 62 /** GPIO ports identificator. */
Kojto 98:8ab26030e058 63 typedef enum
Kojto 98:8ab26030e058 64 {
Kojto 98:8ab26030e058 65 gpioPortA = 0, /**< Port A */
Kojto 98:8ab26030e058 66 gpioPortB = 1, /**< Port B */
Kojto 98:8ab26030e058 67 gpioPortC = 2, /**< Port C */
Kojto 98:8ab26030e058 68 gpioPortD = 3, /**< Port D */
Kojto 98:8ab26030e058 69 gpioPortE = 4, /**< Port E */
Kojto 98:8ab26030e058 70 gpioPortF = 5 /**< Port F */
Kojto 98:8ab26030e058 71 } GPIO_Port_TypeDef;
Kojto 98:8ab26030e058 72
Kojto 98:8ab26030e058 73 /** GPIO drive mode. */
Kojto 98:8ab26030e058 74 typedef enum
Kojto 98:8ab26030e058 75 {
Kojto 98:8ab26030e058 76 /** Default 6mA */
Kojto 98:8ab26030e058 77 gpioDriveModeStandard = GPIO_P_CTRL_DRIVEMODE_STANDARD,
Kojto 98:8ab26030e058 78 /** 0.5 mA */
Kojto 98:8ab26030e058 79 gpioDriveModeLowest = GPIO_P_CTRL_DRIVEMODE_LOWEST,
Kojto 98:8ab26030e058 80 /** 20 mA */
Kojto 98:8ab26030e058 81 gpioDriveModeHigh = GPIO_P_CTRL_DRIVEMODE_HIGH,
Kojto 98:8ab26030e058 82 /** 2 mA */
Kojto 98:8ab26030e058 83 gpioDriveModeLow = GPIO_P_CTRL_DRIVEMODE_LOW
Kojto 98:8ab26030e058 84 } GPIO_DriveMode_TypeDef;
Kojto 98:8ab26030e058 85
Kojto 98:8ab26030e058 86 /** Pin mode. For more details on each mode, please refer to the EFM32
Kojto 98:8ab26030e058 87 * reference manual. */
Kojto 98:8ab26030e058 88 typedef enum
Kojto 98:8ab26030e058 89 {
Kojto 98:8ab26030e058 90 /** Input disabled. Pullup if DOUT is set. */
Kojto 98:8ab26030e058 91 gpioModeDisabled = _GPIO_P_MODEL_MODE0_DISABLED,
Kojto 98:8ab26030e058 92 /** Input enabled. Filter if DOUT is set */
Kojto 98:8ab26030e058 93 gpioModeInput = _GPIO_P_MODEL_MODE0_INPUT,
Kojto 98:8ab26030e058 94 /** Input enabled. DOUT determines pull direction */
Kojto 98:8ab26030e058 95 gpioModeInputPull = _GPIO_P_MODEL_MODE0_INPUTPULL,
Kojto 98:8ab26030e058 96 /** Input enabled with filter. DOUT determines pull direction */
Kojto 98:8ab26030e058 97 gpioModeInputPullFilter = _GPIO_P_MODEL_MODE0_INPUTPULLFILTER,
Kojto 98:8ab26030e058 98 /** Push-pull output */
Kojto 98:8ab26030e058 99 gpioModePushPull = _GPIO_P_MODEL_MODE0_PUSHPULL,
Kojto 98:8ab26030e058 100 /** Push-pull output with drive-strength set by DRIVEMODE */
Kojto 98:8ab26030e058 101 gpioModePushPullDrive = _GPIO_P_MODEL_MODE0_PUSHPULLDRIVE,
Kojto 98:8ab26030e058 102 /** Wired-or output */
Kojto 98:8ab26030e058 103 gpioModeWiredOr = _GPIO_P_MODEL_MODE0_WIREDOR,
Kojto 98:8ab26030e058 104 /** Wired-or output with pull-down */
Kojto 98:8ab26030e058 105 gpioModeWiredOrPullDown = _GPIO_P_MODEL_MODE0_WIREDORPULLDOWN,
Kojto 98:8ab26030e058 106 /** Open-drain output */
Kojto 98:8ab26030e058 107 gpioModeWiredAnd = _GPIO_P_MODEL_MODE0_WIREDAND,
Kojto 98:8ab26030e058 108 /** Open-drain output with filter */
Kojto 98:8ab26030e058 109 gpioModeWiredAndFilter = _GPIO_P_MODEL_MODE0_WIREDANDFILTER,
Kojto 98:8ab26030e058 110 /** Open-drain output with pullup */
Kojto 98:8ab26030e058 111 gpioModeWiredAndPullUp = _GPIO_P_MODEL_MODE0_WIREDANDPULLUP,
Kojto 98:8ab26030e058 112 /** Open-drain output with filter and pullup */
Kojto 98:8ab26030e058 113 gpioModeWiredAndPullUpFilter = _GPIO_P_MODEL_MODE0_WIREDANDPULLUPFILTER,
Kojto 98:8ab26030e058 114 /** Open-drain output with drive-strength set by DRIVEMODE */
Kojto 98:8ab26030e058 115 gpioModeWiredAndDrive = _GPIO_P_MODEL_MODE0_WIREDANDDRIVE,
Kojto 98:8ab26030e058 116 /** Open-drain output with filter and drive-strength set by DRIVEMODE */
Kojto 98:8ab26030e058 117 gpioModeWiredAndDriveFilter = _GPIO_P_MODEL_MODE0_WIREDANDDRIVEFILTER,
Kojto 98:8ab26030e058 118 /** Open-drain output with pullup and drive-strength set by DRIVEMODE */
Kojto 98:8ab26030e058 119 gpioModeWiredAndDrivePullUp = _GPIO_P_MODEL_MODE0_WIREDANDDRIVEPULLUP,
Kojto 98:8ab26030e058 120 /** Open-drain output with filter, pullup and drive-strength set by DRIVEMODE */
Kojto 98:8ab26030e058 121 gpioModeWiredAndDrivePullUpFilter = _GPIO_P_MODEL_MODE0_WIREDANDDRIVEPULLUPFILTER
Kojto 98:8ab26030e058 122 } GPIO_Mode_TypeDef;
Kojto 98:8ab26030e058 123
Kojto 98:8ab26030e058 124
Kojto 98:8ab26030e058 125 /*******************************************************************************
Kojto 98:8ab26030e058 126 ******************************* DEFINES ***********************************
Kojto 98:8ab26030e058 127 ******************************************************************************/
Kojto 98:8ab26030e058 128
Kojto 98:8ab26030e058 129 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
Kojto 98:8ab26030e058 130
Kojto 98:8ab26030e058 131 /** Validation of pin typically usable in assert statements. */
Kojto 98:8ab26030e058 132 #define GPIO_PIN_VALID(pin) ((pin) < 16)
Kojto 98:8ab26030e058 133
Kojto 98:8ab26030e058 134 /** Validation of port typically usable in assert statements. */
Kojto 98:8ab26030e058 135 #define GPIO_PORT_VALID(port) ((port) <= gpioPortF)
Kojto 98:8ab26030e058 136
Kojto 98:8ab26030e058 137 /** @endcond */
Kojto 98:8ab26030e058 138
Kojto 98:8ab26030e058 139
Kojto 98:8ab26030e058 140 /*******************************************************************************
Kojto 98:8ab26030e058 141 ***************************** PROTOTYPES **********************************
Kojto 98:8ab26030e058 142 ******************************************************************************/
Kojto 98:8ab26030e058 143
Kojto 98:8ab26030e058 144 void GPIO_DbgLocationSet(unsigned int location);
Kojto 98:8ab26030e058 145
Kojto 98:8ab26030e058 146 void GPIO_IntConfig(GPIO_Port_TypeDef port,
Kojto 98:8ab26030e058 147 unsigned int pin,
Kojto 98:8ab26030e058 148 bool risingEdge,
Kojto 98:8ab26030e058 149 bool fallingEdge,
Kojto 98:8ab26030e058 150 bool enable);
Kojto 98:8ab26030e058 151
Kojto 98:8ab26030e058 152 void GPIO_PinModeSet(GPIO_Port_TypeDef port,
Kojto 98:8ab26030e058 153 unsigned int pin,
Kojto 98:8ab26030e058 154 GPIO_Mode_TypeDef mode,
Kojto 98:8ab26030e058 155 unsigned int out);
Kojto 98:8ab26030e058 156
Kojto 98:8ab26030e058 157 # if defined( GPIO_CTRL_EM4RET )
Kojto 98:8ab26030e058 158 __STATIC_INLINE void GPIO_EM4SetPinRetention(bool enable);
Kojto 98:8ab26030e058 159 #endif
Kojto 98:8ab26030e058 160
Kojto 98:8ab26030e058 161 /***************************************************************************//**
Kojto 98:8ab26030e058 162 * @brief
Kojto 98:8ab26030e058 163 * Enable/disable serial wire clock pin.
Kojto 98:8ab26030e058 164 *
Kojto 98:8ab26030e058 165 * @note
Kojto 98:8ab26030e058 166 * Disabling SWDClk will disable the debug interface, which may result in
Kojto 98:8ab26030e058 167 * a lockout if done early in startup (before debugger is able to halt core).
Kojto 98:8ab26030e058 168 *
Kojto 98:8ab26030e058 169 * @param[in] enable
Kojto 98:8ab26030e058 170 * @li false - disable serial wire clock.
Kojto 98:8ab26030e058 171 * @li true - enable serial wire clock (default after reset).
Kojto 98:8ab26030e058 172 ******************************************************************************/
Kojto 98:8ab26030e058 173 __STATIC_INLINE void GPIO_DbgSWDClkEnable(bool enable)
Kojto 98:8ab26030e058 174 {
Kojto 98:8ab26030e058 175 BITBAND_Peripheral(&(GPIO->ROUTE), _GPIO_ROUTE_SWCLKPEN_SHIFT, (unsigned int)enable);
Kojto 98:8ab26030e058 176 }
Kojto 98:8ab26030e058 177
Kojto 98:8ab26030e058 178
Kojto 98:8ab26030e058 179 /***************************************************************************//**
Kojto 98:8ab26030e058 180 * @brief
Kojto 98:8ab26030e058 181 * Enable/disable serial wire data pin.
Kojto 98:8ab26030e058 182 *
Kojto 98:8ab26030e058 183 * @note
Kojto 98:8ab26030e058 184 * Disabling SWDClk will disable the debug interface, which may result in
Kojto 98:8ab26030e058 185 * a lockout if done early in startup (before debugger is able to halt core).
Kojto 98:8ab26030e058 186 *
Kojto 98:8ab26030e058 187 * @param[in] enable
Kojto 98:8ab26030e058 188 * @li false - disable serial wire data pin.
Kojto 98:8ab26030e058 189 * @li true - enable serial wire data pin (default after reset).
Kojto 98:8ab26030e058 190 ******************************************************************************/
Kojto 98:8ab26030e058 191 __STATIC_INLINE void GPIO_DbgSWDIOEnable(bool enable)
Kojto 98:8ab26030e058 192 {
Kojto 98:8ab26030e058 193 BITBAND_Peripheral(&(GPIO->ROUTE), _GPIO_ROUTE_SWDIOPEN_SHIFT, (unsigned int)enable);
Kojto 98:8ab26030e058 194 }
Kojto 98:8ab26030e058 195
Kojto 98:8ab26030e058 196
Kojto 98:8ab26030e058 197 #if defined( GPIO_ROUTE_SWOPEN )
Kojto 98:8ab26030e058 198 /***************************************************************************//**
Kojto 98:8ab26030e058 199 * @brief
Kojto 98:8ab26030e058 200 * Enable/Disable serial wire output pin.
Kojto 98:8ab26030e058 201 *
Kojto 98:8ab26030e058 202 * @note
Kojto 98:8ab26030e058 203 * Enabling this pin is not sufficient to fully enable serial wire output
Kojto 98:8ab26030e058 204 * which is also dependent on issues outside the GPIO module. Please refer to
Kojto 98:8ab26030e058 205 * DBG_SWOEnable().
Kojto 98:8ab26030e058 206 *
Kojto 98:8ab26030e058 207 * @param[in] enable
Kojto 98:8ab26030e058 208 * @li false - disable serial wire viewer pin (default after reset).
Kojto 98:8ab26030e058 209 * @li true - enable serial wire viewer pin.
Kojto 98:8ab26030e058 210 ******************************************************************************/
Kojto 98:8ab26030e058 211 __STATIC_INLINE void GPIO_DbgSWOEnable(bool enable)
Kojto 98:8ab26030e058 212 {
Kojto 98:8ab26030e058 213 BITBAND_Peripheral(&(GPIO->ROUTE), _GPIO_ROUTE_SWOPEN_SHIFT, (unsigned int)enable);
Kojto 98:8ab26030e058 214 }
Kojto 98:8ab26030e058 215 #endif
Kojto 98:8ab26030e058 216
Kojto 98:8ab26030e058 217 void GPIO_DriveModeSet(GPIO_Port_TypeDef port, GPIO_DriveMode_TypeDef mode);
Kojto 98:8ab26030e058 218
Kojto 98:8ab26030e058 219
Kojto 98:8ab26030e058 220 # if defined( _GPIO_EM4WUEN_MASK )
Kojto 98:8ab26030e058 221 /**************************************************************************//**
Kojto 98:8ab26030e058 222 * @brief
Kojto 98:8ab26030e058 223 * Disable GPIO pin wake-up from EM4.
Kojto 98:8ab26030e058 224 *
Kojto 98:8ab26030e058 225 * @param[in] pinmask
Kojto 98:8ab26030e058 226 * Bitmask containing the bitwise logic OR of which GPIO pin(s) to disable.
Kojto 98:8ab26030e058 227 * Refer to Reference Manuals for pinmask to GPIO port/pin mapping.
Kojto 98:8ab26030e058 228 *****************************************************************************/
Kojto 98:8ab26030e058 229 __STATIC_INLINE void GPIO_EM4DisablePinWakeup(uint32_t pinmask)
Kojto 98:8ab26030e058 230 {
Kojto 98:8ab26030e058 231 EFM_ASSERT((pinmask & ~_GPIO_EM4WUEN_MASK) == 0);
Kojto 98:8ab26030e058 232
Kojto 98:8ab26030e058 233 GPIO->EM4WUEN &= ~pinmask;
Kojto 98:8ab26030e058 234 }
Kojto 98:8ab26030e058 235 #endif
Kojto 98:8ab26030e058 236
Kojto 98:8ab26030e058 237
Kojto 98:8ab26030e058 238 # if defined( _GPIO_EM4WUEN_MASK )
Kojto 98:8ab26030e058 239 /**************************************************************************//**
Kojto 98:8ab26030e058 240 * @brief
Kojto 98:8ab26030e058 241 * Enable GPIO pin wake-up from EM4. When the function exits,
Kojto 98:8ab26030e058 242 * EM4 mode can be safely entered.
Kojto 98:8ab26030e058 243 *
Kojto 98:8ab26030e058 244 * @note
Kojto 98:8ab26030e058 245 * It is assumed that the GPIO pin modes are set correctly.
Kojto 98:8ab26030e058 246 * Valid modes are @ref gpioModeInput and @ref gpioModeInputPull.
Kojto 98:8ab26030e058 247 *
Kojto 98:8ab26030e058 248 * @param[in] pinmask
Kojto 98:8ab26030e058 249 * Bitmask containing the bitwise logic OR of which GPIO pin(s) to enable.
Kojto 98:8ab26030e058 250 * Refer to Reference Manuals for pinmask to GPIO port/pin mapping.
Kojto 98:8ab26030e058 251 * @param[in] polaritymask
Kojto 98:8ab26030e058 252 * Bitmask containing the bitwise logic OR of GPIO pin(s) wake-up polarity.
Kojto 98:8ab26030e058 253 * Refer to Reference Manuals for pinmask to GPIO port/pin mapping.
Kojto 98:8ab26030e058 254 *****************************************************************************/
Kojto 98:8ab26030e058 255 __STATIC_INLINE void GPIO_EM4EnablePinWakeup(uint32_t pinmask,
Kojto 98:8ab26030e058 256 uint32_t polaritymask)
Kojto 98:8ab26030e058 257 {
Kojto 98:8ab26030e058 258 EFM_ASSERT((pinmask & ~_GPIO_EM4WUEN_MASK) == 0);
Kojto 98:8ab26030e058 259 EFM_ASSERT((polaritymask & ~_GPIO_EM4WUPOL_MASK) == 0);
Kojto 98:8ab26030e058 260
Kojto 98:8ab26030e058 261 GPIO->EM4WUPOL &= ~pinmask; /* Set wakeup polarity */
Kojto 98:8ab26030e058 262 GPIO->EM4WUPOL |= pinmask & polaritymask;
Kojto 98:8ab26030e058 263 GPIO->EM4WUEN |= pinmask; /* Enable wakeup */
Kojto 98:8ab26030e058 264
Kojto 98:8ab26030e058 265 GPIO_EM4SetPinRetention(true); /* Enable pin retention */
Kojto 98:8ab26030e058 266
Kojto 98:8ab26030e058 267 GPIO->CMD = GPIO_CMD_EM4WUCLR; /* Clear wake-up logic */
Kojto 98:8ab26030e058 268 }
Kojto 98:8ab26030e058 269 #endif
Kojto 98:8ab26030e058 270
Kojto 98:8ab26030e058 271 #if defined( _GPIO_EM4WUCAUSE_MASK )
Kojto 98:8ab26030e058 272 /**************************************************************************//**
Kojto 98:8ab26030e058 273 * @brief
Kojto 98:8ab26030e058 274 * Check which GPIO pin(s) that caused a wake-up from EM4.
Kojto 98:8ab26030e058 275 *
Kojto 98:8ab26030e058 276 * @return
Kojto 98:8ab26030e058 277 * Bitmask containing the bitwise logic OR of which GPIO pin(s) caused the
Kojto 98:8ab26030e058 278 * wake-up. Refer to Reference Manuals for pinmask to GPIO port/pin mapping.
Kojto 98:8ab26030e058 279 *****************************************************************************/
Kojto 98:8ab26030e058 280 __STATIC_INLINE uint32_t GPIO_EM4GetPinWakeupCause(void)
Kojto 98:8ab26030e058 281 {
Kojto 98:8ab26030e058 282 return GPIO->EM4WUCAUSE & _GPIO_EM4WUCAUSE_MASK;
Kojto 98:8ab26030e058 283 }
Kojto 98:8ab26030e058 284 #endif
Kojto 98:8ab26030e058 285
Kojto 98:8ab26030e058 286
Kojto 98:8ab26030e058 287 # if defined( GPIO_CTRL_EM4RET )
Kojto 98:8ab26030e058 288 /**************************************************************************//**
Kojto 98:8ab26030e058 289 * @brief
Kojto 98:8ab26030e058 290 * Enable GPIO pin retention of output enable, output value, pull enable and
Kojto 98:8ab26030e058 291 * pull direction in EM4.
Kojto 98:8ab26030e058 292 *
Kojto 98:8ab26030e058 293 * @param[in] enable
Kojto 98:8ab26030e058 294 * @li true - enable EM4 pin retention.
Kojto 98:8ab26030e058 295 * @li false - disable EM4 pin retention.
Kojto 98:8ab26030e058 296 *****************************************************************************/
Kojto 98:8ab26030e058 297 __STATIC_INLINE void GPIO_EM4SetPinRetention(bool enable)
Kojto 98:8ab26030e058 298 {
Kojto 98:8ab26030e058 299 if (enable)
Kojto 98:8ab26030e058 300 {
Kojto 98:8ab26030e058 301 GPIO->CTRL |= GPIO_CTRL_EM4RET;
Kojto 98:8ab26030e058 302 }
Kojto 98:8ab26030e058 303 else
Kojto 98:8ab26030e058 304 {
Kojto 98:8ab26030e058 305 GPIO->CTRL &= ~GPIO_CTRL_EM4RET;
Kojto 98:8ab26030e058 306 }
Kojto 98:8ab26030e058 307 }
Kojto 98:8ab26030e058 308 #endif
Kojto 98:8ab26030e058 309
Kojto 98:8ab26030e058 310
Kojto 98:8ab26030e058 311 /***************************************************************************//**
Kojto 98:8ab26030e058 312 * @brief
Kojto 98:8ab26030e058 313 * Enable/disable input sensing.
Kojto 98:8ab26030e058 314 *
Kojto 98:8ab26030e058 315 * @details
Kojto 98:8ab26030e058 316 * Disabling input sensing if not used, can save some energy consumption.
Kojto 98:8ab26030e058 317 *
Kojto 98:8ab26030e058 318 * @param[in] val
Kojto 98:8ab26030e058 319 * Bitwise logic OR of one or more of:
Kojto 98:8ab26030e058 320 * @li GPIO_INSENSE_INT - interrupt input sensing.
Kojto 98:8ab26030e058 321 * @li GPIO_INSENSE_PRS - peripheral reflex system input sensing.
Kojto 98:8ab26030e058 322 *
Kojto 98:8ab26030e058 323 * @param[in] mask
Kojto 98:8ab26030e058 324 * Mask containing bitwise logic OR of bits similar as for @p val used to indicate
Kojto 98:8ab26030e058 325 * which input sense options to disable/enable.
Kojto 98:8ab26030e058 326 ******************************************************************************/
Kojto 98:8ab26030e058 327 __STATIC_INLINE void GPIO_InputSenseSet(uint32_t val, uint32_t mask)
Kojto 98:8ab26030e058 328 {
Kojto 98:8ab26030e058 329 GPIO->INSENSE = (GPIO->INSENSE & ~mask) | (val & mask);
Kojto 98:8ab26030e058 330 }
Kojto 98:8ab26030e058 331
Kojto 98:8ab26030e058 332
Kojto 98:8ab26030e058 333 /***************************************************************************//**
Kojto 98:8ab26030e058 334 * @brief
Kojto 98:8ab26030e058 335 * Clear one or more pending GPIO interrupts.
Kojto 98:8ab26030e058 336 *
Kojto 98:8ab26030e058 337 * @param[in] flags
Kojto 98:8ab26030e058 338 * Bitwise logic OR of GPIO interrupt sources to clear.
Kojto 98:8ab26030e058 339 ******************************************************************************/
Kojto 98:8ab26030e058 340 __STATIC_INLINE void GPIO_IntClear(uint32_t flags)
Kojto 98:8ab26030e058 341 {
Kojto 98:8ab26030e058 342 GPIO->IFC = flags;
Kojto 98:8ab26030e058 343 }
Kojto 98:8ab26030e058 344
Kojto 98:8ab26030e058 345
Kojto 98:8ab26030e058 346 /***************************************************************************//**
Kojto 98:8ab26030e058 347 * @brief
Kojto 98:8ab26030e058 348 * Disable one or more GPIO interrupts.
Kojto 98:8ab26030e058 349 *
Kojto 98:8ab26030e058 350 * @param[in] flags
Kojto 98:8ab26030e058 351 * GPIO interrupt sources to disable.
Kojto 98:8ab26030e058 352 ******************************************************************************/
Kojto 98:8ab26030e058 353 __STATIC_INLINE void GPIO_IntDisable(uint32_t flags)
Kojto 98:8ab26030e058 354 {
Kojto 98:8ab26030e058 355 GPIO->IEN &= ~flags;
Kojto 98:8ab26030e058 356 }
Kojto 98:8ab26030e058 357
Kojto 98:8ab26030e058 358
Kojto 98:8ab26030e058 359 /***************************************************************************//**
Kojto 98:8ab26030e058 360 * @brief
Kojto 98:8ab26030e058 361 * Enable one or more GPIO interrupts.
Kojto 98:8ab26030e058 362 *
Kojto 98:8ab26030e058 363 * @note
Kojto 98:8ab26030e058 364 * Depending on the use, a pending interrupt may already be set prior to
Kojto 98:8ab26030e058 365 * enabling the interrupt. Consider using GPIO_IntClear() prior to enabling
Kojto 98:8ab26030e058 366 * if such a pending interrupt should be ignored.
Kojto 98:8ab26030e058 367 *
Kojto 98:8ab26030e058 368 * @param[in] flags
Kojto 98:8ab26030e058 369 * GPIO interrupt sources to enable.
Kojto 98:8ab26030e058 370 ******************************************************************************/
Kojto 98:8ab26030e058 371 __STATIC_INLINE void GPIO_IntEnable(uint32_t flags)
Kojto 98:8ab26030e058 372 {
Kojto 98:8ab26030e058 373 GPIO->IEN |= flags;
Kojto 98:8ab26030e058 374 }
Kojto 98:8ab26030e058 375
Kojto 98:8ab26030e058 376
Kojto 98:8ab26030e058 377 /***************************************************************************//**
Kojto 98:8ab26030e058 378 * @brief
Kojto 98:8ab26030e058 379 * Get pending GPIO interrupts.
Kojto 98:8ab26030e058 380 *
Kojto 98:8ab26030e058 381 * @return
Kojto 98:8ab26030e058 382 * GPIO interrupt sources pending.
Kojto 98:8ab26030e058 383 ******************************************************************************/
Kojto 98:8ab26030e058 384 __STATIC_INLINE uint32_t GPIO_IntGet(void)
Kojto 98:8ab26030e058 385 {
Kojto 98:8ab26030e058 386 return(GPIO->IF);
Kojto 98:8ab26030e058 387 }
Kojto 98:8ab26030e058 388
Kojto 98:8ab26030e058 389
Kojto 98:8ab26030e058 390 /***************************************************************************//**
Kojto 98:8ab26030e058 391 * @brief
Kojto 98:8ab26030e058 392 * Get enabled and pending GPIO interrupt flags.
Kojto 98:8ab26030e058 393 * Useful for handling more interrupt sources in the same interrupt handler.
Kojto 98:8ab26030e058 394 *
Kojto 98:8ab26030e058 395 * @note
Kojto 98:8ab26030e058 396 * Interrupt flags are not cleared by the use of this function.
Kojto 98:8ab26030e058 397 *
Kojto 98:8ab26030e058 398 * @return
Kojto 98:8ab26030e058 399 * Pending and enabled GPIO interrupt sources.
Kojto 98:8ab26030e058 400 * The return value is the bitwise AND combination of
Kojto 98:8ab26030e058 401 * - the OR combination of enabled interrupt sources in GPIO_IEN register
Kojto 98:8ab26030e058 402 * and
Kojto 98:8ab26030e058 403 * - the OR combination of valid interrupt flags in GPIO_IF register.
Kojto 98:8ab26030e058 404 ******************************************************************************/
Kojto 98:8ab26030e058 405 __STATIC_INLINE uint32_t GPIO_IntGetEnabled(void)
Kojto 98:8ab26030e058 406 {
Kojto 98:8ab26030e058 407 uint32_t tmp;
Kojto 98:8ab26030e058 408
Kojto 98:8ab26030e058 409 /* Store GPIO->IEN in temporary variable in order to define explicit order
Kojto 98:8ab26030e058 410 * of volatile accesses. */
Kojto 98:8ab26030e058 411 tmp = GPIO->IEN;
Kojto 98:8ab26030e058 412
Kojto 98:8ab26030e058 413 /* Bitwise AND of pending and enabled interrupts */
Kojto 98:8ab26030e058 414 return GPIO->IF & tmp;
Kojto 98:8ab26030e058 415 }
Kojto 98:8ab26030e058 416
Kojto 98:8ab26030e058 417
Kojto 98:8ab26030e058 418 /**************************************************************************//**
Kojto 98:8ab26030e058 419 * @brief
Kojto 98:8ab26030e058 420 * Set one or more pending GPIO interrupts from SW.
Kojto 98:8ab26030e058 421 *
Kojto 98:8ab26030e058 422 * @param[in] flags
Kojto 98:8ab26030e058 423 * GPIO interrupt sources to set to pending.
Kojto 98:8ab26030e058 424 *****************************************************************************/
Kojto 98:8ab26030e058 425 __STATIC_INLINE void GPIO_IntSet(uint32_t flags)
Kojto 98:8ab26030e058 426 {
Kojto 98:8ab26030e058 427 GPIO->IFS = flags;
Kojto 98:8ab26030e058 428 }
Kojto 98:8ab26030e058 429
Kojto 98:8ab26030e058 430
Kojto 98:8ab26030e058 431 /***************************************************************************//**
Kojto 98:8ab26030e058 432 * @brief
Kojto 98:8ab26030e058 433 * Locks the GPIO configuration.
Kojto 98:8ab26030e058 434 ******************************************************************************/
Kojto 98:8ab26030e058 435 __STATIC_INLINE void GPIO_Lock(void)
Kojto 98:8ab26030e058 436 {
Kojto 98:8ab26030e058 437 GPIO->LOCK = GPIO_LOCK_LOCKKEY_LOCK;
Kojto 98:8ab26030e058 438 }
Kojto 98:8ab26030e058 439
Kojto 98:8ab26030e058 440
Kojto 98:8ab26030e058 441 /***************************************************************************//**
Kojto 98:8ab26030e058 442 * @brief
Kojto 98:8ab26030e058 443 * Read the pad value for a single pin in a GPIO port.
Kojto 98:8ab26030e058 444 *
Kojto 98:8ab26030e058 445 * @param[in] port
Kojto 98:8ab26030e058 446 * The GPIO port to access.
Kojto 98:8ab26030e058 447 *
Kojto 98:8ab26030e058 448 * @param[in] pin
Kojto 98:8ab26030e058 449 * The pin number to read.
Kojto 98:8ab26030e058 450 *
Kojto 98:8ab26030e058 451 * @return
Kojto 98:8ab26030e058 452 * The pin value, 0 or 1.
Kojto 98:8ab26030e058 453 ******************************************************************************/
Kojto 98:8ab26030e058 454 __STATIC_INLINE unsigned int GPIO_PinInGet(GPIO_Port_TypeDef port, unsigned int pin)
Kojto 98:8ab26030e058 455 {
Kojto 98:8ab26030e058 456 EFM_ASSERT(GPIO_PORT_VALID(port) && GPIO_PIN_VALID(pin));
Kojto 98:8ab26030e058 457
Kojto 98:8ab26030e058 458 return((unsigned int)((GPIO->P[port].DIN >> pin) & 0x1));
Kojto 98:8ab26030e058 459 }
Kojto 98:8ab26030e058 460
Kojto 98:8ab26030e058 461
Kojto 98:8ab26030e058 462 /***************************************************************************//**
Kojto 98:8ab26030e058 463 * @brief
Kojto 98:8ab26030e058 464 * Set a single pin in GPIO data out port register to 0.
Kojto 98:8ab26030e058 465 *
Kojto 98:8ab26030e058 466 * @note
Kojto 98:8ab26030e058 467 * In order for the setting to take effect on the output pad, the pin must
Kojto 98:8ab26030e058 468 * have been configured properly. If not, it will take effect whenever the
Kojto 98:8ab26030e058 469 * pin has been properly configured.
Kojto 98:8ab26030e058 470 *
Kojto 98:8ab26030e058 471 * @param[in] port
Kojto 98:8ab26030e058 472 * The GPIO port to access.
Kojto 98:8ab26030e058 473 *
Kojto 98:8ab26030e058 474 * @param[in] pin
Kojto 98:8ab26030e058 475 * The pin to set.
Kojto 98:8ab26030e058 476 ******************************************************************************/
Kojto 98:8ab26030e058 477 __STATIC_INLINE void GPIO_PinOutClear(GPIO_Port_TypeDef port, unsigned int pin)
Kojto 98:8ab26030e058 478 {
Kojto 98:8ab26030e058 479 EFM_ASSERT(GPIO_PORT_VALID(port) && GPIO_PIN_VALID(pin));
Kojto 98:8ab26030e058 480
Kojto 98:8ab26030e058 481 GPIO->P[port].DOUTCLR = 1 << pin;
Kojto 98:8ab26030e058 482 }
Kojto 98:8ab26030e058 483
Kojto 98:8ab26030e058 484
Kojto 98:8ab26030e058 485 /***************************************************************************//**
Kojto 98:8ab26030e058 486 * @brief
Kojto 98:8ab26030e058 487 * Get current setting for a pin in a GPIO port data out register.
Kojto 98:8ab26030e058 488 *
Kojto 98:8ab26030e058 489 * @param[in] port
Kojto 98:8ab26030e058 490 * The GPIO port to access.
Kojto 98:8ab26030e058 491 *
Kojto 98:8ab26030e058 492 * @param[in] pin
Kojto 98:8ab26030e058 493 * The pin to get setting for.
Kojto 98:8ab26030e058 494 *
Kojto 98:8ab26030e058 495 * @return
Kojto 98:8ab26030e058 496 * The DOUT setting for the requested pin, 0 or 1.
Kojto 98:8ab26030e058 497 ******************************************************************************/
Kojto 98:8ab26030e058 498 __STATIC_INLINE unsigned int GPIO_PinOutGet(GPIO_Port_TypeDef port, unsigned int pin)
Kojto 98:8ab26030e058 499 {
Kojto 98:8ab26030e058 500 EFM_ASSERT(GPIO_PORT_VALID(port) && GPIO_PIN_VALID(pin));
Kojto 98:8ab26030e058 501
Kojto 98:8ab26030e058 502 return((unsigned int)((GPIO->P[port].DOUT >> pin) & 0x1));
Kojto 98:8ab26030e058 503 }
Kojto 98:8ab26030e058 504
Kojto 98:8ab26030e058 505
Kojto 98:8ab26030e058 506 /***************************************************************************//**
Kojto 98:8ab26030e058 507 * @brief
Kojto 98:8ab26030e058 508 * Set a single pin in GPIO data out register to 1.
Kojto 98:8ab26030e058 509 *
Kojto 98:8ab26030e058 510 * @note
Kojto 98:8ab26030e058 511 * In order for the setting to take effect on the output pad, the pin must
Kojto 98:8ab26030e058 512 * have been configured properly. If not, it will take effect whenever the
Kojto 98:8ab26030e058 513 * pin has been properly configured.
Kojto 98:8ab26030e058 514 *
Kojto 98:8ab26030e058 515 * @param[in] port
Kojto 98:8ab26030e058 516 * The GPIO port to access.
Kojto 98:8ab26030e058 517 *
Kojto 98:8ab26030e058 518 * @param[in] pin
Kojto 98:8ab26030e058 519 * The pin to set.
Kojto 98:8ab26030e058 520 ******************************************************************************/
Kojto 98:8ab26030e058 521 __STATIC_INLINE void GPIO_PinOutSet(GPIO_Port_TypeDef port, unsigned int pin)
Kojto 98:8ab26030e058 522 {
Kojto 98:8ab26030e058 523 EFM_ASSERT(GPIO_PORT_VALID(port) && GPIO_PIN_VALID(pin));
Kojto 98:8ab26030e058 524
Kojto 98:8ab26030e058 525 GPIO->P[port].DOUTSET = 1 << pin;
Kojto 98:8ab26030e058 526 }
Kojto 98:8ab26030e058 527
Kojto 98:8ab26030e058 528
Kojto 98:8ab26030e058 529 /***************************************************************************//**
Kojto 98:8ab26030e058 530 * @brief
Kojto 98:8ab26030e058 531 * Toggle a single pin in GPIO port data out register.
Kojto 98:8ab26030e058 532 *
Kojto 98:8ab26030e058 533 * @note
Kojto 98:8ab26030e058 534 * In order for the setting to take effect on the output pad, the pin must
Kojto 98:8ab26030e058 535 * have been configured properly. If not, it will take effect whenever the
Kojto 98:8ab26030e058 536 * pin has been properly configured.
Kojto 98:8ab26030e058 537 *
Kojto 98:8ab26030e058 538 * @param[in] port
Kojto 98:8ab26030e058 539 * The GPIO port to access.
Kojto 98:8ab26030e058 540 *
Kojto 98:8ab26030e058 541 * @param[in] pin
Kojto 98:8ab26030e058 542 * The pin to toggle.
Kojto 98:8ab26030e058 543 ******************************************************************************/
Kojto 98:8ab26030e058 544 __STATIC_INLINE void GPIO_PinOutToggle(GPIO_Port_TypeDef port, unsigned int pin)
Kojto 98:8ab26030e058 545 {
Kojto 98:8ab26030e058 546 EFM_ASSERT(GPIO_PORT_VALID(port) && GPIO_PIN_VALID(pin));
Kojto 98:8ab26030e058 547
Kojto 98:8ab26030e058 548 GPIO->P[port].DOUTTGL = 1 << pin;
Kojto 98:8ab26030e058 549 }
Kojto 98:8ab26030e058 550
Kojto 98:8ab26030e058 551
Kojto 98:8ab26030e058 552 /***************************************************************************//**
Kojto 98:8ab26030e058 553 * @brief
Kojto 98:8ab26030e058 554 * Read the pad values for GPIO port.
Kojto 98:8ab26030e058 555 *
Kojto 98:8ab26030e058 556 * @param[in] port
Kojto 98:8ab26030e058 557 * The GPIO port to access.
Kojto 98:8ab26030e058 558 ******************************************************************************/
Kojto 98:8ab26030e058 559 __STATIC_INLINE uint32_t GPIO_PortInGet(GPIO_Port_TypeDef port)
Kojto 98:8ab26030e058 560 {
Kojto 98:8ab26030e058 561 EFM_ASSERT(GPIO_PORT_VALID(port));
Kojto 98:8ab26030e058 562
Kojto 98:8ab26030e058 563 return(GPIO->P[port].DIN & _GPIO_P_DIN_DIN_MASK);
Kojto 98:8ab26030e058 564 }
Kojto 98:8ab26030e058 565
Kojto 98:8ab26030e058 566
Kojto 98:8ab26030e058 567 /***************************************************************************//**
Kojto 98:8ab26030e058 568 * @brief
Kojto 98:8ab26030e058 569 * Set bits in DOUT register for a port to 0.
Kojto 98:8ab26030e058 570 *
Kojto 98:8ab26030e058 571 * @note
Kojto 98:8ab26030e058 572 * In order for the setting to take effect on the output pad, the pin must
Kojto 98:8ab26030e058 573 * have been configured properly. If not, it will take effect whenever the
Kojto 98:8ab26030e058 574 * pin has been properly configured.
Kojto 98:8ab26030e058 575 *
Kojto 98:8ab26030e058 576 * @param[in] port
Kojto 98:8ab26030e058 577 * The GPIO port to access.
Kojto 98:8ab26030e058 578 *
Kojto 98:8ab26030e058 579 * @param[in] pins
Kojto 98:8ab26030e058 580 * Bit mask for bits to clear in DOUT register.
Kojto 98:8ab26030e058 581 ******************************************************************************/
Kojto 98:8ab26030e058 582 __STATIC_INLINE void GPIO_PortOutClear(GPIO_Port_TypeDef port, uint32_t pins)
Kojto 98:8ab26030e058 583 {
Kojto 98:8ab26030e058 584 EFM_ASSERT(GPIO_PORT_VALID(port));
Kojto 98:8ab26030e058 585
Kojto 98:8ab26030e058 586 GPIO->P[port].DOUTCLR = pins & _GPIO_P_DOUTCLR_DOUTCLR_MASK;
Kojto 98:8ab26030e058 587 }
Kojto 98:8ab26030e058 588
Kojto 98:8ab26030e058 589
Kojto 98:8ab26030e058 590 /***************************************************************************//**
Kojto 98:8ab26030e058 591 * @brief
Kojto 98:8ab26030e058 592 * Get current setting for a GPIO port data out register.
Kojto 98:8ab26030e058 593 *
Kojto 98:8ab26030e058 594 * @param[in] port
Kojto 98:8ab26030e058 595 * The GPIO port to access.
Kojto 98:8ab26030e058 596 *
Kojto 98:8ab26030e058 597 * @return
Kojto 98:8ab26030e058 598 * The data out setting for the requested port.
Kojto 98:8ab26030e058 599 ******************************************************************************/
Kojto 98:8ab26030e058 600 __STATIC_INLINE uint32_t GPIO_PortOutGet(GPIO_Port_TypeDef port)
Kojto 98:8ab26030e058 601 {
Kojto 98:8ab26030e058 602 EFM_ASSERT(GPIO_PORT_VALID(port));
Kojto 98:8ab26030e058 603
Kojto 98:8ab26030e058 604 return(GPIO->P[port].DOUT & _GPIO_P_DOUT_DOUT_MASK);
Kojto 98:8ab26030e058 605 }
Kojto 98:8ab26030e058 606
Kojto 98:8ab26030e058 607
Kojto 98:8ab26030e058 608 /***************************************************************************//**
Kojto 98:8ab26030e058 609 * @brief
Kojto 98:8ab26030e058 610 * Set bits GPIO data out register to 1.
Kojto 98:8ab26030e058 611 *
Kojto 98:8ab26030e058 612 * @note
Kojto 98:8ab26030e058 613 * In order for the setting to take effect on the respective output pads, the
Kojto 98:8ab26030e058 614 * pins must have been configured properly. If not, it will take effect
Kojto 98:8ab26030e058 615 * whenever the pin has been properly configured.
Kojto 98:8ab26030e058 616 *
Kojto 98:8ab26030e058 617 * @param[in] port
Kojto 98:8ab26030e058 618 * The GPIO port to access.
Kojto 98:8ab26030e058 619 *
Kojto 98:8ab26030e058 620 * @param[in] pins
Kojto 98:8ab26030e058 621 * Bit mask for bits to set to 1 in DOUT register.
Kojto 98:8ab26030e058 622 ******************************************************************************/
Kojto 98:8ab26030e058 623 __STATIC_INLINE void GPIO_PortOutSet(GPIO_Port_TypeDef port, uint32_t pins)
Kojto 98:8ab26030e058 624 {
Kojto 98:8ab26030e058 625 EFM_ASSERT(GPIO_PORT_VALID(port));
Kojto 98:8ab26030e058 626
Kojto 98:8ab26030e058 627 GPIO->P[port].DOUTSET = pins & _GPIO_P_DOUTSET_DOUTSET_MASK;
Kojto 98:8ab26030e058 628 }
Kojto 98:8ab26030e058 629
Kojto 98:8ab26030e058 630
Kojto 98:8ab26030e058 631 /***************************************************************************//**
Kojto 98:8ab26030e058 632 * @brief
Kojto 98:8ab26030e058 633 * Set GPIO port data out register.
Kojto 98:8ab26030e058 634 *
Kojto 98:8ab26030e058 635 * @note
Kojto 98:8ab26030e058 636 * In order for the setting to take effect on the respective output pads, the
Kojto 98:8ab26030e058 637 * pins must have been configured properly. If not, it will take effect
Kojto 98:8ab26030e058 638 * whenever the pin has been properly configured.
Kojto 98:8ab26030e058 639 *
Kojto 98:8ab26030e058 640 * @param[in] port
Kojto 98:8ab26030e058 641 * The GPIO port to access.
Kojto 98:8ab26030e058 642 *
Kojto 98:8ab26030e058 643 * @param[in] val
Kojto 98:8ab26030e058 644 * Value to write to port data out register.
Kojto 98:8ab26030e058 645 *
Kojto 98:8ab26030e058 646 * @param[in] mask
Kojto 98:8ab26030e058 647 * Mask indicating which bits to modify.
Kojto 98:8ab26030e058 648 ******************************************************************************/
Kojto 98:8ab26030e058 649 __STATIC_INLINE void GPIO_PortOutSetVal(GPIO_Port_TypeDef port, uint32_t val, uint32_t mask)
Kojto 98:8ab26030e058 650 {
Kojto 98:8ab26030e058 651 EFM_ASSERT(GPIO_PORT_VALID(port));
Kojto 98:8ab26030e058 652
Kojto 98:8ab26030e058 653 GPIO->P[port].DOUT = (GPIO->P[port].DOUT & ~mask) | (val & mask);
Kojto 98:8ab26030e058 654 }
Kojto 98:8ab26030e058 655
Kojto 98:8ab26030e058 656
Kojto 98:8ab26030e058 657 /***************************************************************************//**
Kojto 98:8ab26030e058 658 * @brief
Kojto 98:8ab26030e058 659 * Toggle a single pin in GPIO port data out register.
Kojto 98:8ab26030e058 660 *
Kojto 98:8ab26030e058 661 * @note
Kojto 98:8ab26030e058 662 * In order for the setting to take effect on the output pad, the pin must
Kojto 98:8ab26030e058 663 * have been configured properly. If not, it will take effect whenever the
Kojto 98:8ab26030e058 664 * pin has been properly configured.
Kojto 98:8ab26030e058 665 *
Kojto 98:8ab26030e058 666 * @param[in] port
Kojto 98:8ab26030e058 667 * The GPIO port to access.
Kojto 98:8ab26030e058 668 *
Kojto 98:8ab26030e058 669 * @param[in] pins
Kojto 98:8ab26030e058 670 * Bitmask with pins to toggle.
Kojto 98:8ab26030e058 671 ******************************************************************************/
Kojto 98:8ab26030e058 672 __STATIC_INLINE void GPIO_PortOutToggle(GPIO_Port_TypeDef port, uint32_t pins)
Kojto 98:8ab26030e058 673 {
Kojto 98:8ab26030e058 674 EFM_ASSERT(GPIO_PORT_VALID(port));
Kojto 98:8ab26030e058 675
Kojto 98:8ab26030e058 676 GPIO->P[port].DOUTTGL = pins & _GPIO_P_DOUTTGL_DOUTTGL_MASK;
Kojto 98:8ab26030e058 677 }
Kojto 98:8ab26030e058 678
Kojto 98:8ab26030e058 679
Kojto 98:8ab26030e058 680 /***************************************************************************//**
Kojto 98:8ab26030e058 681 * @brief
Kojto 98:8ab26030e058 682 * Unlocks the GPIO configuration.
Kojto 98:8ab26030e058 683 ******************************************************************************/
Kojto 98:8ab26030e058 684 __STATIC_INLINE void GPIO_Unlock(void)
Kojto 98:8ab26030e058 685 {
Kojto 98:8ab26030e058 686 GPIO->LOCK = GPIO_LOCK_LOCKKEY_UNLOCK;
Kojto 98:8ab26030e058 687 }
Kojto 98:8ab26030e058 688
Kojto 98:8ab26030e058 689
Kojto 98:8ab26030e058 690 /** @} (end addtogroup GPIO) */
Kojto 98:8ab26030e058 691 /** @} (end addtogroup EM_Library) */
Kojto 98:8ab26030e058 692
Kojto 98:8ab26030e058 693 #ifdef __cplusplus
Kojto 98:8ab26030e058 694 }
Kojto 98:8ab26030e058 695 #endif
Kojto 98:8ab26030e058 696
Kojto 98:8ab26030e058 697 #endif /* defined(GPIO_COUNT) && (GPIO_COUNT > 0) */
Kojto 98:8ab26030e058 698 #endif /* __SILICON_LABS_EM_GPIO_H_ */