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 return SYSCFG->CHIPREV; 59 #endif 60 } 61 #endif // defined(_SYSCFG_CHIPREV_FAMILY_MASK) || defined(_SYSCFG_CHIPREV_PARTNUMBER_MASK) 62 63 #if defined(_SYSCFG_DMEM0RAMCTRL_RAMWSEN_MASK) 64 /******************************************************************************* 65 * @brief Sets DMEM0RAMCTRL RAMWSEN bit to 1 66 ******************************************************************************/ SYSCFG_setDmem0RamCtrlRamwsenBit(void)67__STATIC_INLINE void SYSCFG_setDmem0RamCtrlRamwsenBit(void) 68 { 69 #if defined(SL_TRUSTZONE_NONSECURE) 70 sli_tz_syscfg_set_dmem0ramctrl_ramwsen_bit(); 71 #else 72 73 SYSCFG->DMEM0RAMCTRL = SYSCFG->DMEM0RAMCTRL | _SYSCFG_DMEM0RAMCTRL_RAMWSEN_MASK; 74 #endif 75 } 76 77 /******************************************************************************* 78 * @brief Clears DMEM0RAMCTRL RAMWSEN bit to 0 79 ******************************************************************************/ SYSCFG_clearDmem0RamCtrlRamwsenBit(void)80__STATIC_INLINE void SYSCFG_clearDmem0RamCtrlRamwsenBit(void) 81 { 82 #if defined(SL_TRUSTZONE_NONSECURE) 83 sli_tz_syscfg_clear_dmem0ramctrl_ramwsen_bit(); 84 #else 85 SYSCFG->DMEM0RAMCTRL = SYSCFG->DMEM0RAMCTRL & ~_SYSCFG_DMEM0RAMCTRL_RAMWSEN_MASK; 86 #endif 87 } 88 89 /******************************************************************************* 90 * @brief Reads DMEM0RAMCTRL RAMWSEN bit 91 ******************************************************************************/ SYSCFG_getDmem0RamCtrlRamwsenBit(void)92__STATIC_INLINE uint32_t SYSCFG_getDmem0RamCtrlRamwsenBit(void) 93 { 94 #if defined(SL_TRUSTZONE_NONSECURE) 95 return sli_tz_syscfg_get_dmem0ramctrl_ramwsen_bit(); 96 #else 97 return (SYSCFG->DMEM0RAMCTRL & _SYSCFG_DMEM0RAMCTRL_RAMWSEN_MASK) >> _SYSCFG_DMEM0RAMCTRL_RAMWSEN_SHIFT; 98 #endif 99 } 100 101 #endif //_SYSCFG_DMEM0RAMCTRL_RAMWSEN_MASK 102 #if defined(_SYSCFG_DMEM0RETNCTRL_MASK) 103 104 /******************************************************************************* 105 * @brief Reads DMEM0RETNCTRL register 106 ******************************************************************************/ SYSCFG_readDmem0RetnCtrl(void)107__STATIC_INLINE uint32_t SYSCFG_readDmem0RetnCtrl(void) 108 { 109 #if defined(SL_TRUSTZONE_NONSECURE) 110 return sli_tz_syscfg_read_dmem0retnctrl_register(); 111 #else 112 return SYSCFG->DMEM0RETNCTRL; 113 #endif 114 } 115 /******************************************************************************* 116 * @brief Mask DMEM0RETNCTRL register with provided mask 117 * 118 * @param mask - A mask that is to be used to mask the DMEM0RETNCTRL register 119 ******************************************************************************/ SYSCFG_maskDmem0RetnCtrl(uint32_t mask)120__STATIC_INLINE void SYSCFG_maskDmem0RetnCtrl(uint32_t mask) 121 { 122 #if defined(SL_TRUSTZONE_NONSECURE) 123 sli_tz_syscfg_mask_dmem0retnctrl_register(mask); 124 #else 125 SYSCFG->DMEM0RETNCTRL = SYSCFG->DMEM0RETNCTRL | mask; 126 #endif 127 } 128 129 /******************************************************************************* 130 * @brief Set DMEM0RETNCTRL to zero 131 ******************************************************************************/ SYSCFG_zeroDmem0RetnCtrl(void)132__STATIC_INLINE void SYSCFG_zeroDmem0RetnCtrl(void) 133 { 134 #if defined(SL_TRUSTZONE_NONSECURE) 135 sli_tz_syscfg_zero_dmem0retnctrl_register(); 136 #else 137 SYSCFG->DMEM0RETNCTRL = 0x0UL; 138 #endif 139 } 140 #endif // _SYSCFG_DMEM0RETNCTRL_MASK 141 142 #if defined(_SYSCFG_CFGSYSTIC_MASK) 143 /******************************************************************************* 144 * @brief Set SYSTICEXTCLKEN bit in CFGSYSTIC to one 145 ******************************************************************************/ SYSCFG_setSysTicExtClkEnCfgSysTic(void)146__STATIC_INLINE void SYSCFG_setSysTicExtClkEnCfgSysTic(void) 147 { 148 #if defined(SL_TRUSTZONE_NONSECURE) 149 sli_tz_syscfg_set_systicextclken_cfgsystic(); 150 #else 151 SYSCFG->CFGSYSTIC = (SYSCFG->CFGSYSTIC | _SYSCFG_CFGSYSTIC_SYSTICEXTCLKEN_MASK); 152 #endif 153 } 154 155 /******************************************************************************* 156 * @brief Clear SYSTICEXTCLKEN bit in CFGSYSTIC to zero 157 ******************************************************************************/ SYSCFG_clearSysTicExtClkEnCfgSysTic(void)158__STATIC_INLINE void SYSCFG_clearSysTicExtClkEnCfgSysTic(void) 159 { 160 #if defined(SL_TRUSTZONE_NONSECURE) 161 sli_tz_syscfg_clear_systicextclken_cfgsystic(); 162 #else 163 SYSCFG->CFGSYSTIC = (SYSCFG->CFGSYSTIC & ~_SYSCFG_CFGSYSTIC_SYSTICEXTCLKEN_MASK); 164 #endif 165 } 166 #endif //_SYSCFG_CFGSYSTIC_MASK 167 #endif //SYSCFG 168 #ifdef __cplusplus 169 } 170 #endif 171 #endif // EM_SYSCFG_H 172