HardFault_Handler when trying to add touch functionality
We have a custom template project created in cubeMX for the board STM32H735-DK that was created only to have some functionalities,
now I have taken that template and added the screen functionality and now im trying to add the touch functionality,
I have copied the BSP folder to the drivers folder and copied the STM32TouchController.cpp file (i've changed it a bit because I'm not using CMSIS_v2 and the configASSERT(0) doesn't compile)
STM32TouchController.cpp:
#include <STM32TouchController.hpp>
#include <stm32h735g_discovery_ts.h>
#include <TouchGFXHAL.hpp>
void STM32TouchController::init()
{
TS_Init_t hTS;
hTS.Orientation = TS_SWAP_XY;
hTS.Accuracy = 0;
hTS.Width = touchgfx::HAL::FRAME_BUFFER_WIDTH;
hTS.Height = touchgfx::HAL::FRAME_BUFFER_HEIGHT;
BSP_TS_Init(0, &hTS);
}
bool STM32TouchController::sampleTouch(int32_t& x, int32_t& y)
{
TS_State_t TS_State = { 0 };
// This should never fail !!
//if (BSP_TS_GetState(0, &TS_State) != BSP_ERROR_NONE)
//{
//configASSERT(0);
//}
if (BSP_TS_GetState(0, &TS_State) == BSP_ERROR_NONE)
{
if (TS_State.TouchDetected)
{
x = TS_State.TouchX;
y = TS_State.TouchY;
return true;
}
}
return false;
}
Debug variables before BSP_TS_GetState(0, &TS_State); error:

My problem is that get to HardFault_Handler(void) from the file stm32h7xx_it.c just after executing the following line:
stm32h735g_discovery_ts.c:
if(Ts_Drv->GetState(Ts_CompObj[Instance], &state) < 0)
Debug variables before Ts_Drv->GetState(Ts_CompObj[Instance], &state); error:

