aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32-wpan/src/wba/ll_sys_if.rs
blob: 992c2a6f117b468acce060bef882c13e6c63db4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
#[allow(dead_code)]
fn test_fn() {}

// /* USER CODE BEGIN Header */
// /**
//   ******************************************************************************
//   * @file    ll_sys_if.c
//   * @author  MCD Application Team
//   * @brief   Source file for initiating system
//   ******************************************************************************
//   * @attention
//   *
//   * Copyright (c) 2022 STMicroelectronics.
//   * All rights reserved.
//   *
//   * This software is licensed under terms that can be found in the LICENSE file
//   * in the root directory of this software component.
//   * If no LICENSE file comes with this software, it is provided AS-IS.
//   *
//   ******************************************************************************
//   */
// /* USER CODE END Header */
//
// #include "main.h"
// #include "app_common.h"
// #include "app_conf.h"
// #include "log_module.h"
// #include "ll_intf_cmn.h"
// #include "ll_sys.h"
// #include "ll_sys_if.h"
// #include "stm32_rtos.h"
// #include "utilities_common.h"
// #if (USE_TEMPERATURE_BASED_RADIO_CALIBRATION == 1)
// #include "temp_measurement.h"
// #endif /* (USE_TEMPERATURE_BASED_RADIO_CALIBRATION == 1) */
// #if (CFG_LPM_STANDBY_SUPPORTED == 0)
// extern void profile_reset(void);
// #endif
// /* Private defines -----------------------------------------------------------*/
// /* Radio event scheduling method - must be set at 1 */
// #define USE_RADIO_LOW_ISR                   (1)
// #define NEXT_EVENT_SCHEDULING_FROM_ISR      (1)
//
// /* USER CODE BEGIN PD */
//
// /* USER CODE END PD */
//
// /* Private macros ------------------------------------------------------------*/
// /* USER CODE BEGIN PM */
//
// /* USER CODE END PM */
//
// /* Private constants ---------------------------------------------------------*/
// /* USER CODE BEGIN PC */
//
// /* USER CODE END PC */
//
// /* Private variables ---------------------------------------------------------*/
// /* USER CODE BEGIN PV */
//
// /* USER CODE END PV */
//
// /* Global variables ----------------------------------------------------------*/
//
// /* USER CODE BEGIN GV */
//
// /* USER CODE END GV */
//
// /* Private functions prototypes-----------------------------------------------*/
// #if (USE_TEMPERATURE_BASED_RADIO_CALIBRATION == 1)
// static void ll_sys_bg_temperature_measurement_init(void);
// #endif /* USE_TEMPERATURE_BASED_RADIO_CALIBRATION */
// static void ll_sys_sleep_clock_source_selection(void);
// static uint8_t ll_sys_BLE_sleep_clock_accuracy_selection(void);
// void ll_sys_reset(void);
//
// /* USER CODE BEGIN PFP */
//
// /* USER CODE END PFP */
//
// /* External variables --------------------------------------------------------*/
//
// /* USER CODE BEGIN EV */
//
// /* USER CODE END EV */
//
// /* Functions Definition ------------------------------------------------------*/
//
// /**
//   * @brief  Link Layer background process initialization
//   * @param  None
//   * @retval None
//   */
// void ll_sys_bg_process_init(void)
// {
//   /* Register Link Layer task */
//   UTIL_SEQ_RegTask(1U << CFG_TASK_LINK_LAYER, UTIL_SEQ_RFU, ll_sys_bg_process);
// }
//
// /**
//   * @brief  Link Layer background process next iteration scheduling
//   * @param  None
//   * @retval None
//   */
// void ll_sys_schedule_bg_process(void)
// {
//   UTIL_SEQ_SetTask(1U << CFG_TASK_LINK_LAYER, TASK_PRIO_LINK_LAYER);
// }
//
// /**
//   * @brief  Link Layer background process next iteration scheduling from ISR
//   * @param  None
//   * @retval None
//   */
// void ll_sys_schedule_bg_process_isr(void)
// {
//   UTIL_SEQ_SetTask(1U << CFG_TASK_LINK_LAYER, TASK_PRIO_LINK_LAYER);
// }
//
// /**
//   * @brief  Link Layer configuration phase before application startup.
//   * @param  None
//   * @retval None
//   */
// void ll_sys_config_params(void)
// {
// /* USER CODE BEGIN ll_sys_config_params_0 */
//
// /* USER CODE END ll_sys_config_params_0 */
//
//   /* Configure link layer behavior for low ISR use and next event scheduling method:
//    * - SW low ISR is used.
//    * - Next event is scheduled from ISR.
//    */
//   ll_intf_cmn_config_ll_ctx_params(USE_RADIO_LOW_ISR, NEXT_EVENT_SCHEDULING_FROM_ISR);
//   /* Apply the selected link layer sleep timer source */
//   ll_sys_sleep_clock_source_selection();
//
// /* USER CODE BEGIN ll_sys_config_params_1 */
//
// /* USER CODE END ll_sys_config_params_1 */
//
// #if (USE_TEMPERATURE_BASED_RADIO_CALIBRATION == 1)
//   /* Initialize link layer temperature measurement background task */
//   ll_sys_bg_temperature_measurement_init();
//
//   /* Link layer IP uses temperature based calibration instead of periodic one */
//   ll_intf_cmn_set_temperature_sensor_state();
// #endif /* USE_TEMPERATURE_BASED_RADIO_CALIBRATION */
//
//   /* Link Layer power table */
//   ll_intf_cmn_select_tx_power_table(CFG_RF_TX_POWER_TABLE_ID);
//
// #if (USE_CTE_DEGRADATION == 1u)
//   /* Apply CTE degradation */
//   ll_sys_apply_cte_settings ();
// #endif /* (USE_CTE_DEGRADATION == 1u) */
//
// /* USER CODE BEGIN ll_sys_config_params_2 */
//
// /* USER CODE END ll_sys_config_params_2 */
// }
//
// #if (USE_TEMPERATURE_BASED_RADIO_CALIBRATION == 1)
//
// /**
//   * @brief  Link Layer temperature request background process initialization
//   * @param  None
//   * @retval None
//   */
// void ll_sys_bg_temperature_measurement_init(void)
// {
//   /* Register Temperature Measurement task */
//   UTIL_SEQ_RegTask(1U << CFG_TASK_TEMP_MEAS, UTIL_SEQ_RFU, TEMPMEAS_RequestTemperatureMeasurement);
// }
//
// /**
//   * @brief  Request backroud task processing for temperature measurement
//   * @param  None
//   * @retval None
//   */
// void ll_sys_bg_temperature_measurement(void)
// {
//   static uint8_t initial_temperature_acquisition = 0;
//
//   if(initial_temperature_acquisition == 0)
//   {
//     TEMPMEAS_RequestTemperatureMeasurement();
//     initial_temperature_acquisition = 1;
//   }
//   else
//   {
//     UTIL_SEQ_SetTask(1U << CFG_TASK_TEMP_MEAS, CFG_SEQ_PRIO_0);
//   }
// }
//
// #endif /* USE_TEMPERATURE_BASED_RADIO_CALIBRATION */
//
// uint8_t ll_sys_BLE_sleep_clock_accuracy_selection(void)
// {
//   uint8_t BLE_sleep_clock_accuracy = 0;
// #if (CFG_RADIO_LSE_SLEEP_TIMER_CUSTOM_SCA_RANGE == 0)
//   uint32_t RevID = LL_DBGMCU_GetRevisionID();
// #endif
//   uint32_t linklayer_slp_clk_src = LL_RCC_RADIO_GetSleepTimerClockSource();
//
//   if(linklayer_slp_clk_src == LL_RCC_RADIOSLEEPSOURCE_LSE)
//   {
//     /* LSE selected as Link Layer sleep clock source.
//        Sleep clock accuracy is different regarding the WBA device ID and revision
//      */
// #if (CFG_RADIO_LSE_SLEEP_TIMER_CUSTOM_SCA_RANGE == 0)
// #if defined(STM32WBA52xx) || defined(STM32WBA54xx) || defined(STM32WBA55xx)
//     if(RevID == REV_ID_A)
//     {
//       BLE_sleep_clock_accuracy = STM32WBA5x_REV_ID_A_SCA_RANGE;
//     }
//     else if(RevID == REV_ID_B)
//     {
//       BLE_sleep_clock_accuracy = STM32WBA5x_REV_ID_B_SCA_RANGE;
//     }
//     else
//     {
//       /* Revision ID not supported, default value of 500ppm applied */
//       BLE_sleep_clock_accuracy = STM32WBA5x_DEFAULT_SCA_RANGE;
//     }
// #elif defined(STM32WBA65xx)
//     BLE_sleep_clock_accuracy = STM32WBA6x_SCA_RANGE;
//     UNUSED(RevID);
// #else
//     UNUSED(RevID);
// #endif /* defined(STM32WBA52xx) || defined(STM32WBA54xx) || defined(STM32WBA55xx) */
// #else /* CFG_RADIO_LSE_SLEEP_TIMER_CUSTOM_SCA_RANGE */
//     BLE_sleep_clock_accuracy = CFG_RADIO_LSE_SLEEP_TIMER_CUSTOM_SCA_RANGE;
// #endif /* CFG_RADIO_LSE_SLEEP_TIMER_CUSTOM_SCA_RANGE */
//   }
//   else
//   {
//     /* LSE is not the Link Layer sleep clock source, sleep clock accurcay default value is 500 ppm */
//     BLE_sleep_clock_accuracy = STM32WBA5x_DEFAULT_SCA_RANGE;
//   }
//
//   return BLE_sleep_clock_accuracy;
// }
//
// void ll_sys_sleep_clock_source_selection(void)
// {
//   uint16_t freq_value = 0;
//   uint32_t linklayer_slp_clk_src = LL_RCC_RADIOSLEEPSOURCE_NONE;
//
//   linklayer_slp_clk_src = LL_RCC_RADIO_GetSleepTimerClockSource();
//   switch(linklayer_slp_clk_src)
//   {
//     case LL_RCC_RADIOSLEEPSOURCE_LSE:
//       linklayer_slp_clk_src = RTC_SLPTMR;
//       break;
//
//     case LL_RCC_RADIOSLEEPSOURCE_LSI:
//       linklayer_slp_clk_src = RCO_SLPTMR;
//       break;
//
//     case LL_RCC_RADIOSLEEPSOURCE_HSE_DIV1000:
//       linklayer_slp_clk_src = CRYSTAL_OSCILLATOR_SLPTMR;
//       break;
//
//     case LL_RCC_RADIOSLEEPSOURCE_NONE:
//       /* No Link Layer sleep clock source selected */
//       assert_param(0);
//       break;
//   }
//   ll_intf_cmn_le_select_slp_clk_src((uint8_t)linklayer_slp_clk_src, &freq_value);
// }
//
// void ll_sys_reset(void)
// {
//   uint8_t bsca = 0;
//   /* Link layer timings */
//   uint8_t drift_time = DRIFT_TIME_DEFAULT;
//   uint8_t exec_time = EXEC_TIME_DEFAULT;
//
// /* USER CODE BEGIN ll_sys_reset_0 */
//
// /* USER CODE END ll_sys_reset_0 */
//
//   /* Apply the selected link layer sleep timer source */
//   ll_sys_sleep_clock_source_selection();
//
//   /* Configure the link layer sleep clock accuracy */
//   bsca = ll_sys_BLE_sleep_clock_accuracy_selection();
//   ll_intf_le_set_sleep_clock_accuracy(bsca);
//
//   /* Update link layer timings depending on selected configuration */
//   if(LL_RCC_RADIO_GetSleepTimerClockSource() == LL_RCC_RADIOSLEEPSOURCE_LSI)
//   {
//     drift_time += DRIFT_TIME_EXTRA_LSI2;
//     exec_time += EXEC_TIME_EXTRA_LSI2;
//   }
//   else
//   {
// #if defined(__GNUC__) && defined(DEBUG)
//     drift_time += DRIFT_TIME_EXTRA_GCC_DEBUG;
//     exec_time += EXEC_TIME_EXTRA_GCC_DEBUG;
// #endif
//   }
//
//   /* USER CODE BEGIN ll_sys_reset_1 */
//
//   /* USER CODE END ll_sys_reset_1 */
//
//   if((drift_time != DRIFT_TIME_DEFAULT) || (exec_time != EXEC_TIME_DEFAULT))
//   {
//     ll_sys_config_BLE_schldr_timings(drift_time, exec_time);
//   }
//   /* USER CODE BEGIN ll_sys_reset_2 */
//
//   /* USER CODE END ll_sys_reset_2 */
// }
// #if defined(STM32WBA52xx) || defined(STM32WBA54xx) || defined(STM32WBA55xx) || defined(STM32WBA65xx)
// void ll_sys_apply_cte_settings(void)
// {
//   ll_intf_apply_cte_degrad_change();
// }
// #endif /* defined(STM32WBA52xx) || defined(STM32WBA54xx) || defined(STM32WBA55xx) || defined(STM32WBA65xx) */
//
// #if (CFG_LPM_STANDBY_SUPPORTED == 0)
// void ll_sys_get_ble_profile_statistics(uint32_t* exec_time, uint32_t* drift_time, uint32_t* average_drift_time, uint8_t reset)
// {
//   if (reset != 0U)
//   {
//     profile_reset();
//   }
//   ll_intf_get_profile_statistics(exec_time, drift_time, average_drift_time);
// }
// #endif
//