aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32-wpan/src/wba/ll_sys_if.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-stm32-wpan/src/wba/ll_sys_if.rs')
-rw-r--r--embassy-stm32-wpan/src/wba/ll_sys_if.rs335
1 files changed, 335 insertions, 0 deletions
diff --git a/embassy-stm32-wpan/src/wba/ll_sys_if.rs b/embassy-stm32-wpan/src/wba/ll_sys_if.rs
new file mode 100644
index 000000000..992c2a6f1
--- /dev/null
+++ b/embassy-stm32-wpan/src/wba/ll_sys_if.rs
@@ -0,0 +1,335 @@
1#[allow(dead_code)]
2fn test_fn() {}
3
4// /* USER CODE BEGIN Header */
5// /**
6// ******************************************************************************
7// * @file ll_sys_if.c
8// * @author MCD Application Team
9// * @brief Source file for initiating system
10// ******************************************************************************
11// * @attention
12// *
13// * Copyright (c) 2022 STMicroelectronics.
14// * All rights reserved.
15// *
16// * This software is licensed under terms that can be found in the LICENSE file
17// * in the root directory of this software component.
18// * If no LICENSE file comes with this software, it is provided AS-IS.
19// *
20// ******************************************************************************
21// */
22// /* USER CODE END Header */
23//
24// #include "main.h"
25// #include "app_common.h"
26// #include "app_conf.h"
27// #include "log_module.h"
28// #include "ll_intf_cmn.h"
29// #include "ll_sys.h"
30// #include "ll_sys_if.h"
31// #include "stm32_rtos.h"
32// #include "utilities_common.h"
33// #if (USE_TEMPERATURE_BASED_RADIO_CALIBRATION == 1)
34// #include "temp_measurement.h"
35// #endif /* (USE_TEMPERATURE_BASED_RADIO_CALIBRATION == 1) */
36// #if (CFG_LPM_STANDBY_SUPPORTED == 0)
37// extern void profile_reset(void);
38// #endif
39// /* Private defines -----------------------------------------------------------*/
40// /* Radio event scheduling method - must be set at 1 */
41// #define USE_RADIO_LOW_ISR (1)
42// #define NEXT_EVENT_SCHEDULING_FROM_ISR (1)
43//
44// /* USER CODE BEGIN PD */
45//
46// /* USER CODE END PD */
47//
48// /* Private macros ------------------------------------------------------------*/
49// /* USER CODE BEGIN PM */
50//
51// /* USER CODE END PM */
52//
53// /* Private constants ---------------------------------------------------------*/
54// /* USER CODE BEGIN PC */
55//
56// /* USER CODE END PC */
57//
58// /* Private variables ---------------------------------------------------------*/
59// /* USER CODE BEGIN PV */
60//
61// /* USER CODE END PV */
62//
63// /* Global variables ----------------------------------------------------------*/
64//
65// /* USER CODE BEGIN GV */
66//
67// /* USER CODE END GV */
68//
69// /* Private functions prototypes-----------------------------------------------*/
70// #if (USE_TEMPERATURE_BASED_RADIO_CALIBRATION == 1)
71// static void ll_sys_bg_temperature_measurement_init(void);
72// #endif /* USE_TEMPERATURE_BASED_RADIO_CALIBRATION */
73// static void ll_sys_sleep_clock_source_selection(void);
74// static uint8_t ll_sys_BLE_sleep_clock_accuracy_selection(void);
75// void ll_sys_reset(void);
76//
77// /* USER CODE BEGIN PFP */
78//
79// /* USER CODE END PFP */
80//
81// /* External variables --------------------------------------------------------*/
82//
83// /* USER CODE BEGIN EV */
84//
85// /* USER CODE END EV */
86//
87// /* Functions Definition ------------------------------------------------------*/
88//
89// /**
90// * @brief Link Layer background process initialization
91// * @param None
92// * @retval None
93// */
94// void ll_sys_bg_process_init(void)
95// {
96// /* Register Link Layer task */
97// UTIL_SEQ_RegTask(1U << CFG_TASK_LINK_LAYER, UTIL_SEQ_RFU, ll_sys_bg_process);
98// }
99//
100// /**
101// * @brief Link Layer background process next iteration scheduling
102// * @param None
103// * @retval None
104// */
105// void ll_sys_schedule_bg_process(void)
106// {
107// UTIL_SEQ_SetTask(1U << CFG_TASK_LINK_LAYER, TASK_PRIO_LINK_LAYER);
108// }
109//
110// /**
111// * @brief Link Layer background process next iteration scheduling from ISR
112// * @param None
113// * @retval None
114// */
115// void ll_sys_schedule_bg_process_isr(void)
116// {
117// UTIL_SEQ_SetTask(1U << CFG_TASK_LINK_LAYER, TASK_PRIO_LINK_LAYER);
118// }
119//
120// /**
121// * @brief Link Layer configuration phase before application startup.
122// * @param None
123// * @retval None
124// */
125// void ll_sys_config_params(void)
126// {
127// /* USER CODE BEGIN ll_sys_config_params_0 */
128//
129// /* USER CODE END ll_sys_config_params_0 */
130//
131// /* Configure link layer behavior for low ISR use and next event scheduling method:
132// * - SW low ISR is used.
133// * - Next event is scheduled from ISR.
134// */
135// ll_intf_cmn_config_ll_ctx_params(USE_RADIO_LOW_ISR, NEXT_EVENT_SCHEDULING_FROM_ISR);
136// /* Apply the selected link layer sleep timer source */
137// ll_sys_sleep_clock_source_selection();
138//
139// /* USER CODE BEGIN ll_sys_config_params_1 */
140//
141// /* USER CODE END ll_sys_config_params_1 */
142//
143// #if (USE_TEMPERATURE_BASED_RADIO_CALIBRATION == 1)
144// /* Initialize link layer temperature measurement background task */
145// ll_sys_bg_temperature_measurement_init();
146//
147// /* Link layer IP uses temperature based calibration instead of periodic one */
148// ll_intf_cmn_set_temperature_sensor_state();
149// #endif /* USE_TEMPERATURE_BASED_RADIO_CALIBRATION */
150//
151// /* Link Layer power table */
152// ll_intf_cmn_select_tx_power_table(CFG_RF_TX_POWER_TABLE_ID);
153//
154// #if (USE_CTE_DEGRADATION == 1u)
155// /* Apply CTE degradation */
156// ll_sys_apply_cte_settings ();
157// #endif /* (USE_CTE_DEGRADATION == 1u) */
158//
159// /* USER CODE BEGIN ll_sys_config_params_2 */
160//
161// /* USER CODE END ll_sys_config_params_2 */
162// }
163//
164// #if (USE_TEMPERATURE_BASED_RADIO_CALIBRATION == 1)
165//
166// /**
167// * @brief Link Layer temperature request background process initialization
168// * @param None
169// * @retval None
170// */
171// void ll_sys_bg_temperature_measurement_init(void)
172// {
173// /* Register Temperature Measurement task */
174// UTIL_SEQ_RegTask(1U << CFG_TASK_TEMP_MEAS, UTIL_SEQ_RFU, TEMPMEAS_RequestTemperatureMeasurement);
175// }
176//
177// /**
178// * @brief Request backroud task processing for temperature measurement
179// * @param None
180// * @retval None
181// */
182// void ll_sys_bg_temperature_measurement(void)
183// {
184// static uint8_t initial_temperature_acquisition = 0;
185//
186// if(initial_temperature_acquisition == 0)
187// {
188// TEMPMEAS_RequestTemperatureMeasurement();
189// initial_temperature_acquisition = 1;
190// }
191// else
192// {
193// UTIL_SEQ_SetTask(1U << CFG_TASK_TEMP_MEAS, CFG_SEQ_PRIO_0);
194// }
195// }
196//
197// #endif /* USE_TEMPERATURE_BASED_RADIO_CALIBRATION */
198//
199// uint8_t ll_sys_BLE_sleep_clock_accuracy_selection(void)
200// {
201// uint8_t BLE_sleep_clock_accuracy = 0;
202// #if (CFG_RADIO_LSE_SLEEP_TIMER_CUSTOM_SCA_RANGE == 0)
203// uint32_t RevID = LL_DBGMCU_GetRevisionID();
204// #endif
205// uint32_t linklayer_slp_clk_src = LL_RCC_RADIO_GetSleepTimerClockSource();
206//
207// if(linklayer_slp_clk_src == LL_RCC_RADIOSLEEPSOURCE_LSE)
208// {
209// /* LSE selected as Link Layer sleep clock source.
210// Sleep clock accuracy is different regarding the WBA device ID and revision
211// */
212// #if (CFG_RADIO_LSE_SLEEP_TIMER_CUSTOM_SCA_RANGE == 0)
213// #if defined(STM32WBA52xx) || defined(STM32WBA54xx) || defined(STM32WBA55xx)
214// if(RevID == REV_ID_A)
215// {
216// BLE_sleep_clock_accuracy = STM32WBA5x_REV_ID_A_SCA_RANGE;
217// }
218// else if(RevID == REV_ID_B)
219// {
220// BLE_sleep_clock_accuracy = STM32WBA5x_REV_ID_B_SCA_RANGE;
221// }
222// else
223// {
224// /* Revision ID not supported, default value of 500ppm applied */
225// BLE_sleep_clock_accuracy = STM32WBA5x_DEFAULT_SCA_RANGE;
226// }
227// #elif defined(STM32WBA65xx)
228// BLE_sleep_clock_accuracy = STM32WBA6x_SCA_RANGE;
229// UNUSED(RevID);
230// #else
231// UNUSED(RevID);
232// #endif /* defined(STM32WBA52xx) || defined(STM32WBA54xx) || defined(STM32WBA55xx) */
233// #else /* CFG_RADIO_LSE_SLEEP_TIMER_CUSTOM_SCA_RANGE */
234// BLE_sleep_clock_accuracy = CFG_RADIO_LSE_SLEEP_TIMER_CUSTOM_SCA_RANGE;
235// #endif /* CFG_RADIO_LSE_SLEEP_TIMER_CUSTOM_SCA_RANGE */
236// }
237// else
238// {
239// /* LSE is not the Link Layer sleep clock source, sleep clock accurcay default value is 500 ppm */
240// BLE_sleep_clock_accuracy = STM32WBA5x_DEFAULT_SCA_RANGE;
241// }
242//
243// return BLE_sleep_clock_accuracy;
244// }
245//
246// void ll_sys_sleep_clock_source_selection(void)
247// {
248// uint16_t freq_value = 0;
249// uint32_t linklayer_slp_clk_src = LL_RCC_RADIOSLEEPSOURCE_NONE;
250//
251// linklayer_slp_clk_src = LL_RCC_RADIO_GetSleepTimerClockSource();
252// switch(linklayer_slp_clk_src)
253// {
254// case LL_RCC_RADIOSLEEPSOURCE_LSE:
255// linklayer_slp_clk_src = RTC_SLPTMR;
256// break;
257//
258// case LL_RCC_RADIOSLEEPSOURCE_LSI:
259// linklayer_slp_clk_src = RCO_SLPTMR;
260// break;
261//
262// case LL_RCC_RADIOSLEEPSOURCE_HSE_DIV1000:
263// linklayer_slp_clk_src = CRYSTAL_OSCILLATOR_SLPTMR;
264// break;
265//
266// case LL_RCC_RADIOSLEEPSOURCE_NONE:
267// /* No Link Layer sleep clock source selected */
268// assert_param(0);
269// break;
270// }
271// ll_intf_cmn_le_select_slp_clk_src((uint8_t)linklayer_slp_clk_src, &freq_value);
272// }
273//
274// void ll_sys_reset(void)
275// {
276// uint8_t bsca = 0;
277// /* Link layer timings */
278// uint8_t drift_time = DRIFT_TIME_DEFAULT;
279// uint8_t exec_time = EXEC_TIME_DEFAULT;
280//
281// /* USER CODE BEGIN ll_sys_reset_0 */
282//
283// /* USER CODE END ll_sys_reset_0 */
284//
285// /* Apply the selected link layer sleep timer source */
286// ll_sys_sleep_clock_source_selection();
287//
288// /* Configure the link layer sleep clock accuracy */
289// bsca = ll_sys_BLE_sleep_clock_accuracy_selection();
290// ll_intf_le_set_sleep_clock_accuracy(bsca);
291//
292// /* Update link layer timings depending on selected configuration */
293// if(LL_RCC_RADIO_GetSleepTimerClockSource() == LL_RCC_RADIOSLEEPSOURCE_LSI)
294// {
295// drift_time += DRIFT_TIME_EXTRA_LSI2;
296// exec_time += EXEC_TIME_EXTRA_LSI2;
297// }
298// else
299// {
300// #if defined(__GNUC__) && defined(DEBUG)
301// drift_time += DRIFT_TIME_EXTRA_GCC_DEBUG;
302// exec_time += EXEC_TIME_EXTRA_GCC_DEBUG;
303// #endif
304// }
305//
306// /* USER CODE BEGIN ll_sys_reset_1 */
307//
308// /* USER CODE END ll_sys_reset_1 */
309//
310// if((drift_time != DRIFT_TIME_DEFAULT) || (exec_time != EXEC_TIME_DEFAULT))
311// {
312// ll_sys_config_BLE_schldr_timings(drift_time, exec_time);
313// }
314// /* USER CODE BEGIN ll_sys_reset_2 */
315//
316// /* USER CODE END ll_sys_reset_2 */
317// }
318// #if defined(STM32WBA52xx) || defined(STM32WBA54xx) || defined(STM32WBA55xx) || defined(STM32WBA65xx)
319// void ll_sys_apply_cte_settings(void)
320// {
321// ll_intf_apply_cte_degrad_change();
322// }
323// #endif /* defined(STM32WBA52xx) || defined(STM32WBA54xx) || defined(STM32WBA55xx) || defined(STM32WBA65xx) */
324//
325// #if (CFG_LPM_STANDBY_SUPPORTED == 0)
326// void ll_sys_get_ble_profile_statistics(uint32_t* exec_time, uint32_t* drift_time, uint32_t* average_drift_time, uint8_t reset)
327// {
328// if (reset != 0U)
329// {
330// profile_reset();
331// }
332// ll_intf_get_profile_statistics(exec_time, drift_time, average_drift_time);
333// }
334// #endif
335//