1 /** 2 ****************************************************************************** 3 * @file ll_sys_intf.c 4 * @author MCD Application Team 5 * @brief Link Layer IP general system interface 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2022 STMicroelectronics. 10 * All rights reserved. 11 * 12 * This software is licensed under terms that can be found in the LICENSE file 13 * in the root directory of this software component. 14 * If no LICENSE file comes with this software, it is provided AS-IS. 15 * 16 ****************************************************************************** 17 */ 18 19 #include "linklayer_plat.h" 20 #include "ll_sys.h" 21 #include "event_manager.h" 22 #include "ll_intf.h" 23 24 /** 25 * @brief Initialize the Link Layer SoC dependencies 26 * @param None 27 * @retval None 28 */ ll_sys_init()29void ll_sys_init() 30 { 31 LINKLAYER_PLAT_ClockInit(); 32 } 33 34 /** 35 * @brief Blocking delay in us 36 * @param None 37 * @retval None 38 */ ll_sys_delay_us(uint32_t delay)39void ll_sys_delay_us(uint32_t delay) 40 { 41 LINKLAYER_PLAT_DelayUs(delay); 42 } 43 44 /** 45 * @brief Assert checking 46 * @param None 47 * @retval None 48 */ ll_sys_assert(uint8_t condition)49void ll_sys_assert(uint8_t condition) 50 { 51 LINKLAYER_PLAT_Assert(condition); 52 } 53 54 /** 55 * @brief Radio active clock management 56 * @param None 57 * @retval None 58 */ ll_sys_radio_ack_ctrl(uint8_t enable)59void ll_sys_radio_ack_ctrl(uint8_t enable) 60 { 61 LINKLAYER_PLAT_AclkCtrl(enable); 62 } 63 64 /** 65 * @brief Link Layer waits for radio bus clock ready 66 * @param None 67 * @retval None 68 */ ll_sys_radio_wait_for_busclkrdy(void)69void ll_sys_radio_wait_for_busclkrdy(void) 70 { 71 LINKLAYER_PLAT_WaitHclkRdy(); 72 } 73 74 /** 75 * @brief Get RNG number for the Link Layer IP 76 * @param None 77 * @retval None 78 */ ll_sys_get_rng(uint8_t * ptr_rnd,uint32_t len)79void ll_sys_get_rng(uint8_t *ptr_rnd, uint32_t len) 80 { 81 LINKLAYER_PLAT_GetRNG(ptr_rnd, len); 82 } 83 84 /** 85 * @brief Initialize the main radio interrupt 86 * @param intr_cb radio interrupt callback to link with the radio IRQ 87 * @retval None 88 */ ll_sys_setup_radio_intr(void (* intr_cb)())89void ll_sys_setup_radio_intr(void (*intr_cb)()) 90 { 91 LINKLAYER_PLAT_SetupRadioIT(intr_cb); 92 } 93 94 /** 95 * @brief Initialize the radio SW low interrupt 96 * @param intr_cb radio SW low interrupt interrupt callback to link 97 * with the defined interrupt vector 98 * @retval None 99 */ ll_sys_setup_radio_sw_low_intr(void (* intr_cb)())100void ll_sys_setup_radio_sw_low_intr(void (*intr_cb)()) 101 { 102 LINKLAYER_PLAT_SetupSwLowIT(intr_cb); 103 } 104 105 /** 106 * @brief Trigger the radio SW low interrupt 107 * @param None 108 * @retval None 109 */ ll_sys_radio_sw_low_intr_trigger(uint8_t priority)110void ll_sys_radio_sw_low_intr_trigger(uint8_t priority) 111 { 112 LINKLAYER_PLAT_TriggerSwLowIT(priority); 113 } 114 115 /** 116 * @brief Link Layer radio activity event notification 117 * @param start start/end of radio event 118 * @retval None 119 */ ll_sys_radio_evt_not(uint8_t start)120void ll_sys_radio_evt_not(uint8_t start) 121 { 122 if(start) 123 { 124 LINKLAYER_PLAT_StartRadioEvt(); 125 } 126 127 else 128 { 129 LINKLAYER_PLAT_StopRadioEvt(); 130 } 131 } 132 133 /** 134 * @brief Link Layer RCO calibration notification 135 * @param start start/end of RCO calibration 136 * @retval None 137 */ ll_sys_rco_clbr_not(uint8_t start)138void ll_sys_rco_clbr_not(uint8_t start) 139 { 140 if(start) 141 { 142 LINKLAYER_PLAT_RCOStartClbr(); 143 } 144 145 else 146 { 147 LINKLAYER_PLAT_RCOStopClbr(); 148 } 149 } 150 151 /** 152 * @brief Link Layer temperature request 153 * @param None 154 * @retval None 155 */ ll_sys_request_temperature(void)156void ll_sys_request_temperature(void) 157 { 158 LINKLAYER_PLAT_RequestTemperature(); 159 } 160 161 /** 162 * @brief Link Layer background task pcoessing procedure 163 * @param None 164 * @retval None 165 */ ll_sys_bg_process(void)166void ll_sys_bg_process(void) 167 { 168 if(emngr_can_mcu_sleep() == 0) 169 { 170 ll_sys_dp_slp_exit(); 171 emngr_handle_all_events(); 172 173 HostStack_Process(); 174 } 175 176 if(emngr_can_mcu_sleep() == 0) 177 { 178 ll_sys_schedule_bg_process(); 179 } 180 } 181 ll_sys_schldr_timing_update_not(Evnt_timing_t * p_evnt_timing)182void ll_sys_schldr_timing_update_not(Evnt_timing_t * p_evnt_timing) 183 { 184 LINKLAYER_PLAT_SCHLDR_TIMING_UPDATE_NOT(p_evnt_timing); 185 } 186 187 /** 188 * @brief Get the number of concurrent state machines for the Link Layer 189 * @param None 190 * @retval Supported number of concurrent state machines 191 */ ll_sys_get_concurrent_state_machines_num(void)192uint8_t ll_sys_get_concurrent_state_machines_num(void) 193 { 194 return MAX_NUM_CNCRT_STAT_MCHNS; 195 } 196 HostStack_Process(void)197__WEAK void HostStack_Process(void) 198 { 199 200 } 201