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_cmu.h
Kojto 98:8ab26030e058 3 * @brief Clock management unit (CMU) 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_CMU_H_
Kojto 98:8ab26030e058 35 #define __SILICON_LABS_EM_CMU_H_
Kojto 98:8ab26030e058 36
Kojto 98:8ab26030e058 37 #include "em_device.h"
Kojto 98:8ab26030e058 38 #if defined( CMU_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 CMU
Kojto 98:8ab26030e058 54 * @{
Kojto 98:8ab26030e058 55 ******************************************************************************/
Kojto 98:8ab26030e058 56
Kojto 98:8ab26030e058 57 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
Kojto 98:8ab26030e058 58
Kojto 98:8ab26030e058 59 /* Select register ids, for internal use */
Kojto 98:8ab26030e058 60 #define CMU_NOSEL_REG 0
Kojto 98:8ab26030e058 61 #define CMU_HFCLKSEL_REG 1
Kojto 98:8ab26030e058 62 #define CMU_LFACLKSEL_REG 2
Kojto 98:8ab26030e058 63 #define CMU_LFBCLKSEL_REG 3
Kojto 98:8ab26030e058 64 #define CMU_DBGCLKSEL_REG 4
Kojto 98:8ab26030e058 65 #if defined( _CMU_CMD_USBCCLKSEL_MASK )
Kojto 98:8ab26030e058 66 #define CMU_USBCCLKSEL_REG 5
Kojto 98:8ab26030e058 67 #endif
Kojto 98:8ab26030e058 68 #if defined( _CMU_LFCLKSEL_LFC_MASK )
Kojto 98:8ab26030e058 69 #define CMU_LFCCLKSEL_REG 6
Kojto 98:8ab26030e058 70 #endif
Kojto 98:8ab26030e058 71
Kojto 98:8ab26030e058 72 #define CMU_SEL_REG_POS 0
Kojto 98:8ab26030e058 73 #define CMU_SEL_REG_MASK 0xf
Kojto 98:8ab26030e058 74
Kojto 98:8ab26030e058 75 /* Divisor register ids, for internal use */
Kojto 98:8ab26030e058 76 #define CMU_NODIV_REG 0
Kojto 98:8ab26030e058 77 #define CMU_HFPERCLKDIV_REG 1
Kojto 98:8ab26030e058 78 #define CMU_HFCORECLKDIV_REG 2
Kojto 98:8ab26030e058 79 #define CMU_LFAPRESC0_REG 3
Kojto 98:8ab26030e058 80 #define CMU_LFBPRESC0_REG 4
Kojto 98:8ab26030e058 81 #if defined( _CMU_CTRL_HFCLKDIV_MASK )
Kojto 98:8ab26030e058 82 #define CMU_HFCLKDIV_REG 5
Kojto 98:8ab26030e058 83 #endif
Kojto 98:8ab26030e058 84 #define CMU_DIV_REG_POS 4
Kojto 98:8ab26030e058 85 #define CMU_DIV_REG_MASK 0xf
Kojto 98:8ab26030e058 86
Kojto 98:8ab26030e058 87 /* Enable register ids, for internal use */
Kojto 98:8ab26030e058 88 #define CMU_NO_EN_REG 0
Kojto 98:8ab26030e058 89 #define CMU_HFPERCLKDIV_EN_REG 1
Kojto 98:8ab26030e058 90 #define CMU_HFPERCLKEN0_EN_REG 2
Kojto 98:8ab26030e058 91 #define CMU_HFCORECLKEN0_EN_REG 3
Kojto 98:8ab26030e058 92 #define CMU_LFACLKEN0_EN_REG 4
Kojto 98:8ab26030e058 93 #define CMU_LFBCLKEN0_EN_REG 5
Kojto 98:8ab26030e058 94 #define CMU_PCNT_EN_REG 6
Kojto 98:8ab26030e058 95 #if defined( _CMU_LFCCLKEN0_MASK )
Kojto 98:8ab26030e058 96 #define CMU_LFCCLKEN0_EN_REG 7
Kojto 98:8ab26030e058 97 #endif
Kojto 98:8ab26030e058 98
Kojto 98:8ab26030e058 99 #define CMU_EN_REG_POS 8
Kojto 98:8ab26030e058 100 #define CMU_EN_REG_MASK 0xf
Kojto 98:8ab26030e058 101
Kojto 98:8ab26030e058 102 /* Enable register bit position, for internal use */
Kojto 98:8ab26030e058 103 #define CMU_EN_BIT_POS 12
Kojto 98:8ab26030e058 104 #define CMU_EN_BIT_MASK 0x1f
Kojto 98:8ab26030e058 105
Kojto 98:8ab26030e058 106 /* Clock branch bitfield position, for internal use */
Kojto 98:8ab26030e058 107 #define CMU_HF_CLK_BRANCH 0
Kojto 98:8ab26030e058 108 #define CMU_HFPER_CLK_BRANCH 1
Kojto 98:8ab26030e058 109 #define CMU_HFCORE_CLK_BRANCH 2
Kojto 98:8ab26030e058 110 #define CMU_LFA_CLK_BRANCH 3
Kojto 98:8ab26030e058 111 #define CMU_RTC_CLK_BRANCH 4
Kojto 98:8ab26030e058 112 #define CMU_LETIMER_CLK_BRANCH 5
Kojto 98:8ab26030e058 113 #define CMU_LCDPRE_CLK_BRANCH 6
Kojto 98:8ab26030e058 114 #define CMU_LCD_CLK_BRANCH 7
Kojto 98:8ab26030e058 115 #define CMU_LESENSE_CLK_BRANCH 8
Kojto 98:8ab26030e058 116 #define CMU_LFB_CLK_BRANCH 9
Kojto 98:8ab26030e058 117 #define CMU_LEUART0_CLK_BRANCH 10
Kojto 98:8ab26030e058 118 #define CMU_LEUART1_CLK_BRANCH 11
Kojto 98:8ab26030e058 119 #define CMU_DBG_CLK_BRANCH 12
Kojto 98:8ab26030e058 120 #define CMU_AUX_CLK_BRANCH 13
Kojto 98:8ab26030e058 121 #define CMU_USBC_CLK_BRANCH 14
Kojto 98:8ab26030e058 122 #define CMU_LFC_CLK_BRANCH 15
Kojto 98:8ab26030e058 123 #define CMU_USBLE_CLK_BRANCH 16
Kojto 98:8ab26030e058 124
Kojto 98:8ab26030e058 125 #define CMU_CLK_BRANCH_POS 17
Kojto 98:8ab26030e058 126 #define CMU_CLK_BRANCH_MASK 0x1f
Kojto 98:8ab26030e058 127
Kojto 98:8ab26030e058 128 /** @endcond */
Kojto 98:8ab26030e058 129
Kojto 98:8ab26030e058 130 /*******************************************************************************
Kojto 98:8ab26030e058 131 ******************************** ENUMS ************************************
Kojto 98:8ab26030e058 132 ******************************************************************************/
Kojto 98:8ab26030e058 133
Kojto 98:8ab26030e058 134 /** Clock divisors. These values are valid for prescalers. */
Kojto 98:8ab26030e058 135 #define cmuClkDiv_1 1 /**< Divide clock by 1. */
Kojto 98:8ab26030e058 136 #define cmuClkDiv_2 2 /**< Divide clock by 2. */
Kojto 98:8ab26030e058 137 #define cmuClkDiv_4 4 /**< Divide clock by 4. */
Kojto 98:8ab26030e058 138 #define cmuClkDiv_8 8 /**< Divide clock by 8. */
Kojto 98:8ab26030e058 139 #define cmuClkDiv_16 16 /**< Divide clock by 16. */
Kojto 98:8ab26030e058 140 #define cmuClkDiv_32 32 /**< Divide clock by 32. */
Kojto 98:8ab26030e058 141 #define cmuClkDiv_64 64 /**< Divide clock by 64. */
Kojto 98:8ab26030e058 142 #define cmuClkDiv_128 128 /**< Divide clock by 128. */
Kojto 98:8ab26030e058 143 #define cmuClkDiv_256 256 /**< Divide clock by 256. */
Kojto 98:8ab26030e058 144 #define cmuClkDiv_512 512 /**< Divide clock by 512. */
Kojto 98:8ab26030e058 145 #define cmuClkDiv_1024 1024 /**< Divide clock by 1024. */
Kojto 98:8ab26030e058 146 #define cmuClkDiv_2048 2048 /**< Divide clock by 2048. */
Kojto 98:8ab26030e058 147 #define cmuClkDiv_4096 4096 /**< Divide clock by 4096. */
Kojto 98:8ab26030e058 148 #define cmuClkDiv_8192 8192 /**< Divide clock by 8192. */
Kojto 98:8ab26030e058 149 #define cmuClkDiv_16384 16384 /**< Divide clock by 16384. */
Kojto 98:8ab26030e058 150 #define cmuClkDiv_32768 32768 /**< Divide clock by 32768. */
Kojto 98:8ab26030e058 151
Kojto 98:8ab26030e058 152 /** Clock divider configuration */
Kojto 98:8ab26030e058 153 typedef uint32_t CMU_ClkDiv_TypeDef;
Kojto 98:8ab26030e058 154
Kojto 98:8ab26030e058 155 /** High frequency RC bands. */
Kojto 98:8ab26030e058 156 typedef enum
Kojto 98:8ab26030e058 157 {
Kojto 98:8ab26030e058 158 /** 1MHz RC band. */
Kojto 98:8ab26030e058 159 cmuHFRCOBand_1MHz = _CMU_HFRCOCTRL_BAND_1MHZ,
Kojto 98:8ab26030e058 160 /** 7MHz RC band. */
Kojto 98:8ab26030e058 161 cmuHFRCOBand_7MHz = _CMU_HFRCOCTRL_BAND_7MHZ,
Kojto 98:8ab26030e058 162 /** 11MHz RC band. */
Kojto 98:8ab26030e058 163 cmuHFRCOBand_11MHz = _CMU_HFRCOCTRL_BAND_11MHZ,
Kojto 98:8ab26030e058 164 /** 14MHz RC band. */
Kojto 98:8ab26030e058 165 cmuHFRCOBand_14MHz = _CMU_HFRCOCTRL_BAND_14MHZ,
Kojto 98:8ab26030e058 166 /** 21MHz RC band. */
Kojto 98:8ab26030e058 167 cmuHFRCOBand_21MHz = _CMU_HFRCOCTRL_BAND_21MHZ,
Kojto 98:8ab26030e058 168 #if defined( _CMU_HFRCOCTRL_BAND_28MHZ )
Kojto 98:8ab26030e058 169 /** 28MHz RC band. */
Kojto 98:8ab26030e058 170 cmuHFRCOBand_28MHz = _CMU_HFRCOCTRL_BAND_28MHZ
Kojto 98:8ab26030e058 171 #endif
Kojto 98:8ab26030e058 172 } CMU_HFRCOBand_TypeDef;
Kojto 98:8ab26030e058 173
Kojto 98:8ab26030e058 174
Kojto 98:8ab26030e058 175 #if defined( _CMU_AUXHFRCOCTRL_BAND_MASK )
Kojto 98:8ab26030e058 176 /** AUX High frequency RC bands. */
Kojto 98:8ab26030e058 177 typedef enum
Kojto 98:8ab26030e058 178 {
Kojto 98:8ab26030e058 179 /** 1MHz RC band. */
Kojto 98:8ab26030e058 180 cmuAUXHFRCOBand_1MHz = _CMU_AUXHFRCOCTRL_BAND_1MHZ,
Kojto 98:8ab26030e058 181 /** 7MHz RC band. */
Kojto 98:8ab26030e058 182 cmuAUXHFRCOBand_7MHz = _CMU_AUXHFRCOCTRL_BAND_7MHZ,
Kojto 98:8ab26030e058 183 /** 11MHz RC band. */
Kojto 98:8ab26030e058 184 cmuAUXHFRCOBand_11MHz = _CMU_AUXHFRCOCTRL_BAND_11MHZ,
Kojto 98:8ab26030e058 185 /** 14MHz RC band. */
Kojto 98:8ab26030e058 186 cmuAUXHFRCOBand_14MHz = _CMU_AUXHFRCOCTRL_BAND_14MHZ,
Kojto 98:8ab26030e058 187 /** 21MHz RC band. */
Kojto 98:8ab26030e058 188 cmuAUXHFRCOBand_21MHz = _CMU_AUXHFRCOCTRL_BAND_21MHZ,
Kojto 98:8ab26030e058 189 #if defined( _CMU_AUXHFRCOCTRL_BAND_28MHZ )
Kojto 98:8ab26030e058 190 /** 28MHz RC band. */
Kojto 98:8ab26030e058 191 cmuAUXHFRCOBand_28MHz = _CMU_AUXHFRCOCTRL_BAND_28MHZ
Kojto 98:8ab26030e058 192 #endif
Kojto 98:8ab26030e058 193 } CMU_AUXHFRCOBand_TypeDef;
Kojto 98:8ab26030e058 194 #endif
Kojto 98:8ab26030e058 195
Kojto 98:8ab26030e058 196 #if defined( _CMU_USHFRCOCONF_BAND_MASK )
Kojto 98:8ab26030e058 197 /** USB High frequency RC bands. */
Kojto 98:8ab26030e058 198 typedef enum
Kojto 98:8ab26030e058 199 {
Kojto 98:8ab26030e058 200 /** 24MHz RC band. */
Kojto 98:8ab26030e058 201 cmuUSHFRCOBand_24MHz = _CMU_USHFRCOCONF_BAND_24MHZ,
Kojto 98:8ab26030e058 202 /** 48MHz RC band. */
Kojto 98:8ab26030e058 203 cmuUSHFRCOBand_48MHz = _CMU_USHFRCOCONF_BAND_48MHZ,
Kojto 98:8ab26030e058 204 } CMU_USHFRCOBand_TypeDef;
Kojto 98:8ab26030e058 205 #endif
Kojto 98:8ab26030e058 206
Kojto 98:8ab26030e058 207
Kojto 98:8ab26030e058 208 /** Clock points in CMU. Please refer to CMU overview in reference manual. */
Kojto 98:8ab26030e058 209 typedef enum
Kojto 98:8ab26030e058 210 {
Kojto 98:8ab26030e058 211 /*******************/
Kojto 98:8ab26030e058 212 /* HF clock branch */
Kojto 98:8ab26030e058 213 /*******************/
Kojto 98:8ab26030e058 214
Kojto 98:8ab26030e058 215 /** High frequency clock */
Kojto 98:8ab26030e058 216 #if defined( _CMU_CTRL_HFCLKDIV_MASK )
Kojto 98:8ab26030e058 217 cmuClock_HF = (CMU_HFCLKDIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 218 (CMU_HFCLKSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 219 (CMU_NO_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 220 (0 << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 221 (CMU_HF_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 222 #else
Kojto 98:8ab26030e058 223 cmuClock_HF = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 224 (CMU_HFCLKSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 225 (CMU_NO_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 226 (0 << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 227 (CMU_HF_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 228 #endif
Kojto 98:8ab26030e058 229
Kojto 98:8ab26030e058 230 /** Debug clock */
Kojto 98:8ab26030e058 231 cmuClock_DBG = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 232 (CMU_DBGCLKSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 233 (CMU_NO_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 234 (0 << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 235 (CMU_DBG_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 236
Kojto 98:8ab26030e058 237 /** AUX clock */
Kojto 98:8ab26030e058 238 cmuClock_AUX = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 239 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 240 (CMU_NO_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 241 (0 << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 242 (CMU_AUX_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 243
Kojto 98:8ab26030e058 244 /**********************************/
Kojto 98:8ab26030e058 245 /* HF peripheral clock sub-branch */
Kojto 98:8ab26030e058 246 /**********************************/
Kojto 98:8ab26030e058 247
Kojto 98:8ab26030e058 248 /** High frequency peripheral clock */
Kojto 98:8ab26030e058 249 cmuClock_HFPER = (CMU_HFPERCLKDIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 250 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 251 (CMU_HFPERCLKDIV_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 252 (_CMU_HFPERCLKDIV_HFPERCLKEN_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 253 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 254
Kojto 98:8ab26030e058 255 #if defined(_CMU_HFPERCLKEN0_USART0_MASK)
Kojto 98:8ab26030e058 256 /** Universal sync/async receiver/transmitter 0 clock. */
Kojto 98:8ab26030e058 257 cmuClock_USART0 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 258 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 259 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 260 (_CMU_HFPERCLKEN0_USART0_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 261 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 262 #endif
Kojto 98:8ab26030e058 263
Kojto 98:8ab26030e058 264 #if defined(_CMU_HFPERCLKEN0_USARTRF0_MASK)
Kojto 98:8ab26030e058 265 /** Universal sync/async receiver/transmitter 0 clock. */
Kojto 98:8ab26030e058 266 cmuClock_USARTRF0 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 267 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 268 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 269 (_CMU_HFPERCLKEN0_USARTRF0_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 270 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 271 #endif
Kojto 98:8ab26030e058 272
Kojto 98:8ab26030e058 273 #if defined(_CMU_HFPERCLKEN0_USART1_MASK)
Kojto 98:8ab26030e058 274 /** Universal sync/async receiver/transmitter 1 clock. */
Kojto 98:8ab26030e058 275 cmuClock_USART1 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 276 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 277 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 278 (_CMU_HFPERCLKEN0_USART1_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 279 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 280 #endif
Kojto 98:8ab26030e058 281
Kojto 98:8ab26030e058 282 #if defined(_CMU_HFPERCLKEN0_USART2_MASK)
Kojto 98:8ab26030e058 283 /** Universal sync/async receiver/transmitter 2 clock. */
Kojto 98:8ab26030e058 284 cmuClock_USART2 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 285 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 286 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 287 (_CMU_HFPERCLKEN0_USART2_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 288 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 289 #endif
Kojto 98:8ab26030e058 290
Kojto 98:8ab26030e058 291 #if defined(_CMU_HFPERCLKEN0_UART0_MASK)
Kojto 98:8ab26030e058 292 /** Universal async receiver/transmitter 0 clock. */
Kojto 98:8ab26030e058 293 cmuClock_UART0 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 294 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 295 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 296 (_CMU_HFPERCLKEN0_UART0_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 297 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 298 #endif
Kojto 98:8ab26030e058 299
Kojto 98:8ab26030e058 300 #if defined(_CMU_HFPERCLKEN0_UART1_MASK)
Kojto 98:8ab26030e058 301 /** Universal async receiver/transmitter 1 clock. */
Kojto 98:8ab26030e058 302 cmuClock_UART1 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 303 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 304 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 305 (_CMU_HFPERCLKEN0_UART1_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 306 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 307 #endif
Kojto 98:8ab26030e058 308
Kojto 98:8ab26030e058 309 #if defined(_CMU_HFPERCLKEN0_TIMER0_MASK)
Kojto 98:8ab26030e058 310 /** Timer 0 clock. */
Kojto 98:8ab26030e058 311 cmuClock_TIMER0 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 312 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 313 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 314 (_CMU_HFPERCLKEN0_TIMER0_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 315 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 316 #endif
Kojto 98:8ab26030e058 317
Kojto 98:8ab26030e058 318 #if defined(_CMU_HFPERCLKEN0_TIMER1_MASK)
Kojto 98:8ab26030e058 319 /** Timer 1 clock. */
Kojto 98:8ab26030e058 320 cmuClock_TIMER1 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 321 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 322 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 323 (_CMU_HFPERCLKEN0_TIMER1_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 324 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 325 #endif
Kojto 98:8ab26030e058 326
Kojto 98:8ab26030e058 327 #if defined(_CMU_HFPERCLKEN0_TIMER2_MASK)
Kojto 98:8ab26030e058 328 /** Timer 2 clock. */
Kojto 98:8ab26030e058 329 cmuClock_TIMER2 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 330 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 331 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 332 (_CMU_HFPERCLKEN0_TIMER2_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 333 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 334 #endif
Kojto 98:8ab26030e058 335
Kojto 98:8ab26030e058 336 #if defined(_CMU_HFPERCLKEN0_TIMER3_MASK)
Kojto 98:8ab26030e058 337 /** Timer 3 clock. */
Kojto 98:8ab26030e058 338 cmuClock_TIMER3 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 339 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 340 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 341 (_CMU_HFPERCLKEN0_TIMER3_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 342 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 343 #endif
Kojto 98:8ab26030e058 344
Kojto 98:8ab26030e058 345 #if defined(_CMU_HFPERCLKEN0_ACMP0_MASK)
Kojto 98:8ab26030e058 346 /** Analog comparator 0 clock. */
Kojto 98:8ab26030e058 347 cmuClock_ACMP0 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 348 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 349 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 350 (_CMU_HFPERCLKEN0_ACMP0_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 351 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 352 #endif
Kojto 98:8ab26030e058 353
Kojto 98:8ab26030e058 354 #if defined(_CMU_HFPERCLKEN0_ACMP1_MASK)
Kojto 98:8ab26030e058 355 /** Analog comparator 1 clock. */
Kojto 98:8ab26030e058 356 cmuClock_ACMP1 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 357 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 358 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 359 (_CMU_HFPERCLKEN0_ACMP1_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 360 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 361 #endif
Kojto 98:8ab26030e058 362
Kojto 98:8ab26030e058 363 #if defined(_CMU_HFPERCLKEN0_PRS_MASK)
Kojto 98:8ab26030e058 364 /** Peripheral reflex system clock. */
Kojto 98:8ab26030e058 365 cmuClock_PRS = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 366 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 367 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 368 (_CMU_HFPERCLKEN0_PRS_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 369 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 370 #endif
Kojto 98:8ab26030e058 371
Kojto 98:8ab26030e058 372 #if defined(_CMU_HFPERCLKEN0_DAC0_MASK)
Kojto 98:8ab26030e058 373 /** Digital to analog converter 0 clock. */
Kojto 98:8ab26030e058 374 cmuClock_DAC0 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 375 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 376 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 377 (_CMU_HFPERCLKEN0_DAC0_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 378 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 379 #endif
Kojto 98:8ab26030e058 380
Kojto 98:8ab26030e058 381 #if defined(_CMU_HFPERCLKEN0_IDAC0_MASK)
Kojto 98:8ab26030e058 382 /** Digital to analog converter 0 clock. */
Kojto 98:8ab26030e058 383 cmuClock_IDAC0 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 384 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 385 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 386 (_CMU_HFPERCLKEN0_IDAC0_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 387 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 388 #endif
Kojto 98:8ab26030e058 389
Kojto 98:8ab26030e058 390 #if defined(GPIO_PRESENT)
Kojto 98:8ab26030e058 391 /** General purpose input/output clock. */
Kojto 98:8ab26030e058 392 cmuClock_GPIO = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 393 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 394 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 395 (_CMU_HFPERCLKEN0_GPIO_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 396 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 397 #endif
Kojto 98:8ab26030e058 398
Kojto 98:8ab26030e058 399 #if defined(VCMP_PRESENT)
Kojto 98:8ab26030e058 400 /** Voltage comparator clock. */
Kojto 98:8ab26030e058 401 cmuClock_VCMP = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 402 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 403 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 404 (_CMU_HFPERCLKEN0_VCMP_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 405 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 406 #endif
Kojto 98:8ab26030e058 407
Kojto 98:8ab26030e058 408 #if defined(_CMU_HFPERCLKEN0_ADC0_MASK)
Kojto 98:8ab26030e058 409 /** Analog to digital converter 0 clock. */
Kojto 98:8ab26030e058 410 cmuClock_ADC0 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 411 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 412 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 413 (_CMU_HFPERCLKEN0_ADC0_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 414 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 415 #endif
Kojto 98:8ab26030e058 416
Kojto 98:8ab26030e058 417 #if defined(_CMU_HFPERCLKEN0_I2C0_MASK)
Kojto 98:8ab26030e058 418 /** I2C 0 clock. */
Kojto 98:8ab26030e058 419 cmuClock_I2C0 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 420 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 421 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 422 (_CMU_HFPERCLKEN0_I2C0_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 423 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 424 #endif
Kojto 98:8ab26030e058 425
Kojto 98:8ab26030e058 426 #if defined(_CMU_HFPERCLKEN0_I2C1_MASK)
Kojto 98:8ab26030e058 427 /** I2C 1 clock. */
Kojto 98:8ab26030e058 428 cmuClock_I2C1 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 429 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 430 (CMU_HFPERCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 431 (_CMU_HFPERCLKEN0_I2C1_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 432 (CMU_HFPER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 433 #endif
Kojto 98:8ab26030e058 434
Kojto 98:8ab26030e058 435 /**********************/
Kojto 98:8ab26030e058 436 /* HF core sub-branch */
Kojto 98:8ab26030e058 437 /**********************/
Kojto 98:8ab26030e058 438
Kojto 98:8ab26030e058 439 /** Core clock */
Kojto 98:8ab26030e058 440 cmuClock_CORE = (CMU_HFCORECLKDIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 441 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 442 (CMU_NO_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 443 (0 << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 444 (CMU_HFCORE_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 445
Kojto 98:8ab26030e058 446 #if defined(AES_PRESENT)
Kojto 98:8ab26030e058 447 /** Advanced encryption standard accelerator clock. */
Kojto 98:8ab26030e058 448 cmuClock_AES = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 449 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 450 (CMU_HFCORECLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 451 (_CMU_HFCORECLKEN0_AES_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 452 (CMU_HFCORE_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 453 #endif
Kojto 98:8ab26030e058 454
Kojto 98:8ab26030e058 455 #if defined(DMA_PRESENT)
Kojto 98:8ab26030e058 456 /** Direct memory access controller clock. */
Kojto 98:8ab26030e058 457 cmuClock_DMA = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 458 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 459 (CMU_HFCORECLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 460 (_CMU_HFCORECLKEN0_DMA_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 461 (CMU_HFCORE_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 462 #endif
Kojto 98:8ab26030e058 463 /** Low energy clocking module clock. */
Kojto 98:8ab26030e058 464 cmuClock_CORELE = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 465 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 466 (CMU_HFCORECLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 467 (_CMU_HFCORECLKEN0_LE_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 468 (CMU_HFCORE_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 469
Kojto 98:8ab26030e058 470 #if defined(EBI_PRESENT)
Kojto 98:8ab26030e058 471 /** External bus interface clock. */
Kojto 98:8ab26030e058 472 cmuClock_EBI = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 473 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 474 (CMU_HFCORECLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 475 (_CMU_HFCORECLKEN0_EBI_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 476 (CMU_HFCORE_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 477 #endif
Kojto 98:8ab26030e058 478
Kojto 98:8ab26030e058 479 #if defined(USB_PRESENT)
Kojto 98:8ab26030e058 480 /** USB Core clock. */
Kojto 98:8ab26030e058 481 cmuClock_USBC = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 482 (CMU_USBCCLKSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 483 (CMU_HFCORECLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 484 (_CMU_HFCORECLKEN0_USBC_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 485 (CMU_USBC_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 486
Kojto 98:8ab26030e058 487 #endif
Kojto 98:8ab26030e058 488
Kojto 98:8ab26030e058 489 #if defined(USB_PRESENT)
Kojto 98:8ab26030e058 490 /** USB clock. */
Kojto 98:8ab26030e058 491 cmuClock_USB = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 492 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 493 (CMU_HFCORECLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 494 (_CMU_HFCORECLKEN0_USB_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 495 (CMU_HFCORE_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 496 #endif
Kojto 98:8ab26030e058 497
Kojto 98:8ab26030e058 498 /***************/
Kojto 98:8ab26030e058 499 /* LF A branch */
Kojto 98:8ab26030e058 500 /***************/
Kojto 98:8ab26030e058 501
Kojto 98:8ab26030e058 502 /** Low frequency A clock */
Kojto 98:8ab26030e058 503 cmuClock_LFA = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 504 (CMU_LFACLKSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 505 (CMU_NO_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 506 (0 << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 507 (CMU_LFA_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 508
Kojto 98:8ab26030e058 509 #if defined(RTC_PRESENT)
Kojto 98:8ab26030e058 510 /** Real time counter clock. */
Kojto 98:8ab26030e058 511 cmuClock_RTC = (CMU_LFAPRESC0_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 512 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 513 (CMU_LFACLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 514 (_CMU_LFACLKEN0_RTC_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 515 (CMU_RTC_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 516 #endif
Kojto 98:8ab26030e058 517
Kojto 98:8ab26030e058 518 #if defined(_CMU_LFACLKEN0_LETIMER0_MASK)
Kojto 98:8ab26030e058 519 /** Low energy timer 0 clock. */
Kojto 98:8ab26030e058 520 cmuClock_LETIMER0 = (CMU_LFAPRESC0_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 521 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 522 (CMU_LFACLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 523 (_CMU_LFACLKEN0_LETIMER0_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 524 (CMU_LETIMER_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 525 #endif
Kojto 98:8ab26030e058 526
Kojto 98:8ab26030e058 527 #if defined(_CMU_LFACLKEN0_LCD_MASK)
Kojto 98:8ab26030e058 528 /** Liquid crystal display, pre FDIV clock. */
Kojto 98:8ab26030e058 529 cmuClock_LCDpre = (CMU_LFAPRESC0_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 530 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 531 (CMU_NO_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 532 (0 << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 533 (CMU_LCDPRE_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 534
Kojto 98:8ab26030e058 535 /** Liquid crystal display clock. Please notice that FDIV prescaler
Kojto 98:8ab26030e058 536 * must be set by special API. */
Kojto 98:8ab26030e058 537 cmuClock_LCD = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 538 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 539 (CMU_LFACLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 540 (_CMU_LFACLKEN0_LCD_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 541 (CMU_LCD_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 542 #endif
Kojto 98:8ab26030e058 543
Kojto 98:8ab26030e058 544 #if defined(_CMU_PCNTCTRL_PCNT0CLKEN_MASK)
Kojto 98:8ab26030e058 545 /** Pulse counter 0 clock. */
Kojto 98:8ab26030e058 546 cmuClock_PCNT0 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 547 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 548 (CMU_PCNT_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 549 (_CMU_PCNTCTRL_PCNT0CLKEN_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 550 (CMU_LFA_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 551 #endif
Kojto 98:8ab26030e058 552
Kojto 98:8ab26030e058 553 #if defined(_CMU_PCNTCTRL_PCNT1CLKEN_MASK)
Kojto 98:8ab26030e058 554 /** Pulse counter 1 clock. */
Kojto 98:8ab26030e058 555 cmuClock_PCNT1 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 556 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 557 (CMU_PCNT_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 558 (_CMU_PCNTCTRL_PCNT1CLKEN_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 559 (CMU_LFA_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 560 #endif
Kojto 98:8ab26030e058 561
Kojto 98:8ab26030e058 562 #if defined(_CMU_PCNTCTRL_PCNT2CLKEN_MASK)
Kojto 98:8ab26030e058 563 /** Pulse counter 2 clock. */
Kojto 98:8ab26030e058 564 cmuClock_PCNT2 = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 565 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 566 (CMU_PCNT_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 567 (_CMU_PCNTCTRL_PCNT2CLKEN_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 568 (CMU_LFA_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 569 #endif
Kojto 98:8ab26030e058 570 #if defined(_CMU_LFACLKEN0_LESENSE_MASK)
Kojto 98:8ab26030e058 571 /** LESENSE clock. */
Kojto 98:8ab26030e058 572 cmuClock_LESENSE = (CMU_LFAPRESC0_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 573 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 574 (CMU_LFACLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 575 (_CMU_LFACLKEN0_LESENSE_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 576 (CMU_LESENSE_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 577 #endif
Kojto 98:8ab26030e058 578
Kojto 98:8ab26030e058 579 /***************/
Kojto 98:8ab26030e058 580 /* LF B branch */
Kojto 98:8ab26030e058 581 /***************/
Kojto 98:8ab26030e058 582
Kojto 98:8ab26030e058 583 /** Low frequency B clock */
Kojto 98:8ab26030e058 584 cmuClock_LFB = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 585 (CMU_LFBCLKSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 586 (CMU_NO_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 587 (0 << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 588 (CMU_LFB_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 589
Kojto 98:8ab26030e058 590 #if defined(_CMU_LFBCLKEN0_LEUART0_MASK)
Kojto 98:8ab26030e058 591 /** Low energy universal asynchronous receiver/transmitter 0 clock. */
Kojto 98:8ab26030e058 592 cmuClock_LEUART0 = (CMU_LFBPRESC0_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 593 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 594 (CMU_LFBCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 595 (_CMU_LFBCLKEN0_LEUART0_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 596 (CMU_LEUART0_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 597 #endif
Kojto 98:8ab26030e058 598
Kojto 98:8ab26030e058 599 #if defined(_CMU_LFBCLKEN0_LEUART1_MASK)
Kojto 98:8ab26030e058 600 /** Low energy universal asynchronous receiver/transmitter 1 clock. */
Kojto 98:8ab26030e058 601 cmuClock_LEUART1 = (CMU_LFBPRESC0_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 602 (CMU_NOSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 603 (CMU_LFBCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 604 (_CMU_LFBCLKEN0_LEUART1_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 605 (CMU_LEUART1_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 606 #endif
Kojto 98:8ab26030e058 607
Kojto 98:8ab26030e058 608 /***************/
Kojto 98:8ab26030e058 609 /* LF C branch */
Kojto 98:8ab26030e058 610 /***************/
Kojto 98:8ab26030e058 611
Kojto 98:8ab26030e058 612 /** Low frequency C clock */
Kojto 98:8ab26030e058 613 #if defined( _CMU_LFCLKSEL_LFC_MASK )
Kojto 98:8ab26030e058 614 cmuClock_LFC = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 615 (CMU_LFCCLKSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 616 (CMU_NO_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 617 (0 << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 618 (CMU_LFC_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 619 #endif
Kojto 98:8ab26030e058 620
Kojto 98:8ab26030e058 621 #if defined(_CMU_LFCCLKEN0_USBLE_MASK)
Kojto 98:8ab26030e058 622 /** USB LE clock. */
Kojto 98:8ab26030e058 623 cmuClock_USBLE = (CMU_NODIV_REG << CMU_DIV_REG_POS) |
Kojto 98:8ab26030e058 624 (CMU_LFCCLKSEL_REG << CMU_SEL_REG_POS) |
Kojto 98:8ab26030e058 625 (CMU_LFCCLKEN0_EN_REG << CMU_EN_REG_POS) |
Kojto 98:8ab26030e058 626 (_CMU_LFCCLKEN0_USBLE_SHIFT << CMU_EN_BIT_POS) |
Kojto 98:8ab26030e058 627 (CMU_USBLE_CLK_BRANCH << CMU_CLK_BRANCH_POS),
Kojto 98:8ab26030e058 628 #endif
Kojto 98:8ab26030e058 629
Kojto 98:8ab26030e058 630 } CMU_Clock_TypeDef;
Kojto 98:8ab26030e058 631
Kojto 98:8ab26030e058 632
Kojto 98:8ab26030e058 633 /** Oscillator types. */
Kojto 98:8ab26030e058 634 typedef enum
Kojto 98:8ab26030e058 635 {
Kojto 98:8ab26030e058 636 cmuOsc_LFXO, /**< Low frequency crystal oscillator. */
Kojto 98:8ab26030e058 637 cmuOsc_LFRCO, /**< Low frequency RC oscillator. */
Kojto 98:8ab26030e058 638 cmuOsc_HFXO, /**< High frequency crystal oscillator. */
Kojto 98:8ab26030e058 639 cmuOsc_HFRCO, /**< High frequency RC oscillator. */
Kojto 98:8ab26030e058 640 cmuOsc_AUXHFRCO, /**< Auxiliary high frequency RC oscillator. */
Kojto 98:8ab26030e058 641 #if defined( _CMU_STATUS_USHFRCOENS_MASK )
Kojto 98:8ab26030e058 642 cmuOsc_USHFRCO, /**< USB high frequency RC oscillator */
Kojto 98:8ab26030e058 643 #endif
Kojto 98:8ab26030e058 644 #if defined( _CMU_LFCLKSEL_LFAE_ULFRCO )
Kojto 98:8ab26030e058 645 cmuOsc_ULFRCO /**< Ultra low frequency RC oscillator. */
Kojto 98:8ab26030e058 646 #endif
Kojto 98:8ab26030e058 647 } CMU_Osc_TypeDef;
Kojto 98:8ab26030e058 648
Kojto 98:8ab26030e058 649
Kojto 98:8ab26030e058 650 /** Selectable clock sources. */
Kojto 98:8ab26030e058 651 typedef enum
Kojto 98:8ab26030e058 652 {
Kojto 98:8ab26030e058 653 cmuSelect_Error, /**< Usage error. */
Kojto 98:8ab26030e058 654 cmuSelect_Disabled, /**< Clock selector disabled. */
Kojto 98:8ab26030e058 655 cmuSelect_LFXO, /**< Low frequency crystal oscillator. */
Kojto 98:8ab26030e058 656 cmuSelect_LFRCO, /**< Low frequency RC oscillator. */
Kojto 98:8ab26030e058 657 cmuSelect_HFXO, /**< High frequency crystal oscillator. */
Kojto 98:8ab26030e058 658 cmuSelect_HFRCO, /**< High frequency RC oscillator. */
Kojto 98:8ab26030e058 659 cmuSelect_CORELEDIV2, /**< Core low energy clock divided by 2. */
Kojto 98:8ab26030e058 660 cmuSelect_AUXHFRCO, /**< Auxilliary clock source can be used for debug clock */
Kojto 98:8ab26030e058 661 cmuSelect_HFCLK, /**< Divided HFCLK on Giant for debug clock, undivided on Tiny Gecko and for USBC (not used on Gecko) */
Kojto 98:8ab26030e058 662 #if defined( _CMU_STATUS_USHFRCOENS_MASK )
Kojto 98:8ab26030e058 663 cmuSelect_USHFRCO, /**< USB high frequency RC oscillator */
Kojto 98:8ab26030e058 664 #endif
Kojto 98:8ab26030e058 665 #if defined( _CMU_CMD_HFCLKSEL_USHFRCODIV2 )
Kojto 98:8ab26030e058 666 cmuSelect_USHFRCODIV2,/**< USB high frequency RC oscillator */
Kojto 98:8ab26030e058 667 #endif
Kojto 98:8ab26030e058 668 #if defined( _CMU_LFCLKSEL_LFAE_ULFRCO )
Kojto 98:8ab26030e058 669 cmuSelect_ULFRCO, /**< Ultra low frequency RC oscillator. */
Kojto 98:8ab26030e058 670 #endif
Kojto 98:8ab26030e058 671 } CMU_Select_TypeDef;
Kojto 98:8ab26030e058 672
Kojto 98:8ab26030e058 673
Kojto 98:8ab26030e058 674 /*******************************************************************************
Kojto 98:8ab26030e058 675 ***************************** PROTOTYPES **********************************
Kojto 98:8ab26030e058 676 ******************************************************************************/
Kojto 98:8ab26030e058 677
Kojto 98:8ab26030e058 678 void CMU_ClockEnable(CMU_Clock_TypeDef clock, bool enable);
Kojto 98:8ab26030e058 679 uint32_t CMU_ClockFreqGet(CMU_Clock_TypeDef clock);
Kojto 98:8ab26030e058 680 CMU_ClkDiv_TypeDef CMU_ClockDivGet(CMU_Clock_TypeDef clock);
Kojto 98:8ab26030e058 681 CMU_Select_TypeDef CMU_ClockSelectGet(CMU_Clock_TypeDef clock);
Kojto 98:8ab26030e058 682 void CMU_ClockDivSet(CMU_Clock_TypeDef clock, CMU_ClkDiv_TypeDef div);
Kojto 98:8ab26030e058 683 void CMU_ClockSelectSet(CMU_Clock_TypeDef clock, CMU_Select_TypeDef ref);
Kojto 98:8ab26030e058 684
Kojto 98:8ab26030e058 685 CMU_HFRCOBand_TypeDef CMU_HFRCOBandGet(void);
Kojto 98:8ab26030e058 686 void CMU_HFRCOBandSet(CMU_HFRCOBand_TypeDef band);
Kojto 98:8ab26030e058 687
Kojto 98:8ab26030e058 688 #if defined( _CMU_AUXHFRCOCTRL_BAND_MASK )
Kojto 98:8ab26030e058 689 CMU_AUXHFRCOBand_TypeDef CMU_AUXHFRCOBandGet(void);
Kojto 98:8ab26030e058 690 void CMU_AUXHFRCOBandSet(CMU_AUXHFRCOBand_TypeDef band);
Kojto 98:8ab26030e058 691 #endif
Kojto 98:8ab26030e058 692
Kojto 98:8ab26030e058 693 #if defined( _CMU_USHFRCOCONF_BAND_MASK )
Kojto 98:8ab26030e058 694 CMU_USHFRCOBand_TypeDef CMU_USHFRCOBandGet(void);
Kojto 98:8ab26030e058 695 void CMU_USHFRCOBandSet(CMU_USHFRCOBand_TypeDef band);
Kojto 98:8ab26030e058 696 #endif
Kojto 98:8ab26030e058 697
Kojto 98:8ab26030e058 698 void CMU_HFRCOStartupDelaySet(uint32_t delay);
Kojto 98:8ab26030e058 699 uint32_t CMU_HFRCOStartupDelayGet(void);
Kojto 98:8ab26030e058 700
Kojto 98:8ab26030e058 701 void CMU_OscillatorEnable(CMU_Osc_TypeDef osc, bool enable, bool wait);
Kojto 98:8ab26030e058 702 uint32_t CMU_OscillatorTuningGet(CMU_Osc_TypeDef osc);
Kojto 98:8ab26030e058 703 void CMU_OscillatorTuningSet(CMU_Osc_TypeDef osc, uint32_t val);
Kojto 98:8ab26030e058 704
Kojto 98:8ab26030e058 705 bool CMU_PCNTClockExternalGet(unsigned int inst);
Kojto 98:8ab26030e058 706 void CMU_PCNTClockExternalSet(unsigned int inst, bool external);
Kojto 98:8ab26030e058 707
Kojto 98:8ab26030e058 708 uint32_t CMU_LCDClkFDIVGet(void);
Kojto 98:8ab26030e058 709 void CMU_LCDClkFDIVSet(uint32_t div);
Kojto 98:8ab26030e058 710
Kojto 98:8ab26030e058 711 void CMU_FreezeEnable(bool enable);
Kojto 98:8ab26030e058 712 uint32_t CMU_Calibrate(uint32_t HFCycles, CMU_Osc_TypeDef reference);
Kojto 98:8ab26030e058 713
Kojto 98:8ab26030e058 714 #if defined( _CMU_CALCTRL_UPSEL_MASK ) && defined( _CMU_CALCTRL_DOWNSEL_MASK )
Kojto 98:8ab26030e058 715 void CMU_CalibrateConfig(uint32_t downCycles, CMU_Osc_TypeDef downSel,
Kojto 98:8ab26030e058 716 CMU_Osc_TypeDef upSel);
Kojto 98:8ab26030e058 717 #endif
Kojto 98:8ab26030e058 718
Kojto 98:8ab26030e058 719 /***************************************************************************//**
Kojto 98:8ab26030e058 720 * @brief
Kojto 98:8ab26030e058 721 * Clear one or more pending CMU interrupts.
Kojto 98:8ab26030e058 722 *
Kojto 98:8ab26030e058 723 * @param[in] flags
Kojto 98:8ab26030e058 724 * CMU interrupt sources to clear.
Kojto 98:8ab26030e058 725 ******************************************************************************/
Kojto 98:8ab26030e058 726 __STATIC_INLINE void CMU_IntClear(uint32_t flags)
Kojto 98:8ab26030e058 727 {
Kojto 98:8ab26030e058 728 CMU->IFC = flags;
Kojto 98:8ab26030e058 729 }
Kojto 98:8ab26030e058 730
Kojto 98:8ab26030e058 731
Kojto 98:8ab26030e058 732 /***************************************************************************//**
Kojto 98:8ab26030e058 733 * @brief
Kojto 98:8ab26030e058 734 * Disable one or more CMU interrupts.
Kojto 98:8ab26030e058 735 *
Kojto 98:8ab26030e058 736 * @param[in] flags
Kojto 98:8ab26030e058 737 * CMU interrupt sources to disable.
Kojto 98:8ab26030e058 738 ******************************************************************************/
Kojto 98:8ab26030e058 739 __STATIC_INLINE void CMU_IntDisable(uint32_t flags)
Kojto 98:8ab26030e058 740 {
Kojto 98:8ab26030e058 741 CMU->IEN &= ~flags;
Kojto 98:8ab26030e058 742 }
Kojto 98:8ab26030e058 743
Kojto 98:8ab26030e058 744
Kojto 98:8ab26030e058 745 /***************************************************************************//**
Kojto 98:8ab26030e058 746 * @brief
Kojto 98:8ab26030e058 747 * Enable one or more CMU interrupts.
Kojto 98:8ab26030e058 748 *
Kojto 98:8ab26030e058 749 * @note
Kojto 98:8ab26030e058 750 * Depending on the use, a pending interrupt may already be set prior to
Kojto 98:8ab26030e058 751 * enabling the interrupt. Consider using CMU_IntClear() prior to enabling
Kojto 98:8ab26030e058 752 * if such a pending interrupt should be ignored.
Kojto 98:8ab26030e058 753 *
Kojto 98:8ab26030e058 754 * @param[in] flags
Kojto 98:8ab26030e058 755 * CMU interrupt sources to enable.
Kojto 98:8ab26030e058 756 ******************************************************************************/
Kojto 98:8ab26030e058 757 __STATIC_INLINE void CMU_IntEnable(uint32_t flags)
Kojto 98:8ab26030e058 758 {
Kojto 98:8ab26030e058 759 CMU->IEN |= flags;
Kojto 98:8ab26030e058 760 }
Kojto 98:8ab26030e058 761
Kojto 98:8ab26030e058 762
Kojto 98:8ab26030e058 763 /***************************************************************************//**
Kojto 98:8ab26030e058 764 * @brief
Kojto 98:8ab26030e058 765 * Get pending CMU interrupts.
Kojto 98:8ab26030e058 766 *
Kojto 98:8ab26030e058 767 * @return
Kojto 98:8ab26030e058 768 * CMU interrupt sources pending.
Kojto 98:8ab26030e058 769 ******************************************************************************/
Kojto 98:8ab26030e058 770 __STATIC_INLINE uint32_t CMU_IntGet(void)
Kojto 98:8ab26030e058 771 {
Kojto 98:8ab26030e058 772 return CMU->IF;
Kojto 98:8ab26030e058 773 }
Kojto 98:8ab26030e058 774
Kojto 98:8ab26030e058 775
Kojto 98:8ab26030e058 776 /***************************************************************************//**
Kojto 98:8ab26030e058 777 * @brief
Kojto 98:8ab26030e058 778 * Get enabled and pending CMU interrupt flags.
Kojto 98:8ab26030e058 779 *
Kojto 98:8ab26030e058 780 * @details
Kojto 98:8ab26030e058 781 * Useful for handling more interrupt sources in the same interrupt handler.
Kojto 98:8ab26030e058 782 *
Kojto 98:8ab26030e058 783 * @note
Kojto 98:8ab26030e058 784 * The event bits are not cleared by the use of this function.
Kojto 98:8ab26030e058 785 *
Kojto 98:8ab26030e058 786 * @return
Kojto 98:8ab26030e058 787 * Pending and enabled CMU interrupt sources.
Kojto 98:8ab26030e058 788 * The return value is the bitwise AND combination of
Kojto 98:8ab26030e058 789 * - the OR combination of enabled interrupt sources in CMU_IEN_nnn
Kojto 98:8ab26030e058 790 * register (CMU_IEN_nnn) and
Kojto 98:8ab26030e058 791 * - the OR combination of valid interrupt flags of the CMU module
Kojto 98:8ab26030e058 792 * (CMU_IF_nnn).
Kojto 98:8ab26030e058 793 ******************************************************************************/
Kojto 98:8ab26030e058 794 __STATIC_INLINE uint32_t CMU_IntGetEnabled(void)
Kojto 98:8ab26030e058 795 {
Kojto 98:8ab26030e058 796 uint32_t tmp = 0U;
Kojto 98:8ab26030e058 797
Kojto 98:8ab26030e058 798
Kojto 98:8ab26030e058 799 /* Store LESENSE->IEN in temporary variable in order to define explicit order
Kojto 98:8ab26030e058 800 * of volatile accesses. */
Kojto 98:8ab26030e058 801 tmp = CMU->IEN;
Kojto 98:8ab26030e058 802
Kojto 98:8ab26030e058 803 /* Bitwise AND of pending and enabled interrupts */
Kojto 98:8ab26030e058 804 return CMU->IF & tmp;
Kojto 98:8ab26030e058 805 }
Kojto 98:8ab26030e058 806
Kojto 98:8ab26030e058 807
Kojto 98:8ab26030e058 808 /**************************************************************************//**
Kojto 98:8ab26030e058 809 * @brief
Kojto 98:8ab26030e058 810 * Set one or more pending CMU interrupts from SW.
Kojto 98:8ab26030e058 811 *
Kojto 98:8ab26030e058 812 * @param[in] flags
Kojto 98:8ab26030e058 813 * CMU interrupt sources to set to pending.
Kojto 98:8ab26030e058 814 *****************************************************************************/
Kojto 98:8ab26030e058 815 __STATIC_INLINE void CMU_IntSet(uint32_t flags)
Kojto 98:8ab26030e058 816 {
Kojto 98:8ab26030e058 817 CMU->IFS = flags;
Kojto 98:8ab26030e058 818 }
Kojto 98:8ab26030e058 819
Kojto 98:8ab26030e058 820
Kojto 98:8ab26030e058 821 /***************************************************************************//**
Kojto 98:8ab26030e058 822 * @brief
Kojto 98:8ab26030e058 823 * Lock the CMU in order to protect some of its registers against unintended
Kojto 98:8ab26030e058 824 * modification.
Kojto 98:8ab26030e058 825 *
Kojto 98:8ab26030e058 826 * @details
Kojto 98:8ab26030e058 827 * Please refer to the reference manual for CMU registers that will be
Kojto 98:8ab26030e058 828 * locked.
Kojto 98:8ab26030e058 829 *
Kojto 98:8ab26030e058 830 * @note
Kojto 98:8ab26030e058 831 * If locking the CMU registers, they must be unlocked prior to using any
Kojto 98:8ab26030e058 832 * CMU API functions modifying CMU registers protected by the lock.
Kojto 98:8ab26030e058 833 ******************************************************************************/
Kojto 98:8ab26030e058 834 __STATIC_INLINE void CMU_Lock(void)
Kojto 98:8ab26030e058 835 {
Kojto 98:8ab26030e058 836 CMU->LOCK = CMU_LOCK_LOCKKEY_LOCK;
Kojto 98:8ab26030e058 837 }
Kojto 98:8ab26030e058 838
Kojto 98:8ab26030e058 839
Kojto 98:8ab26030e058 840 /***************************************************************************//**
Kojto 98:8ab26030e058 841 * @brief
Kojto 98:8ab26030e058 842 * Unlock the CMU so that writing to locked registers again is possible.
Kojto 98:8ab26030e058 843 ******************************************************************************/
Kojto 98:8ab26030e058 844 __STATIC_INLINE void CMU_Unlock(void)
Kojto 98:8ab26030e058 845 {
Kojto 98:8ab26030e058 846 CMU->LOCK = CMU_LOCK_LOCKKEY_UNLOCK;
Kojto 98:8ab26030e058 847 }
Kojto 98:8ab26030e058 848
Kojto 98:8ab26030e058 849
Kojto 98:8ab26030e058 850 /***************************************************************************//**
Kojto 98:8ab26030e058 851 * @brief
Kojto 98:8ab26030e058 852 * Get calibration count register
Kojto 98:8ab26030e058 853 * @note
Kojto 98:8ab26030e058 854 * If continuous calibrartion mode is active, calibration busy will allmost
Kojto 98:8ab26030e058 855 * always be on, and we just need to read the value, where the normal case
Kojto 98:8ab26030e058 856 * would be that this function call has been triggered by the CALRDY
Kojto 98:8ab26030e058 857 * interrupt flag.
Kojto 98:8ab26030e058 858 * @return
Kojto 98:8ab26030e058 859 * Calibration count, the number of UPSEL clocks (see CMU_CalibrateConfig)
Kojto 98:8ab26030e058 860 * in the period of DOWNSEL oscillator clock cycles configured by a previous
Kojto 98:8ab26030e058 861 * write operation to CMU->CALCNT
Kojto 98:8ab26030e058 862 ******************************************************************************/
Kojto 98:8ab26030e058 863 __STATIC_INLINE uint32_t CMU_CalibrateCountGet(void)
Kojto 98:8ab26030e058 864 {
Kojto 98:8ab26030e058 865 /* Wait until calibration completes, UNLESS continuous calibration mode is */
Kojto 98:8ab26030e058 866 /* active */
Kojto 98:8ab26030e058 867 #if defined( CMU_CALCTRL_CONT )
Kojto 98:8ab26030e058 868 if (!(CMU->CALCTRL & CMU_CALCTRL_CONT))
Kojto 98:8ab26030e058 869 {
Kojto 98:8ab26030e058 870 while (CMU->STATUS & CMU_STATUS_CALBSY)
Kojto 98:8ab26030e058 871 ;
Kojto 98:8ab26030e058 872 }
Kojto 98:8ab26030e058 873 #else
Kojto 98:8ab26030e058 874 while (CMU->STATUS & CMU_STATUS_CALBSY)
Kojto 98:8ab26030e058 875 ;
Kojto 98:8ab26030e058 876 #endif
Kojto 98:8ab26030e058 877 return CMU->CALCNT;
Kojto 98:8ab26030e058 878 }
Kojto 98:8ab26030e058 879
Kojto 98:8ab26030e058 880
Kojto 98:8ab26030e058 881 /***************************************************************************//**
Kojto 98:8ab26030e058 882 * @brief
Kojto 98:8ab26030e058 883 * Starts calibration
Kojto 98:8ab26030e058 884 * @note
Kojto 98:8ab26030e058 885 * This call is usually invoked after CMU_CalibrateConfig() and possibly
Kojto 98:8ab26030e058 886 * CMU_CalibrateCont()
Kojto 98:8ab26030e058 887 ******************************************************************************/
Kojto 98:8ab26030e058 888 __STATIC_INLINE void CMU_CalibrateStart(void)
Kojto 98:8ab26030e058 889 {
Kojto 98:8ab26030e058 890 CMU->CMD = CMU_CMD_CALSTART;
Kojto 98:8ab26030e058 891 }
Kojto 98:8ab26030e058 892
Kojto 98:8ab26030e058 893
Kojto 98:8ab26030e058 894 #if defined( CMU_CMD_CALSTOP )
Kojto 98:8ab26030e058 895 /***************************************************************************//**
Kojto 98:8ab26030e058 896 * @brief
Kojto 98:8ab26030e058 897 * Stop the calibration counters
Kojto 98:8ab26030e058 898 ******************************************************************************/
Kojto 98:8ab26030e058 899 __STATIC_INLINE void CMU_CalibrateStop(void)
Kojto 98:8ab26030e058 900 {
Kojto 98:8ab26030e058 901 CMU->CMD = CMU_CMD_CALSTOP;
Kojto 98:8ab26030e058 902 }
Kojto 98:8ab26030e058 903 #endif
Kojto 98:8ab26030e058 904
Kojto 98:8ab26030e058 905
Kojto 98:8ab26030e058 906 #if defined( CMU_CALCTRL_CONT )
Kojto 98:8ab26030e058 907 /***************************************************************************//**
Kojto 98:8ab26030e058 908 * @brief
Kojto 98:8ab26030e058 909 * Configures continuous calibration mode
Kojto 98:8ab26030e058 910 * @param[in] enable
Kojto 98:8ab26030e058 911 * If true, enables continuous calibration, if false disables continuous
Kojto 98:8ab26030e058 912 * calibrartion
Kojto 98:8ab26030e058 913 ******************************************************************************/
Kojto 98:8ab26030e058 914 __STATIC_INLINE void CMU_CalibrateCont(bool enable)
Kojto 98:8ab26030e058 915 {
Kojto 98:8ab26030e058 916 BITBAND_Peripheral(&(CMU->CALCTRL), _CMU_CALCTRL_CONT_SHIFT, enable);
Kojto 98:8ab26030e058 917 }
Kojto 98:8ab26030e058 918 #endif
Kojto 98:8ab26030e058 919
Kojto 98:8ab26030e058 920 /** @} (end addtogroup CMU) */
Kojto 98:8ab26030e058 921 /** @} (end addtogroup EM_Library) */
Kojto 98:8ab26030e058 922
Kojto 98:8ab26030e058 923 #ifdef __cplusplus
Kojto 98:8ab26030e058 924 }
Kojto 98:8ab26030e058 925 #endif
Kojto 98:8ab26030e058 926
Kojto 98:8ab26030e058 927 #endif /* defined( CMU_PRESENT ) */
Kojto 98:8ab26030e058 928 #endif /* __SILICON_LABS_EM_CMU_H_ */