Loading...
Searching...
No Matches
stmpe811.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Inria
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
19
20#include "saul.h"
21#include "periph/gpio.h"
22#if IS_USED(MODULE_STMPE811_SPI)
23#include "periph/spi.h"
24#else
25#include "periph/i2c.h"
26#endif
27
28#ifdef MODULE_TOUCH_DEV
29#include "touch_dev.h"
30#endif
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
43
63
67typedef struct {
68 uint16_t x;
69 uint16_t y;
71
77typedef void (*stmpe811_event_cb_t)(void *arg);
78
86typedef struct {
87#if IS_USED(MODULE_STMPE811_SPI)
88 /* SPI configuration */
89 spi_t spi;
90 spi_mode_t mode;
91 spi_clk_t clk;
92 gpio_t cs;
93#else
94 /* I2C details */
96 uint8_t addr;
97#endif
98 gpio_t int_pin;
99 uint16_t xmax;
100 uint16_t ymax;
104
108typedef struct {
109#ifdef MODULE_TOUCH_DEV
110 touch_dev_t *dev;
111#endif
114 void *cb_arg;
115 uint16_t prev_x;
116 uint16_t prev_y;
117} stmpe811_t;
118
133 stmpe811_event_cb_t cb, void *arg);
134
145
156
157#ifdef __cplusplus
158}
159#endif
160
spi_clk_t
Definition periph_cpu.h:348
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
Low-level GPIO peripheral driver interface definitions.
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:155
void(* stmpe811_event_cb_t)(void *arg)
Signature of touch event callback triggered from interrupt.
Definition stmpe811.h:77
int stmpe811_read_touch_position(stmpe811_t *dev, stmpe811_touch_position_t *position)
Read the touch position.
int stmpe811_read_touch_state(const stmpe811_t *dev, stmpe811_touch_state_t *state)
Read the touch state (pressed or released)
stmpe811_touch_state_t
Touch state enum.
Definition stmpe811.h:39
int stmpe811_init(stmpe811_t *dev, const stmpe811_params_t *params, stmpe811_event_cb_t cb, void *arg)
Initialize the given STMPE811 device.
stmpe811_touch_conv_t
Touch screen coordinate conversions.
Definition stmpe811.h:57
@ STMPE811_TOUCH_STATE_RELEASED
Touchscreen is released.
Definition stmpe811.h:41
@ STMPE811_TOUCH_STATE_PRESSED
Touchscreen is pressed.
Definition stmpe811.h:40
@ STMPE811_MIRROR_X
Mirror X, applied after optional swapping.
Definition stmpe811.h:59
@ STMPE811_NO_CONV
No conversion.
Definition stmpe811.h:58
@ STMPE811_SWAP_XY
Swap XY, applied before optional mirroring.
Definition stmpe811.h:61
@ STMPE811_MIRROR_Y
Mirror Y, applied after optional swapping.
Definition stmpe811.h:60
struct touch_dev touch_dev_t
Forward declaration for touch device struct.
Definition touch_dev.h:35
Low-level I2C peripheral driver interface definition.
spi_mode_t
Support SPI modes.
Definition periph_cpu.h:39
Low-level SPI peripheral driver interface definition.
Device initialization parameters.
Definition stmpe811.h:86
gpio_t int_pin
Touch screen interrupt pin.
Definition stmpe811.h:98
uint16_t ymax
Touch screen max Y position.
Definition stmpe811.h:100
stmpe811_touch_conv_t xyconv
Touch screen coordinates conversion, swapping is applied before mirroring.
Definition stmpe811.h:101
uint8_t addr
Device I2C address.
Definition stmpe811.h:96
i2c_t i2c
I2C device which is used.
Definition stmpe811.h:95
uint16_t xmax
Touch screen max X position.
Definition stmpe811.h:99
Device descriptor for the STMPE811 sensor.
Definition stmpe811.h:108
stmpe811_event_cb_t cb
Configured IRQ event callback.
Definition stmpe811.h:113
uint16_t prev_x
Previous X coordinate.
Definition stmpe811.h:115
uint16_t prev_y
Previous Y coordinate.
Definition stmpe811.h:116
void * cb_arg
Extra argument for the callback.
Definition stmpe811.h:114
stmpe811_params_t params
Device parameters.
Definition stmpe811.h:112
Touch position structure.
Definition stmpe811.h:67
uint16_t x
X position.
Definition stmpe811.h:68
uint16_t y
Y position.
Definition stmpe811.h:69