picofuse

stmpe610.h
Go to the documentation of this file.
1 
12 #pragma once
13 
14 #include <picofuse/hw.h>
15 #include <stdbool.h>
16 #include <stdint.h>
17 
19 // TYPES
20 
26 
31 typedef struct {
34 
39 typedef enum {
44 
62 typedef struct {
64  uint16_t x;
65  uint16_t y;
66  uint8_t z;
68 
76 typedef void (*dev_stmpe610_callback_t)(dev_stmpe610_t *stmpe610,
77  const dev_stmpe610_touch_t *touch,
78  void *userdata);
79 
81 // LIFECYCLE
82 
92 
110  dev_stmpe610_callback_t callback,
111  void *userdata,
112  const dev_stmpe610_config_t *config);
113 
121 void dev_stmpe610_deinit(dev_stmpe610_t *stmpe610);
122 
125 // PROPERTIES
127 
138 bool dev_stmpe610_irq_active(const dev_stmpe610_t *stmpe610);
139 
142 // METHODS
144 
161 void dev_stmpe610_poll(dev_stmpe610_t *stmpe610);
162 
void dev_stmpe610_default_config(dev_stmpe610_config_t *config)
Fill an STMPE610 config struct with safe defaults.
dev_stmpe610_touch_event_t
Touch contact state reported to a dev_stmpe610_callback_t.
Definition: stmpe610.h:39
struct hw_deviceio_t hw_deviceio_t
Opaque device I/O handle.
Definition: deviceio.h:48
struct hw_gpio_t hw_gpio_t
GPIO logical pin structure.
Definition: gpio.h:50
uint16_t x
Raw X ADC reading - see struct doc.
Definition: stmpe610.h:64
Contact lifted - no longer touching.
Definition: stmpe610.h:40
void dev_stmpe610_poll(dev_stmpe610_t *stmpe610)
Poll the controller, invoking the callback if the touch state changed.
A new contact.
Definition: stmpe610.h:41
struct dev_stmpe610_t dev_stmpe610_t
Opaque STMPE610 handle.
Definition: stmpe610.h:25
uint8_t z
Raw pressure ADC reading - see struct doc.
Definition: stmpe610.h:66
An existing contact moved.
Definition: stmpe610.h:42
Optional STMPE610 initialization options.
Definition: stmpe610.h:31
bool irq_active_low
True when the interrupt pin is active low.
Definition: stmpe610.h:32
Hardware abstraction headers for on-board peripherals.
The single touch contact reported to a dev_stmpe610_callback_t - unlike a capacitive controller...
Definition: stmpe610.h:62
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().
Definition: stmpe610.h:76
dev_stmpe610_touch_event_t event
Contact state for this sample.
Definition: stmpe610.h:63
uint16_t y
Raw Y ADC reading - see struct doc.
Definition: stmpe610.h:65
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.
bool dev_stmpe610_irq_active(const dev_stmpe610_t *stmpe610)
Report whether the STMPE610 interrupt line is currently asserted.
void dev_stmpe610_deinit(dev_stmpe610_t *stmpe610)
Deinitialize an STMPE610 controller.