Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
stmpe.h
Go to the documentation of this file.
1/*
2 * This file is part of the Ultibo project, https://ultibo.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2026 Garry Wood <garry@softoz.com.au>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26#ifndef _ULTIBO_STMPE_H
27#define _ULTIBO_STMPE_H
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include "ultibo/gpio.h"
34#include "ultibo/i2c.h"
35#include "ultibo/spi.h"
36#include "ultibo/touch.h"
37
39#define STMPE610_GPIO_DESCRIPTION "STMicroelectronics STMPE610 I/O Expander"
40#define STMPE801_GPIO_DESCRIPTION "STMicroelectronics STMPE801 I/O Expander"
41#define STMPE811_GPIO_DESCRIPTION "STMicroelectronics STMPE811 I/O Expander"
42#define STMPE1601_GPIO_DESCRIPTION "STMicroelectronics STMPE1601 I/O Expander"
43#define STMPE1801_GPIO_DESCRIPTION "STMicroelectronics STMPE1801 I/O Expander"
44#define STMPE2401_GPIO_DESCRIPTION "STMicroelectronics STMPE2401 I/O Expander"
45#define STMPE2403_GPIO_DESCRIPTION "STMicroelectronics STMPE2403 I/O Expander"
46
47#define STMPE610_TOUCH_DESCRIPTION "STMicroelectronics STMPE610 Touch Controller"
48#define STMPE811_TOUCH_DESCRIPTION "STMicroelectronics STMPE811 Touch Controller"
49
50#define STMPE610_GPIO_MIN_PIN GPIO_PIN_2
51#define STMPE610_GPIO_MAX_PIN GPIO_PIN_7
52#define STMPE610_GPIO_PIN_COUNT 6
53
54#define STMPE801_GPIO_MIN_PIN GPIO_PIN_0
55#define STMPE801_GPIO_MAX_PIN GPIO_PIN_7
56#define STMPE801_GPIO_PIN_COUNT 8
57
58#define STMPE811_GPIO_MIN_PIN GPIO_PIN_0
59#define STMPE811_GPIO_MAX_PIN GPIO_PIN_7
60#define STMPE811_GPIO_PIN_COUNT 8
61
62#define STMPE1601_GPIO_MIN_PIN GPIO_PIN_0
63#define STMPE1601_GPIO_MAX_PIN GPIO_PIN_15
64#define STMPE1601_GPIO_PIN_COUNT 16
65
66#define STMPE1801_GPIO_MIN_PIN GPIO_PIN_0
67#define STMPE1801_GPIO_MAX_PIN GPIO_PIN_17
68#define STMPE1801_GPIO_PIN_COUNT 18
69
70#define STMPE240X_GPIO_MIN_PIN GPIO_PIN_0
71#define STMPE240X_GPIO_MAX_PIN GPIO_PIN_23
72#define STMPE240X_GPIO_PIN_COUNT 24
73
74#define STMPE_GPIO_MAX_LEVEL GPIO_LEVEL_HIGH
75
76#define STMPE_GPIO_MAX_PULL GPIO_PULL_DOWN
77
78#define STMPE610_GPIO_MIN_FUNCTION GPIO_FUNCTION_IN
79#define STMPE610_GPIO_MAX_FUNCTION GPIO_FUNCTION_ALT0
80#define STMPE610_GPIO_FUNCTION_COUNT 3
81
82#define STMPE801_GPIO_MIN_FUNCTION GPIO_FUNCTION_IN
83#define STMPE801_GPIO_MAX_FUNCTION GPIO_FUNCTION_OUT
84#define STMPE801_GPIO_FUNCTION_COUNT 2
85
86#define STMPE811_GPIO_MIN_FUNCTION GPIO_FUNCTION_IN
87#define STMPE811_GPIO_MAX_FUNCTION GPIO_FUNCTION_ALT0
88#define STMPE811_GPIO_FUNCTION_COUNT 3
89
90#define STMPE1601_GPIO_MIN_FUNCTION GPIO_FUNCTION_IN
91#define STMPE1601_GPIO_MAX_FUNCTION GPIO_FUNCTION_ALT1
92#define STMPE1601_GPIO_FUNCTION_COUNT 4
93
94#define STMPE1801_GPIO_MIN_FUNCTION GPIO_FUNCTION_IN
95#define STMPE1801_GPIO_MAX_FUNCTION GPIO_FUNCTION_ALT0
96#define STMPE1801_GPIO_FUNCTION_COUNT 3
97
98#define STMPE240X_GPIO_MIN_FUNCTION GPIO_FUNCTION_IN
99#define STMPE240X_GPIO_MAX_FUNCTION GPIO_FUNCTION_ALT2
100#define STMPE240X_GPIO_FUNCTION_COUNT 5
101
102#define STMPE610_MAX_POINTS 1
103#define STMPE610_MAX_X 0xFFF
104#define STMPE610_MAX_Y 0xFFF
105#define STMPE610_MAX_Z 0xFF
106
107#define STMPE811_MAX_POINTS 1
108#define STMPE811_MAX_X 0xFFF
109#define STMPE811_MAX_Y 0xFFF
110#define STMPE811_MAX_Z 0xFF
111
113#define STMPE_CHIP_STMPE610 1
114#define STMPE_CHIP_STMPE801 2
115#define STMPE_CHIP_STMPE811 3
116#define STMPE_CHIP_STMPE1601 4
117#define STMPE_CHIP_STMPE1801 5
118#define STMPE_CHIP_STMPE2401 6
119#define STMPE_CHIP_STMPE2403 7
120
122#define STMPE_DIR_ASCENDING 0
123#define STMPE_DIR_DESCENDING 1
124
126#define STMPE_I2C_RATE 400000
127
129#define STMPE_SPI_RATE 500000
130
131#define STMPE_SPI_READ_CMD (1 << 7)
132
135#define STMPE811_REG_CHIP_ID 0x00
136#define STMPE811_REG_ID_VER 0x02
137#define STMPE811_REG_SYS_CTRL1 0x03
138#define STMPE811_REG_SYS_CTRL2 0x04
139#define STMPE811_REG_SPI_CFG 0x08
140#define STMPE811_REG_INT_CTRL 0x09
141#define STMPE811_REG_INT_EN 0x0A
142#define STMPE811_REG_INT_STA 0x0B
143
144#define STMPE811_REG_GPIO_INT_EN 0x0C
145#define STMPE811_REG_GPIO_INT_STA 0x0D
146#define STMPE811_REG_ADC_INT_EN 0x0E
147#define STMPE811_REG_ADC_INT_STA 0x0F
148#define STMPE811_REG_GPIO_SET_PIN 0x10
149#define STMPE811_REG_GPIO_CLR_PIN 0x11
150#define STMPE811_REG_GPIO_MP_STA 0x12
151#define STMPE811_REG_GPIO_SET_DIR 0x13
152#define STMPE811_REG_GPIO_ED 0x14
153#define STMPE811_REG_GPIO_RE 0x15
154#define STMPE811_REG_GPIO_FE 0x16
155#define STMPE811_REG_GPIO_AF 0x17
156
157#define STMPE811_REG_ADC_CTRL1 0x20
158#define STMPE811_REG_ADC_CTRL2 0x21
159#define STMPE811_REG_ADC_CAPT 0x22
160#define STMPE811_REG_ADC_DATA_CH0 0x30
161#define STMPE811_REG_ADC_DATA_CH1 0x32
162#define STMPE811_REG_ADC_DATA_CH2 0x34
163#define STMPE811_REG_ADC_DATA_CH3 0x36
164#define STMPE811_REG_ADC_DATA_CH4 0x38
165#define STMPE811_REG_ADC_DATA_CH5 0x3A
166#define STMPE811_REG_ADC_DATA_CH6 0x3C
167#define STMPE811_REG_ADC_DATA_CH7 0x3E
168
169#define STMPE811_REG_TSC_CTRL 0x40
170#define STMPE811_REG_TSC_CFG 0x41
171#define STMPE811_REG_WDW_TR_X 0x42
172#define STMPE811_REG_WDW_TR_Y 0x44
173#define STMPE811_REG_WDW_BL_X 0x46
174#define STMPE811_REG_WDW_BL_Y 0x48
175#define STMPE811_REG_FIFO_TH 0x4A
176#define STMPE811_REG_FIFO_STA 0x4B
177#define STMPE811_REG_FIFO_SIZE 0x4C
178#define STMPE811_REG_TSC_DATA_X 0x4D
179#define STMPE811_REG_TSC_DATA_Y 0x4F
180#define STMPE811_REG_TSC_DATA_Z 0x51
181#define STMPE811_REG_TSC_DATA_XYZ 0x52
182#define STMPE811_REG_TSC_FRACTION_Z 0x56
183#define STMPE811_REG_TSC_DATA 0x57
184#define STMPE811_REG_TSC_I_DRIVE 0x58
185#define STMPE811_REG_TSC_SHIELD 0x59
187#define STMPE811_REG_TEMP_CTRL 0x60
188#define STMPE811_REG_TEMP_DATA 0x61
189#define STMPE811_REG_TEMP_TH 0x62
190
191#define STMPE811_REG_MAX 0x62
192#define STMPE811_REG_SIZE 1
193
195#define STMPE801_REG_CHIP_ID 0x00
196#define STMPE801_REG_ID_VER 0x02
197#define STMPE801_REG_SYS_CTRL 0x04
198#define STMPE801_REG_GPIO_INT_EN 0x08
199#define STMPE801_REG_GPIO_INT_STA 0x09
200#define STMPE801_REG_GPIO_MP_STA 0x10
201#define STMPE801_REG_GPIO_SET_PIN 0x11
202#define STMPE801_REG_GPIO_SET_DIR 0x12
203
204#define STMPE801_REG_MAX 0x12
205#define STMPE801_REG_SIZE 1
206
208#define STMPE1601_REG_CHIP_ID 0x80
209#define STMPE1601_REG_ID_VER 0x81
210
211#define STMPE1601_REG_SYS_CTRL 0x02
212#define STMPE1601_REG_SYS_CTRL2 0x03
213#define STMPE1601_REG_INT_CTRL_MSB 0x10
214#define STMPE1601_REG_INT_CTRL_LSB 0x11
215#define STMPE1601_REG_INT_EN_MSB 0x12
216#define STMPE1601_REG_INT_EN_LSB 0x13
217#define STMPE1601_REG_INT_STA_MSB 0x14
218#define STMPE1601_REG_INT_STA_LSB 0x15
219
220#define STMPE1601_REG_GPIO_INT_EN_MSB 0x16
221#define STMPE1601_REG_GPIO_INT_EN_LSB 0x17
222#define STMPE1601_REG_GPIO_INT_STA_MSB 0x18
223#define STMPE1601_REG_GPIO_INT_STA_LSB 0x19
224
225#define STMPE1601_REG_GPIO_SET_PIN_MSB 0x82
226#define STMPE1601_REG_GPIO_SET_PIN_LSB 0x83
227#define STMPE1601_REG_GPIO_CLR_PIN_MSB 0x84
228#define STMPE1601_REG_GPIO_CLR_PIN_LSB 0x85
229#define STMPE1601_REG_GPIO_MP_STA_MSB 0x86
230#define STMPE1601_REG_GPIO_MP_STA_LSB 0x87
231#define STMPE1601_REG_GPIO_SET_DIR_MSB 0x88
232#define STMPE1601_REG_GPIO_SET_DIR_LSB 0x89
233
234#define STMPE1601_REG_GPIO_ED_MSB 0x8A
235#define STMPE1601_REG_GPIO_ED_LSB 0x8B
236#define STMPE1601_REG_GPIO_RE_MSB 0x8C
237#define STMPE1601_REG_GPIO_RE_LSB 0x8D
238#define STMPE1601_REG_GPIO_FE_MSB 0x8E
239#define STMPE1601_REG_GPIO_FE_LSB 0x8F
240#define STMPE1601_REG_GPIO_PU_MSB 0x90
241#define STMPE1601_REG_GPIO_PU_LSB 0x91
242#define STMPE1601_REG_GPIO_AF_U_MSB 0x92
243#define STMPE1601_REG_GPIO_AF_U_LSB 0x93
244#define STMPE1601_REG_GPIO_AF_L_MSB 0x94
245#define STMPE1601_REG_GPIO_AF_L_LSB 0x95
246
247#define STMPE1601_REG_GPIO_LT_EN 0x96
248#define STMPE1601_REG_GPIO_LT_DIR 0x97
249
250#define STMPE1601_REG_MAX 0xBF
251#define STMPE1601_REG_SIZE 2
252
254#define STMPE1801_REG_CHIP_ID 0x00
255#define STMPE1801_REG_ID_VER 0x01
256
257#define STMPE1801_REG_SYS_CTRL 0x02
258#define STMPE1801_REG_INT_CTRL_LOW 0x04
259#define STMPE1801_REG_INT_CTRL_HIGH 0x05
260#define STMPE1801_REG_INT_EN_LOW 0x06
261#define STMPE1801_REG_INT_EN_HIGH 0x07
262#define STMPE1801_REG_INT_STA_LOW 0x08
263#define STMPE1801_REG_INT_STA_HIGH 0x09
264
265#define STMPE1801_REG_GPIO_INT_EN_LOW 0x0A
266#define STMPE1801_REG_GPIO_INT_EN_MID 0x0B
267#define STMPE1801_REG_GPIO_INT_EN_HIGH 0x0C
268#define STMPE1801_REG_GPIO_INT_STA_LOW 0x0D
269#define STMPE1801_REG_GPIO_INT_STA_MID 0x0E
270#define STMPE1801_REG_GPIO_INT_STA_HIGH 0x0F
271#define STMPE1801_REG_GPIO_SET_PIN_LOW 0x10
272#define STMPE1801_REG_GPIO_SET_PIN_MID 0x11
273#define STMPE1801_REG_GPIO_SET_PIN_HIGH 0x12
274#define STMPE1801_REG_GPIO_CLR_PIN_LOW 0x13
275#define STMPE1801_REG_GPIO_CLR_PIN_MID 0x14
276#define STMPE1801_REG_GPIO_CLR_PIN_HIGH 0x15
277#define STMPE1801_REG_GPIO_MP_STA_LOW 0x16
278#define STMPE1801_REG_GPIO_MP_STA_MID 0x17
279#define STMPE1801_REG_GPIO_MP_STA_HIGH 0x18
280#define STMPE1801_REG_GPIO_SET_DIR_LOW 0x19
281#define STMPE1801_REG_GPIO_SET_DIR_MID 0x1A
282#define STMPE1801_REG_GPIO_SET_DIR_HIGH 0x1B
283
284#define STMPE1801_REG_GPIO_RE_LOW 0x1C
285#define STMPE1801_REG_GPIO_RE_MID 0x1D
286#define STMPE1801_REG_GPIO_RE_HIGH 0x1E
287#define STMPE1801_REG_GPIO_FE_LOW 0x1F
288#define STMPE1801_REG_GPIO_FE_MID 0x20
289#define STMPE1801_REG_GPIO_FE_HIGH 0x21
290#define STMPE1801_REG_GPIO_PULL_UP_LOW 0x22
291#define STMPE1801_REG_GPIO_PULL_UP_MID 0x23
292#define STMPE1801_REG_GPIO_PULL_UP_HIGH 0x24
293
294#define STMPE1801_REG_KPC_ROW 0x30
295#define STMPE1801_REG_KPC_COL_LOW 0x31
296#define STMPE1801_REG_KPC_COL_HIGH 0x32
297#define STMPE1801_REG_KPC_CTRL_LOW 0x33
298#define STMPE1801_REG_KPC_CTRL_MID 0x34
299#define STMPE1801_REG_KPC_CTRL_HIGH 0x35
300#define STMPE1801_REG_KPC_CMD 0x36
301#define STMPE1801_REG_KPC_COMB_KEY_0 0x37
302#define STMPE1801_REG_KPC_COMB_KEY_1 0x38
303#define STMPE1801_REG_KPC_COMB_KEY_2 0x39
304#define STMPE1801_REG_KPC_DATA_BYTE0 0x3A
305#define STMPE1801_REG_KPC_DATA_BYTE1 0x3B
306#define STMPE1801_REG_KPC_DATA_BYTE2 0x3C
307#define STMPE1801_REG_KPC_DATA_BYTE3 0x3D
308#define STMPE1801_REG_KPC_DATA_BYTE4 0x3E
309
310#define STMPE1801_REG_MAX 0x3E
311#define STMPE1801_REG_SIZE 3
312
314#define STMPE240X_REG_CHIP_ID 0x80
315#define STMPE240X_REG_ID_VER 0x81
316
317#define STMPE240X_REG_SYS_CTRL 0x02
318#define STMPE240X_REG_INT_CTRL_MSB 0x10
319#define STMPE240X_REG_INT_CTRL_LSB 0x11
320#define STMPE240X_REG_INT_EN_MSB 0x12
321#define STMPE240X_REG_INT_EN_LSB 0x13
322#define STMPE240X_REG_INT_STA_MSB 0x14
323#define STMPE240X_REG_INT_STA_LSB 0x15
324
325#define STMPE240X_REG_GPIO_INT_EN_MSB 0x16
326#define STMPE240X_REG_GPIO_INT_EN_MID 0x17
327#define STMPE240X_REG_GPIO_INT_EN_LSB 0x18
328#define STMPE240X_REG_GPIO_INT_STA_MSB 0x19
329#define STMPE240X_REG_GPIO_INT_STA_MID 0x1A
330#define STMPE240X_REG_GPIO_INT_STA_LSB 0x1B
331#define STMPE240X_REG_GPIO_MP_STA_MSB 0xA2
332#define STMPE240X_REG_GPIO_MP_STA_MID 0xA3
333#define STMPE240X_REG_GPIO_MP_STA_LSB 0xA4
334#define STMPE240X_REG_GPIO_SET_PIN_MSB 0x83
335#define STMPE240X_REG_GPIO_SET_PIN_MID 0x84
336#define STMPE240X_REG_GPIO_SET_PIN_LSB 0x85
337#define STMPE240X_REG_GPIO_CLR_PIN_MSB 0x86
338#define STMPE240X_REG_GPIO_CLR_PIN_MID 0x87
339#define STMPE240X_REG_GPIO_CLR_PIN_LSB 0x88
340#define STMPE240X_REG_GPIO_SET_DIR_MSB 0x89
341#define STMPE240X_REG_GPIO_SET_DIR_MID 0x8A
342#define STMPE240X_REG_GPIO_SET_DIR_LSB 0x8B
343#define STMPE240X_REG_GPIO_ED_MSB 0x8C
344#define STMPE240X_REG_GPIO_ED_MID 0x8D
345#define STMPE240X_REG_GPIO_ED_LSB 0x8E
346#define STMPE240X_REG_GPIO_RE_MSB 0x8F
347#define STMPE240X_REG_GPIO_RE_MID 0x90
348#define STMPE240X_REG_GPIO_RE_LSB 0x91
349#define STMPE240X_REG_GPIO_FE_MSB 0x92
350#define STMPE240X_REG_GPIO_FE_MID 0x93
351#define STMPE240X_REG_GPIO_FE_LSB 0x94
352#define STMPE240X_REG_GPIO_PULL_UP_MSB 0x95
353#define STMPE240X_REG_GPIO_PULL_UP_MID 0x96
354#define STMPE240X_REG_GPIO_PULL_UP_LSB 0x97
355#define STMPE240X_REG_GPIO_PULL_DN_MSB 0x98
356#define STMPE240X_REG_GPIO_PULL_DN_MID 0x99
357#define STMPE240X_REG_GPIO_PULL_DN_LSB 0x9A
358#define STMPE240X_REG_GPIO_AF_U_MSB 0x9B
359#define STMPE240X_REG_GPIO_AF_U_MID 0x9C
360#define STMPE240X_REG_GPIO_AF_U_LSB 0x9D
361#define STMPE240X_REG_GPIO_AF_L_MSB 0x9E
362#define STMPE240X_REG_GPIO_AF_L_MID 0x9F
363#define STMPE240X_REG_GPIO_AF_L_LSB 0xA0
364
365#define STMPE240X_REG_PWMCS 0x30
366#define STMPE240X_REG_PWMIC0 0x38
367#define STMPE240X_REG_PWMIC1 0x39
368#define STMPE240X_REG_PWMIC2 0x3A
369
370#define STMPE240X_REG_KPC_COL 0x60
371#define STMPE240X_REG_KPC_ROW_MSB 0x61
372#define STMPE240X_REG_KPC_ROW_LSB 0x62
373#define STMPE240X_REG_KPC_CTRL_MSB 0x63
374#define STMPE240X_REG_KPC_CTRL_LSB 0x64
375#define STMPE240X_REG_KPC_DATA_BYTE0 0x68
376#define STMPE240X_REG_KPC_DATA_BYTE1 0x69
377#define STMPE240X_REG_KPC_DATA_BYTE2 0x6A
378
379#define STMPE240X_REG_MAX 0xBF
380#define STMPE240X_REG_SIZE 3
381
382#define STMPE_REG_UNKNOWN 0xFF
383
386#define STMPE811_CHIP_ID 0x0811
387
389#define STMPE801_CHIP_ID 0x0801
390
392#define STMPE1601_CHIP_ID 0x02
393
395#define STMPE1801_CHIP_ID 0xC1
396
398#define STMPE240X_CHIP_ID 0x01
399
402#define STMPE811_SYS_CTRL2_TS_OFF (1 << 3)
403#define STMPE811_SYS_CTRL2_GPIO_OFF (1 << 2)
404#define STMPE811_SYS_CTRL2_TSC_OFF (1 << 1)
405#define STMPE811_SYS_CTRL2_ADC_OFF (1 << 0)
406
408#define STMPE801_SYS_CTRL_RESET (1 << 7)
409#define STMPE801_SYS_CTRL_INT_EN (1 << 2)
410#define STMPE801_SYS_CTRL_INT_HI (1 << 0)
411
413#define STMPE1601_SYS_CTRL_RESET (1 << 7)
414#define STMPE1601_SYS_CTRL_ENABLE_GPIO (1 << 3)
415#define STMPE1601_SYS_CTRL_ENABLE_KPC (1 << 1)
416#define STMPE1601_SYS_CTRL_ENABLE_SPWM (1 << 0)
417
419#define STMPE1801_SYS_CTRL_RESET (1 << 7)
420
422#define STMPE240X_SYS_CTRL_RESET (1 << 7)
423#define STMPE240X_SYS_CTRL_ENABLE_GPIO (1 << 3)
424#define STMPE240X_SYS_CTRL_ENABLE_PWM (1 << 2)
425#define STMPE240X_SYS_CTRL_ENABLE_KPC (1 << 1)
426#define STMPE240X_SYS_CTRL_ENABLE_ROT (1 << 0)
427
430#define STMPE811_TSC_CTRL_TSC_STA (1 << 7)
431#define STMPE811_TSC_CTRL_TRACK_MASK (7 << 4)
432#define STMPE811_TSC_CTRL_OPMODE_XYZ (0 << 1)
433#define STMPE811_TSC_CTRL_OPMODE_XY (1 << 1)
434#define STMPE811_TSC_CTRL_OPMODE_X (2 << 1)
435#define STMPE811_TSC_CTRL_OPMODE_Y (3 << 1)
436#define STMPE811_TSC_CTRL_OPMODE_Z (4 << 1)
437#define STMPE811_TSC_CTRL_TSC_EN (1 << 0)
438
441#define STMPE811_TSC_CFG_AVE_CTRL_1 (0 << 6)
442#define STMPE811_TSC_CFG_AVE_CTRL_2 (1 << 6)
443#define STMPE811_TSC_CFG_AVE_CTRL_4 (2 << 6)
444#define STMPE811_TSC_CFG_AVE_CTRL_8 (3 << 6)
445#define STMPE811_TSC_CFG_TOUCH_DET_DELAY_MASK (7 << 3)
446#define STMPE811_TSC_CFG_SETTLING_MASK (7 << 0)
447
450#define STMPE811_ADC_CTRL1_SAMPLE_TIME_MASK (7 << 4)
451#define STMPE811_ADC_CTRL1_MOD_12B (1 << 3)
452#define STMPE811_ADC_CTRL1_REF_SEL (1 << 1)
453
456#define STMPE811_ADC_CTRL2_ADC_FREQ_MASK (3 << 0)
457
460#define STMPE811_FIFO_STA_RESET (1 << 0)
461
464#define STMPE811_INT_CTRL_POLARITY (1 << 2)
465#define STMPE811_INT_CTRL_TYPE (1 << 1)
466#define STMPE811_INT_CTRL_GLOBAL (1 << 0)
467
470#define STMPE811_INT_EN_GPIO (1 << 7)
471#define STMPE811_INT_EN_ADC (1 << 6)
472#define STMPE811_INT_EN_TEMP_SENS (1 << 5)
473#define STMPE811_INT_EN_FIFO_EMPTY (1 << 4)
474#define STMPE811_INT_EN_FIFO_FULL (1 << 3)
475#define STMPE811_INT_EN_FIFO_OFLOW (1 << 2)
476#define STMPE811_INT_EN_FIFO_TH (1 << 1)
477#define STMPE811_INT_EN_TOUCH_DET (1 << 0)
478
481#define STMPE811_INT_STA_GPIO (1 << 7)
482#define STMPE811_INT_STA_ADC (1 << 6)
483#define STMPE811_INT_STA_TEMP_SENS (1 << 5)
484#define STMPE811_INT_STA_FIFO_EMPTY (1 << 4)
485#define STMPE811_INT_STA_FIFO_FULL (1 << 3)
486#define STMPE811_INT_STA_FIFO_OFLOW (1 << 2)
487#define STMPE811_INT_STA_FIFO_TH (1 << 1)
488#define STMPE811_INT_STA_TOUCH_DET (1 << 0)
489
490#define STMPE811_INT_STA_TOUCH_MASK STMPE811_INT_STA_FIFO_EMPTY | STMPE811_INT_STA_FIFO_FULL | STMPE811_INT_STA_FIFO_OFLOW | STMPE811_INT_STA_FIFO_TH | STMPE811_INT_STA_TOUCH_DET
491
495{
496 // General Properties
497 uint32_t chip;
499 // I2C Properties
501 uint16_t address;
502 // SPI Properties
504 uint16_t chipselect;
505 // Register Properties
506 uint32_t regmax;
507 uint32_t regdir;
508 uint32_t regsize;
509};
510
511
514{
515 // Control Register offsets
516 uint8_t sysctrl;
517 uint8_t intctrl;
518 uint8_t intenable;
519 uint8_t intstatus;
520 // GPIO Registers offsets
523 uint8_t gpiopinget;
524 uint8_t gpiopinset;
525 uint8_t gpiopinclr;
526 uint8_t gpiodirset;
527 uint8_t gpiofuncset;
528 uint8_t gpiopullup;
533 // Touchscreen Register offsets (610 and 811 Only)
534 uint8_t adcctrl1;
535 uint8_t adcctrl2;
536 uint8_t tscctrl;
537 uint8_t tsccfg;
539 uint8_t fifostatus;
540 uint8_t tscdataxyz;
542 uint8_t tscidrive;
543};
544
545
546typedef struct _STMPE_GPIO STMPE_GPIO;
548{
549 // GPIO Properties
551 // STMPE Properties
554};
555
556
559{
560 // Touch Properties
562 // General Properties
563 uint16_t maxx;
564 uint16_t maxy;
565 uint16_t maxz;
566 uint16_t width;
567 uint16_t height;
568 uint32_t maxpoints;
569 // STMPE Properties
573};
574
576static uint8_t STMPE_SAMPLE_TIME = 4;
577static uint8_t STMPE_MOD_12B = 1;
578static uint8_t STMPE_REF_SEL = 0;
579static uint8_t STMPE_ADC_FREQ = 2;
580static uint8_t STMPE_AVE_CTRL = 3;
581static uint8_t STMPE_TOUCH_DET_DELAY = 4;
582static uint8_t STMPE_SETTLING = 2;
583static uint8_t STMPE_FRACTION_Z = 7;
584static uint8_t STMPE_I_DRIVE = 0;
585
588
590
601GPIO_DEVICE * STDCALL stmpe610_gpio_create(I2C_DEVICE *i2c, SPI_DEVICE *spi, uint16_t address, uint16_t chipselect, GPIO_INFO *irq);
602
611
622GPIO_DEVICE * STDCALL stmpe811_gpio_create(I2C_DEVICE *i2c, SPI_DEVICE *spi, uint16_t address, uint16_t chipselect, GPIO_INFO *irq);
623
632
641
650
657
670TOUCH_DEVICE * STDCALL stmpe610_touch_create(I2C_DEVICE *i2c, SPI_DEVICE *spi, uint16_t address, uint16_t chipselect, uint32_t width, uint32_t height, GPIO_INFO *irq);
671
684TOUCH_DEVICE * STDCALL stmpe811_touch_create(I2C_DEVICE *i2c, SPI_DEVICE *spi, uint16_t address, uint16_t chipselect, uint32_t width, uint32_t height, GPIO_INFO *irq);
685
692
693#ifdef __cplusplus
694}
695#endif
696
697#endif // _ULTIBO_STMPE_H
#define STDCALL
Definition globaltypes.h:45
HANDLE TIMER_HANDLE
Definition globaltypes.h:119
struct _GPIO_DEVICE GPIO_DEVICE
Forward declared for GPIOPin.
Definition gpio.h:85
struct _GPIO_INFO GPIO_INFO
Definition gpio.h:176
struct _I2C_DEVICE I2C_DEVICE
Definition i2c.h:81
struct _SPI_DEVICE SPI_DEVICE
Definition spi.h:108
GPIO_DEVICE *STDCALL stmpe1801_gpio_create(I2C_DEVICE *i2c, uint16_t address, GPIO_INFO *irq)
Create, register and start a new STMPE1801 GPIO device connected to the specified I2C device.
GPIO_DEVICE *STDCALL stmpe2401_gpio_create(I2C_DEVICE *i2c, uint16_t address, GPIO_INFO *irq)
Create, register and start a new STMPE2401 GPIO device connected to the specified I2C device.
GPIO_DEVICE *STDCALL stmpe801_gpio_create(I2C_DEVICE *i2c, uint16_t address, GPIO_INFO *irq)
Create, register and start a new STMPE801 GPIO device connected to the specified I2C device.
TOUCH_DEVICE *STDCALL stmpe811_touch_create(I2C_DEVICE *i2c, SPI_DEVICE *spi, uint16_t address, uint16_t chipselect, uint32_t width, uint32_t height, GPIO_INFO *irq)
Create, register and start a new STMPE811 Touch device connected to the specified I2C or SPI device.
struct _STMPE_TOUCH STMPE_TOUCH
Definition stmpe.h:557
struct _STMPE_CONTROL STMPE_CONTROL
Definition stmpe.h:493
uint32_t STDCALL stmpe_gpio_destroy(GPIO_DEVICE *gpio)
Stop, deregister and destroy an STMPE GPIO device created by this driver.
GPIO_DEVICE *STDCALL stmpe1601_gpio_create(I2C_DEVICE *i2c, uint16_t address, GPIO_INFO *irq)
Create, register and start a new STMPE1601 GPIO device connected to the specified I2C device.
uint32_t STDCALL stmpe_touch_destroy(TOUCH_DEVICE *touch)
Stop, deregister and destroy an STMPE Touch device created by this driver.
GPIO_DEVICE *STDCALL stmpe610_gpio_create(I2C_DEVICE *i2c, SPI_DEVICE *spi, uint16_t address, uint16_t chipselect, GPIO_INFO *irq)
Create, register and start a new STMPE610 GPIO device connected to the specified I2C or SPI device.
TOUCH_DEVICE *STDCALL stmpe610_touch_create(I2C_DEVICE *i2c, SPI_DEVICE *spi, uint16_t address, uint16_t chipselect, uint32_t width, uint32_t height, GPIO_INFO *irq)
Create, register and start a new STMPE610 Touch device connected to the specified I2C or SPI device.
struct _STMPE_OFFSETS STMPE_OFFSETS
Definition stmpe.h:512
struct _STMPE_GPIO STMPE_GPIO
Definition stmpe.h:546
void STDCALL stmpe_init(void)
GPIO_DEVICE *STDCALL stmpe811_gpio_create(I2C_DEVICE *i2c, SPI_DEVICE *spi, uint16_t address, uint16_t chipselect, GPIO_INFO *irq)
Create, register and start a new STMPE811 GPIO device connected to the specified I2C or SPI device.
Definition stmpe.h:495
uint32_t regmax
The maximum register address for read or write.
Definition stmpe.h:506
I2C_DEVICE * i2c
The I2C device this device is connected to (Optional).
Definition stmpe.h:500
uint16_t address
The I2C address of the device.
Definition stmpe.h:501
uint16_t chipselect
The SPI chip select of the device.
Definition stmpe.h:504
uint32_t regsize
The standard size of a register read or write.
Definition stmpe.h:508
uint32_t regdir
The register address direction (Ascending / Descending).
Definition stmpe.h:507
GPIO_INFO irq
The GPIO information for the IRQ line (Optional).
Definition stmpe.h:498
uint32_t chip
The chip type (eg STMPE_CHIP_STMPE610).
Definition stmpe.h:497
SPI_DEVICE * spi
The SPI device this device is connected to (Optional).
Definition stmpe.h:503
Definition stmpe.h:548
GPIO_DEVICE gpio
Definition stmpe.h:550
STMPE_CONTROL control
The control information (Chip, I2C, SPI etc) for this device.
Definition stmpe.h:552
STMPE_OFFSETS offsets
The register offsets for this device.
Definition stmpe.h:553
Definition stmpe.h:514
uint8_t gpiorisingedge
Definition stmpe.h:531
uint8_t gpiofuncset
Definition stmpe.h:527
uint8_t gpiodirset
Definition stmpe.h:526
uint8_t tscfractionz
Definition stmpe.h:541
uint8_t intctrl
Definition stmpe.h:517
uint8_t tscctrl
Definition stmpe.h:536
uint8_t adcctrl1
Definition stmpe.h:534
uint8_t intenable
Definition stmpe.h:518
uint8_t adcctrl2
Definition stmpe.h:535
uint8_t fifostatus
Definition stmpe.h:539
uint8_t gpiopinclr
Definition stmpe.h:525
uint8_t tscidrive
Definition stmpe.h:542
uint8_t gpiointstatus
Definition stmpe.h:522
uint8_t sysctrl
Definition stmpe.h:516
uint8_t tsccfg
Definition stmpe.h:537
uint8_t gpiopinset
Definition stmpe.h:524
uint8_t intstatus
Definition stmpe.h:519
uint8_t tscdataxyz
Definition stmpe.h:540
uint8_t gpiointenable
Definition stmpe.h:521
uint8_t gpiopinget
Definition stmpe.h:523
uint8_t fifothreshold
Definition stmpe.h:538
uint8_t gpiofallingedge
Definition stmpe.h:532
uint8_t gpioedgedetect
Definition stmpe.h:530
uint8_t gpiopulldown
Definition stmpe.h:529
uint8_t gpiopullup
Definition stmpe.h:528
Definition stmpe.h:559
uint16_t maxy
Maximum Y value for this device.
Definition stmpe.h:564
uint16_t maxx
Maximum X value for this device.
Definition stmpe.h:563
uint16_t maxz
Maximum Z value for this device.
Definition stmpe.h:565
STMPE_CONTROL control
The control information (Chip, I2C, SPI etc) for this device.
Definition stmpe.h:570
uint16_t height
Screen height for this device.
Definition stmpe.h:567
uint32_t maxpoints
Maximum touch points for this device.
Definition stmpe.h:568
TOUCH_DEVICE touch
Definition stmpe.h:561
STMPE_OFFSETS offsets
The register offsets for this device.
Definition stmpe.h:571
uint16_t width
Screen width for this device.
Definition stmpe.h:566
TIMER_HANDLE timer
Handle for touch release timer.
Definition stmpe.h:572
struct _TOUCH_DEVICE TOUCH_DEVICE
Definition touch.h:151