STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
stmpe811.h
Go to the documentation of this file.
1 
39 /* Define to prevent recursive inclusion -------------------------------------*/
40 #ifndef __STMPE811_H
41 #define __STMPE811_H
42 
43 #ifdef __cplusplus
44  extern "C" {
45 #endif
46 
47 /* Includes ------------------------------------------------------------------*/
48 #include "../Common/ts.h"
49 #include "../Common/io.h"
50 
74 /* Chip IDs */
75 #define STMPE811_ID 0x0811
76 
77 /* Identification registers & System Control */
78 #define STMPE811_REG_CHP_ID_LSB 0x00
79 #define STMPE811_REG_CHP_ID_MSB 0x01
80 #define STMPE811_REG_ID_VER 0x02
81 
82 /* Global interrupt Enable bit */
83 #define STMPE811_GIT_EN 0x01
84 
85 /* IO expander functionalities */
86 #define STMPE811_ADC_FCT 0x01
87 #define STMPE811_TS_FCT 0x02
88 #define STMPE811_IO_FCT 0x04
89 #define STMPE811_TEMPSENS_FCT 0x08
90 
91 /* Global Interrupts definitions */
92 #define STMPE811_GIT_IO 0x80 /* IO interrupt */
93 #define STMPE811_GIT_ADC 0x40 /* ADC interrupt */
94 #define STMPE811_GIT_TEMP 0x20 /* Not implemented */
95 #define STMPE811_GIT_FE 0x10 /* FIFO empty interrupt */
96 #define STMPE811_GIT_FF 0x08 /* FIFO full interrupt */
97 #define STMPE811_GIT_FOV 0x04 /* FIFO overflowed interrupt */
98 #define STMPE811_GIT_FTH 0x02 /* FIFO above threshold interrupt */
99 #define STMPE811_GIT_TOUCH 0x01 /* Touch is detected interrupt */
100 #define STMPE811_ALL_GIT 0x1F /* All global interrupts */
101 #define STMPE811_TS_IT (STMPE811_GIT_TOUCH | STMPE811_GIT_FTH | STMPE811_GIT_FOV | STMPE811_GIT_FF | STMPE811_GIT_FE) /* Touch screen interrupts */
102 
103 /* General Control Registers */
104 #define STMPE811_REG_SYS_CTRL1 0x03
105 #define STMPE811_REG_SYS_CTRL2 0x04
106 #define STMPE811_REG_SPI_CFG 0x08
107 
108 /* Interrupt system Registers */
109 #define STMPE811_REG_INT_CTRL 0x09
110 #define STMPE811_REG_INT_EN 0x0A
111 #define STMPE811_REG_INT_STA 0x0B
112 #define STMPE811_REG_IO_INT_EN 0x0C
113 #define STMPE811_REG_IO_INT_STA 0x0D
114 
115 /* IO Registers */
116 #define STMPE811_REG_IO_SET_PIN 0x10
117 #define STMPE811_REG_IO_CLR_PIN 0x11
118 #define STMPE811_REG_IO_MP_STA 0x12
119 #define STMPE811_REG_IO_DIR 0x13
120 #define STMPE811_REG_IO_ED 0x14
121 #define STMPE811_REG_IO_RE 0x15
122 #define STMPE811_REG_IO_FE 0x16
123 #define STMPE811_REG_IO_AF 0x17
124 
125 /* ADC Registers */
126 #define STMPE811_REG_ADC_INT_EN 0x0E
127 #define STMPE811_REG_ADC_INT_STA 0x0F
128 #define STMPE811_REG_ADC_CTRL1 0x20
129 #define STMPE811_REG_ADC_CTRL2 0x21
130 #define STMPE811_REG_ADC_CAPT 0x22
131 #define STMPE811_REG_ADC_DATA_CH0 0x30
132 #define STMPE811_REG_ADC_DATA_CH1 0x32
133 #define STMPE811_REG_ADC_DATA_CH2 0x34
134 #define STMPE811_REG_ADC_DATA_CH3 0x36
135 #define STMPE811_REG_ADC_DATA_CH4 0x38
136 #define STMPE811_REG_ADC_DATA_CH5 0x3A
137 #define STMPE811_REG_ADC_DATA_CH6 0x3B
138 #define STMPE811_REG_ADC_DATA_CH7 0x3C
139 
140 /* Touch Screen Registers */
141 #define STMPE811_REG_TSC_CTRL 0x40
142 #define STMPE811_REG_TSC_CFG 0x41
143 #define STMPE811_REG_WDM_TR_X 0x42
144 #define STMPE811_REG_WDM_TR_Y 0x44
145 #define STMPE811_REG_WDM_BL_X 0x46
146 #define STMPE811_REG_WDM_BL_Y 0x48
147 #define STMPE811_REG_FIFO_TH 0x4A
148 #define STMPE811_REG_FIFO_STA 0x4B
149 #define STMPE811_REG_FIFO_SIZE 0x4C
150 #define STMPE811_REG_TSC_DATA_X 0x4D
151 #define STMPE811_REG_TSC_DATA_Y 0x4F
152 #define STMPE811_REG_TSC_DATA_Z 0x51
153 #define STMPE811_REG_TSC_DATA_XYZ 0x52
154 #define STMPE811_REG_TSC_FRACT_XYZ 0x56
155 #define STMPE811_REG_TSC_DATA_INC 0x57
156 #define STMPE811_REG_TSC_DATA_NON_INC 0xD7
157 #define STMPE811_REG_TSC_I_DRIVE 0x58
158 #define STMPE811_REG_TSC_SHIELD 0x59
159 
160 /* Touch Screen Pins definition */
161 #define STMPE811_TOUCH_YD STMPE811_PIN_7
162 #define STMPE811_TOUCH_XD STMPE811_PIN_6
163 #define STMPE811_TOUCH_YU STMPE811_PIN_5
164 #define STMPE811_TOUCH_XU STMPE811_PIN_4
165 #define STMPE811_TOUCH_IO_ALL (uint32_t)(STMPE811_TOUCH_YD | STMPE811_TOUCH_XD | STMPE811_TOUCH_YU | STMPE811_TOUCH_XU)
166 
167 /* IO Pins definition */
168 #define STMPE811_PIN_0 0x01
169 #define STMPE811_PIN_1 0x02
170 #define STMPE811_PIN_2 0x04
171 #define STMPE811_PIN_3 0x08
172 #define STMPE811_PIN_4 0x10
173 #define STMPE811_PIN_5 0x20
174 #define STMPE811_PIN_6 0x40
175 #define STMPE811_PIN_7 0x80
176 #define STMPE811_PIN_ALL 0xFF
177 
178 /* IO Pins directions */
179 #define STMPE811_DIRECTION_IN 0x00
180 #define STMPE811_DIRECTION_OUT 0x01
181 
182 /* IO IT types */
183 #define STMPE811_TYPE_LEVEL 0x00
184 #define STMPE811_TYPE_EDGE 0x02
185 
186 /* IO IT polarity */
187 #define STMPE811_POLARITY_LOW 0x00
188 #define STMPE811_POLARITY_HIGH 0x04
189 
190 /* IO Pin IT edge modes */
191 #define STMPE811_EDGE_FALLING 0x01
192 #define STMPE811_EDGE_RISING 0x02
193 
194 /* TS registers masks */
195 #define STMPE811_TS_CTRL_ENABLE 0x01
196 #define STMPE811_TS_CTRL_STATUS 0x80
197 
215 void stmpe811_Init(uint16_t DeviceAddr);
216 void stmpe811_Reset(uint16_t DeviceAddr);
217 uint16_t stmpe811_ReadID(uint16_t DeviceAddr);
218 void stmpe811_EnableGlobalIT(uint16_t DeviceAddr);
219 void stmpe811_DisableGlobalIT(uint16_t DeviceAddr);
220 void stmpe811_EnableITSource(uint16_t DeviceAddr, uint8_t Source);
221 void stmpe811_DisableITSource(uint16_t DeviceAddr, uint8_t Source);
222 void stmpe811_SetITPolarity(uint16_t DeviceAddr, uint8_t Polarity);
223 void stmpe811_SetITType(uint16_t DeviceAddr, uint8_t Type);
224 uint8_t stmpe811_GlobalITStatus(uint16_t DeviceAddr, uint8_t Source);
225 uint8_t stmpe811_ReadGITStatus(uint16_t DeviceAddr, uint8_t Source);
226 void stmpe811_ClearGlobalIT(uint16_t DeviceAddr, uint8_t Source);
227 
231 void stmpe811_IO_Start(uint16_t DeviceAddr, uint32_t IO_Pin);
232 uint8_t stmpe811_IO_Config(uint16_t DeviceAddr, uint32_t IO_Pin, IO_ModeTypedef IO_Mode);
233 void stmpe811_IO_InitPin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Direction);
234 void stmpe811_IO_EnableAF(uint16_t DeviceAddr, uint32_t IO_Pin);
235 void stmpe811_IO_DisableAF(uint16_t DeviceAddr, uint32_t IO_Pin);
236 void stmpe811_IO_SetEdgeMode(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Edge);
237 void stmpe811_IO_WritePin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t PinState);
238 uint32_t stmpe811_IO_ReadPin(uint16_t DeviceAddr, uint32_t IO_Pin);
239 void stmpe811_IO_EnableIT(uint16_t DeviceAddr);
240 void stmpe811_IO_DisableIT(uint16_t DeviceAddr);
241 void stmpe811_IO_EnablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin);
242 void stmpe811_IO_DisablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin);
243 uint32_t stmpe811_IO_ITStatus(uint16_t DeviceAddr, uint32_t IO_Pin);
244 void stmpe811_IO_ClearIT(uint16_t DeviceAddr, uint32_t IO_Pin);
245 
249 void stmpe811_TS_Start(uint16_t DeviceAddr);
250 uint8_t stmpe811_TS_DetectTouch(uint16_t DeviceAddr);
251 void stmpe811_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y);
252 void stmpe811_TS_EnableIT(uint16_t DeviceAddr);
253 void stmpe811_TS_DisableIT(uint16_t DeviceAddr);
254 uint8_t stmpe811_TS_ITStatus (uint16_t DeviceAddr);
255 void stmpe811_TS_ClearIT (uint16_t DeviceAddr);
256 
257 void IOE_Init(void);
258 void IOE_ITConfig (void);
259 void IOE_Delay(uint32_t delay);
260 void IOE_Write(uint8_t addr, uint8_t reg, uint8_t value);
261 uint8_t IOE_Read(uint8_t addr, uint8_t reg);
262 uint16_t IOE_ReadMultiple(uint8_t addr, uint8_t reg, uint8_t *buffer, uint16_t length);
263 
264 /* Touch screen driver structure */
266 
267 /* IO driver structure */
269 
270 #ifdef __cplusplus
271 }
272 #endif
273 #endif /* __STMPE811_H */
274 
291 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
void stmpe811_TS_Start(uint16_t DeviceAddr)
STMPE811 Touch screen functionalities functions.
Definition: stmpe811.c:762
void stmpe811_EnableITSource(uint16_t DeviceAddr, uint8_t Source)
Enable the interrupt mode for the selected IT source.
Definition: stmpe811.c:246
void stmpe811_IO_SetEdgeMode(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Edge)
Configure the Edge for which a transition is detectable for the selected pin.
Definition: stmpe811.c:577
void stmpe811_Init(uint16_t DeviceAddr)
STMPE811 Control functions.
Definition: stmpe811.c:131
uint32_t stmpe811_IO_ReadPin(uint16_t DeviceAddr, uint32_t IO_Pin)
Return the state of the selected IO pin(s).
Definition: stmpe811.c:640
IO_ModeTypedef
Definition: io.h:74
void stmpe811_EnableGlobalIT(uint16_t DeviceAddr)
Enable the Global interrupt.
Definition: stmpe811.c:199
void stmpe811_IO_EnableIT(uint16_t DeviceAddr)
Enable the global IO interrupt source.
Definition: stmpe811.c:650
void stmpe811_TS_ClearIT(uint16_t DeviceAddr)
Configure the selected source to generate a global interrupt or not.
Definition: stmpe811.c:933
void stmpe811_IO_EnableAF(uint16_t DeviceAddr, uint32_t IO_Pin)
Enable the AF for the selected IO pin(s).
Definition: stmpe811.c:552
void stmpe811_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y)
Get the touch screen X and Y positions values.
Definition: stmpe811.c:869
void IOE_ITConfig(void)
uint8_t IOE_Read(uint8_t addr, uint8_t reg)
uint8_t stmpe811_ReadGITStatus(uint16_t DeviceAddr, uint8_t Source)
Return the Global interrupts status.
Definition: stmpe811.c:371
void stmpe811_IO_DisableAF(uint16_t DeviceAddr, uint32_t IO_Pin)
Disable the AF for the selected IO pin(s).
Definition: stmpe811.c:529
void IOE_Init(void)
void stmpe811_ClearGlobalIT(uint16_t DeviceAddr, uint8_t Source)
Clear the selected Global interrupt pending bit(s)
Definition: stmpe811.c:391
IO_DrvTypeDef stmpe811_io_drv
Definition: stmpe811.c:93
void stmpe811_IO_DisablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin)
Disable interrupt mode for the selected IO pin(s).
Definition: stmpe811.c:705
void stmpe811_TS_DisableIT(uint16_t DeviceAddr)
Configure the selected source to generate a global interrupt or not.
Definition: stmpe811.c:908
void IOE_Write(uint8_t addr, uint8_t reg, uint8_t value)
void stmpe811_SetITPolarity(uint16_t DeviceAddr, uint8_t Polarity)
Set the global interrupt Polarity.
Definition: stmpe811.c:295
uint8_t stmpe811_TS_DetectTouch(uint16_t DeviceAddr)
Return if there is touch detected or not.
Definition: stmpe811.c:837
uint16_t IOE_ReadMultiple(uint8_t addr, uint8_t reg, uint8_t *buffer, uint16_t length)
void stmpe811_IO_WritePin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t PinState)
Write a new IO pin state.
Definition: stmpe811.c:617
void stmpe811_IO_InitPin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Direction)
Initialize the selected IO pin direction.
Definition: stmpe811.c:500
uint16_t stmpe811_ReadID(uint16_t DeviceAddr)
Read the stmpe811 IO Expander device ID.
Definition: stmpe811.c:184
uint32_t stmpe811_IO_ITStatus(uint16_t DeviceAddr, uint32_t IO_Pin)
Check the status of the selected IO interrupt pending bit.
Definition: stmpe811.c:726
void IOE_Delay(uint32_t delay)
void stmpe811_Reset(uint16_t DeviceAddr)
Reset the stmpe811 by Software.
Definition: stmpe811.c:164
void stmpe811_TS_EnableIT(uint16_t DeviceAddr)
Configure the selected source to generate a global interrupt or not.
Definition: stmpe811.c:892
void stmpe811_IO_DisableIT(uint16_t DeviceAddr)
Disable the global IO interrupt source.
Definition: stmpe811.c:666
void stmpe811_DisableITSource(uint16_t DeviceAddr, uint8_t Source)
Disable the interrupt mode for the selected IT source.
Definition: stmpe811.c:273
void stmpe811_IO_EnablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin)
Enable interrupt mode for the selected IO pin(s).
Definition: stmpe811.c:683
uint8_t stmpe811_IO_Config(uint16_t DeviceAddr, uint32_t IO_Pin, IO_ModeTypedef IO_Mode)
Configures the IO pin(s) according to IO mode structure value.
Definition: stmpe811.c:437
void stmpe811_DisableGlobalIT(uint16_t DeviceAddr)
Disable the Global interrupt.
Definition: stmpe811.c:218
void stmpe811_IO_Start(uint16_t DeviceAddr, uint32_t IO_Pin)
STMPE811 IO functionalities functions.
Definition: stmpe811.c:405
TS_DrvTypeDef stmpe811_ts_drv
Definition: stmpe811.c:78
uint8_t stmpe811_TS_ITStatus(uint16_t DeviceAddr)
Configure the selected source to generate a global interrupt or not.
Definition: stmpe811.c:922
void stmpe811_SetITType(uint16_t DeviceAddr, uint8_t Type)
Set the global interrupt Type.
Definition: stmpe811.c:321
uint8_t stmpe811_GlobalITStatus(uint16_t DeviceAddr, uint8_t Source)
Check the selected Global interrupt source pending bit.
Definition: stmpe811.c:352
void stmpe811_IO_ClearIT(uint16_t DeviceAddr, uint32_t IO_Pin)
Clear the selected IO interrupt pending bit(s).
Definition: stmpe811.c:739