H753_CPP_SPI_Resistive_Touch_Screen_Controller 1.0
STM32H753 SPI resistive touchscreen (Adafruit 333 overlay + 5767 TSC2046 controller) driver and tutorial
Loading...
Searching...
No Matches
touchSelfTest.h File Reference

Startup self-test for the TSC2046 touch controller. More...

#include "main.h"
#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Classes

struct  touchSelfTestReport_t
 Result of the most recent touchSelfTestRunAll(). More...
 

Enumerations

enum  touchSelfTestId_t { TOUCH_SELFTEST_NONE = 0 , TOUCH_SELFTEST_SPI_TRANSFER , TOUCH_SELFTEST_FRAMING , TOUCH_SELFTEST_IDLE }
 Self-test identifiers. More...
 

Functions

const touchSelfTestReport_ttouchSelfTestRunAll (void)
 Runs every self-test in order, stopping at the first failure, and prints progress and a PASS/FAIL verdict to stdout. Requires initTSC2046() to have run.
 
const touchSelfTestReport_ttouchSelfTestGetReport (void)
 

Detailed Description

Startup self-test for the TSC2046 touch controller.

Startup self-test for the TSC2046 touch controller, run once at boot before the touch loop starts. Structure follows this site's other validation suites (test-ID and status enums, one persistent report struct, RunAll()), scaled to what can be checked on a touch controller. Each test targets a failure that actually occurred while bringing this hardware up:

  1. SPI transfer – a raw HAL transaction to the chip completes without error.
  2. Framing – the response has the TSC2046's fixed shape (leading null bit, three trailing zero bits) and the four channels are not all identical; catches a floating/stuck MISO line (unpowered chip, loose wire).
  3. Idle – with the panel untouched, no sample looks like a touch. Catches a pressed, shorted or mis-seated panel, and detection logic that mistakes idle junk for touches.
Note
Deliberately NOT included: a check of the TSC2046's built-in temperature sensor (TSC2046::readTemperatureC()). It would prove the chip is powered without needing the panel, but the on-die temperature reading is not accurate – it comes from a two-current diode measurement that depends on the reference voltage and a datasheet approximation, and has never been checked against a real thermometer on this hardware – so a pass/fail limit on it would risk failing a healthy board. The framing test already covers "is the chip answering". The driver function remains available for anyone who wants a rough chip temperature, but do not treat its value as a calibrated measurement.

The suite is non-destructive: it only reads. Keep hands off the panel while it runs (about a third of a second).

Created on: Sep 19, 2026 Author: johng

Definition in file touchSelfTest.h.

Enumeration Type Documentation

◆ touchSelfTestId_t

Self-test identifiers.

Definition at line 53 of file touchSelfTest.h.

Function Documentation

◆ touchSelfTestGetReport()

const touchSelfTestReport_t * touchSelfTestGetReport ( void )
Return values
Themost recent report, without re-running any test.

◆ touchSelfTestRunAll()

const touchSelfTestReport_t * touchSelfTestRunAll ( void )

Runs every self-test in order, stopping at the first failure, and prints progress and a PASS/FAIL verdict to stdout. Requires initTSC2046() to have run.

Return values
Pointerto a persistent report describing the outcome.

Referenced by main().