/ * @brief * Select reference clock/oscillator used for a clock branch. * * @details * Notice that if a selected reference is not enabled prior to selecting its * use, it will be enabled, and this function will wait for the selected * oscillator to be stable. It will however NOT be disabled if another * reference clock is selected later. * * This feature is particularly import
| 1340 | * @li #cmuSelect_ULFRCO |
| 1341 | *****************************************************************************/ |
| 1342 | void CMU_ClockSelectSet(CMU_Clock_TypeDef clock, CMU_Select_TypeDef ref) |
| 1343 | { |
| 1344 | uint32_t select = cmuOsc_HFRCO; |
| 1345 | CMU_Osc_TypeDef osc = cmuOsc_HFRCO; |
| 1346 | uint32_t freq; |
| 1347 | uint32_t selReg; |
| 1348 | uint32_t lfShift; |
| 1349 | #if defined(_EFM32_TINY_FAMILY) || defined(_EFM32_GIANT_FAMILY) |
| 1350 | uint32_t lfExtendedShift; |
| 1351 | uint32_t lfExtended = 0; |
| 1352 | #endif |
| 1353 | uint32_t tmp; |
| 1354 | |
| 1355 | selReg = (clock >> CMU_SEL_REG_POS) & CMU_SEL_REG_MASK; |
| 1356 | |
| 1357 | switch (selReg) |
| 1358 | { |
| 1359 | case CMU_HFCLKSEL_REG: |
| 1360 | switch (ref) |
| 1361 | { |
| 1362 | case cmuSelect_LFXO: |
| 1363 | select = CMU_CMD_HFCLKSEL_LFXO; |
| 1364 | osc = cmuOsc_LFXO; |
| 1365 | break; |
| 1366 | |
| 1367 | case cmuSelect_LFRCO: |
| 1368 | select = CMU_CMD_HFCLKSEL_LFRCO; |
| 1369 | osc = cmuOsc_LFRCO; |
| 1370 | break; |
| 1371 | |
| 1372 | case cmuSelect_HFXO: |
| 1373 | select = CMU_CMD_HFCLKSEL_HFXO; |
| 1374 | osc = cmuOsc_HFXO; |
| 1375 | #if defined(_EFM32_GIANT_FAMILY) |
| 1376 | /* Adjust HFXO buffer current for high frequencies, enable HFLE for */ |
| 1377 | /* frequencies above 32MHz */ |
| 1378 | if(SystemHFXOClockGet() > CMU_MAX_FREQ_HFLE) |
| 1379 | { |
| 1380 | CMU->CTRL = (CMU->CTRL & ~_CMU_CTRL_HFXOBUFCUR_MASK) | |
| 1381 | CMU_CTRL_HFXOBUFCUR_BOOSTABOVE32MHZ | |
| 1382 | /* Must have HFLE enabled to access some LE peripherals >=32MHz */ |
| 1383 | CMU_CTRL_HFLE; |
| 1384 | } else { |
| 1385 | /* This can happen if the user configures the EFM32_HFXO_FREQ to */ |
| 1386 | /* use another oscillator frequency */ |
| 1387 | CMU->CTRL = (CMU->CTRL & ~_CMU_CTRL_HFXOBUFCUR_MASK) | |
| 1388 | CMU_CTRL_HFXOBUFCUR_BOOSTUPTO32MHZ; |
| 1389 | } |
| 1390 | #endif |
| 1391 | break; |
| 1392 | |
| 1393 | case cmuSelect_HFRCO: |
| 1394 | select = CMU_CMD_HFCLKSEL_HFRCO; |
| 1395 | osc = cmuOsc_HFRCO; |
| 1396 | break; |
| 1397 | |
| 1398 | #if defined(_EFM32_TINY_FAMILY) || defined(_EFM32_GIANT_FAMILY) |
| 1399 | case cmuSelect_ULFRCO: |
no test coverage detected