picofuse

stmpe610.h
Go to the documentation of this file.
1 
12 #pragma once
13 
14 #include <picofuse/hid/event.h>
15 #include <picofuse/hw.h>
16 #include <stdbool.h>
17 #include <stdint.h>
18 
20 // TYPES
21 
27 
32 typedef struct {
37 
64 typedef void (*dev_stmpe610_callback_t)(dev_stmpe610_t *stmpe610,
65  const hid_touch_t *touch,
66  void *userdata);
67 
69 // LIFECYCLE
70 
80 
97  const dev_stmpe610_config_t *config);
98 
106 void dev_stmpe610_deinit(dev_stmpe610_t *stmpe610);
107 
121  dev_stmpe610_callback_t callback,
122  void *userdata);
123 
126 // PROPERTIES
128 
139 bool dev_stmpe610_irq_active(const dev_stmpe610_t *stmpe610);
140 
143 // METHODS
145 
168 void dev_stmpe610_poll(dev_stmpe610_t *stmpe610);
169 
172 // HID
174 
214  dev_stmpe610_t *stmpe610,
215  uint32_t polling_interval_ms,
216  void *userdata);
217 
void dev_stmpe610_default_config(dev_stmpe610_config_t *config)
Fill an STMPE610 config struct with safe defaults.
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
void dev_stmpe610_poll(dev_stmpe610_t *stmpe610)
Poll the controller, invoking the callback if the touch state changed.
struct dev_stmpe610_t dev_stmpe610_t
Opaque STMPE610 handle.
Definition: stmpe610.h:26
Optional STMPE610 initialization options.
Definition: stmpe610.h:32
Touch-oriented HID event payload.
Definition: event.h:80
bool irq_active_low
True when the interrupt pin is active low.
Definition: stmpe610.h:33
Hardware abstraction headers for on-board peripherals.
struct hid_device_t hid_device_t
HID child-device descriptor tracked by a HID instance.
Definition: device.h:46
void dev_stmpe610_set_callback(dev_stmpe610_t *stmpe610, dev_stmpe610_callback_t callback, void *userdata)
Set (or replace) the callback invoked from dev_stmpe610_poll().
dev_stmpe610_t * dev_stmpe610_init(hw_deviceio_t *device, 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.
struct hid_t hid_t
Opaque HID instance handle.
Definition: device.h:40
void dev_stmpe610_deinit(dev_stmpe610_t *stmpe610)
Deinitialize an STMPE610 controller.
void(* dev_stmpe610_callback_t)(dev_stmpe610_t *stmpe610, const hid_touch_t *touch, void *userdata)
Touch event callback invoked from dev_stmpe610_poll().
Definition: stmpe610.h:64
hid_device_t * dev_stmpe610_register_hid(hid_t *instance, dev_stmpe610_t *stmpe610, uint32_t polling_interval_ms, void *userdata)
Register an STMPE610 controller as a HID touchscreen source.
hw_gpio_t * int_pin
Optional interrupt GPIO handle.
Definition: stmpe610.h:34