stmpe811.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Inria
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
21 #ifndef STMPE811_H
22 #define STMPE811_H
23 
24 #include "saul.h"
25 #include "periph/gpio.h"
26 #include "periph/i2c.h"
27 
28 #ifdef MODULE_TOUCH_DEV
29 #include "touch_dev.h"
30 #endif
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
39 enum {
44 };
45 
49 typedef enum {
53 
57 typedef struct {
58  uint16_t x;
59  uint16_t y;
61 
67 typedef void (*touch_event_cb_t)(void *arg);
68 
72 typedef struct {
74  uint8_t addr;
75  gpio_t int_pin;
76  uint16_t xmax;
77  uint16_t ymax;
79 
83 typedef struct {
84 #ifdef MODULE_TOUCH_DEV
85  touch_dev_t *dev;
86 #endif
88  uint16_t prev_x;
89  uint16_t prev_y;
90 } stmpe811_t;
91 
105 int stmpe811_init(stmpe811_t *dev, const stmpe811_params_t * params,
106  touch_event_cb_t cb, void *arg);
107 
118 
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif /* STMPE811_H */
135 
stmpe811_params_t::i2c
i2c_t i2c
I2C device which is used.
Definition: stmpe811.h:73
stmpe811_t
Device descriptor for the STMPE811 sensor.
Definition: stmpe811.h:83
stmpe811_params_t::xmax
uint16_t xmax
Touch screen max X position.
Definition: stmpe811.h:76
stmpe811_params_t
Device initialization parameters.
Definition: stmpe811.h:72
stmpe811_t::params
stmpe811_params_t params
Device parameters.
Definition: stmpe811.h:87
stmpe811_touch_position_t::y
uint16_t y
Y position.
Definition: stmpe811.h:59
STMPE811_TOUCH_STATE_RELEASED
@ STMPE811_TOUCH_STATE_RELEASED
Touchscreen is released.
Definition: stmpe811.h:51
i2c_t
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
stmpe811_t::prev_x
uint16_t prev_x
Previous X coordinate.
Definition: stmpe811.h:88
stmpe811_params_t::ymax
uint16_t ymax
Touch screen max Y position.
Definition: stmpe811.h:77
stmpe811_touch_position_t
Touch position structure.
Definition: stmpe811.h:57
stmpe811_init
int stmpe811_init(stmpe811_t *dev, const stmpe811_params_t *params, touch_event_cb_t cb, void *arg)
Initialize the given STMPE811 device.
STMPE811_ERR_RESET
@ STMPE811_ERR_RESET
Software reset failed.
Definition: stmpe811.h:43
stmpe811_read_touch_position
int stmpe811_read_touch_position(stmpe811_t *dev, stmpe811_touch_position_t *position)
Read the touch position.
STMPE811_ERR_NODEV
@ STMPE811_ERR_NODEV
No valid device on I2C bus.
Definition: stmpe811.h:42
stmpe811_t::prev_y
uint16_t prev_y
Previous Y coordinate.
Definition: stmpe811.h:89
STMPE811_ERR_I2C
@ STMPE811_ERR_I2C
Error on the I2C bus.
Definition: stmpe811.h:41
touch_dev
Generic type for a touch device.
Definition: touch_dev.h:83
touch_event_cb_t
void(* touch_event_cb_t)(void *arg)
Signature of touch event callback triggered from interrupt.
Definition: stmpe811.h:67
STMPE811_TOUCH_STATE_PRESSED
@ STMPE811_TOUCH_STATE_PRESSED
Touchscreen is pressed.
Definition: stmpe811.h:50
gpio.h
Low-level GPIO peripheral driver interface definitions.
stmpe811_read_touch_state
int stmpe811_read_touch_state(const stmpe811_t *dev, stmpe811_touch_state_t *state)
Read the touch state (pressed or released)
stmpe811_params_t::int_pin
gpio_t int_pin
Touch screen interrupt pin.
Definition: stmpe811.h:75
saul.h
Definition of the generic [S]ensor [A]ctuator [U]ber [L]ayer.
STMPE811_OK
@ STMPE811_OK
Everything was fine.
Definition: stmpe811.h:40
stmpe811_touch_position_t::x
uint16_t x
X position.
Definition: stmpe811.h:58
stmpe811_params_t::addr
uint8_t addr
Device I2C address.
Definition: stmpe811.h:74
i2c.h
Low-level I2C peripheral driver interface definition.
stmpe811_touch_state_t
stmpe811_touch_state_t
Touch state enum.
Definition: stmpe811.h:49