|
H753_CPP_SPI_Resistive_Touch_Screen_Controller 1.0
STM32H753 SPI resistive touchscreen (Adafruit 333 overlay + 5767 TSC2046 controller) driver and tutorial
|
Small STM32 HAL (C++) helpers for talking to SPI devices: STM32SPIDevice wraps one SPI_HandleTypeDef plus a chip-select pin with automatic CS bracketing, and STM32BusIORegister reads a single addressable register on top of it.
Modeled on the hardware-SPI subset of Adafruit's Adafruit_BusIO as a design reference. It is an independent STM32 HAL implementation, not a direct port. Software (bit-banged) SPI, I2C, and register writes are not included.
main.h providing the HAL headers (CubeMX/CubeIDE generated project)Cloning a project that already includes it:
If you forgot the flag, the STM32BusIO/ folder is empty; run git submodule update --init to fill it.
Then in STM32CubeIDE, add the folder as a source location and add ../STM32BusIO to the include paths for both C and C++ (Project > Properties > C/C++ Build > Settings).
main.cThe classes in this library are C++, but STM32CubeIDE generates main.c as plain C, and you should not rename it to main.cpp (CubeMX regenerates main.c, not main.cpp). Keep main.c as C and reach the library through a small C-callable wrapper:
extern "C" in a header..cpp file that creates the STM32SPIDevice object (or the driver built on it, such as STM32_TSC2046) with new after MX_SPIx_Init() has run (not as a global, which would construct too early).main.c, and put those calls only inside CubeMX's "safe areas": the code between the /* USER CODE BEGIN ... */ and /* USER CODE END ... */ markers. CubeMX overwrites everything outside those markers whenever it regenerates main.c.The tutorial STM32 C++ Code Integration with STM32CubeIDE walks through this step by step.
Not thread-safe or ISR-safe. Each transaction asserts CS, transfers, then deasserts with no locking. Use from a single context, or add your own mutex/critical section.
The API docs are generated with Doxygen and are not committed to the repo. From this folder, run:
The HTML is written to docs/ (open docs/html/index.html). Graphviz is optional, for call graphs; see the commented HAVE_DOT lines in Doxyfile.
MIT. Portions of the API shape are derived from Adafruit_BusIO, Copyright (c) 2017 Adafruit Industries (MIT). See LICENSE.