1 /***************************************************************************//** 2 * @file 3 * @brief Device initialization for LFRCO. 4 ******************************************************************************* 5 * # License 6 * <b>Copyright 2019 Silicon Laboratories Inc. www.silabs.com</b> 7 ******************************************************************************* 8 * 9 * SPDX-License-Identifier: Zlib 10 * 11 * The licensor of this software is Silicon Laboratories Inc. 12 * 13 * This software is provided 'as-is', without any express or implied 14 * warranty. In no event will the authors be held liable for any damages 15 * arising from the use of this software. 16 * 17 * Permission is granted to anyone to use this software for any purpose, 18 * including commercial applications, and to alter it and redistribute it 19 * freely, subject to the following restrictions: 20 * 21 * 1. The origin of this software must not be misrepresented; you must not 22 * claim that you wrote the original software. If you use this software 23 * in a product, an acknowledgment in the product documentation would be 24 * appreciated but is not required. 25 * 2. Altered source versions must be plainly marked as such, and must not be 26 * misrepresented as being the original software. 27 * 3. This notice may not be removed or altered from any source distribution. 28 * 29 ******************************************************************************/ 30 #include "sl_device_init_lfrco.h" 31 #include "em_cmu.h" 32 33 #if defined(_SILICON_LABS_32B_SERIES_1) 34 #include "sl_device_init_lfrco_config.h" 35 #elif defined(_SILICON_LABS_32B_SERIES_2) && defined(PLFRCO_PRESENT) 36 #include "sl_device_init_lfrco_config.h" 37 #endif 38 sl_device_init_lfrco(void)39sl_status_t sl_device_init_lfrco(void) 40 { 41 #if defined(_SILICON_LABS_32B_SERIES_2) && defined(PLFRCO_PRESENT) 42 CMU_LFRCOSetPrecision(SL_DEVICE_INIT_LFRCO_PRECISION); 43 #endif 44 45 #if defined(_SILICON_LABS_32B_SERIES_1) 46 #if SL_DEVICE_INIT_LFRCO_ENVREF == 0 47 CMU->LFRCOCTRL &= ~(CMU_LFRCOCTRL_ENVREF); 48 #else 49 CMU->LFRCOCTRL |= CMU_LFRCOCTRL_ENVREF; 50 #endif 51 52 #if SL_DEVICE_INIT_LFRCO_ENCHOP == 0 53 CMU->LFRCOCTRL &= ~(CMU_LFRCOCTRL_ENCHOP); 54 #else 55 CMU->LFRCOCTRL |= CMU_LFRCOCTRL_ENCHOP; 56 #endif 57 58 #if SL_DEVICE_INIT_LFRCO_ENDEM == 0 59 CMU->LFRCOCTRL &= ~(CMU_LFRCOCTRL_ENDEM); 60 #else 61 CMU->LFRCOCTRL |= CMU_LFRCOCTRL_ENDEM; 62 #endif 63 #endif // defined(_SILICON_LABS_32B_SERIES_1) 64 65 return SL_STATUS_OK; 66 } 67