EasyManua.ls Logo

ST STM32F0 Series

ST STM32F0 Series
52 pages
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...
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 cnt=0;
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); //00
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
Discovery board: STM32L0538-DISCO
AN5105 - Rev 1
page 45/52

Table of Contents

Other manuals for ST STM32F0 Series

Related product manuals