picofuse

Data Structures | Typedefs | Enumerations
STMPE610

This module provides a device-level API for STMPE610 resistive touch controllers over SPI (e.g. More...

Collaboration diagram for STMPE610:

Data Structures

struct  dev_stmpe610_config_t
 Optional STMPE610 initialization options. More...
 
struct  dev_stmpe610_touch_t
 The single touch contact reported to a dev_stmpe610_callback_t - unlike a capacitive controller, STMPE610 is resistive and only ever reports one point at a time. More...
 

Typedefs

typedef struct dev_stmpe610_t dev_stmpe610_t
 Opaque STMPE610 handle.
 
typedef void(* dev_stmpe610_callback_t) (dev_stmpe610_t *stmpe610, const dev_stmpe610_touch_t *touch, void *userdata)
 Touch event callback invoked from dev_stmpe610_poll(). More...
 

Enumerations

enum  dev_stmpe610_touch_event_t { dev_stmpe610_touch_up = 0, dev_stmpe610_touch_down = 1, dev_stmpe610_touch_move = 2 }
 Touch contact state reported to a dev_stmpe610_callback_t. More...
 

Lifecycle

void dev_stmpe610_default_config (dev_stmpe610_config_t *config)
 Fill an STMPE610 config struct with safe defaults. More...
 
dev_stmpe610_tdev_stmpe610_init (hw_deviceio_t *device, hw_gpio_t *int_pin, dev_stmpe610_callback_t callback, void *userdata, const dev_stmpe610_config_t *config)
 Initialize an STMPE610 resistive touch controller over SPI. More...
 
void dev_stmpe610_deinit (dev_stmpe610_t *stmpe610)
 Deinitialize an STMPE610 controller. More...
 

Properties

bool dev_stmpe610_irq_active (const dev_stmpe610_t *stmpe610)
 Report whether the STMPE610 interrupt line is currently asserted. More...
 

Methods

void dev_stmpe610_poll (dev_stmpe610_t *stmpe610)
 Poll the controller, invoking the callback if the touch state changed. More...
 

Detailed Description

This module provides a device-level API for STMPE610 resistive touch controllers over SPI (e.g.

Adafruit's 2.8" PiTFT resistive touch display, which pairs it with an ILI9341 display controller on the same SPI bus but a separate chip-select).

Typedef Documentation

◆ dev_stmpe610_callback_t

typedef void(* dev_stmpe610_callback_t) (dev_stmpe610_t *stmpe610, const dev_stmpe610_touch_t *touch, void *userdata)

Touch event callback invoked from dev_stmpe610_poll().

Parameters
stmpe610STMPE610 handle.
touchThe touch contact that changed.
userdataUser-defined data pointer passed to dev_stmpe610_init().

Definition at line 76 of file stmpe610.h.

Enumeration Type Documentation

◆ dev_stmpe610_touch_event_t

Touch contact state reported to a dev_stmpe610_callback_t.

Enumerator
dev_stmpe610_touch_up 

Contact lifted - no longer touching.

dev_stmpe610_touch_down 

A new contact.

dev_stmpe610_touch_move 

An existing contact moved.

Definition at line 39 of file stmpe610.h.

39  {
dev_stmpe610_touch_event_t
Touch contact state reported to a dev_stmpe610_callback_t.
Definition: stmpe610.h:39
Contact lifted - no longer touching.
Definition: stmpe610.h:40
A new contact.
Definition: stmpe610.h:41
An existing contact moved.
Definition: stmpe610.h:42

Function Documentation

◆ dev_stmpe610_default_config()

void dev_stmpe610_default_config ( dev_stmpe610_config_t config)

Fill an STMPE610 config struct with safe defaults.

Parameters
configConfig structure to initialize.

◆ dev_stmpe610_deinit()

void dev_stmpe610_deinit ( dev_stmpe610_t stmpe610)

Deinitialize an STMPE610 controller.

Parameters
stmpe610STMPE610 handle.

Passing NULL is safe and is a no-op.

◆ dev_stmpe610_init()

dev_stmpe610_t* dev_stmpe610_init ( hw_deviceio_t device,
hw_gpio_t int_pin,
dev_stmpe610_callback_t  callback,
void *  userdata,
const dev_stmpe610_config_t config 
)

Initialize an STMPE610 resistive touch controller over SPI.

Parameters
deviceSPI device handle from hw_spi_init() / hw_spi_init_default() / hw_spi_init_device(), already opened on the controller's own chip-select (separate from any display sharing the same bus).
int_pinOptional interrupt GPIO handle. Pass NULL to always poll.
callbackOptional callback invoked from dev_stmpe610_poll() each time the touch state actually changes. Pass NULL if only dev_stmpe610_irq_active() or the interrupt pin's own level matters.
userdataUser-defined data pointer passed to callback.
configOptional pointer to initialization options. Pass NULL to use default values.
Returns
STMPE610 handle, or NULL on failure (including a chip ID mismatch - nothing responding correctly at the given chip-select).

◆ dev_stmpe610_irq_active()

bool dev_stmpe610_irq_active ( const dev_stmpe610_t stmpe610)

Report whether the STMPE610 interrupt line is currently asserted.

Parameters
stmpe610STMPE610 handle.
Return values
trueThe controller is signalling a pending update.
falseNo pending update is signalled, or no interrupt pin exists.

◆ dev_stmpe610_poll()

void dev_stmpe610_poll ( dev_stmpe610_t stmpe610)

Poll the controller, invoking the callback if the touch state changed.

Parameters
stmpe610STMPE610 handle.

When an interrupt pin is configured, this function skips the SPI transaction entirely when no touch is pending and the previous sample was already idle. The callback registered with dev_stmpe610_init() (if any) is invoked only when a new contact, a moved contact, or a lifted contact is actually detected - never for an unchanged, still-idle, or still-touching-with-nothing-new poll.