1 /***************************************************************************//** 2 * @file 3 * @brief API defining acces to SYSCFG registers 4 ******************************************************************************* 5 * # License 6 * <b>Copyright 2022 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 31 #ifndef EM_SYSCFG_H 32 #define EM_SYSCFG_H 33 34 #include "em_device.h" 35 36 #if defined(SL_TRUSTZONE_NONSECURE) 37 #include "sli_tz_service_syscfg.h" 38 #endif 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 #if defined(SYSCFG) 45 /******************************************************************************* 46 ******************************** TZ SERVICES ********************************** 47 ******************************************************************************/ 48 49 #if defined(_SYSCFG_CHIPREV_FAMILY_MASK) || defined(_SYSCFG_CHIPREV_PARTNUMBER_MASK) 50 /******************************************************************************* 51 * @brief Reads CHIPREV register 52 ******************************************************************************/ SYSCFG_readChipRev(void)53__STATIC_INLINE uint32_t SYSCFG_readChipRev(void) 54 { 55 #if defined(SL_TRUSTZONE_NONSECURE) 56 return sli_tz_syscfg_read_chiprev_register(); 57 #else 58 #if defined(CMU_CLKEN0_SYSCFG) 59 CMU->CLKEN0_SET = CMU_CLKEN0_SYSCFG; 60 #endif 61 return SYSCFG->CHIPREV; 62 #endif 63 } 64 #endif // defined(_SYSCFG_CHIPREV_FAMILY_MASK) || defined(_SYSCFG_CHIPREV_PARTNUMBER_MASK) 65 66 #if defined(_SYSCFG_DMEM0RAMCTRL_RAMWSEN_MASK) 67 /******************************************************************************* 68 * @brief Sets DMEM0RAMCTRL RAMWSEN bit to 1 69 ******************************************************************************/ SYSCFG_setDmem0RamCtrlRamwsenBit(void)70__STATIC_INLINE void SYSCFG_setDmem0RamCtrlRamwsenBit(void) 71 { 72 #if defined(SL_TRUSTZONE_NONSECURE) 73 sli_tz_syscfg_set_dmem0ramctrl_ramwsen_bit(); 74 #else 75 76 SYSCFG->DMEM0RAMCTRL = SYSCFG->DMEM0RAMCTRL | _SYSCFG_DMEM0RAMCTRL_RAMWSEN_MASK; 77 #endif 78 } 79 80 /******************************************************************************* 81 * @brief Clears DMEM0RAMCTRL RAMWSEN bit to 0 82 ******************************************************************************/ SYSCFG_clearDmem0RamCtrlRamwsenBit(void)83__STATIC_INLINE void SYSCFG_clearDmem0RamCtrlRamwsenBit(void) 84 { 85 #if defined(SL_TRUSTZONE_NONSECURE) 86 sli_tz_syscfg_clear_dmem0ramctrl_ramwsen_bit(); 87 #else 88 SYSCFG->DMEM0RAMCTRL = SYSCFG->DMEM0RAMCTRL & ~_SYSCFG_DMEM0RAMCTRL_RAMWSEN_MASK; 89 #endif 90 } 91 92 /******************************************************************************* 93 * @brief Reads DMEM0RAMCTRL RAMWSEN bit 94 ******************************************************************************/ SYSCFG_getDmem0RamCtrlRamwsenBit(void)95__STATIC_INLINE uint32_t SYSCFG_getDmem0RamCtrlRamwsenBit(void) 96 { 97 #if defined(SL_TRUSTZONE_NONSECURE) 98 return sli_tz_syscfg_get_dmem0ramctrl_ramwsen_bit(); 99 #else 100 return (SYSCFG->DMEM0RAMCTRL & _SYSCFG_DMEM0RAMCTRL_RAMWSEN_MASK) >> _SYSCFG_DMEM0RAMCTRL_RAMWSEN_SHIFT; 101 #endif 102 } 103 104 #endif //_SYSCFG_DMEM0RAMCTRL_RAMWSEN_MASK 105 #if defined(_SYSCFG_DMEM0RETNCTRL_MASK) 106 107 /******************************************************************************* 108 * @brief Reads DMEM0RETNCTRL register 109 ******************************************************************************/ SYSCFG_readDmem0RetnCtrl(void)110__STATIC_INLINE uint32_t SYSCFG_readDmem0RetnCtrl(void) 111 { 112 #if defined(SL_TRUSTZONE_NONSECURE) 113 return sli_tz_syscfg_read_dmem0retnctrl_register(); 114 #else 115 return SYSCFG->DMEM0RETNCTRL; 116 #endif 117 } 118 /******************************************************************************* 119 * @brief Mask DMEM0RETNCTRL register with provided mask 120 * 121 * @param mask - A mask that is to be used to mask the DMEM0RETNCTRL register 122 ******************************************************************************/ SYSCFG_maskDmem0RetnCtrl(uint32_t mask)123__STATIC_INLINE void SYSCFG_maskDmem0RetnCtrl(uint32_t mask) 124 { 125 #if defined(SL_TRUSTZONE_NONSECURE) 126 sli_tz_syscfg_mask_dmem0retnctrl_register(mask); 127 #else 128 SYSCFG->DMEM0RETNCTRL = SYSCFG->DMEM0RETNCTRL | mask; 129 #endif 130 } 131 132 /******************************************************************************* 133 * @brief Set DMEM0RETNCTRL to zero 134 ******************************************************************************/ SYSCFG_zeroDmem0RetnCtrl(void)135__STATIC_INLINE void SYSCFG_zeroDmem0RetnCtrl(void) 136 { 137 #if defined(SL_TRUSTZONE_NONSECURE) 138 sli_tz_syscfg_zero_dmem0retnctrl_register(); 139 #else 140 SYSCFG->DMEM0RETNCTRL = 0x0UL; 141 #endif 142 } 143 #endif // _SYSCFG_DMEM0RETNCTRL_MASK 144 145 #if defined(_SYSCFG_CFGSYSTIC_MASK) 146 /******************************************************************************* 147 * @brief Set SYSTICEXTCLKEN bit in CFGSYSTIC to one 148 ******************************************************************************/ SYSCFG_setSysTicExtClkEnCfgSysTic(void)149__STATIC_INLINE void SYSCFG_setSysTicExtClkEnCfgSysTic(void) 150 { 151 #if defined(SL_TRUSTZONE_NONSECURE) 152 sli_tz_syscfg_set_systicextclken_cfgsystic(); 153 #else 154 SYSCFG->CFGSYSTIC = (SYSCFG->CFGSYSTIC | _SYSCFG_CFGSYSTIC_SYSTICEXTCLKEN_MASK); 155 #endif 156 } 157 158 /******************************************************************************* 159 * @brief Clear SYSTICEXTCLKEN bit in CFGSYSTIC to zero 160 ******************************************************************************/ SYSCFG_clearSysTicExtClkEnCfgSysTic(void)161__STATIC_INLINE void SYSCFG_clearSysTicExtClkEnCfgSysTic(void) 162 { 163 #if defined(SL_TRUSTZONE_NONSECURE) 164 sli_tz_syscfg_clear_systicextclken_cfgsystic(); 165 #else 166 SYSCFG->CFGSYSTIC = (SYSCFG->CFGSYSTIC & ~_SYSCFG_CFGSYSTIC_SYSTICEXTCLKEN_MASK); 167 #endif 168 } 169 #endif //_SYSCFG_CFGSYSTIC_MASK 170 #endif //SYSCFG 171 #ifdef __cplusplus 172 } 173 #endif 174 #endif // EM_SYSCFG_H 175