
Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1
166
Ver.1.0.0
1) Blink for 3s with the frequency of 1Hz: turn on for 500ms, turn off for 500ms, and
repeat for 3 times.
led_cfg_t led_event1 = {500,
500 , 3, 0x00, };
2) Blink for 50s with the frequency of 4Hz: turn on for 125ms, turn off for 125ms, and
repeat for 200 times.
led_cfg_t led_event2 = {125, 125 , 200, 0x00, };
3) Always on: onTime_ms is non-zero, offTime_ms is zero, and repeatCount is 0xff.
led_cfg_t led_event3 = {100,
0 ,
0xff, 0x00, };
4) Always off: onTime_ms is zero, offTime_ms is non-zero, and repeatCount is 0xff.
led_cfg_t led_event4 = {0, 100, 0xff, 0x00, };
5) Turn on for 3s, and then turn off: onTime_ms is 1000, offTime_ms is 0, and
repeatCount is 0x3.
led_cfg_t led_event5 = {1000, 0,
3,
0x00, };
The
“device_led_setup” can be invoked to deliver a led_event to LED task management.
device_led_setup(led_event1);
8.2.2 LED Event Priority
Users can define multiple LED events in SDK, however, only a LED event is allowed to
be executed at the same time. No task list is set for the simple LED management: When
LED is idle, LED will accept any LED event delivered by invoking the “device_led_setup”.
When LED is busy with a LED event (old LED event), if another event (new LED event)
comes, MCU will compare priority level of the two LED events; if the new LED event has
higher priority level, the old LED event will be discarded and MCU starts to execute the
new LED event; if the new LED event has the same or lower priority level, MCU
continues executing the old LED event, while the new LED event will be completely
discarded, rather than buffered.
By defining LED events with different priority levels, user can realize corresponding LED
indicating effect.
Since inquiry scheme is used for LED management, MCU should not enter long suspend
(e.g. 10ms * 50 = 500ms) with latency enabled and LED task ongoing
(DEVICE_LED_BUSY); otherwise LED event with small onTime_ms value (e.g. 250ms)
won’t be responded in time, thus LED blinking effect will be influenced.
#define DEVICE_LED_BUSY (device_led.repeatCount)
The corresponding processing needs to be added in blt_pm_proc, as shown below:
user_task_flg = scan_pin_need || key_not_released || DEVICE_LED_BUSY;
if(user_task_flg){
bls_pm_setManualLatency(0); //Manually disable latency