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 Mar 30 13:26:47 2017 +0100
Revision:
139:856d2700e60b
Parent:
128:9bcdf88f62b0
Release 139 of the mbed library

Ports for Upcoming Targets

3934: [Silicon Labs] Update to HAL and devices https://github.com/ARMmbed/mbed-os/pull/3934

Known Issues

There is an issue with LPC1768 failing the 'Semihost file system' test with this release.

Fixes and Changes

3691: [TLS / hw acceleration] AES ECB for NUCLEO_F439ZI https://github.com/ARMmbed/mbed-os/pull/3691
3869: NCS36510: Default range changed from 0 to 950mV - ADC https://github.com/ARMmbed/mbed-os/pull/3869
3893: [STM32F7] Update STM32 Cube version v1.6.0 https://github.com/ARMmbed/mbed-os/pull/3893
3917: Fix mistake register setting in serial_format() https://github.com/ARMmbed/mbed-os/pull/3917
3927: [DELTA_DFBM_NQ620] Add RC calibration setting and revise mbed_overrides.c https://github.com/ARMmbed/mbed-os/pull/3927
3918: [NUC472/M453] Support unique locally administered MAC address and other driver updates https://github.com/ARMmbed/mbed-os/pull/3918
3920: Heap size adjusted to work for both tls-client and mbed-client https://github.com/ARMmbed/mbed-os/pull/3920
3969: NUCLEO_F302R8: Add missing PB_8/PB_9 CAN pins https://github.com/ARMmbed/mbed-os/pull/3969

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