48 #include "../Common/ts.h" 49 #include "../Common/io.h" 75 #define STMPE811_ID 0x0811 78 #define STMPE811_REG_CHP_ID_LSB 0x00 79 #define STMPE811_REG_CHP_ID_MSB 0x01 80 #define STMPE811_REG_ID_VER 0x02 83 #define STMPE811_GIT_EN 0x01 86 #define STMPE811_ADC_FCT 0x01 87 #define STMPE811_TS_FCT 0x02 88 #define STMPE811_IO_FCT 0x04 89 #define STMPE811_TEMPSENS_FCT 0x08 92 #define STMPE811_GIT_IO 0x80 93 #define STMPE811_GIT_ADC 0x40 94 #define STMPE811_GIT_TEMP 0x20 95 #define STMPE811_GIT_FE 0x10 96 #define STMPE811_GIT_FF 0x08 97 #define STMPE811_GIT_FOV 0x04 98 #define STMPE811_GIT_FTH 0x02 99 #define STMPE811_GIT_TOUCH 0x01 100 #define STMPE811_ALL_GIT 0x1F 101 #define STMPE811_TS_IT (STMPE811_GIT_TOUCH | STMPE811_GIT_FTH | STMPE811_GIT_FOV | STMPE811_GIT_FF | STMPE811_GIT_FE) 104 #define STMPE811_REG_SYS_CTRL1 0x03 105 #define STMPE811_REG_SYS_CTRL2 0x04 106 #define STMPE811_REG_SPI_CFG 0x08 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 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 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 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 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) 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 179 #define STMPE811_DIRECTION_IN 0x00 180 #define STMPE811_DIRECTION_OUT 0x01 183 #define STMPE811_TYPE_LEVEL 0x00 184 #define STMPE811_TYPE_EDGE 0x02 187 #define STMPE811_POLARITY_LOW 0x00 188 #define STMPE811_POLARITY_HIGH 0x04 191 #define STMPE811_EDGE_FALLING 0x01 192 #define STMPE811_EDGE_RISING 0x02 195 #define STMPE811_TS_CTRL_ENABLE 0x01 196 #define STMPE811_TS_CTRL_STATUS 0x80 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);
void stmpe811_TS_Start(uint16_t DeviceAddr)
STMPE811 Touch screen functionalities functions.
void stmpe811_EnableITSource(uint16_t DeviceAddr, uint8_t Source)
Enable the interrupt mode for the selected IT source.
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.
void stmpe811_Init(uint16_t DeviceAddr)
STMPE811 Control functions.
uint32_t stmpe811_IO_ReadPin(uint16_t DeviceAddr, uint32_t IO_Pin)
Return the state of the selected IO pin(s).
void stmpe811_EnableGlobalIT(uint16_t DeviceAddr)
Enable the Global interrupt.
void stmpe811_IO_EnableIT(uint16_t DeviceAddr)
Enable the global IO interrupt source.
void stmpe811_TS_ClearIT(uint16_t DeviceAddr)
Configure the selected source to generate a global interrupt or not.
void stmpe811_IO_EnableAF(uint16_t DeviceAddr, uint32_t IO_Pin)
Enable the AF for the selected IO pin(s).
void stmpe811_TS_GetXY(uint16_t DeviceAddr, uint16_t *X, uint16_t *Y)
Get the touch screen X and Y positions values.
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.
void stmpe811_IO_DisableAF(uint16_t DeviceAddr, uint32_t IO_Pin)
Disable the AF for the selected IO pin(s).
void stmpe811_ClearGlobalIT(uint16_t DeviceAddr, uint8_t Source)
Clear the selected Global interrupt pending bit(s)
IO_DrvTypeDef stmpe811_io_drv
void stmpe811_IO_DisablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin)
Disable interrupt mode for the selected IO pin(s).
void stmpe811_TS_DisableIT(uint16_t DeviceAddr)
Configure the selected source to generate a global interrupt or not.
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.
uint8_t stmpe811_TS_DetectTouch(uint16_t DeviceAddr)
Return if there is touch detected or not.
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.
void stmpe811_IO_InitPin(uint16_t DeviceAddr, uint32_t IO_Pin, uint8_t Direction)
Initialize the selected IO pin direction.
uint16_t stmpe811_ReadID(uint16_t DeviceAddr)
Read the stmpe811 IO Expander device ID.
uint32_t stmpe811_IO_ITStatus(uint16_t DeviceAddr, uint32_t IO_Pin)
Check the status of the selected IO interrupt pending bit.
void IOE_Delay(uint32_t delay)
void stmpe811_Reset(uint16_t DeviceAddr)
Reset the stmpe811 by Software.
void stmpe811_TS_EnableIT(uint16_t DeviceAddr)
Configure the selected source to generate a global interrupt or not.
void stmpe811_IO_DisableIT(uint16_t DeviceAddr)
Disable the global IO interrupt source.
void stmpe811_DisableITSource(uint16_t DeviceAddr, uint8_t Source)
Disable the interrupt mode for the selected IT source.
void stmpe811_IO_EnablePinIT(uint16_t DeviceAddr, uint32_t IO_Pin)
Enable interrupt mode for the selected IO pin(s).
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.
void stmpe811_DisableGlobalIT(uint16_t DeviceAddr)
Disable the Global interrupt.
void stmpe811_IO_Start(uint16_t DeviceAddr, uint32_t IO_Pin)
STMPE811 IO functionalities functions.
TS_DrvTypeDef stmpe811_ts_drv
uint8_t stmpe811_TS_ITStatus(uint16_t DeviceAddr)
Configure the selected source to generate a global interrupt or not.
void stmpe811_SetITType(uint16_t DeviceAddr, uint8_t Type)
Set the global interrupt Type.
uint8_t stmpe811_GlobalITStatus(uint16_t DeviceAddr, uint8_t Source)
Check the selected Global interrupt source pending bit.
void stmpe811_IO_ClearIT(uint16_t DeviceAddr, uint32_t IO_Pin)
Clear the selected IO interrupt pending bit(s).