
Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1
171
Ver.1.0.0
9.3 Add Timer Task
The API below is used to add timer task.
typedef
int
(*
blt_timer_callback_t
)(
void
);
int
blt_soft_timer_add
(
blt_timer_callback_t
func,
u32
interval_us);
“func”: timer task function;“interval_us”: timing value (unit: us). The int-type return value
corresponds to three processing methods:
1) If the return value is less than 0, this executed task will be automatically deleted.
2) If the return value is 0, the old interval_us will be used as timing cycle.
3) If the return value is more than 0, this return value will be used as the new timing
cycle (unit: us).
As shown in the implementation code, if timer number exceeds the maximum value, the
adding operation will fail. Whenever a new timer task is added, re-ordering must be
implemented to ensure timer tasks are time-ordered, while the index corresponding to the
nearest timer task should be 0.
9.4 Delete Timer Task
As introduced above, timer task will be automatically deleted when the return value is
less than 0. Except for this case, the API below can be called to specify the timer task to
be deleted.
int
blt_soft_timer_delete
(
blt_timer_callback_t
func);
9.5 Demo
For Demo
code of blt soft timer, please refer to “TEST_USER_BLT_SOFT_TIMER” in
5316 feature.
int
gpio_test0
(
void
)
{