EasyManua.ls Logo

TELINK SEMICONDUCTOR TLSR8232 - LED Management; LED Task Related Functions; LED Task Configuration and Management; LED Event Definition

Default Icon
211 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1 165 Ver.1.0.0
8. LED Management
8.1 LED Task Related Functions
Source code about LED management is available in vendor/common/blt_led.c of 5316
BLE SDK for user reference. Users can directly include the “vendor/common/blt_led.h
into their C files.
The following three functions need to be called:
void device_led_init(u32 gpio,u8 polarity);
int device_led_setup(led_cfg_t led_cfg);
static inline void device_led_process(void);
In initialization, the “device_led_init(u32 gpio, u8 polarity)” is used to set current GPIO
and polarity corresponding to LED. If “polarity” is set as 1, it indicates LED will be turned
on when GPIO outputs high level; if “polarity” is set as 0, it indicates LED will be turned
on when GPIO outputs low level.
The “device_led_process” function is added in UI Entry of mainloop. It’s used to check
whether LED task is not finished (DEVICE_LED_BUSY). If yes, MCU will carry out
corresponding LED task operation.
8.2 LED Task Configuration and Management
8.2.1 LED Event Definition
The following structure is used to define a LED event.
typedef struct{
unsigned short onTime_ms;
unsigned short offTime_ms;
unsigned char repeatCount; //0xff special for long
on(offTime_ms=0)/long off(onTime_ms=0)
unsigned char priority; //0x00 < 0x01 < 0x02 < 0x04 < 0x08 <
0x10 < 0x20 < 0x40 < 0x80
} led_cfg_t;
The unsigned short int type “onTime_ms” and “offTime_ms” specify light on and off time
(unit: ms) for current LED event, respectively. The two variables can reach the maximum
value of 65535.
The unsigned char type repeatCount” specifies blinking times (i.e. repeat times for light
on and off action specified by the “onTime_ms” and “offTime_ms”). The variable can
reach the maximum value of 255.
The “priority” specifies the priority level for current LED event.
To define a LED event when the LED light stays on/off, set the repeatCount” as
255(0xff), set “onTime_ms”/“offTime_ms” as 0 or non-zero correspondingly.
LED event examples:

Table of Contents