2025-05-26 10:24 AM
Hi there,
I have found an issue in code generation where there is a mismatch between a variable declaration in tsl_user.h and its definition in tsl_user.c.
The bug can be reproduced by following these steps:
Create a new project using the board selector tab and select "NUCLEO-L152RE".
Enable TS and TOUCHSENSING in the .ioc
In TS, allocate 8 of the 10 groups for one sampling cap and one pad each.
In TOUCHSENSING, set TSLPRM_TOTAL_TOUCHKEYS_B to 8 and select the corresponding keys below this parameter.
Upon code generation, the tsl_user.h header file contains:
extern CONST TSL_TouchKey_T MyTKeys[];
and the tsl_user.c source file contains:
/* TouchKeys list (ROM) */
CONST TSL_TouchKeyB_T MyTKeysB[TSLPRM_TOTAL_TOUCHKEYS_B] =
{
{ &MyTKeys_Data[0], &MyTKeys_Param[0], &MyChannels_Data[CHANNEL_0_DEST] },
{ &MyTKeys_Data[1], &MyTKeys_Param[1], &MyChannels_Data[CHANNEL_1_DEST] },
{ &MyTKeys_Data[2], &MyTKeys_Param[2], &MyChannels_Data[CHANNEL_2_DEST] },
{ &MyTKeys_Data[3], &MyTKeys_Param[3], &MyChannels_Data[CHANNEL_3_DEST] },
{ &MyTKeys_Data[4], &MyTKeys_Param[4], &MyChannels_Data[CHANNEL_4_DEST] },
{ &MyTKeys_Data[5], &MyTKeys_Param[5], &MyChannels_Data[CHANNEL_5_DEST] },
{ &MyTKeys_Data[6], &MyTKeys_Param[6], &MyChannels_Data[CHANNEL_6_DEST] },
{ &MyTKeys_Data[7], &MyTKeys_Param[7], &MyChannels_Data[CHANNEL_7_DEST] }
};
meaning that when I attempt to access MyTKeysB in main.c using something like
#include "tsl.h"
#include "tsl_user.h"
MyTKeysB[i].p_Data->StateId
the compiler returns
../Core/Src/main.c:514:13: error: 'MyTKeysB' undeclared (first use in this function); did you mean 'MyTKeys'?
514 | if (MyTKeysB[i].p_Data->StateId == TSL_STATEID_DETECT ||
| ^~~~~~~~
| MyTKeys
../Core/Src/main.c:514:13: note: each undeclared identifier is reported only once for each function it appears in
make: *** [Core/Src/subdir.mk:40: Core/Src/main.o] Error 1
make: *** Waiting for unfinished jobs....
However, if I then manually change the line in tsl_user.h to
extern CONST TSL_TouchKeyB_T MyTKeysB[];
the code runs as expected and the basic touch keys work properly.
I don't have another machine to try this on right now, but I've been able to reproduce this issue on demand on my machine. Perhaps someone can confirm.
Thanks!
2025-05-26 1:13 PM
Hello @h7-v and welcome to the ST Community.
Thank you so much for reporting this. Could you please upload your .ioc file here for test.
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-05-26 4:12 PM
Hi STTwo,
Thanks! Here's a fresh project .ioc using default parameters when asked on project creation. It has only two basic touch keys configured but the code generation exhibits the same behaviour between the tsl_user header and source files.
Let me know if you need anything else.
Cheers!