@@ -31,15 +31,8 @@ LOG_MODULE_REGISTER(bt_driver);
31
31
#define DT_DRV_COMPAT st_hci_stm32wb0
32
32
33
33
/* Max HS startup time expressed in system time (1953 us / 2.4414 us) */
34
- #define MAX_HS_STARTUP_TIME 320
35
- #define BLE_WKUP_PRIO 0
36
- #define BLE_WKUP_FLAGS 0
37
34
#define BLE_TX_RX_PRIO 0
38
35
#define BLE_TX_RX_FLAGS 0
39
- #define CPU_WKUP_PRIO 1
40
- #define CPU_WKUP_FLAGS 0
41
- #define BLE_ERROR_PRIO 3
42
- #define BLE_ERROR_FLAGS 0
43
36
#define BLE_RXTX_SEQ_PRIO 3
44
37
#define BLE_RXTX_SEQ_FLAGS 0
45
38
#define PKA_PRIO 2
@@ -58,7 +51,7 @@ LOG_MODULE_REGISTER(bt_driver);
58
51
59
52
static uint32_t __noinit dyn_alloc_a [BLE_DYN_ALLOC_SIZE >> 2 ];
60
53
static uint8_t buffer_out_mem [MAX_EVENT_SIZE ];
61
- static struct k_work_delayable hal_radio_timer_work , ble_stack_work ;
54
+ static struct k_work_delayable ble_stack_work ;
62
55
63
56
static struct net_buf * get_rx (uint8_t * msg );
64
57
static PKA_HandleTypeDef hpka ;
@@ -77,6 +70,14 @@ int BLEPLAT_NvmGet(void)
77
70
return 0 ;
78
71
}
79
72
73
+ uint8_t BLEPLAT_SetRadioTimerValue (uint32_t Time , uint8_t EventType , uint8_t CalReq )
74
+ {
75
+ uint8_t retval ;
76
+
77
+ retval = HAL_RADIO_TIMER_SetRadioTimerValue (Time , EventType , CalReq );
78
+ return retval ;
79
+ }
80
+
80
81
static void blestack_process (struct k_work * work )
81
82
{
82
83
BLE_STACK_Tick ();
@@ -85,11 +86,6 @@ static void blestack_process(struct k_work *work)
85
86
}
86
87
}
87
88
88
- static void vtimer_process (struct k_work * work )
89
- {
90
- HAL_RADIO_TIMER_Tick ();
91
- }
92
-
93
89
/* "If, since the last power-on or reset, the Host has ever issued a legacy
94
90
* advertising command and then issues an extended advertising command, or
95
91
* has ever issued an extended advertising command and then issues a legacy
@@ -210,28 +206,13 @@ void send_event(uint8_t *buffer_out, uint16_t buffer_out_length, int8_t overflow
210
206
211
207
void HAL_RADIO_TIMER_TxRxWakeUpCallback (void )
212
208
{
213
- k_work_schedule (& hal_radio_timer_work , K_NO_WAIT );
214
- k_work_schedule (& ble_stack_work , K_NO_WAIT );
215
- }
216
-
217
- void HAL_RADIO_TIMER_CpuWakeUpCallback (void )
218
- {
219
- k_work_schedule (& hal_radio_timer_work , K_NO_WAIT );
220
209
k_work_schedule (& ble_stack_work , K_NO_WAIT );
221
210
}
222
211
223
212
void HAL_RADIO_TxRxCallback (uint32_t flags )
224
213
{
225
214
BLE_STACK_RadioHandler (flags );
226
215
k_work_schedule (& ble_stack_work , K_NO_WAIT );
227
- k_work_schedule (& hal_radio_timer_work , K_NO_WAIT );
228
- }
229
-
230
- ISR_DIRECT_DECLARE (RADIO_TIMER_TXRX_WKUP_IRQHandler )
231
- {
232
- HAL_RADIO_TIMER_TXRX_WKUP_IRQHandler ();
233
- ISR_DIRECT_PM (); /* PM done after servicing interrupt for best latency */
234
- return 1 ;
235
216
}
236
217
237
218
ISR_DIRECT_DECLARE (RADIO_TXRX_IRQHandler )
@@ -248,56 +229,24 @@ ISR_DIRECT_DECLARE(RADIO_TXRX_SEQ_IRQHandler)
248
229
return 1 ;
249
230
}
250
231
251
- ISR_DIRECT_DECLARE (RADIO_TIMER_CPU_WKUP_IRQHandler )
252
- {
253
- HAL_RADIO_TIMER_TimeoutCallback ();
254
- HAL_RADIO_TIMER_CpuWakeUpCallback ();
255
- ISR_DIRECT_PM (); /* PM done after servicing interrupt for best latency */
256
- return 1 ;
257
- }
258
-
259
- ISR_DIRECT_DECLARE (RADIO_TIMER_ERROR_IRQHandler )
260
- {
261
- volatile uint32_t debug_cmd ;
262
-
263
- BLUE -> DEBUGCMDREG |= 1 ;
264
- /* If the device is configured with CLK_SYS = 64MHz
265
- * and BLE clock = 16MHz, a register read is necessary
266
- * to ensure interrupt register is properly cleared
267
- * due to AHB down converter latency
268
- */
269
- debug_cmd = BLUE -> DEBUGCMDREG ;
270
- LOG_ERR ("Timer error" );
271
- ISR_DIRECT_PM (); /* PM done after servicing interrupt for best latency */
272
- return 1 ;
273
- }
274
-
275
232
/* Function called from PKA_IRQHandler() context. */
276
233
void PKAMGR_IRQCallback (void )
277
234
{
278
235
k_work_schedule (& ble_stack_work , K_NO_WAIT );
279
236
}
280
237
281
- static int _PKA_IRQHandler (void * args )
238
+ static void _PKA_IRQHandler (void * args )
282
239
{
283
240
ARG_UNUSED (args );
284
241
285
242
HAL_PKA_IRQHandler (& hpka );
286
- ISR_DIRECT_PM (); /* PM done after servicing interrupt for best latency */
287
- return 1 ;
288
243
}
289
244
290
245
static void ble_isr_installer (void )
291
246
{
292
- IRQ_DIRECT_CONNECT (RADIO_TIMER_TXRX_WKUP_IRQn , BLE_WKUP_PRIO ,
293
- RADIO_TIMER_TXRX_WKUP_IRQHandler , BLE_WKUP_FLAGS );
294
247
IRQ_DIRECT_CONNECT (RADIO_TXRX_IRQn , BLE_TX_RX_PRIO , RADIO_TXRX_IRQHandler , BLE_TX_RX_FLAGS );
295
- IRQ_DIRECT_CONNECT (RADIO_TIMER_CPU_WKUP_IRQn , CPU_WKUP_PRIO ,
296
- RADIO_TIMER_CPU_WKUP_IRQHandler , CPU_WKUP_FLAGS );
297
248
IRQ_DIRECT_CONNECT (RADIO_TXRX_SEQ_IRQn , BLE_RXTX_SEQ_PRIO , RADIO_TXRX_SEQ_IRQHandler ,
298
249
BLE_RXTX_SEQ_FLAGS );
299
- IRQ_DIRECT_CONNECT (RADIO_TIMER_ERROR_IRQn , BLE_ERROR_PRIO , RADIO_TIMER_ERROR_IRQHandler ,
300
- BLE_ERROR_FLAGS );
301
250
IRQ_CONNECT (PKA_IRQn , PKA_PRIO , _PKA_IRQHandler , NULL , PKA_FLAGS );
302
251
}
303
252
@@ -450,7 +399,6 @@ static int bt_hci_stm32wb0_send(const struct device *dev, struct net_buf *buf)
450
399
static int bt_hci_stm32wb0_open (const struct device * dev , bt_hci_recv_t recv )
451
400
{
452
401
struct hci_data * data = dev -> data ;
453
- RADIO_TIMER_InitTypeDef VTIMER_InitStruct = {MAX_HS_STARTUP_TIME , 0 , 0 };
454
402
RADIO_HandleTypeDef hradio = {0 };
455
403
BLE_STACK_InitTypeDef BLE_STACK_InitParams = {
456
404
.BLEStartRamAddress = (uint8_t * )dyn_alloc_a ,
@@ -487,8 +435,6 @@ static int bt_hci_stm32wb0_open(const struct device *dev, bt_hci_recv_t recv)
487
435
ble_isr_installer ();
488
436
hradio .Instance = RADIO ;
489
437
HAL_RADIO_Init (& hradio );
490
- HAL_RADIO_TIMER_Init (& VTIMER_InitStruct );
491
-
492
438
HW_AES_Init ();
493
439
hpka .Instance = PKA ;
494
440
HAL_PKA_Init (& hpka );
@@ -505,7 +451,6 @@ static int bt_hci_stm32wb0_open(const struct device *dev, bt_hci_recv_t recv)
505
451
aci_adv_nwk_init ();
506
452
507
453
data -> recv = recv ;
508
- k_work_init_delayable (& hal_radio_timer_work , vtimer_process );
509
454
k_work_init_delayable (& ble_stack_work , blestack_process );
510
455
k_work_schedule (& ble_stack_work , K_NO_WAIT );
511
456
0 commit comments