Stm32L0538-Disco Software Basic Algorythm - ST STM32F0 Series Application Note

Getting started with touch sensing control on stm32 microcontrollers
Hide thumbs Also See for STM32F0 Series:
Table of Contents

Advertisement

7.3.6
STM32L0538-DISCO software basic algorithm
Below is showed an example to show keys usage instead of slider usage.
Open your IDE and in main.c file add the following lines:
/* USER CODE BEGIN 3 */
extern TSL_TouchKey_T MyTKeys[];
static uint32_t
tsl_user_status_t status = TSL_USER_STATUS_BUSY;
status = tsl_user_Exec();
if(TSL_USER_STATUS_BUSY == status)
{
// Nothing to do
if(cnt++%50==0){
}
HAL_Delay(1);
}
else
{
HAL_GPIO_WritePin(LD_R_GPIO_Port, LD_R_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(LD_G_GPIO_Port, LD_G_Pin, GPIO_PIN_RESET);
if(MyTKeys[0].p_Data->StateId == TSL_STATEID_DETECT)
{
HAL_GPIO_WritePin(LD_R_GPIO_Port, LD_R_Pin, GPIO_PIN_SET); //11
HAL_GPIO_WritePin(LD_G_GPIO_Port, LD_G_Pin, GPIO_PIN_SET);
}
if(MyTKeys[1].p_Data->StateId == TSL_STATEID_DETECT)
{
HAL_GPIO_WritePin(LD_R_GPIO_Port, LD_R_Pin, GPIO_PIN_SET); //01
HAL_GPIO_WritePin(LD_G_GPIO_Port, LD_G_Pin, GPIO_PIN_RESET);
}
if(MyTKeys[2].p_Data->StateId == TSL_STATEID_DETECT)
{
HAL_GPIO_WritePin(LD_R_GPIO_Port, LD_R_Pin, GPIO_PIN_RESET);//01
HAL_GPIO_WritePin(LD_G_GPIO_Port, LD_G_Pin, GPIO_PIN_SET);
}
}
}
/* USER CODE BEGIN 3 */
Now the system is functional and ready to be used.
The Led is blink according to the position of the on slider.
AN5105 - Rev 1
cnt=0;
AN5105
Discovery board: STM32L0538-DISCO
//00
page 45/52

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the STM32F0 Series and is the answer not in the manual?

Questions and answers

Table of Contents