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_emu.h
Kojto 98:8ab26030e058 3 * @brief Energy management unit (EMU) 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_EMU_H__
Kojto 98:8ab26030e058 35 #define __SILICON_LABS_EM_EMU_H__
Kojto 98:8ab26030e058 36
Kojto 98:8ab26030e058 37 #include "em_device.h"
Kojto 98:8ab26030e058 38 #if defined( EMU_PRESENT )
Kojto 98:8ab26030e058 39
Kojto 98:8ab26030e058 40 #include <stdbool.h>
Kojto 98:8ab26030e058 41 #include "em_bitband.h"
Kojto 98:8ab26030e058 42
Kojto 98:8ab26030e058 43 #ifdef __cplusplus
Kojto 98:8ab26030e058 44 extern "C" {
Kojto 98:8ab26030e058 45 #endif
Kojto 98:8ab26030e058 46
Kojto 98:8ab26030e058 47 /***************************************************************************//**
Kojto 98:8ab26030e058 48 * @addtogroup EM_Library
Kojto 98:8ab26030e058 49 * @{
Kojto 98:8ab26030e058 50 ******************************************************************************/
Kojto 98:8ab26030e058 51
Kojto 98:8ab26030e058 52 /***************************************************************************//**
Kojto 98:8ab26030e058 53 * @addtogroup EMU
Kojto 98:8ab26030e058 54 * @{
Kojto 98:8ab26030e058 55 ******************************************************************************/
Kojto 98:8ab26030e058 56
Kojto 98:8ab26030e058 57 /*******************************************************************************
Kojto 98:8ab26030e058 58 ******************************** ENUMS ************************************
Kojto 98:8ab26030e058 59 ******************************************************************************/
Kojto 98:8ab26030e058 60
Kojto 98:8ab26030e058 61 typedef enum
Kojto 98:8ab26030e058 62 {
Kojto 98:8ab26030e058 63 /** Enable EM2 and 3 voltage regulator reduced drive strength (reduced leakage current) */
Kojto 98:8ab26030e058 64 #if defined( _EMU_CTRL_EM23VREG_MASK )
Kojto 98:8ab26030e058 65 emuEM23Vreg_REDUCED = EMU_CTRL_EM23VREG_REDUCED,
Kojto 98:8ab26030e058 66 #elif defined( _EMU_CTRL_EMVREG_MASK )
Kojto 98:8ab26030e058 67 emuEM23Vreg_REDUCED = EMU_CTRL_EMVREG_REDUCED,
Kojto 98:8ab26030e058 68 #endif
Kojto 98:8ab26030e058 69 /** Enable EM2 and 3 voltage regulator full drive strength (faster startup) */
Kojto 98:8ab26030e058 70 #if defined( _EMU_CTRL_EM23VREG_MASK )
Kojto 98:8ab26030e058 71 emuEM23Vreg_FULL = EMU_CTRL_EM23VREG_FULL,
Kojto 98:8ab26030e058 72 #elif defined( _EMU_CTRL_EMVREG_MASK )
Kojto 98:8ab26030e058 73 emuEM23Vreg_FULL = EMU_CTRL_EMVREG_FULL,
Kojto 98:8ab26030e058 74 #endif
Kojto 98:8ab26030e058 75 } EMU_EM23VregMode;
Kojto 98:8ab26030e058 76
Kojto 98:8ab26030e058 77 #if defined( _EMU_EM4CONF_OSC_MASK )
Kojto 98:8ab26030e058 78 /** EM4 duty oscillator */
Kojto 98:8ab26030e058 79 typedef enum
Kojto 98:8ab26030e058 80 {
Kojto 98:8ab26030e058 81 /** Select ULFRCO as duty oscillator in EM4 */
Kojto 98:8ab26030e058 82 emuEM4Osc_ULFRCO = EMU_EM4CONF_OSC_ULFRCO,
Kojto 98:8ab26030e058 83 /** Select LFXO as duty oscillator in EM4 */
Kojto 98:8ab26030e058 84 emuEM4Osc_LFXO = EMU_EM4CONF_OSC_LFXO,
Kojto 98:8ab26030e058 85 /** Select LFRCO as duty oscillator in EM4 */
Kojto 98:8ab26030e058 86 emuEM4Osc_LFRCO = EMU_EM4CONF_OSC_LFRCO
Kojto 98:8ab26030e058 87 } EMU_EM4Osc_TypeDef;
Kojto 98:8ab26030e058 88 #endif
Kojto 98:8ab26030e058 89
Kojto 98:8ab26030e058 90 #if defined( _EMU_BUCTRL_PROBE_MASK )
Kojto 98:8ab26030e058 91 /** Backup Power Voltage Probe types */
Kojto 98:8ab26030e058 92 typedef enum
Kojto 98:8ab26030e058 93 {
Kojto 98:8ab26030e058 94 /** Disable voltage probe */
Kojto 98:8ab26030e058 95 emuProbe_Disable = EMU_BUCTRL_PROBE_DISABLE,
Kojto 98:8ab26030e058 96 /** Connect probe to VDD_DREG */
Kojto 98:8ab26030e058 97 emuProbe_VDDDReg = EMU_BUCTRL_PROBE_VDDDREG,
Kojto 98:8ab26030e058 98 /** Connect probe to BU_IN */
Kojto 98:8ab26030e058 99 emuProbe_BUIN = EMU_BUCTRL_PROBE_BUIN,
Kojto 98:8ab26030e058 100 /** Connect probe to BU_OUT */
Kojto 98:8ab26030e058 101 emuProbe_BUOUT = EMU_BUCTRL_PROBE_BUOUT
Kojto 98:8ab26030e058 102 } EMU_Probe_TypeDef;
Kojto 98:8ab26030e058 103 #endif
Kojto 98:8ab26030e058 104
Kojto 98:8ab26030e058 105 #if defined( _EMU_PWRCONF_PWRRES_MASK )
Kojto 98:8ab26030e058 106 /** Backup Power Domain resistor selection */
Kojto 98:8ab26030e058 107 typedef enum
Kojto 98:8ab26030e058 108 {
Kojto 98:8ab26030e058 109 /** Main power and backup power connected with RES0 series resistance */
Kojto 98:8ab26030e058 110 emuRes_Res0 = EMU_PWRCONF_PWRRES_RES0,
Kojto 98:8ab26030e058 111 /** Main power and backup power connected with RES1 series resistance */
Kojto 98:8ab26030e058 112 emuRes_Res1 = EMU_PWRCONF_PWRRES_RES1,
Kojto 98:8ab26030e058 113 /** Main power and backup power connected with RES2 series resistance */
Kojto 98:8ab26030e058 114 emuRes_Res2 = EMU_PWRCONF_PWRRES_RES2,
Kojto 98:8ab26030e058 115 /** Main power and backup power connected with RES3 series resistance */
Kojto 98:8ab26030e058 116 emuRes_Res3 = EMU_PWRCONF_PWRRES_RES3,
Kojto 98:8ab26030e058 117 } EMU_Resistor_TypeDef;
Kojto 98:8ab26030e058 118 #endif
Kojto 98:8ab26030e058 119
Kojto 98:8ab26030e058 120 #if defined( BU_PRESENT )
Kojto 98:8ab26030e058 121 /** Backup Power Domain power connection */
Kojto 98:8ab26030e058 122 typedef enum
Kojto 98:8ab26030e058 123 {
Kojto 98:8ab26030e058 124 /** No connection between main and backup power */
Kojto 98:8ab26030e058 125 emuPower_None = EMU_BUINACT_PWRCON_NONE,
Kojto 98:8ab26030e058 126 /** Main power and backup power connected through diode,
Kojto 98:8ab26030e058 127 allowing current from backup to main only */
Kojto 98:8ab26030e058 128 emuPower_BUMain = EMU_BUINACT_PWRCON_BUMAIN,
Kojto 98:8ab26030e058 129 /** Main power and backup power connected through diode,
Kojto 98:8ab26030e058 130 allowing current from main to backup only */
Kojto 98:8ab26030e058 131 emuPower_MainBU = EMU_BUINACT_PWRCON_MAINBU,
Kojto 98:8ab26030e058 132 /** Main power and backup power connected without diode */
Kojto 98:8ab26030e058 133 emuPower_NoDiode = EMU_BUINACT_PWRCON_NODIODE,
Kojto 98:8ab26030e058 134 } EMU_Power_TypeDef;
Kojto 98:8ab26030e058 135 #endif
Kojto 98:8ab26030e058 136
Kojto 98:8ab26030e058 137 /** BOD threshold setting selector, active or inactive mode */
Kojto 98:8ab26030e058 138 typedef enum
Kojto 98:8ab26030e058 139 {
Kojto 98:8ab26030e058 140 /** Configure BOD threshold for active mode */
Kojto 98:8ab26030e058 141 emuBODMode_Active,
Kojto 98:8ab26030e058 142 /** Configure BOD threshold for inactive mode */
Kojto 98:8ab26030e058 143 emuBODMode_Inactive,
Kojto 98:8ab26030e058 144 } EMU_BODMode_TypeDef;
Kojto 98:8ab26030e058 145
Kojto 98:8ab26030e058 146
Kojto 98:8ab26030e058 147
Kojto 98:8ab26030e058 148 /*******************************************************************************
Kojto 98:8ab26030e058 149 ******************************* STRUCTS ***********************************
Kojto 98:8ab26030e058 150 ******************************************************************************/
Kojto 98:8ab26030e058 151
Kojto 98:8ab26030e058 152 /** Energy Mode 2 and 3 initialization structure */
Kojto 98:8ab26030e058 153 typedef struct
Kojto 98:8ab26030e058 154 {
Kojto 98:8ab26030e058 155 bool em23Vreg;
Kojto 98:8ab26030e058 156 } EMU_EM23Init_TypeDef;
Kojto 98:8ab26030e058 157
Kojto 98:8ab26030e058 158 /** Default initialization of EM2 and 3 configuration */
Kojto 98:8ab26030e058 159 #define EMU_EM23INIT_DEFAULT \
Kojto 98:8ab26030e058 160 { false } /* Reduced voltage regulator drive strength in EM2 and EM3 */
Kojto 98:8ab26030e058 161
Kojto 98:8ab26030e058 162
Kojto 98:8ab26030e058 163 /** Energy Mode 4 initialization structure */
Kojto 98:8ab26030e058 164 typedef struct
Kojto 98:8ab26030e058 165 {
Kojto 98:8ab26030e058 166 /* Init parameters for platforms with EMU->EM4CONF register */
Kojto 98:8ab26030e058 167 #if defined( _EMU_EM4CONF_MASK )
Kojto 98:8ab26030e058 168 bool lockConfig; /** Lock configuration of regulator, BOD and oscillator */
Kojto 98:8ab26030e058 169 bool buBodRstDis; /** When set, no reset will be asserted due to Brownout when in EM4 */
Kojto 98:8ab26030e058 170 EMU_EM4Osc_TypeDef osc; /** EM4 duty oscillator */
Kojto 98:8ab26030e058 171 bool buRtcWakeup; /** Wake up on EM4 BURTC interrupt */
Kojto 98:8ab26030e058 172 bool vreg; /** Enable EM4 voltage regulator */
Kojto 98:8ab26030e058 173 #else
Kojto 98:8ab26030e058 174 bool reserved; /** Placeholder for empty structs */
Kojto 98:8ab26030e058 175 #endif
Kojto 98:8ab26030e058 176 } EMU_EM4Init_TypeDef;
Kojto 98:8ab26030e058 177
Kojto 98:8ab26030e058 178 /** Default initialization of EM4 configuration */
Kojto 98:8ab26030e058 179 #if defined( _EMU_EM4CONF_MASK )
Kojto 98:8ab26030e058 180 #define EMU_EM4INIT_DEFAULT \
Kojto 98:8ab26030e058 181 { false, /* Dont't lock configuration after it's been set */ \
Kojto 98:8ab26030e058 182 false, /* No reset will be asserted due to Brownout when in EM4 */ \
Kojto 98:8ab26030e058 183 emuEM4Osc_ULFRCO, /* Use default ULFRCO oscillator */ \
Kojto 98:8ab26030e058 184 true, /* Wake up on EM4 BURTC interrupt */ \
Kojto 98:8ab26030e058 185 true, /* Enable VREG */ \
Kojto 98:8ab26030e058 186 }
Kojto 98:8ab26030e058 187 #else
Kojto 98:8ab26030e058 188 #define EMU_EM4INIT_DEFAULT \
Kojto 98:8ab26030e058 189 { false, /* Placeholder default value */ \
Kojto 98:8ab26030e058 190 }
Kojto 98:8ab26030e058 191 #endif
Kojto 98:8ab26030e058 192
Kojto 98:8ab26030e058 193
Kojto 98:8ab26030e058 194 #if defined( BU_PRESENT )
Kojto 98:8ab26030e058 195 /** Backup Power Domain Initialization structure */
Kojto 98:8ab26030e058 196 typedef struct
Kojto 98:8ab26030e058 197 {
Kojto 98:8ab26030e058 198 /* Backup Power Domain power configuration */
Kojto 98:8ab26030e058 199
Kojto 98:8ab26030e058 200 /** Voltage probe select, selects ADC voltage */
Kojto 98:8ab26030e058 201 EMU_Probe_TypeDef probe;
Kojto 98:8ab26030e058 202 /** Enable BOD calibration mode */
Kojto 98:8ab26030e058 203 bool bodCal;
Kojto 98:8ab26030e058 204 /** Enable BU_STAT status pin for active BU mode */
Kojto 98:8ab26030e058 205 bool statusPinEnable;
Kojto 98:8ab26030e058 206
Kojto 98:8ab26030e058 207 /* Backup Power Domain connection configuration */
Kojto 98:8ab26030e058 208 /** Power domain resistor */
Kojto 98:8ab26030e058 209 EMU_Resistor_TypeDef resistor;
Kojto 98:8ab26030e058 210 /** BU_VOUT strong enable */
Kojto 98:8ab26030e058 211 bool voutStrong;
Kojto 98:8ab26030e058 212 /** BU_VOUT medium enable */
Kojto 98:8ab26030e058 213 bool voutMed;
Kojto 98:8ab26030e058 214 /** BU_VOUT weak enable */
Kojto 98:8ab26030e058 215 bool voutWeak;
Kojto 98:8ab26030e058 216 /** Power connection, when not in Backup Mode */
Kojto 98:8ab26030e058 217 EMU_Power_TypeDef inactivePower;
Kojto 98:8ab26030e058 218 /** Power connection, when in Backup Mode */
Kojto 98:8ab26030e058 219 EMU_Power_TypeDef activePower;
Kojto 98:8ab26030e058 220 /** Enable backup power domain, and release reset, enable BU_VIN pin */
Kojto 98:8ab26030e058 221 bool enable;
Kojto 98:8ab26030e058 222 } EMU_BUPDInit_TypeDef;
Kojto 98:8ab26030e058 223
Kojto 98:8ab26030e058 224 /** Default */
Kojto 98:8ab26030e058 225 #define EMU_BUPDINIT_DEFAULT \
Kojto 98:8ab26030e058 226 { emuProbe_Disable, /* Do not enable voltage probe */ \
Kojto 98:8ab26030e058 227 false, /* Disable BOD calibration mode */ \
Kojto 98:8ab26030e058 228 false, /* Disable BU_STAT pin for backup mode indication */ \
Kojto 98:8ab26030e058 229 \
Kojto 98:8ab26030e058 230 emuRes_Res0, /* RES0 series resistance between main and backup power */ \
Kojto 98:8ab26030e058 231 false, /* Don't enable strong switch */ \
Kojto 98:8ab26030e058 232 false, /* Don't enable medium switch */ \
Kojto 98:8ab26030e058 233 false, /* Don't enable weak switch */ \
Kojto 98:8ab26030e058 234 \
Kojto 98:8ab26030e058 235 emuPower_None, /* No connection between main and backup power (inactive mode) */ \
Kojto 98:8ab26030e058 236 emuPower_None, /* No connection between main and backup power (active mode) */ \
Kojto 98:8ab26030e058 237 true /* Enable BUPD enter on BOD, enable BU_VIN pin, release BU reset */ \
Kojto 98:8ab26030e058 238 }
Kojto 98:8ab26030e058 239 #endif
Kojto 98:8ab26030e058 240
Kojto 98:8ab26030e058 241
Kojto 98:8ab26030e058 242 /*******************************************************************************
Kojto 98:8ab26030e058 243 ***************************** PROTOTYPES **********************************
Kojto 98:8ab26030e058 244 ******************************************************************************/
Kojto 98:8ab26030e058 245
Kojto 98:8ab26030e058 246 /***************************************************************************//**
Kojto 98:8ab26030e058 247 * @brief
Kojto 98:8ab26030e058 248 * Enter energy mode 1 (EM1).
Kojto 98:8ab26030e058 249 ******************************************************************************/
Kojto 98:8ab26030e058 250 __STATIC_INLINE void EMU_EnterEM1(void)
Kojto 98:8ab26030e058 251 {
Kojto 98:8ab26030e058 252 /* Just enter Cortex-M3 sleep mode */
Kojto 98:8ab26030e058 253 SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
Kojto 98:8ab26030e058 254 __WFI();
Kojto 98:8ab26030e058 255 }
Kojto 98:8ab26030e058 256
Kojto 98:8ab26030e058 257 void EMU_EM23Init(EMU_EM23Init_TypeDef *em23Init);
Kojto 98:8ab26030e058 258 #if defined( _EMU_EM4CONF_MASK )
Kojto 98:8ab26030e058 259 void EMU_EM4Init(EMU_EM4Init_TypeDef *em4Init);
Kojto 98:8ab26030e058 260 #endif
Kojto 98:8ab26030e058 261 void EMU_EnterEM2(bool restore);
Kojto 98:8ab26030e058 262 void EMU_EnterEM3(bool restore);
Kojto 98:8ab26030e058 263 void EMU_EnterEM4(void);
Kojto 98:8ab26030e058 264 void EMU_MemPwrDown(uint32_t blocks);
Kojto 98:8ab26030e058 265 void EMU_UpdateOscConfig(void);
Kojto 98:8ab26030e058 266 #if defined( BU_PRESENT )
Kojto 98:8ab26030e058 267 void EMU_BUPDInit(EMU_BUPDInit_TypeDef *bupdInit);
Kojto 98:8ab26030e058 268 void EMU_BUThresholdSet(EMU_BODMode_TypeDef mode, uint32_t value);
Kojto 98:8ab26030e058 269 void EMU_BUThresRangeSet(EMU_BODMode_TypeDef mode, uint32_t value);
Kojto 98:8ab26030e058 270 #endif
Kojto 98:8ab26030e058 271
Kojto 98:8ab26030e058 272
Kojto 98:8ab26030e058 273 #if defined( _EMU_IF_MASK )
Kojto 98:8ab26030e058 274 /***************************************************************************//**
Kojto 98:8ab26030e058 275 * @brief
Kojto 98:8ab26030e058 276 * Clear one or more pending EMU interrupts.
Kojto 98:8ab26030e058 277 *
Kojto 98:8ab26030e058 278 * @param[in] flags
Kojto 98:8ab26030e058 279 * Pending EMU interrupt sources to clear. Use one or more valid
Kojto 98:8ab26030e058 280 * interrupt flags for the EMU module (EMU_IFC_nnn).
Kojto 98:8ab26030e058 281 ******************************************************************************/
Kojto 98:8ab26030e058 282 __STATIC_INLINE void EMU_IntClear(uint32_t flags)
Kojto 98:8ab26030e058 283 {
Kojto 98:8ab26030e058 284 EMU->IFC = flags;
Kojto 98:8ab26030e058 285 }
Kojto 98:8ab26030e058 286
Kojto 98:8ab26030e058 287
Kojto 98:8ab26030e058 288 /***************************************************************************//**
Kojto 98:8ab26030e058 289 * @brief
Kojto 98:8ab26030e058 290 * Disable one or more EMU interrupts.
Kojto 98:8ab26030e058 291 *
Kojto 98:8ab26030e058 292 * @param[in] flags
Kojto 98:8ab26030e058 293 * EMU interrupt sources to disable. Use one or more valid
Kojto 98:8ab26030e058 294 * interrupt flags for the EMU module (EMU_IEN_nnn).
Kojto 98:8ab26030e058 295 ******************************************************************************/
Kojto 98:8ab26030e058 296 __STATIC_INLINE void EMU_IntDisable(uint32_t flags)
Kojto 98:8ab26030e058 297 {
Kojto 98:8ab26030e058 298 EMU->IEN &= ~(flags);
Kojto 98:8ab26030e058 299 }
Kojto 98:8ab26030e058 300
Kojto 98:8ab26030e058 301
Kojto 98:8ab26030e058 302 /***************************************************************************//**
Kojto 98:8ab26030e058 303 * @brief
Kojto 98:8ab26030e058 304 * Enable one or more EMU interrupts.
Kojto 98:8ab26030e058 305 *
Kojto 98:8ab26030e058 306 * @note
Kojto 98:8ab26030e058 307 * Depending on the use, a pending interrupt may already be set prior to
Kojto 98:8ab26030e058 308 * enabling the interrupt. Consider using EMU_IntClear() prior to enabling
Kojto 98:8ab26030e058 309 * if such a pending interrupt should be ignored.
Kojto 98:8ab26030e058 310 *
Kojto 98:8ab26030e058 311 * @param[in] flags
Kojto 98:8ab26030e058 312 * EMU interrupt sources to enable. Use one or more valid
Kojto 98:8ab26030e058 313 * interrupt flags for the EMU module (EMU_IEN_nnn).
Kojto 98:8ab26030e058 314 ******************************************************************************/
Kojto 98:8ab26030e058 315 __STATIC_INLINE void EMU_IntEnable(uint32_t flags)
Kojto 98:8ab26030e058 316 {
Kojto 98:8ab26030e058 317 EMU->IEN |= flags;
Kojto 98:8ab26030e058 318 }
Kojto 98:8ab26030e058 319
Kojto 98:8ab26030e058 320
Kojto 98:8ab26030e058 321 /***************************************************************************//**
Kojto 98:8ab26030e058 322 * @brief
Kojto 98:8ab26030e058 323 * Get pending EMU interrupt flags.
Kojto 98:8ab26030e058 324 *
Kojto 98:8ab26030e058 325 * @note
Kojto 98:8ab26030e058 326 * The event bits are not cleared by the use of this function.
Kojto 98:8ab26030e058 327 *
Kojto 98:8ab26030e058 328 * @return
Kojto 98:8ab26030e058 329 * EMU interrupt sources pending. Returns one or more valid
Kojto 98:8ab26030e058 330 * interrupt flags for the EMU module (EMU_IF_nnn).
Kojto 98:8ab26030e058 331 ******************************************************************************/
Kojto 98:8ab26030e058 332 __STATIC_INLINE uint32_t EMU_IntGet(void)
Kojto 98:8ab26030e058 333 {
Kojto 98:8ab26030e058 334 return EMU->IF;
Kojto 98:8ab26030e058 335 }
Kojto 98:8ab26030e058 336
Kojto 98:8ab26030e058 337
Kojto 98:8ab26030e058 338 /***************************************************************************//**
Kojto 98:8ab26030e058 339 * @brief
Kojto 98:8ab26030e058 340 * Get enabled and pending EMU interrupt flags.
Kojto 98:8ab26030e058 341 * Useful for handling more interrupt sources in the same interrupt handler.
Kojto 98:8ab26030e058 342 *
Kojto 98:8ab26030e058 343 * @note
Kojto 98:8ab26030e058 344 * Interrupt flags are not cleared by the use of this function.
Kojto 98:8ab26030e058 345 *
Kojto 98:8ab26030e058 346 * @return
Kojto 98:8ab26030e058 347 * Pending and enabled EMU interrupt sources
Kojto 98:8ab26030e058 348 * The return value is the bitwise AND of
Kojto 98:8ab26030e058 349 * - the enabled interrupt sources in EMU_IEN and
Kojto 98:8ab26030e058 350 * - the pending interrupt flags EMU_IF
Kojto 98:8ab26030e058 351 ******************************************************************************/
Kojto 98:8ab26030e058 352 __STATIC_INLINE uint32_t EMU_IntGetEnabled(void)
Kojto 98:8ab26030e058 353 {
Kojto 98:8ab26030e058 354 uint32_t ien;
Kojto 98:8ab26030e058 355
Kojto 98:8ab26030e058 356 ien = EMU->IEN;
Kojto 98:8ab26030e058 357 return EMU->IF & ien;
Kojto 98:8ab26030e058 358 }
Kojto 98:8ab26030e058 359
Kojto 98:8ab26030e058 360
Kojto 98:8ab26030e058 361 /***************************************************************************//**
Kojto 98:8ab26030e058 362 * @brief
Kojto 98:8ab26030e058 363 * Set one or more pending EMU interrupts
Kojto 98:8ab26030e058 364 *
Kojto 98:8ab26030e058 365 * @param[in] flags
Kojto 98:8ab26030e058 366 * EMU interrupt sources to set to pending. Use one or more valid
Kojto 98:8ab26030e058 367 * interrupt flags for the EMU module (EMU_IFS_nnn).
Kojto 98:8ab26030e058 368 ******************************************************************************/
Kojto 98:8ab26030e058 369 __STATIC_INLINE void EMU_IntSet(uint32_t flags)
Kojto 98:8ab26030e058 370 {
Kojto 98:8ab26030e058 371 EMU->IFS = flags;
Kojto 98:8ab26030e058 372 }
Kojto 98:8ab26030e058 373 #endif /* _EMU_IF_MASK */
Kojto 98:8ab26030e058 374
Kojto 98:8ab26030e058 375
Kojto 98:8ab26030e058 376 #if defined( _EMU_EM4CONF_LOCKCONF_MASK )
Kojto 98:8ab26030e058 377 /***************************************************************************//**
Kojto 98:8ab26030e058 378 * @brief
Kojto 98:8ab26030e058 379 * Enable or disable EM4 lock configuration
Kojto 98:8ab26030e058 380 * @param[in] enable
Kojto 98:8ab26030e058 381 * If true, locks down EM4 configuration
Kojto 98:8ab26030e058 382 ******************************************************************************/
Kojto 98:8ab26030e058 383 __STATIC_INLINE void EMU_EM4Lock(bool enable)
Kojto 98:8ab26030e058 384 {
Kojto 98:8ab26030e058 385 BITBAND_Peripheral(&(EMU->EM4CONF), _EMU_EM4CONF_LOCKCONF_SHIFT, enable);
Kojto 98:8ab26030e058 386 }
Kojto 98:8ab26030e058 387 #endif
Kojto 98:8ab26030e058 388
Kojto 98:8ab26030e058 389
Kojto 98:8ab26030e058 390 #if defined( _EMU_STATUS_BURDY_MASK )
Kojto 98:8ab26030e058 391 /***************************************************************************//**
Kojto 98:8ab26030e058 392 * @brief
Kojto 98:8ab26030e058 393 * Halts until backup power functionality is ready
Kojto 98:8ab26030e058 394 ******************************************************************************/
Kojto 98:8ab26030e058 395 __STATIC_INLINE void EMU_BUReady(void)
Kojto 98:8ab26030e058 396 {
Kojto 98:8ab26030e058 397 while(!(EMU->STATUS & EMU_STATUS_BURDY));
Kojto 98:8ab26030e058 398 }
Kojto 98:8ab26030e058 399 #endif
Kojto 98:8ab26030e058 400
Kojto 98:8ab26030e058 401
Kojto 98:8ab26030e058 402 #if defined( _EMU_ROUTE_BUVINPEN_MASK )
Kojto 98:8ab26030e058 403 /***************************************************************************//**
Kojto 98:8ab26030e058 404 * @brief
Kojto 98:8ab26030e058 405 * Disable BU_VIN support
Kojto 98:8ab26030e058 406 * @param[in] enable
Kojto 98:8ab26030e058 407 * If true, enables BU_VIN input pin support, if false disables it
Kojto 98:8ab26030e058 408 ******************************************************************************/
Kojto 98:8ab26030e058 409 __STATIC_INLINE void EMU_BUPinEnable(bool enable)
Kojto 98:8ab26030e058 410 {
Kojto 98:8ab26030e058 411 BITBAND_Peripheral(&(EMU->ROUTE), _EMU_ROUTE_BUVINPEN_SHIFT, enable);
Kojto 98:8ab26030e058 412 }
Kojto 98:8ab26030e058 413 #endif
Kojto 98:8ab26030e058 414
Kojto 98:8ab26030e058 415
Kojto 98:8ab26030e058 416 /***************************************************************************//**
Kojto 98:8ab26030e058 417 * @brief
Kojto 98:8ab26030e058 418 * Lock the EMU in order to protect all its registers against unintended
Kojto 98:8ab26030e058 419 * modification.
Kojto 98:8ab26030e058 420 *
Kojto 98:8ab26030e058 421 * @note
Kojto 98:8ab26030e058 422 * If locking the EMU registers, they must be unlocked prior to using any
Kojto 98:8ab26030e058 423 * EMU API functions modifying EMU registers. An exception to this is the
Kojto 98:8ab26030e058 424 * energy mode entering API (EMU_EnterEMn()), which can be used when the
Kojto 98:8ab26030e058 425 * EMU registers are locked.
Kojto 98:8ab26030e058 426 ******************************************************************************/
Kojto 98:8ab26030e058 427 __STATIC_INLINE void EMU_Lock(void)
Kojto 98:8ab26030e058 428 {
Kojto 98:8ab26030e058 429 EMU->LOCK = EMU_LOCK_LOCKKEY_LOCK;
Kojto 98:8ab26030e058 430 }
Kojto 98:8ab26030e058 431
Kojto 98:8ab26030e058 432
Kojto 98:8ab26030e058 433 /***************************************************************************//**
Kojto 98:8ab26030e058 434 * @brief
Kojto 98:8ab26030e058 435 * Unlock the EMU so that writing to locked registers again is possible.
Kojto 98:8ab26030e058 436 ******************************************************************************/
Kojto 98:8ab26030e058 437 __STATIC_INLINE void EMU_Unlock(void)
Kojto 98:8ab26030e058 438 {
Kojto 98:8ab26030e058 439 EMU->LOCK = EMU_LOCK_LOCKKEY_UNLOCK;
Kojto 98:8ab26030e058 440 }
Kojto 98:8ab26030e058 441
Kojto 98:8ab26030e058 442 /***************************************************************************//**
Kojto 98:8ab26030e058 443 * @brief
Kojto 98:8ab26030e058 444 * Block entering EM2 or higher number energy modes.
Kojto 98:8ab26030e058 445 ******************************************************************************/
Kojto 98:8ab26030e058 446 __STATIC_INLINE void EMU_EM2Block(void)
Kojto 98:8ab26030e058 447 {
Kojto 98:8ab26030e058 448 BITBAND_Peripheral(&(EMU->CTRL), _EMU_CTRL_EM2BLOCK_SHIFT, 1U);
Kojto 98:8ab26030e058 449 }
Kojto 98:8ab26030e058 450
Kojto 98:8ab26030e058 451
Kojto 98:8ab26030e058 452 /***************************************************************************//**
Kojto 98:8ab26030e058 453 * @brief
Kojto 98:8ab26030e058 454 * Unblock entering EM2 or higher number energy modes.
Kojto 98:8ab26030e058 455 ******************************************************************************/
Kojto 98:8ab26030e058 456 __STATIC_INLINE void EMU_EM2UnBlock(void)
Kojto 98:8ab26030e058 457 {
Kojto 98:8ab26030e058 458 BITBAND_Peripheral(&(EMU->CTRL), _EMU_CTRL_EM2BLOCK_SHIFT, 0U);
Kojto 98:8ab26030e058 459 }
Kojto 98:8ab26030e058 460
Kojto 98:8ab26030e058 461
Kojto 98:8ab26030e058 462 /** @} (end addtogroup EMU) */
Kojto 98:8ab26030e058 463 /** @} (end addtogroup EM_Library) */
Kojto 98:8ab26030e058 464
Kojto 98:8ab26030e058 465 #ifdef __cplusplus
Kojto 98:8ab26030e058 466 }
Kojto 98:8ab26030e058 467 #endif
Kojto 98:8ab26030e058 468
Kojto 98:8ab26030e058 469 #endif /* defined( EMU_PRESENT ) */
Kojto 98:8ab26030e058 470 #endif /* __EM_EMU_H */