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:
Tue Feb 02 14:43:35 2016 +0000
Revision:
113:f141b2784e32
Child:
128:9bcdf88f62b0
Release 113 of the mbed library

Changes:
- new targets - Silabs Perl Gecko, TY51822
- Silabs - emlib update to 4.1.0, various bugfixes as result
- STM B96B_F446VE - add async serial support
- Freescale KLXX - rtc lock fix
- LPC11U68 and LPC1549 - pwm bugfixes - duty cycle

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
Kojto 113:f141b2784e32 4 * @version 4.2.1
Kojto 113:f141b2784e32 5 *******************************************************************************
Kojto 113:f141b2784e32 6 * @section License
Kojto 113:f141b2784e32 7 * <b>(C) Copyright 2015 Silicon Labs, 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
Kojto 113:f141b2784e32 33 #ifndef EM_CRYOTIMER_H__
Kojto 113:f141b2784e32 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 /***************************************************************************//**
Kojto 113:f141b2784e32 47 * @addtogroup EM_Library
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
Kojto 113:f141b2784e32 56 * The user is responsible for choosing which oscillator to use for the
Kojto 113:f141b2784e32 57 * CRYOTIMER. The oscillator that is choosen must be enabled and ready before
Kojto 113:f141b2784e32 58 * calling this @ref CRYOTIMER_Init function. See @ref CMU_OscillatorEnable
Kojto 113:f141b2784e32 59 * for details of how to enable and wait for an oscillator to become ready.
Kojto 113:f141b2784e32 60 * Note that ULFRCO is always ready while LFRCO and LFXO must be enable by
Kojto 113:f141b2784e32 61 * the user.
Kojto 113:f141b2784e32 62 *
Kojto 113:f141b2784e32 63 * @details
Kojto 113:f141b2784e32 64 * Note that the only oscillator which is running in EM3 is ULFRCO. Keep this
Kojto 113:f141b2784e32 65 * in mind when choosing which oscillator to use for the CRYOTIMER.
Kojto 113:f141b2784e32 66 *
Kojto 113:f141b2784e32 67 * @details
Kojto 113:f141b2784e32 68 * Special care must be taken if the user wants the CRYOTIMER to run during
Kojto 113:f141b2784e32 69 * EM4. All the low frequency oscillators can be used in EM4, however the
Kojto 113:f141b2784e32 70 * oscillator that is used must be be configured to be retained when going
Kojto 113:f141b2784e32 71 * into EM4. This can be configured by using functions in the @ref EMU module.
Kojto 113:f141b2784e32 72 * See @ref EMU_EM4Init and @ref EMU_EM4Init_TypeDef. If an oscillator is
Kojto 113:f141b2784e32 73 * retained in EM4 the user is also responsible for unlatching the retained
Kojto 113:f141b2784e32 74 * configuration on a wakeup from EM4.
Kojto 113:f141b2784e32 75 *
Kojto 113:f141b2784e32 76 * @{
Kojto 113:f141b2784e32 77 ******************************************************************************/
Kojto 113:f141b2784e32 78
Kojto 113:f141b2784e32 79 /*******************************************************************************
Kojto 113:f141b2784e32 80 ********************************* ENUM ************************************
Kojto 113:f141b2784e32 81 ******************************************************************************/
Kojto 113:f141b2784e32 82
Kojto 113:f141b2784e32 83 /** Prescaler selection. */
Kojto 113:f141b2784e32 84 typedef enum
Kojto 113:f141b2784e32 85 {
Kojto 113:f141b2784e32 86 cryotimerPresc_1 = _CRYOTIMER_CTRL_PRESC_DIV1, /**< Divide clock by 1. */
Kojto 113:f141b2784e32 87 cryotimerPresc_2 = _CRYOTIMER_CTRL_PRESC_DIV2, /**< Divide clock by 2. */
Kojto 113:f141b2784e32 88 cryotimerPresc_4 = _CRYOTIMER_CTRL_PRESC_DIV4, /**< Divide clock by 4. */
Kojto 113:f141b2784e32 89 cryotimerPresc_8 = _CRYOTIMER_CTRL_PRESC_DIV8, /**< Divide clock by 8. */
Kojto 113:f141b2784e32 90 cryotimerPresc_16 = _CRYOTIMER_CTRL_PRESC_DIV16, /**< Divide clock by 16. */
Kojto 113:f141b2784e32 91 cryotimerPresc_32 = _CRYOTIMER_CTRL_PRESC_DIV32, /**< Divide clock by 32. */
Kojto 113:f141b2784e32 92 cryotimerPresc_64 = _CRYOTIMER_CTRL_PRESC_DIV64, /**< Divide clock by 64. */
Kojto 113:f141b2784e32 93 cryotimerPresc_128 = _CRYOTIMER_CTRL_PRESC_DIV128, /**< Divide clock by 128. */
Kojto 113:f141b2784e32 94 } CRYOTIMER_Presc_TypeDef;
Kojto 113:f141b2784e32 95
Kojto 113:f141b2784e32 96 /** Low frequency oscillator selection. */
Kojto 113:f141b2784e32 97 typedef enum
Kojto 113:f141b2784e32 98 {
Kojto 113:f141b2784e32 99 cryotimerOscLFRCO = _CRYOTIMER_CTRL_OSCSEL_LFRCO, /**< Select Low Frequency RC Oscillator. */
Kojto 113:f141b2784e32 100 cryotimerOscLFXO = _CRYOTIMER_CTRL_OSCSEL_LFXO, /**< Select Low Frequency Crystal Oscillator. */
Kojto 113:f141b2784e32 101 cryotimerOscULFRCO = _CRYOTIMER_CTRL_OSCSEL_ULFRCO, /**< Select Ultra Low Frequency RC Oscillator. */
Kojto 113:f141b2784e32 102 } CRYOTIMER_Osc_TypeDef;
Kojto 113:f141b2784e32 103
Kojto 113:f141b2784e32 104 /** Period selection value */
Kojto 113:f141b2784e32 105 typedef enum
Kojto 113:f141b2784e32 106 {
Kojto 113:f141b2784e32 107 cryotimerPeriod_1 = 0, /**< Wakeup event after every Pre-scaled clock cycle. */
Kojto 113:f141b2784e32 108 cryotimerPeriod_2 = 1, /**< Wakeup event after 2 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 109 cryotimerPeriod_4 = 2, /**< Wakeup event after 4 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 110 cryotimerPeriod_8 = 3, /**< Wakeup event after 8 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 111 cryotimerPeriod_16 = 4, /**< Wakeup event after 16 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 112 cryotimerPeriod_32 = 5, /**< Wakeup event after 32 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 113 cryotimerPeriod_64 = 6, /**< Wakeup event after 64 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 114 cryotimerPeriod_128 = 7, /**< Wakeup event after 128 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 115 cryotimerPeriod_256 = 8, /**< Wakeup event after 256 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 116 cryotimerPeriod_512 = 9, /**< Wakeup event after 512 Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 117 cryotimerPeriod_1k = 10, /**< Wakeup event after 1k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 118 cryotimerPeriod_2k = 11, /**< Wakeup event after 2k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 119 cryotimerPeriod_4k = 12, /**< Wakeup event after 4k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 120 cryotimerPeriod_8k = 13, /**< Wakeup event after 8k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 121 cryotimerPeriod_16k = 14, /**< Wakeup event after 16k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 122 cryotimerPeriod_32k = 15, /**< Wakeup event after 32k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 123 cryotimerPeriod_64k = 16, /**< Wakeup event after 64k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 124 cryotimerPeriod_128k = 17, /**< Wakeup event after 128k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 125 cryotimerPeriod_256k = 18, /**< Wakeup event after 256k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 126 cryotimerPeriod_512k = 19, /**< Wakeup event after 512k Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 127 cryotimerPeriod_1m = 20, /**< Wakeup event after 1m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 128 cryotimerPeriod_2m = 21, /**< Wakeup event after 2m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 129 cryotimerPeriod_4m = 22, /**< Wakeup event after 4m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 130 cryotimerPeriod_8m = 23, /**< Wakeup event after 8m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 131 cryotimerPeriod_16m = 24, /**< Wakeup event after 16m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 132 cryotimerPeriod_32m = 25, /**< Wakeup event after 32m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 133 cryotimerPeriod_64m = 26, /**< Wakeup event after 64m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 134 cryotimerPeriod_128m = 27, /**< Wakeup event after 128m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 135 cryotimerPeriod_256m = 28, /**< Wakeup event after 256m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 136 cryotimerPeriod_512m = 29, /**< Wakeup event after 512m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 137 cryotimerPeriod_1024m = 30, /**< Wakeup event after 1024m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 138 cryotimerPeriod_2048m = 31, /**< Wakeup event after 2048m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 139 cryotimerPeriod_4096m = 32, /**< Wakeup event after 4096m Pre-scaled clock cycles. */
Kojto 113:f141b2784e32 140 } CRYOTIMER_Period_TypeDef;
Kojto 113:f141b2784e32 141
Kojto 113:f141b2784e32 142 /*******************************************************************************
Kojto 113:f141b2784e32 143 ******************************* STRUCTS ***********************************
Kojto 113:f141b2784e32 144 ******************************************************************************/
Kojto 113:f141b2784e32 145
Kojto 113:f141b2784e32 146 /** CRYOTIMER initialization structure. */
Kojto 113:f141b2784e32 147 typedef struct
Kojto 113:f141b2784e32 148 {
Kojto 113:f141b2784e32 149 /** Enable/disable counting when initialization is completed. */
Kojto 113:f141b2784e32 150 bool enable;
Kojto 113:f141b2784e32 151
Kojto 113:f141b2784e32 152 /** Enable/disable timer counting during debug halt. */
Kojto 113:f141b2784e32 153 bool debugRun;
Kojto 113:f141b2784e32 154
Kojto 113:f141b2784e32 155 /** Enable/disable EM4 Wakeup. */
Kojto 113:f141b2784e32 156 bool em4Wakeup;
Kojto 113:f141b2784e32 157
Kojto 113:f141b2784e32 158 /** Select the oscillator for the CRYOTIMER. */
Kojto 113:f141b2784e32 159 CRYOTIMER_Osc_TypeDef osc;
Kojto 113:f141b2784e32 160
Kojto 113:f141b2784e32 161 /** Prescaler. */
Kojto 113:f141b2784e32 162 CRYOTIMER_Presc_TypeDef presc;
Kojto 113:f141b2784e32 163
Kojto 113:f141b2784e32 164 /** Period between wakeup event/interrupt. */
Kojto 113:f141b2784e32 165 CRYOTIMER_Period_TypeDef period;
Kojto 113:f141b2784e32 166 } CRYOTIMER_Init_TypeDef;
Kojto 113:f141b2784e32 167
Kojto 113:f141b2784e32 168 /*******************************************************************************
Kojto 113:f141b2784e32 169 ******************************* DEFINES ***********************************
Kojto 113:f141b2784e32 170 ******************************************************************************/
Kojto 113:f141b2784e32 171
Kojto 113:f141b2784e32 172 /** Default CRYOTIMER init structure. */
Kojto 113:f141b2784e32 173 #define CRYOTIMER_INIT_DEFAULT \
Kojto 113:f141b2784e32 174 { \
Kojto 113:f141b2784e32 175 true, /* Start counting when init done. */ \
Kojto 113:f141b2784e32 176 false, /* Disable CRYOTIMER during debug halt. */ \
Kojto 113:f141b2784e32 177 false, /* Disable EM4 wakeup. */ \
Kojto 113:f141b2784e32 178 cryotimerOscLFRCO, /* Select Low Frequency RC Oscillator. */ \
Kojto 113:f141b2784e32 179 cryotimerPresc_1, /* LF Oscillator frequency undivided. */ \
Kojto 113:f141b2784e32 180 cryotimerPeriod_4096m, /* Wakeup event after 4096M pre-scaled clock cycles. */ \
Kojto 113:f141b2784e32 181 }
Kojto 113:f141b2784e32 182
Kojto 113:f141b2784e32 183 /*******************************************************************************
Kojto 113:f141b2784e32 184 ***************************** PROTOTYPES **********************************
Kojto 113:f141b2784e32 185 ******************************************************************************/
Kojto 113:f141b2784e32 186
Kojto 113:f141b2784e32 187 /***************************************************************************//**
Kojto 113:f141b2784e32 188 * @brief
Kojto 113:f141b2784e32 189 * Clear the CRYOTIMER period interrupt.
Kojto 113:f141b2784e32 190 *
Kojto 113:f141b2784e32 191 * @param[in] flags
Kojto 113:f141b2784e32 192 * CRYOTIMER interrupt sources to clear. Use CRYOTIMER_IFC_PERIOD
Kojto 113:f141b2784e32 193 ******************************************************************************/
Kojto 113:f141b2784e32 194 __STATIC_INLINE void CRYOTIMER_IntClear(uint32_t flags)
Kojto 113:f141b2784e32 195 {
Kojto 113:f141b2784e32 196 CRYOTIMER->IFC = flags & _CRYOTIMER_IFC_MASK;
Kojto 113:f141b2784e32 197 }
Kojto 113:f141b2784e32 198
Kojto 113:f141b2784e32 199 /***************************************************************************//**
Kojto 113:f141b2784e32 200 * @brief
Kojto 113:f141b2784e32 201 * Get the CRYOTIMER interrupt flag.
Kojto 113:f141b2784e32 202 *
Kojto 113:f141b2784e32 203 * @note
Kojto 113:f141b2784e32 204 * The event bits are not cleared by the use of this function.
Kojto 113:f141b2784e32 205 *
Kojto 113:f141b2784e32 206 * @return
Kojto 113:f141b2784e32 207 * Pending CRYOTIMER interrupt sources.
Kojto 113:f141b2784e32 208 ******************************************************************************/
Kojto 113:f141b2784e32 209 __STATIC_INLINE uint32_t CRYOTIMER_IntGet(void)
Kojto 113:f141b2784e32 210 {
Kojto 113:f141b2784e32 211 return CRYOTIMER->IF;
Kojto 113:f141b2784e32 212 }
Kojto 113:f141b2784e32 213
Kojto 113:f141b2784e32 214 /***************************************************************************//**
Kojto 113:f141b2784e32 215 * @brief
Kojto 113:f141b2784e32 216 * Get enabled and pending CRYOTIMER interrupt flags.
Kojto 113:f141b2784e32 217 * Useful for handling more interrupt sources in the same interrupt handler.
Kojto 113:f141b2784e32 218 *
Kojto 113:f141b2784e32 219 * @note
Kojto 113:f141b2784e32 220 * Interrupt flags are not cleared by the use of this function.
Kojto 113:f141b2784e32 221 *
Kojto 113:f141b2784e32 222 * @return
Kojto 113:f141b2784e32 223 * Pending and enabled CRYOTIMER interrupt sources
Kojto 113:f141b2784e32 224 * The return value is the bitwise AND of
Kojto 113:f141b2784e32 225 * - the enabled interrupt sources in CRYOTIMER_IEN and
Kojto 113:f141b2784e32 226 * - the pending interrupt flags CRYOTIMER_IF
Kojto 113:f141b2784e32 227 ******************************************************************************/
Kojto 113:f141b2784e32 228 __STATIC_INLINE uint32_t CRYOTIMER_IntGetEnabled(void)
Kojto 113:f141b2784e32 229 {
Kojto 113:f141b2784e32 230 uint32_t ien;
Kojto 113:f141b2784e32 231
Kojto 113:f141b2784e32 232 ien = CRYOTIMER->IEN & _CRYOTIMER_IEN_MASK;
Kojto 113:f141b2784e32 233 return CRYOTIMER->IF & ien;
Kojto 113:f141b2784e32 234 }
Kojto 113:f141b2784e32 235
Kojto 113:f141b2784e32 236 /***************************************************************************//**
Kojto 113:f141b2784e32 237 * @brief
Kojto 113:f141b2784e32 238 * Enable one or more CRYOTIMER interrupts.
Kojto 113:f141b2784e32 239 *
Kojto 113:f141b2784e32 240 * @param[in] flags
Kojto 113:f141b2784e32 241 * CRYOTIMER interrupt sources to enable. Use CRYOTIMER_IEN_PERIOD.
Kojto 113:f141b2784e32 242 ******************************************************************************/
Kojto 113:f141b2784e32 243 __STATIC_INLINE void CRYOTIMER_IntEnable(uint32_t flags)
Kojto 113:f141b2784e32 244 {
Kojto 113:f141b2784e32 245 CRYOTIMER->IEN |= (flags & _CRYOTIMER_IEN_MASK);
Kojto 113:f141b2784e32 246 }
Kojto 113:f141b2784e32 247
Kojto 113:f141b2784e32 248 /***************************************************************************//**
Kojto 113:f141b2784e32 249 * @brief
Kojto 113:f141b2784e32 250 * Disable one or more CRYOTIMER interrupts.
Kojto 113:f141b2784e32 251 *
Kojto 113:f141b2784e32 252 * @param[in] flags
Kojto 113:f141b2784e32 253 * CRYOTIMER interrupt sources to disable. Use CRYOTIMER_IEN_PERIOD.
Kojto 113:f141b2784e32 254 ******************************************************************************/
Kojto 113:f141b2784e32 255 __STATIC_INLINE void CRYOTIMER_IntDisable(uint32_t flags)
Kojto 113:f141b2784e32 256 {
Kojto 113:f141b2784e32 257 CRYOTIMER->IEN &= ~(flags & _CRYOTIMER_IEN_MASK);
Kojto 113:f141b2784e32 258 }
Kojto 113:f141b2784e32 259
Kojto 113:f141b2784e32 260 /***************************************************************************//**
Kojto 113:f141b2784e32 261 * @brief
Kojto 113:f141b2784e32 262 * Set the CRYOTIMER period interrupt flag.
Kojto 113:f141b2784e32 263 *
Kojto 113:f141b2784e32 264 * @note
Kojto 113:f141b2784e32 265 * Writes 1 to the interrupt flag set register.
Kojto 113:f141b2784e32 266 *
Kojto 113:f141b2784e32 267 * @param[in] flags
Kojto 113:f141b2784e32 268 * CRYOTIMER interrupt sources to set to pending. Use CRYOTIMER_IFS_PERIOD.
Kojto 113:f141b2784e32 269 ******************************************************************************/
Kojto 113:f141b2784e32 270 __STATIC_INLINE void CRYOTIMER_IntSet(uint32_t flags)
Kojto 113:f141b2784e32 271 {
Kojto 113:f141b2784e32 272 CRYOTIMER->IFS = flags & _CRYOTIMER_IFS_MASK;
Kojto 113:f141b2784e32 273 }
Kojto 113:f141b2784e32 274
Kojto 113:f141b2784e32 275 /***************************************************************************//**
Kojto 113:f141b2784e32 276 * @brief
Kojto 113:f141b2784e32 277 * Set the CRYOTIMER period select
Kojto 113:f141b2784e32 278 *
Kojto 113:f141b2784e32 279 * @note
Kojto 113:f141b2784e32 280 * Sets the duration between the Interrupts/Wakeup events based on
Kojto 113:f141b2784e32 281 * the pre-scaled clock.
Kojto 113:f141b2784e32 282 *
Kojto 113:f141b2784e32 283 * @param[in] period
Kojto 113:f141b2784e32 284 * 2^period is the number of clock cycles before a wakeup event or
Kojto 113:f141b2784e32 285 * interrupt is triggered. The CRYOTIMER_Periodsel_TypeDef enum can
Kojto 113:f141b2784e32 286 * be used a convenience type when calling this function.
Kojto 113:f141b2784e32 287 ******************************************************************************/
Kojto 113:f141b2784e32 288 __STATIC_INLINE void CRYOTIMER_PeriodSet(uint32_t period)
Kojto 113:f141b2784e32 289 {
Kojto 113:f141b2784e32 290 CRYOTIMER->PERIODSEL = period & _CRYOTIMER_PERIODSEL_MASK;
Kojto 113:f141b2784e32 291 }
Kojto 113:f141b2784e32 292
Kojto 113:f141b2784e32 293 /***************************************************************************//**
Kojto 113:f141b2784e32 294 * @brief
Kojto 113:f141b2784e32 295 * Get the CRYOTIMER period select value
Kojto 113:f141b2784e32 296 *
Kojto 113:f141b2784e32 297 * @note
Kojto 113:f141b2784e32 298 * Gets the duration between the Interrupts/Wakeup events in the
Kojto 113:f141b2784e32 299 * CRYOTIMER.
Kojto 113:f141b2784e32 300 *
Kojto 113:f141b2784e32 301 * @return
Kojto 113:f141b2784e32 302 * Duration between the interrupts/wakeup events. Returns the value
Kojto 113:f141b2784e32 303 * of the PERIODSEL register. The number of clock cycles can be calculated
Kojto 113:f141b2784e32 304 * as the 2^n where n is the return value of this function.
Kojto 113:f141b2784e32 305 ******************************************************************************/
Kojto 113:f141b2784e32 306 __STATIC_INLINE uint32_t CRYOTIMER_PeriodGet(void)
Kojto 113:f141b2784e32 307 {
Kojto 113:f141b2784e32 308 return CRYOTIMER->PERIODSEL;
Kojto 113:f141b2784e32 309 }
Kojto 113:f141b2784e32 310
Kojto 113:f141b2784e32 311 /***************************************************************************//**
Kojto 113:f141b2784e32 312 * @brief
Kojto 113:f141b2784e32 313 * Get the CRYOTIMER counter value
Kojto 113:f141b2784e32 314 *
Kojto 113:f141b2784e32 315 * @return
Kojto 113:f141b2784e32 316 * Returns the current CRYOTIMER counter value.
Kojto 113:f141b2784e32 317 ******************************************************************************/
Kojto 113:f141b2784e32 318 __STATIC_INLINE uint32_t CRYOTIMER_CounterGet(void)
Kojto 113:f141b2784e32 319 {
Kojto 113:f141b2784e32 320 return CRYOTIMER->CNT;
Kojto 113:f141b2784e32 321 }
Kojto 113:f141b2784e32 322
Kojto 113:f141b2784e32 323 /***************************************************************************//**
Kojto 113:f141b2784e32 324 * @brief
Kojto 113:f141b2784e32 325 * Enable/disable EM4 wakeup capability.
Kojto 113:f141b2784e32 326 *
Kojto 113:f141b2784e32 327 * @param[in] enable
Kojto 113:f141b2784e32 328 * True to enable EM4 wakeup, false to disable.
Kojto 113:f141b2784e32 329 ******************************************************************************/
Kojto 113:f141b2784e32 330 __STATIC_INLINE void CRYOTIMER_EM4WakeupEnable(bool enable)
Kojto 113:f141b2784e32 331 {
Kojto 113:f141b2784e32 332 BUS_RegBitWrite((&CRYOTIMER->EM4WUEN), _CRYOTIMER_EM4WUEN_EM4WU_SHIFT, enable);
Kojto 113:f141b2784e32 333 }
Kojto 113:f141b2784e32 334
Kojto 113:f141b2784e32 335 /***************************************************************************//**
Kojto 113:f141b2784e32 336 * @brief
Kojto 113:f141b2784e32 337 * Enable/disable the CRYOTIMER.
Kojto 113:f141b2784e32 338 *
Kojto 113:f141b2784e32 339 * @param[in] enable
Kojto 113:f141b2784e32 340 * True to enable the CRYOTIMER, false to disable.
Kojto 113:f141b2784e32 341 ******************************************************************************/
Kojto 113:f141b2784e32 342 __STATIC_INLINE void CRYOTIMER_Enable(bool enable)
Kojto 113:f141b2784e32 343 {
Kojto 113:f141b2784e32 344 BUS_RegBitWrite((&CRYOTIMER->CTRL), _CRYOTIMER_CTRL_EN_SHIFT, enable);
Kojto 113:f141b2784e32 345 }
Kojto 113:f141b2784e32 346
Kojto 113:f141b2784e32 347 void CRYOTIMER_Init(const CRYOTIMER_Init_TypeDef *init);
Kojto 113:f141b2784e32 348
Kojto 113:f141b2784e32 349 #ifdef __cplusplus
Kojto 113:f141b2784e32 350 }
Kojto 113:f141b2784e32 351 #endif
Kojto 113:f141b2784e32 352
Kojto 113:f141b2784e32 353 /** @} (end addtogroup CRYOTIMER) */
Kojto 113:f141b2784e32 354 /** @} (end addtogroup EM_Library) */
Kojto 113:f141b2784e32 355
Kojto 113:f141b2784e32 356 #endif /* defined(CRYOTIMER_PRESENT) && (CRYOTIMER_COUNT == 1) */
Kojto 113:f141b2784e32 357 #endif /* EM_CRYOTIMER_H__ */