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

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

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

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

Ports for Upcoming Targets


Fixes and Changes

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

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 113:f141b2784e32 1 /***************************************************************************//**
Kojto 113:f141b2784e32 2 * @file em_cryotimer.h
Kojto 113:f141b2784e32 3 * @brief Ultra Low Energy Timer/Counter (CRYOTIMER) peripheral API
<> 128:9bcdf88f62b0 4 * @version 5.0.0
Kojto 113:f141b2784e32 5 *******************************************************************************
Kojto 113:f141b2784e32 6 * @section License
<> 128:9bcdf88f62b0 7 * <b>Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com</b>
Kojto 113:f141b2784e32 8 *******************************************************************************
Kojto 113:f141b2784e32 9 *
Kojto 113:f141b2784e32 10 * Permission is granted to anyone to use this software for any purpose,
Kojto 113:f141b2784e32 11 * including commercial applications, and to alter it and redistribute it
Kojto 113:f141b2784e32 12 * freely, subject to the following restrictions:
Kojto 113:f141b2784e32 13 *
Kojto 113:f141b2784e32 14 * 1. The origin of this software must not be misrepresented; you must not
Kojto 113:f141b2784e32 15 * claim that you wrote the original software.@n
Kojto 113:f141b2784e32 16 * 2. Altered source versions must be plainly marked as such, and must not be
Kojto 113:f141b2784e32 17 * misrepresented as being the original software.@n
Kojto 113:f141b2784e32 18 * 3. This notice may not be removed or altered from any source distribution.
Kojto 113:f141b2784e32 19 *
Kojto 113:f141b2784e32 20 * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
Kojto 113:f141b2784e32 21 * obligation to support this Software. Silicon Labs is providing the
Kojto 113:f141b2784e32 22 * Software "AS IS", with no express or implied warranties of any kind,
Kojto 113:f141b2784e32 23 * including, but not limited to, any implied warranties of merchantability
Kojto 113:f141b2784e32 24 * or fitness for any particular purpose or warranties against infringement
Kojto 113:f141b2784e32 25 * of any proprietary rights of a third party.
Kojto 113:f141b2784e32 26 *
Kojto 113:f141b2784e32 27 * Silicon Labs will not be liable for any consequential, incidental, or
Kojto 113:f141b2784e32 28 * special damages, or any other relief, or for any claim by any third party,
Kojto 113:f141b2784e32 29 * arising from your use of this Software.
Kojto 113:f141b2784e32 30 *
Kojto 113:f141b2784e32 31 ******************************************************************************/
Kojto 113:f141b2784e32 32
<> 128:9bcdf88f62b0 33 #ifndef EM_CRYOTIMER_H
<> 128:9bcdf88f62b0 34 #define EM_CRYOTIMER_H
Kojto 113:f141b2784e32 35
Kojto 113:f141b2784e32 36 #include <stdbool.h>
Kojto 113:f141b2784e32 37 #include "em_device.h"
Kojto 113:f141b2784e32 38 #include "em_bus.h"
Kojto 113:f141b2784e32 39
Kojto 113:f141b2784e32 40 #if defined(CRYOTIMER_PRESENT) && (CRYOTIMER_COUNT == 1)
Kojto 113:f141b2784e32 41
Kojto 113:f141b2784e32 42 #ifdef __cplusplus
Kojto 113:f141b2784e32 43 extern "C" {
Kojto 113:f141b2784e32 44 #endif
Kojto 113:f141b2784e32 45
Kojto 113:f141b2784e32 46 /***************************************************************************//**
<> 128:9bcdf88f62b0 47 * @addtogroup emlib
Kojto 113:f141b2784e32 48 * @{
Kojto 113:f141b2784e32 49 ******************************************************************************/
Kojto 113:f141b2784e32 50
Kojto 113:f141b2784e32 51 /***************************************************************************//**
Kojto 113:f141b2784e32 52 * @addtogroup CRYOTIMER
Kojto 113:f141b2784e32 53 * @brief Ultra Low Energy Timer/Counter (CRYOTIMER) Peripheral API
Kojto 113:f141b2784e32 54 *
Kojto 113:f141b2784e32 55 * @details
<> 128:9bcdf88f62b0 56 * The CRYOTIMER is a 32 bit counter which operates on a low frequency
<> 128:9bcdf88f62b0 57 * oscillator, and is capable of running in all Energy Modes. It can provide
<> 128:9bcdf88f62b0 58 * periodic wakeup events and PRS signals which can be used to wake up
<> 128:9bcdf88f62b0 59 * peripherals from any energy mode. The CRYOTIMER provides a very wide range
<> 128:9bcdf88f62b0 60 * of periods for the interrupts facilitating flexible ultra-low energy
<> 128:9bcdf88f62b0 61 * operation. Because of its simplicity, the CRYOTIMER is a lower energy
<> 128:9bcdf88f62b0 62 * solution for periodically waking up the MCU compared to the RTCC.
<> 128:9bcdf88f62b0 63 *
<> 128:9bcdf88f62b0 64 * To configure the CRYOTIMER you call the @ref CRYOTIMER_Init function.
<> 128:9bcdf88f62b0 65 * This function will configure the CRYOTIMER peripheral according to the
<> 128:9bcdf88f62b0 66 * user configuration.
<> 128:9bcdf88f62b0 67 *
<> 128:9bcdf88f62b0 68 * @details
<> 128:9bcdf88f62b0 69 * When using the CRYOTIMER the user has to choose which oscillator to use
<> 128:9bcdf88f62b0 70 * as the CRYOTIMER clock. The CRYOTIMER supports 3 low frequency clock
<> 128:9bcdf88f62b0 71 * these are LFXO, LFRCO and ULFRCO. The oscillator that is chosen must be
<> 128:9bcdf88f62b0 72 * enabled and ready before calling this @ref CRYOTIMER_Init function.
<> 128:9bcdf88f62b0 73 * See @ref CMU_OscillatorEnable for details of how to enable and wait for an
<> 128:9bcdf88f62b0 74 * oscillator to become ready. Note that ULFRCO is always ready while LFRCO
<> 128:9bcdf88f62b0 75 * @ref cmuOsc_LFRCO and LFXO @ref cmuOsc_LFXO must be enabled by the user.
Kojto 113:f141b2784e32 76 *
Kojto 113:f141b2784e32 77 * @details
Kojto 113:f141b2784e32 78 * Note that the only oscillator which is running in EM3 is ULFRCO. Keep this
Kojto 113:f141b2784e32 79 * in mind when choosing which oscillator to use for the CRYOTIMER.
Kojto 113:f141b2784e32 80 *
<> 128:9bcdf88f62b0 81 * Here is an example of how to use the CRYOTIMER to generate an interrupt
<> 128:9bcdf88f62b0 82 * at a configurable period.
<> 128:9bcdf88f62b0 83 *
<> 128:9bcdf88f62b0 84 * @include em_cryotimer_period.c
<> 128:9bcdf88f62b0 85 *
Kojto 113:f141b2784e32 86 * @details
<> 128:9bcdf88f62b0 87 * To use the CRYOTIMER in EM4 the user has to enable EM4 wakeup in the
<> 128:9bcdf88f62b0 88 * CRYOTIMER. This can be done either in the @ref CRYOTIMER_Init_TypeDef
<> 128:9bcdf88f62b0 89 * structure when initializing the CRYOTIMER or at a later time by using
<> 128:9bcdf88f62b0 90 * @ref CRYOTIMER_EM4WakeupEnable.
<> 128:9bcdf88f62b0 91 *
<> 128:9bcdf88f62b0 92 * Note that when using the CRYOTIMER to wakeup from EM4 the application has
<> 128:9bcdf88f62b0 93 * the responsibility to clear the wakeup event. This is done by calling
<> 128:9bcdf88f62b0 94 * @ref CRYOTIMER_IntClear. If the user does not clear the wakeup event then
<> 128:9bcdf88f62b0 95 * the wakeup event will stay pending and will cause an immediate wakeup the
<> 128:9bcdf88f62b0 96 * next time the application attempts to enter EM4.
<> 128:9bcdf88f62b0 97 *
<> 128:9bcdf88f62b0 98 * Here is an example of how to use the CRYOTIMER to wakeup from EM4 after
<> 128:9bcdf88f62b0 99 * a configurable amount of time.
<> 128:9bcdf88f62b0 100 *
<> 128:9bcdf88f62b0 101 * @include em_cryotimer_em4.c
<> 128:9bcdf88f62b0 102 *
<> 128:9bcdf88f62b0 103 * @details
<> 128:9bcdf88f62b0 104 * All the low frequency oscillators can be used in EM4, however the
Kojto 113:f141b2784e32 105 * oscillator that is used must be be configured to be retained when going
Kojto 113:f141b2784e32 106 * into EM4. This can be configured by using functions in the @ref EMU module.
Kojto 113:f141b2784e32 107 * See @ref EMU_EM4Init and @ref EMU_EM4Init_TypeDef. If an oscillator is
Kojto 113:f141b2784e32 108 * retained in EM4 the user is also responsible for unlatching the retained
Kojto 113:f141b2784e32 109 * configuration on a wakeup from EM4.
Kojto 113:f141b2784e32 110 *
Kojto 113:f141b2784e32 111 * @{
Kojto 113:f141b2784e32 112 ******************************************************************************/
Kojto 113:f141b2784e32 113
Kojto 113:f141b2784e32 114 /*******************************************************************************
Kojto 113:f141b2784e32 115 ********************************* ENUM ************************************
Kojto 113:f141b2784e32 116 ******************************************************************************/
Kojto 113:f141b2784e32 117
Kojto 113:f141b2784e32 118 /** Prescaler selection. */
Kojto 113:f141b2784e32 119 typedef enum
Kojto 113:f141b2784e32 120 {
Kojto 113:f141b2784e32 121 cryotimerPresc_1 = _CRYOTIMER_CTRL_PRESC_DIV1, /**< Divide clock by 1. */
Kojto 113:f141b2784e32 122 cryotimerPresc_2 = _CRYOTIMER_CTRL_PRESC_DIV2, /**< Divide clock by 2. */
Kojto 113:f141b2784e32 123 cryotimerPresc_4 = _CRYOTIMER_CTRL_PRESC_DIV4, /**< Divide clock by 4. */
Kojto 113:f141b2784e32 124 cryotimerPresc_8 = _CRYOTIMER_CTRL_PRESC_DIV8, /**< Divide clock by 8. */
Kojto 113:f141b2784e32 125 cryotimerPresc_16 = _CRYOTIMER_CTRL_PRESC_DIV16, /**< Divide clock by 16. */
Kojto 113:f141b2784e32 126 cryotimerPresc_32 = _CRYOTIMER_CTRL_PRESC_DIV32, /**< Divide clock by 32. */
Kojto 113:f141b2784e32 127 cryotimerPresc_64 = _CRYOTIMER_CTRL_PRESC_DIV64, /**< Divide clock by 64. */
Kojto 113:f141b2784e32 128 cryotimerPresc_128 = _CRYOTIMER_CTRL_PRESC_DIV128, /**< Divide clock by 128. */
Kojto 113:f141b2784e32 129 } CRYOTIMER_Presc_TypeDef;
Kojto 113:f141b2784e32 130
Kojto 113:f141b2784e32 131 /** Low frequency oscillator selection. */
<> 128:9bcdf88f62b0 132 typedef enum
Kojto 113:f141b2784e32 133 {
Kojto 113:f141b2784e32 134 cryotimerOscLFRCO = _CRYOTIMER_CTRL_OSCSEL_LFRCO, /**< Select Low Frequency RC Oscillator. */
Kojto 113:f141b2784e32 135 cryotimerOscLFXO = _CRYOTIMER_CTRL_OSCSEL_LFXO, /**< Select Low Frequency Crystal Oscillator. */
Kojto 113:f141b2784e32 136 cryotimerOscULFRCO = _CRYOTIMER_CTRL_OSCSEL_ULFRCO, /**< Select Ultra Low Frequency RC Oscillator. */
Kojto 113:f141b2784e32 137 } CRYOTIMER_Osc_TypeDef;
Kojto 113:f141b2784e32 138
Kojto 113:f141b2784e32 139 /** Period selection value */
Kojto 113:f141b2784e32 140 typedef enum
Kojto 113:f141b2784e32 141 {
Kojto 113:f141b2784e32 142 cryotimerPeriod_1 = 0, /**< Wakeup event after every Pre-scaled clock cycle. */
Kojto 113:f141b2784e32 143 cryotimerPeriod_2 = 1, /**< Wakeup event after 2 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 144 cryotimerPeriod_4 = 2, /**< Wakeup event after 4 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 145 cryotimerPeriod_8 = 3, /**< Wakeup event after 8 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 146 cryotimerPeriod_16 = 4, /**< Wakeup event after 16 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 147 cryotimerPeriod_32 = 5, /**< Wakeup event after 32 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 148 cryotimerPeriod_64 = 6, /**< Wakeup event after 64 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 149 cryotimerPeriod_128 = 7, /**< Wakeup event after 128 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 150 cryotimerPeriod_256 = 8, /**< Wakeup event after 256 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 151 cryotimerPeriod_512 = 9, /**< Wakeup event after 512 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 152 cryotimerPeriod_1k = 10, /**< Wakeup event after 1k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 153 cryotimerPeriod_2k = 11, /**< Wakeup event after 2k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 154 cryotimerPeriod_4k = 12, /**< Wakeup event after 4k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 155 cryotimerPeriod_8k = 13, /**< Wakeup event after 8k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 156 cryotimerPeriod_16k = 14, /**< Wakeup event after 16k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 157 cryotimerPeriod_32k = 15, /**< Wakeup event after 32k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 158 cryotimerPeriod_64k = 16, /**< Wakeup event after 64k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 159 cryotimerPeriod_128k = 17, /**< Wakeup event after 128k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 160 cryotimerPeriod_256k = 18, /**< Wakeup event after 256k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 161 cryotimerPeriod_512k = 19, /**< Wakeup event after 512k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 162 cryotimerPeriod_1m = 20, /**< Wakeup event after 1m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 163 cryotimerPeriod_2m = 21, /**< Wakeup event after 2m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 164 cryotimerPeriod_4m = 22, /**< Wakeup event after 4m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 165 cryotimerPeriod_8m = 23, /**< Wakeup event after 8m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 166 cryotimerPeriod_16m = 24, /**< Wakeup event after 16m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 167 cryotimerPeriod_32m = 25, /**< Wakeup event after 32m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 168 cryotimerPeriod_64m = 26, /**< Wakeup event after 64m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 169 cryotimerPeriod_128m = 27, /**< Wakeup event after 128m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 170 cryotimerPeriod_256m = 28, /**< Wakeup event after 256m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 171 cryotimerPeriod_512m = 29, /**< Wakeup event after 512m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 172 cryotimerPeriod_1024m = 30, /**< Wakeup event after 1024m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 173 cryotimerPeriod_2048m = 31, /**< Wakeup event after 2048m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 174 cryotimerPeriod_4096m = 32, /**< Wakeup event after 4096m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 175 } CRYOTIMER_Period_TypeDef;
Kojto 113:f141b2784e32 176
Kojto 113:f141b2784e32 177 /*******************************************************************************
Kojto 113:f141b2784e32 178 ******************************* STRUCTS ***********************************
Kojto 113:f141b2784e32 179 ******************************************************************************/
Kojto 113:f141b2784e32 180
Kojto 113:f141b2784e32 181 /** CRYOTIMER initialization structure. */
Kojto 113:f141b2784e32 182 typedef struct
Kojto 113:f141b2784e32 183 {
Kojto 113:f141b2784e32 184 /** Enable/disable counting when initialization is completed. */
Kojto 113:f141b2784e32 185 bool enable;
Kojto 113:f141b2784e32 186
Kojto 113:f141b2784e32 187 /** Enable/disable timer counting during debug halt. */
Kojto 113:f141b2784e32 188 bool debugRun;
Kojto 113:f141b2784e32 189
Kojto 113:f141b2784e32 190 /** Enable/disable EM4 Wakeup. */
Kojto 113:f141b2784e32 191 bool em4Wakeup;
Kojto 113:f141b2784e32 192
Kojto 113:f141b2784e32 193 /** Select the oscillator for the CRYOTIMER. */
Kojto 113:f141b2784e32 194 CRYOTIMER_Osc_TypeDef osc;
Kojto 113:f141b2784e32 195
Kojto 113:f141b2784e32 196 /** Prescaler. */
Kojto 113:f141b2784e32 197 CRYOTIMER_Presc_TypeDef presc;
Kojto 113:f141b2784e32 198
Kojto 113:f141b2784e32 199 /** Period between wakeup event/interrupt. */
Kojto 113:f141b2784e32 200 CRYOTIMER_Period_TypeDef period;
Kojto 113:f141b2784e32 201 } CRYOTIMER_Init_TypeDef;
Kojto 113:f141b2784e32 202
Kojto 113:f141b2784e32 203 /*******************************************************************************
Kojto 113:f141b2784e32 204 ******************************* DEFINES ***********************************
Kojto 113:f141b2784e32 205 ******************************************************************************/
Kojto 113:f141b2784e32 206
Kojto 113:f141b2784e32 207 /** Default CRYOTIMER init structure. */
Kojto 113:f141b2784e32 208 #define CRYOTIMER_INIT_DEFAULT \
Kojto 113:f141b2784e32 209 { \
Kojto 113:f141b2784e32 210 true, /* Start counting when init done. */ \
Kojto 113:f141b2784e32 211 false, /* Disable CRYOTIMER during debug halt. */ \
Kojto 113:f141b2784e32 212 false, /* Disable EM4 wakeup. */ \
Kojto 113:f141b2784e32 213 cryotimerOscLFRCO, /* Select Low Frequency RC Oscillator. */ \
Kojto 113:f141b2784e32 214 cryotimerPresc_1, /* LF Oscillator frequency undivided. */ \
Kojto 113:f141b2784e32 215 cryotimerPeriod_4096m, /* Wakeup event after 4096M pre-scaled clock cycles. */ \
Kojto 113:f141b2784e32 216 }
Kojto 113:f141b2784e32 217
Kojto 113:f141b2784e32 218 /*******************************************************************************
Kojto 113:f141b2784e32 219 ***************************** PROTOTYPES **********************************
Kojto 113:f141b2784e32 220 ******************************************************************************/
Kojto 113:f141b2784e32 221
Kojto 113:f141b2784e32 222 /***************************************************************************//**
Kojto 113:f141b2784e32 223 * @brief
Kojto 113:f141b2784e32 224 * Clear the CRYOTIMER period interrupt.
Kojto 113:f141b2784e32 225 *
Kojto 113:f141b2784e32 226 * @param[in] flags
<> 128:9bcdf88f62b0 227 * CRYOTIMER interrupt sources to clear. Use @ref CRYOTIMER_IFC_PERIOD
Kojto 113:f141b2784e32 228 ******************************************************************************/
Kojto 113:f141b2784e32 229 __STATIC_INLINE void CRYOTIMER_IntClear(uint32_t flags)
Kojto 113:f141b2784e32 230 {
Kojto 113:f141b2784e32 231 CRYOTIMER->IFC = flags & _CRYOTIMER_IFC_MASK;
Kojto 113:f141b2784e32 232 }
Kojto 113:f141b2784e32 233
Kojto 113:f141b2784e32 234 /***************************************************************************//**
Kojto 113:f141b2784e32 235 * @brief
Kojto 113:f141b2784e32 236 * Get the CRYOTIMER interrupt flag.
<> 128:9bcdf88f62b0 237 *
Kojto 113:f141b2784e32 238 * @note
Kojto 113:f141b2784e32 239 * The event bits are not cleared by the use of this function.
Kojto 113:f141b2784e32 240 *
Kojto 113:f141b2784e32 241 * @return
<> 128:9bcdf88f62b0 242 * Pending CRYOTIMER interrupt sources. The only interrupt source available
<> 128:9bcdf88f62b0 243 * for the CRYOTIMER is @ref CRYOTIMER_IF_PERIOD.
Kojto 113:f141b2784e32 244 ******************************************************************************/
Kojto 113:f141b2784e32 245 __STATIC_INLINE uint32_t CRYOTIMER_IntGet(void)
Kojto 113:f141b2784e32 246 {
Kojto 113:f141b2784e32 247 return CRYOTIMER->IF;
Kojto 113:f141b2784e32 248 }
Kojto 113:f141b2784e32 249
Kojto 113:f141b2784e32 250 /***************************************************************************//**
Kojto 113:f141b2784e32 251 * @brief
Kojto 113:f141b2784e32 252 * Get enabled and pending CRYOTIMER interrupt flags.
Kojto 113:f141b2784e32 253 * Useful for handling more interrupt sources in the same interrupt handler.
Kojto 113:f141b2784e32 254 *
Kojto 113:f141b2784e32 255 * @note
Kojto 113:f141b2784e32 256 * Interrupt flags are not cleared by the use of this function.
Kojto 113:f141b2784e32 257 *
Kojto 113:f141b2784e32 258 * @return
Kojto 113:f141b2784e32 259 * Pending and enabled CRYOTIMER interrupt sources
Kojto 113:f141b2784e32 260 * The return value is the bitwise AND of
Kojto 113:f141b2784e32 261 * - the enabled interrupt sources in CRYOTIMER_IEN and
Kojto 113:f141b2784e32 262 * - the pending interrupt flags CRYOTIMER_IF
Kojto 113:f141b2784e32 263 ******************************************************************************/
Kojto 113:f141b2784e32 264 __STATIC_INLINE uint32_t CRYOTIMER_IntGetEnabled(void)
Kojto 113:f141b2784e32 265 {
Kojto 113:f141b2784e32 266 uint32_t ien;
Kojto 113:f141b2784e32 267
Kojto 113:f141b2784e32 268 ien = CRYOTIMER->IEN & _CRYOTIMER_IEN_MASK;
Kojto 113:f141b2784e32 269 return CRYOTIMER->IF & ien;
Kojto 113:f141b2784e32 270 }
Kojto 113:f141b2784e32 271
Kojto 113:f141b2784e32 272 /***************************************************************************//**
Kojto 113:f141b2784e32 273 * @brief
Kojto 113:f141b2784e32 274 * Enable one or more CRYOTIMER interrupts.
Kojto 113:f141b2784e32 275 *
Kojto 113:f141b2784e32 276 * @param[in] flags
<> 128:9bcdf88f62b0 277 * CRYOTIMER interrupt sources to enable. Use @ref CRYOTIMER_IEN_PERIOD.
Kojto 113:f141b2784e32 278 ******************************************************************************/
Kojto 113:f141b2784e32 279 __STATIC_INLINE void CRYOTIMER_IntEnable(uint32_t flags)
Kojto 113:f141b2784e32 280 {
Kojto 113:f141b2784e32 281 CRYOTIMER->IEN |= (flags & _CRYOTIMER_IEN_MASK);
Kojto 113:f141b2784e32 282 }
Kojto 113:f141b2784e32 283
Kojto 113:f141b2784e32 284 /***************************************************************************//**
Kojto 113:f141b2784e32 285 * @brief
Kojto 113:f141b2784e32 286 * Disable one or more CRYOTIMER interrupts.
Kojto 113:f141b2784e32 287 *
Kojto 113:f141b2784e32 288 * @param[in] flags
<> 128:9bcdf88f62b0 289 * CRYOTIMER interrupt sources to disable. Use @ref CRYOTIMER_IEN_PERIOD.
Kojto 113:f141b2784e32 290 ******************************************************************************/
Kojto 113:f141b2784e32 291 __STATIC_INLINE void CRYOTIMER_IntDisable(uint32_t flags)
Kojto 113:f141b2784e32 292 {
Kojto 113:f141b2784e32 293 CRYOTIMER->IEN &= ~(flags & _CRYOTIMER_IEN_MASK);
Kojto 113:f141b2784e32 294 }
Kojto 113:f141b2784e32 295
Kojto 113:f141b2784e32 296 /***************************************************************************//**
Kojto 113:f141b2784e32 297 * @brief
Kojto 113:f141b2784e32 298 * Set the CRYOTIMER period interrupt flag.
Kojto 113:f141b2784e32 299 *
Kojto 113:f141b2784e32 300 * @note
Kojto 113:f141b2784e32 301 * Writes 1 to the interrupt flag set register.
Kojto 113:f141b2784e32 302 *
Kojto 113:f141b2784e32 303 * @param[in] flags
<> 128:9bcdf88f62b0 304 * CRYOTIMER interrupt sources to set to pending. Use
<> 128:9bcdf88f62b0 305 * @ref CRYOTIMER_IFS_PERIOD.
Kojto 113:f141b2784e32 306 ******************************************************************************/
Kojto 113:f141b2784e32 307 __STATIC_INLINE void CRYOTIMER_IntSet(uint32_t flags)
Kojto 113:f141b2784e32 308 {
Kojto 113:f141b2784e32 309 CRYOTIMER->IFS = flags & _CRYOTIMER_IFS_MASK;
Kojto 113:f141b2784e32 310 }
Kojto 113:f141b2784e32 311
Kojto 113:f141b2784e32 312 /***************************************************************************//**
Kojto 113:f141b2784e32 313 * @brief
Kojto 113:f141b2784e32 314 * Set the CRYOTIMER period select
Kojto 113:f141b2784e32 315 *
Kojto 113:f141b2784e32 316 * @note
<> 128:9bcdf88f62b0 317 * Sets the duration between the Interrupts/Wakeup events based on
Kojto 113:f141b2784e32 318 * the pre-scaled clock.
Kojto 113:f141b2784e32 319 *
Kojto 113:f141b2784e32 320 * @param[in] period
<> 128:9bcdf88f62b0 321 * 2^period is the number of clock cycles before a wakeup event or
<> 128:9bcdf88f62b0 322 * interrupt is triggered. The CRYOTIMER_Periodsel_TypeDef enum can
Kojto 113:f141b2784e32 323 * be used a convenience type when calling this function.
Kojto 113:f141b2784e32 324 ******************************************************************************/
Kojto 113:f141b2784e32 325 __STATIC_INLINE void CRYOTIMER_PeriodSet(uint32_t period)
Kojto 113:f141b2784e32 326 {
Kojto 113:f141b2784e32 327 CRYOTIMER->PERIODSEL = period & _CRYOTIMER_PERIODSEL_MASK;
Kojto 113:f141b2784e32 328 }
Kojto 113:f141b2784e32 329
Kojto 113:f141b2784e32 330 /***************************************************************************//**
Kojto 113:f141b2784e32 331 * @brief
Kojto 113:f141b2784e32 332 * Get the CRYOTIMER period select value
Kojto 113:f141b2784e32 333 *
Kojto 113:f141b2784e32 334 * @note
<> 128:9bcdf88f62b0 335 * Gets the duration between the Interrupts/Wakeup events in the
Kojto 113:f141b2784e32 336 * CRYOTIMER.
Kojto 113:f141b2784e32 337 *
Kojto 113:f141b2784e32 338 * @return
Kojto 113:f141b2784e32 339 * Duration between the interrupts/wakeup events. Returns the value
Kojto 113:f141b2784e32 340 * of the PERIODSEL register. The number of clock cycles can be calculated
Kojto 113:f141b2784e32 341 * as the 2^n where n is the return value of this function.
Kojto 113:f141b2784e32 342 ******************************************************************************/
Kojto 113:f141b2784e32 343 __STATIC_INLINE uint32_t CRYOTIMER_PeriodGet(void)
Kojto 113:f141b2784e32 344 {
Kojto 113:f141b2784e32 345 return CRYOTIMER->PERIODSEL;
Kojto 113:f141b2784e32 346 }
Kojto 113:f141b2784e32 347
Kojto 113:f141b2784e32 348 /***************************************************************************//**
Kojto 113:f141b2784e32 349 * @brief
Kojto 113:f141b2784e32 350 * Get the CRYOTIMER counter value
Kojto 113:f141b2784e32 351 *
Kojto 113:f141b2784e32 352 * @return
Kojto 113:f141b2784e32 353 * Returns the current CRYOTIMER counter value.
Kojto 113:f141b2784e32 354 ******************************************************************************/
Kojto 113:f141b2784e32 355 __STATIC_INLINE uint32_t CRYOTIMER_CounterGet(void)
Kojto 113:f141b2784e32 356 {
Kojto 113:f141b2784e32 357 return CRYOTIMER->CNT;
Kojto 113:f141b2784e32 358 }
Kojto 113:f141b2784e32 359
Kojto 113:f141b2784e32 360 /***************************************************************************//**
Kojto 113:f141b2784e32 361 * @brief
Kojto 113:f141b2784e32 362 * Enable/disable EM4 wakeup capability.
Kojto 113:f141b2784e32 363 *
Kojto 113:f141b2784e32 364 * @param[in] enable
Kojto 113:f141b2784e32 365 * True to enable EM4 wakeup, false to disable.
Kojto 113:f141b2784e32 366 ******************************************************************************/
Kojto 113:f141b2784e32 367 __STATIC_INLINE void CRYOTIMER_EM4WakeupEnable(bool enable)
Kojto 113:f141b2784e32 368 {
Kojto 113:f141b2784e32 369 BUS_RegBitWrite((&CRYOTIMER->EM4WUEN), _CRYOTIMER_EM4WUEN_EM4WU_SHIFT, enable);
Kojto 113:f141b2784e32 370 }
Kojto 113:f141b2784e32 371
Kojto 113:f141b2784e32 372 /***************************************************************************//**
Kojto 113:f141b2784e32 373 * @brief
Kojto 113:f141b2784e32 374 * Enable/disable the CRYOTIMER.
Kojto 113:f141b2784e32 375 *
Kojto 113:f141b2784e32 376 * @param[in] enable
Kojto 113:f141b2784e32 377 * True to enable the CRYOTIMER, false to disable.
Kojto 113:f141b2784e32 378 ******************************************************************************/
Kojto 113:f141b2784e32 379 __STATIC_INLINE void CRYOTIMER_Enable(bool enable)
Kojto 113:f141b2784e32 380 {
Kojto 113:f141b2784e32 381 BUS_RegBitWrite((&CRYOTIMER->CTRL), _CRYOTIMER_CTRL_EN_SHIFT, enable);
Kojto 113:f141b2784e32 382 }
Kojto 113:f141b2784e32 383
Kojto 113:f141b2784e32 384 void CRYOTIMER_Init(const CRYOTIMER_Init_TypeDef *init);
Kojto 113:f141b2784e32 385
Kojto 113:f141b2784e32 386 #ifdef __cplusplus
Kojto 113:f141b2784e32 387 }
Kojto 113:f141b2784e32 388 #endif
Kojto 113:f141b2784e32 389
Kojto 113:f141b2784e32 390 /** @} (end addtogroup CRYOTIMER) */
<> 128:9bcdf88f62b0 391 /** @} (end addtogroup emlib) */
Kojto 113:f141b2784e32 392
Kojto 113:f141b2784e32 393 #endif /* defined(CRYOTIMER_PRESENT) && (CRYOTIMER_COUNT == 1) */
<> 128:9bcdf88f62b0 394 #endif /* EM_CRYOTIMER_H */