picofuse

ft6236.h
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include <picofuse/hid/event.h>
13 #include <picofuse/hw.h>
14 #include <stdbool.h>
15 #include <stdint.h>
16 
18 // TYPES
19 
24 typedef struct dev_ft6236_t dev_ft6236_t;
25 
31 #define DEV_FT6236_I2C_ADDR_DEFAULT 0x38u
32 
37 #define DEV_FT6236_MAX_POINTS 2u
38 
43 typedef struct {
46  hw_gpio_t *reset_pin;
51 
67 typedef void (*dev_ft6236_callback_t)(dev_ft6236_t *ft6236,
68  const hid_touch_t *touch, void *userdata);
69 
71 // LIFECYCLE
72 
82 
111  const dev_ft6236_config_t *config);
112 
120 void dev_ft6236_deinit(dev_ft6236_t *ft6236);
121 
136  dev_ft6236_callback_t callback, void *userdata);
137 
140 // PROPERTIES
142 
153 bool dev_ft6236_irq_active(const dev_ft6236_t *ft6236);
154 
169 bool dev_ft6236_has_interrupt_pin(const dev_ft6236_t *ft6236);
170 
173 // METHODS
175 
213 void dev_ft6236_poll(dev_ft6236_t *ft6236);
214 
217 // HID
219 
276  uint32_t polling_interval_ms,
277  void *userdata);
278 
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
struct dev_ft6236_t dev_ft6236_t
Opaque FT6236 handle.
Definition: ft6236.h:24
void dev_ft6236_poll(dev_ft6236_t *ft6236)
Poll the controller, invoking the callback for each touch slot whose state actually changed...
Touch-oriented HID event payload.
Definition: event.h:80
dev_ft6236_t * dev_ft6236_init(hw_deviceio_t *device, const dev_ft6236_config_t *config)
Initialize an FT6236-compatible touch controller over I2C.
Hardware abstraction headers for on-board peripherals.
bool dev_ft6236_irq_active(const dev_ft6236_t *ft6236)
Report whether the FT6236 interrupt line is currently asserted.
hw_gpio_t * int_pin
Optional interrupt GPIO handle.
Definition: ft6236.h:45
bool dev_ft6236_has_interrupt_pin(const dev_ft6236_t *ft6236)
Report whether an interrupt pin was configured for this handle.
struct hid_device_t hid_device_t
HID child-device descriptor tracked by a HID instance.
Definition: device.h:46
struct hid_t hid_t
Opaque HID instance handle.
Definition: device.h:40
bool irq_active_low
True when the interrupt pin is active low.
Definition: ft6236.h:44
void dev_ft6236_default_config(dev_ft6236_config_t *config)
Fill an FT6236 config struct with safe defaults.
void(* dev_ft6236_callback_t)(dev_ft6236_t *ft6236, const hid_touch_t *touch, void *userdata)
Touch event callback invoked from dev_ft6236_poll().
Definition: ft6236.h:67
Optional FT6236 initialization options.
Definition: ft6236.h:43
hid_device_t * dev_ft6236_register_hid(hid_t *instance, dev_ft6236_t *ft6236, uint32_t polling_interval_ms, void *userdata)
Register an FT6236 controller as a HID touchscreen source.
void dev_ft6236_deinit(dev_ft6236_t *ft6236)
Deinitialize an FT6236 controller.
void dev_ft6236_set_callback(dev_ft6236_t *ft6236, dev_ft6236_callback_t callback, void *userdata)
Set (or replace) the callback invoked from dev_ft6236_poll().