@@ -30,16 +30,8 @@ LOG_MODULE_REGISTER(bt_driver);
30
30
31
31
#define DT_DRV_COMPAT st_hci_stm32wb0
32
32
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
33
#define BLE_TX_RX_PRIO 0
38
34
#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
35
#define BLE_RXTX_SEQ_PRIO 3
44
36
#define BLE_RXTX_SEQ_FLAGS 0
45
37
#define PKA_PRIO 2
@@ -58,7 +50,7 @@ LOG_MODULE_REGISTER(bt_driver);
58
50
59
51
static uint32_t __noinit dyn_alloc_a [BLE_DYN_ALLOC_SIZE >> 2 ];
60
52
static uint8_t buffer_out_mem [MAX_EVENT_SIZE ];
61
- static struct k_work_delayable hal_radio_timer_work , ble_stack_work ;
53
+ static struct k_work_delayable ble_stack_work ;
62
54
63
55
static struct net_buf * get_rx (uint8_t * msg );
64
56
static PKA_HandleTypeDef hpka ;
@@ -77,6 +69,14 @@ int BLEPLAT_NvmGet(void)
77
69
return 0 ;
78
70
}
79
71
72
+ uint8_t BLEPLAT_SetRadioTimerValue (uint32_t Time , uint8_t EventType , uint8_t CalReq )
73
+ {
74
+ uint8_t retval ;
75
+
76
+ retval = HAL_RADIO_TIMER_SetRadioTimerValue (Time , EventType , CalReq );
77
+ return retval ;
78
+ }
79
+
80
80
static void blestack_process (struct k_work * work )
81
81
{
82
82
BLE_STACK_Tick ();
@@ -85,11 +85,6 @@ static void blestack_process(struct k_work *work)
85
85
}
86
86
}
87
87
88
- static void vtimer_process (struct k_work * work )
89
- {
90
- HAL_RADIO_TIMER_Tick ();
91
- }
92
-
93
88
/* "If, since the last power-on or reset, the Host has ever issued a legacy
94
89
* advertising command and then issues an extended advertising command, or
95
90
* has ever issued an extended advertising command and then issues a legacy
@@ -210,28 +205,13 @@ void send_event(uint8_t *buffer_out, uint16_t buffer_out_length, int8_t overflow
210
205
211
206
void HAL_RADIO_TIMER_TxRxWakeUpCallback (void )
212
207
{
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
208
k_work_schedule (& ble_stack_work , K_NO_WAIT );
221
209
}
222
210
223
211
void HAL_RADIO_TxRxCallback (uint32_t flags )
224
212
{
225
213
BLE_STACK_RadioHandler (flags );
226
214
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
215
}
236
216
237
217
ISR_DIRECT_DECLARE (RADIO_TXRX_IRQHandler )
@@ -248,56 +228,24 @@ ISR_DIRECT_DECLARE(RADIO_TXRX_SEQ_IRQHandler)
248
228
return 1 ;
249
229
}
250
230
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
231
/* Function called from PKA_IRQHandler() context. */
276
232
void PKAMGR_IRQCallback (void )
277
233
{
278
234
k_work_schedule (& ble_stack_work , K_NO_WAIT );
279
235
}
280
236
281
- static int _PKA_IRQHandler (void * args )
237
+ static void _PKA_IRQHandler (void * args )
282
238
{
283
239
ARG_UNUSED (args );
284
240
285
241
HAL_PKA_IRQHandler (& hpka );
286
- ISR_DIRECT_PM (); /* PM done after servicing interrupt for best latency */
287
- return 1 ;
288
242
}
289
243
290
244
static void ble_isr_installer (void )
291
245
{
292
- IRQ_DIRECT_CONNECT (RADIO_TIMER_TXRX_WKUP_IRQn , BLE_WKUP_PRIO ,
293
- RADIO_TIMER_TXRX_WKUP_IRQHandler , BLE_WKUP_FLAGS );
294
246
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
247
IRQ_DIRECT_CONNECT (RADIO_TXRX_SEQ_IRQn , BLE_RXTX_SEQ_PRIO , RADIO_TXRX_SEQ_IRQHandler ,
298
248
BLE_RXTX_SEQ_FLAGS );
299
- IRQ_DIRECT_CONNECT (RADIO_TIMER_ERROR_IRQn , BLE_ERROR_PRIO , RADIO_TIMER_ERROR_IRQHandler ,
300
- BLE_ERROR_FLAGS );
301
249
IRQ_CONNECT (PKA_IRQn , PKA_PRIO , _PKA_IRQHandler , NULL , PKA_FLAGS );
302
250
}
303
251
@@ -449,7 +397,6 @@ static int bt_hci_stm32wb0_send(const struct device *dev, struct net_buf *buf)
449
397
static int bt_hci_stm32wb0_open (const struct device * dev , bt_hci_recv_t recv )
450
398
{
451
399
struct hci_data * data = dev -> data ;
452
- RADIO_TIMER_InitTypeDef VTIMER_InitStruct = {MAX_HS_STARTUP_TIME , 0 , 0 };
453
400
RADIO_HandleTypeDef hradio = {0 };
454
401
BLE_STACK_InitTypeDef BLE_STACK_InitParams = {
455
402
.BLEStartRamAddress = (uint8_t * )dyn_alloc_a ,
@@ -486,8 +433,6 @@ static int bt_hci_stm32wb0_open(const struct device *dev, bt_hci_recv_t recv)
486
433
ble_isr_installer ();
487
434
hradio .Instance = RADIO ;
488
435
HAL_RADIO_Init (& hradio );
489
- HAL_RADIO_TIMER_Init (& VTIMER_InitStruct );
490
-
491
436
HW_AES_Init ();
492
437
hpka .Instance = PKA ;
493
438
HAL_PKA_Init (& hpka );
@@ -504,7 +449,6 @@ static int bt_hci_stm32wb0_open(const struct device *dev, bt_hci_recv_t recv)
504
449
aci_adv_nwk_init ();
505
450
506
451
data -> recv = recv ;
507
- k_work_init_delayable (& hal_radio_timer_work , vtimer_process );
508
452
k_work_init_delayable (& ble_stack_work , blestack_process );
509
453
k_work_schedule (& ble_stack_work , K_NO_WAIT );
510
454
0 commit comments