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
STM32BusIORegister Class Reference

Represents one addressable, read-only, MSB-first register accessed over an STM32SPIDevice, using the "set the top address bit to read" convention (Adafruit_BusIO's ADDRBIT8_HIGH_TOREAD) – e.g. the TSC2046's control byte, whose own START bit already occupies that same top bit, so the OR this class performs is a documented no-op for that specific chip, but is kept for fidelity with the reference API and in case a future chip using this same addressing convention needs the OR to actually do something. More...

#include <STM32BusIORegister.hpp>

Public Member Functions

 STM32BusIORegister (STM32SPIDevice *spiDevice, uint32_t regAddr, size_t width=1, size_t addressWidth=1)
 Constructs a view over one register.
 
uint32_t read ()
 Sends the (address-bit-set) register address, then reads back width bytes MSB-first and returns them as a single value.
 

Detailed Description

Represents one addressable, read-only, MSB-first register accessed over an STM32SPIDevice, using the "set the top address bit to read" convention (Adafruit_BusIO's ADDRBIT8_HIGH_TOREAD) – e.g. the TSC2046's control byte, whose own START bit already occupies that same top bit, so the OR this class performs is a documented no-op for that specific chip, but is kept for fidelity with the reference API and in case a future chip using this same addressing convention needs the OR to actually do something.

A new instance is meant to be constructed on the stack for each register access (matching the reference library's own usage pattern) – it is a thin, stateless-between-calls view over an existing STM32SPIDevice, not a long-lived owned resource.

Warning
Not thread-safe or ISR-safe, for the same reason as STM32SPIDevice: read() ultimately calls STM32SPIDevice::writeThenRead(), which is itself not synchronized.

Definition at line 47 of file STM32BusIORegister.hpp.

Constructor & Destructor Documentation

◆ STM32BusIORegister()

STM32BusIORegister::STM32BusIORegister ( STM32SPIDevice * spiDevice,
uint32_t regAddr,
size_t width = 1,
size_t addressWidth = 1 )

Constructs a view over one register.

Parameters
spiDeviceThe bus to read this register over. Must outlive this object.
regAddrThe register address/command byte. Only the low addressWidth bytes are used.
widthNumber of data bytes to read back, MSB-first. Currently only width == 2 is exercised (by TSC2046), but any width up to 4 is supported since read() accumulates into a uint32_t exactly like the reference library.
addressWidthNumber of address bytes to send. TSC2046 (and every other user of this addressing mode so far) uses 1.

Definition at line 14 of file STM32BusIORegister.cpp.

Member Function Documentation

◆ read()

uint32_t STM32BusIORegister::read ( )

Sends the (address-bit-set) register address, then reads back width bytes MSB-first and returns them as a single value.

Return values
Theregister value, or 0xFFFFFFFF if the underlying SPI transaction failed.

Definition at line 18 of file STM32BusIORegister.cpp.

References STM32SPIDevice::writeThenRead().


The documentation for this class was generated from the following files: