void os_cputime_timer_init(struct hal_timer *timer, hal_timer_cb fp, void *arg)
Initializes a cputime timer, indicated by timer
, with a pointer to a callback function to call when the timer expires. When an optional opaque argument is specified, it is passed to the timer callback function.
The callback function has the following prototype:
void hal_timer_cb(void *arg)
Arguments | Description |
---|---|
timer | Pointer to the hal_timer to initialize. This value cannot be NULL. |
fp | Pointer to the callback function to call when the timer expires. This value cannot be NULL. |
arg | Optional opaque argument to pass to the hal timer callback function. |
N/A
Example of ble_ll setting up a response timer:
ble_ll_wfr_timer_exp(void *arg) { int rx_start; uint8_t lls; ... /* If we have started a reception, there is nothing to do here */ if (!rx_start) { switch (lls) { case BLE_LL_STATE_ADV: ble_ll_adv_wfr_timer_exp(); break; ... /* Do nothing here. Fall through intentional */ case BLE_LL_STATE_INITIATING: default: break; } } } void ble_ll_init(void) { ... os_cputime_timer_init(&g_ble_ll_data.ll_wfr_timer, ble_ll_wfr_timer_exp, NULL); ... }