mikroSDK Reference Manual
|
STMPE811 Touch Controller Driver API Reference. More...
Topics | |
Stmpe811_slave_addreses | |
Defines for two possible STMPE811 slave addreses. | |
FIFO_STA register bits | |
TSC_CTRL_register_bits | |
INT_CTRL_register_bits | |
SYS_CTRL2_register_bits | |
INTERUPT_bits | |
ADC_CTRL2_register_bits | |
ADC_CTRL1_register_bits | |
TSC_CFG_register_bits | |
Data Structures | |
struct | stmpe811_calibration_data_t |
Calibration data structure. More... | |
struct | stmpe811_cfg_t |
STMPE811 Configuration Object. More... | |
struct | stmpe811_t |
STMPE811 Context Object. More... | |
Functions list | |
void | stmpe811_cfg_setup (stmpe811_cfg_t *cfg) |
STMPE811 configuration object setup function. | |
tp_err_t | stmpe811_init (stmpe811_t *ctx, stmpe811_cfg_t *cfg, tp_drv_t *drv) |
STMPE811 Initialization Function. | |
void | stmpe811_default_cfg (stmpe811_t *ctx) |
STMPE811 Default Configuration Function. | |
void | stmpe811_press_coordinates (stmpe811_t *ctx, tp_touch_item_t *touch_item) |
Copies touch information from context object to touch item object. | |
tp_event_t | stmpe811_press_detect (stmpe811_t *ctx) |
Press detection function. | |
tp_err_t | stmpe811_process (stmpe811_t *ctx) |
Function processing events. | |
void | stmpe811_gesture (stmpe811_t *ctx, tp_event_t *event) |
Read gesture information. | |
uint8_t | stmpe811_generic_read_byte (stmpe811_t *ctx, uint8_t reg_addr) |
Reads a single byte from a register. | |
void | stmpe811_generic_write_byte (stmpe811_t *ctx, uint8_t reg_addr, uint8_t val) |
Writes a single byte to a register. | |
void | stmpe811_generic_read (stmpe811_t *ctx, uint8_t reg_addr, uint8_t *buff, uint8_t len) |
Reads desired number of bytes from register to a buffer. | |
void | stmpe811_generic_write (stmpe811_t *ctx, uint8_t reg_addr, uint8_t *buff, uint8_t len) |
Writes desired number of bytes from buffer to a register. | |
void | stmpe811_calibrate (stmpe811_t *ctx) |
Calibrates variables used for converting raw stmpe811 ADC values to pixel coordinates. | |
void | stmpe811_read_xyz (stmpe811_t *ctx, uint16_t *x, uint16_t *y, uint16_t *z) |
Reads x & y coordinate values to x, y, z addresses. | |
void | stmpe811_read_xyz_raw (stmpe811_t *ctx, uint16_t *x, uint16_t *y, uint16_t *z) |
Utility funciton used for calibration. | |
void | stmpe811_get_calibration_data (stmpe811_t *ctx, stmpe811_calibration_data_t *cdata) |
Utility funciton used for getting a copy of current calibration data. | |
void | stmpe811_set_calibration_data (stmpe811_t *ctx, const stmpe811_calibration_data_t *cdata) |
Utility funciton used for setting calibration data. | |
Variables | |
const stmpe811_calibration_data_t | STMPE811_DEFAULT_CALIBRATION_DATA |
Default calibration data specific for MikroE resistive tft boards. | |
#define STMPE811_MAP_PINS | ( | cfg | ) |
Utility macro for mapping STMPE811 touch controllers.
#define STMPE811_REG_ADDR_ADC_CAPT ((uint8_t)0x22) |
8 bit read/write xFF To initiate ADC data acquisition.
#define STMPE811_REG_ADDR_ADC_CTRL1 ((uint8_t)0x20) |
8 bit read/write 0x1C ADC control register.
#define STMPE811_REG_ADDR_ADC_CTRL2 ((uint8_t)0x21) |
8 bit read/write 0x01 ADC control register.
#define STMPE811_REG_ADDR_ADC_DATA_CH0 ((uint8_t)0x30) |
16 bit read only register for ADC channel 0.
#define STMPE811_REG_ADDR_ADC_DATA_CH1 ((uint8_t)0x32) |
16 bit read only register for ADC channel 1 STMPE811 registers STMPE811 20/66 Doc ID 14489 Rev 5.
#define STMPE811_REG_ADDR_ADC_DATA_CH2 ((uint8_t)0x34) |
16 bit read only register for ADC channel 2.
#define STMPE811_REG_ADDR_ADC_DATA_CH3 ((uint8_t)0x36) |
16 bit read only register for ADC channel 3.
#define STMPE811_REG_ADDR_ADC_DATA_CH4 ((uint8_t)0x38) |
16 bit read only register for ADC channel 4.
#define STMPE811_REG_ADDR_ADC_DATA_CH5 ((uint8_t)0x3A) |
16 bit read only register for ADC channel 5.
#define STMPE811_REG_ADDR_ADC_DATA_CH6 ((uint8_t)0x3C) |
16 bit read only register for ADC channel 6.
#define STMPE811_REG_ADDR_ADC_DATA_CH7 ((uint8_t)0x3E) |
16 bit read only register for ADC channel 7.
#define STMPE811_REG_ADDR_ADC_INT_EN ((uint8_t)0x0E) |
8 bit read/write ADC interrupt enable register.
#define STMPE811_REG_ADDR_ADC_INT_STA ((uint8_t)0x0F) |
8 bit read only ADC interrupt status register.
#define STMPE811_REG_ADDR_CHIP_ID ((uint8_t)0x00) |
16 bit read only only register Device identification. Value after reset: 0x0811
#define STMPE811_REG_ADDR_FIFO_SIZE ((uint8_t)0x4C) |
8 bit read only Current filled level of FIFO.
#define STMPE811_REG_ADDR_FIFO_STA ((uint8_t)0x4B) |
8 bit read/write Current status of FIFO. Value after reset: 0x20
#define STMPE811_REG_ADDR_FIFO_TH ((uint8_t)0x4A) |
8 bit read/write FIFO level to generate interrupt. Value after reset: 0x00
#define STMPE811_REG_ADDR_GPIO_AF ((uint8_t)0x17) |
8 bit read/write Alternate function register.
#define STMPE811_REG_ADDR_GPIO_CLR_PIN ((uint8_t)0x11) |
8 bit read/write GPIO clear pin register.
#define STMPE811_REG_ADDR_GPIO_DIR ((uint8_t)0x13) |
8 bit read/write GPIO direction register.
#define STMPE811_REG_ADDR_GPIO_ED ((uint8_t)0x14) |
8 bit read/write GPIO edge detect register.
#define STMPE811_REG_ADDR_GPIO_EN ((uint8_t)0x0C) |
8 bit read/write GPIO interrupt enable register.
#define STMPE811_REG_ADDR_GPIO_FE ((uint8_t)0x16) |
8 bit read/write GPIO falling edge register.
#define STMPE811_REG_ADDR_GPIO_INT_STA ((uint8_t)0x0D) |
8 bit read only GPIO interrupt status register.
#define STMPE811_REG_ADDR_GPIO_MP_STA ((uint8_t)0x12) |
8 bit read/write GPIO monitor pin state register.
#define STMPE811_REG_ADDR_GPIO_RE ((uint8_t)0x15) |
8 bit read/write GPIO rising edge register.
#define STMPE811_REG_ADDR_GPIO_SET_PIN ((uint8_t)0x10) |
8 bit read/write GPIO set pin register.
#define STMPE811_REG_ADDR_ID_VER ((uint8_t)0x02) |
8 bit read only register for revision number engineering sample final silicon, value : 0x03.
#define STMPE811_REG_ADDR_INT_CTRL ((uint8_t)0x09) |
8 bit read/write interrupt control register.
#define STMPE811_REG_ADDR_INT_EN ((uint8_t)0x0A) |
8 bit read/write interrupt enable register.
#define STMPE811_REG_ADDR_INT_STA ((uint8_t)0x0B) |
8 bit read only interrupt status register.
#define STMPE811_REG_ADDR_SPI_CFG ((uint8_t)0x08) |
8 bit read/write register for SPI interface configuration. Value after reset 0x01
#define STMPE811_REG_ADDR_SYS_CTRL1 ((uint8_t)0x03) |
8 bit read/write register for reset control. Value after reset 0x00
#define STMPE811_REG_ADDR_SYS_CTRL2 ((uint8_t)0x04) |
8 bit read/write register for clock control. Value after reset: 0x0F.
#define STMPE811_REG_ADDR_TEMP_CTRL ((uint8_t)0x60) |
8 bit read/write register. Temperature sensor setup. Value after reset: 0x00
#define STMPE811_REG_ADDR_TEMP_DATA ((uint8_t)0x61) |
8 bit read only register. Temperature data access port. Value after reset: 0x00
#define STMPE811_REG_ADDR_TEMP_TH ((uint8_t)0x62) |
8 bit read/write register. Threshold for temperature controlled interrupt. Value after reset: 0x00::define
#define STMPE811_REG_ADDR_TSC_CFG ((uint8_t)0x41) |
8 bit read/write Touchscreen controller configuration. Value after reset: 0x00
#define STMPE811_REG_ADDR_TSC_CTRL ((uint8_t)0x40) |
8 bit read/write 4-wire touchscreen controller setup. Value after reset: 0x90
#define STMPE811_REG_ADDR_TSC_DATA ((uint8_t)0x57) |
8 bit read only register. Data port for touchscreen controller data access. Value after reset: 0x00
#define STMPE811_REG_ADDR_TSC_DATA_X ((uint8_t)0x4D) |
16 bit read only Data port for touchscreen controller data access.
#define STMPE811_REG_ADDR_TSC_DATA_XYZ ((uint8_t)0x52) |
32 bit read only Data port for touchscreen controller data access.
#define STMPE811_REG_ADDR_TSC_DATA_Y ((uint8_t)0x4F) |
16 bit read only Data port for touchscreen controller data access.
#define STMPE811_REG_ADDR_TSC_DATA_Z ((uint8_t)0x51) |
8 bit read only Data port for touchscreen controller data access.
#define STMPE811_REG_ADDR_TSC_FRACTION_Z ((uint8_t)0x56) |
8 bit Touchscreen controller FRACTION_Z. Value after reset: 0x00
#define STMPE811_REG_ADDR_TSC_I_DRIVE ((uint8_t)0x58) |
8 bit read/write register. Touchscreen controller drive I. Value after reset: 0x00
#define STMPE811_REG_ADDR_TSC_SHIELD ((uint8_t)0x59) |
8 bit read/write register. Touchscreen controller shield. Value after reset: 0x00
#define STMPE811_REG_ADDR_WDW_BL_X ((uint8_t)0x46) |
16 bit read/write Window setup for bottom left X. Value after reset: 0x0000
#define STMPE811_REG_ADDR_WDW_BL_Y ((uint8_t)0x48) |
16 bit read/write Window setup for bottom left Y. Value after reset: 0x0000
#define STMPE811_REG_ADDR_WDW_TR_X ((uint8_t)0x42) |
16 bit read/write Window setup for top right X. Value after reset: 0x0fff
#define STMPE811_REG_ADDR_WDW_TR_Y ((uint8_t)0x44) |
16 bit read/write Window setup for top right Y. Value after reset: 0x0fff
void stmpe811_calibrate | ( | stmpe811_t * | ctx | ) |
Function nees the user to touch all four corners as close to the edges as possible to find the extreme values. Function also supports holding a pen and moving it across the screen and will use the most extreme coordinates found during that move as corner coordinates, so touching a screen and draging a finger over the one of the four edges unitl touch is no longer detected will give pretty good calibration data.
[in] | ctx | Initialized STMPE811 context structure. See stmpe811_t for more information about the context structure. |
Nothing. |
void stmpe811_cfg_setup | ( | stmpe811_cfg_t * | cfg | ) |
This function initializes STMPE811 configuration structure to default values. Interupt pin will be set to unconnected, screen dimenstion will be set to 0, press threshold will be set to 0 and
[out] | cfg | STMPE811 configuration object. |
Nothing. |
void stmpe811_default_cfg | ( | stmpe811_t * | ctx | ) |
void stmpe811_generic_read | ( | stmpe811_t * | ctx, |
uint8_t | reg_addr, | ||
uint8_t * | buff, | ||
uint8_t | len ) |
This function provides ability to read desired nubmer of bytes from a STMPE811 register. Useful for the small amout of registers that are larger than one byte in size, such as TSC_DATA_XYZ and windowing parameters registers.
[in] | ctx | Initialized STMPE811 context structure. See stmpe811_t for more information about the context structure. |
[in] | reg_addr | Register address from where reading will start. |
[out] | buff | Buffer where read data will be stored. |
[in] | len | Length of data to be read. |
Nothing. |
uint8_t stmpe811_generic_read_byte | ( | stmpe811_t * | ctx, |
uint8_t | reg_addr ) |
This function provides easy single byte read to a STMPE811 register since most of the registers are only 1 byte in size.
[in] | ctx | Initialized STMPE811 context structure. See stmpe811_t for more information about the context structure. |
[in] | reg_addr | Register address from which single byte will be read. See stmpe811_reg_addr_t for more information about register addresses. |
Register | value. |
void stmpe811_generic_write | ( | stmpe811_t * | ctx, |
uint8_t | reg_addr, | ||
uint8_t * | buff, | ||
uint8_t | len ) |
This function provides ability to read desired nubmer of bytes to a STMPE811 register. Useful for the small amout of registers that are larger than one byte in size, such as TSC_DATA_XYZ and windowing parameters registers.
[in] | ctx | Initialized STMPE811 context structure. See stmpe811_t for more information about the context structure. |
[in] | reg_addr | Register address from where writing will start. |
[in] | buff | Data that will be written to register address. |
[in] | len | Length of data to be written. |
Nothing. |
void stmpe811_generic_write_byte | ( | stmpe811_t * | ctx, |
uint8_t | reg_addr, | ||
uint8_t | val ) |
This function provides easy single byte write to a STMPE811 register since most of the registers are only 1 byte in size.
[in] | ctx | Initialized STMPE811 context structure. See stmpe811_t for more information about the context structure. |
[in] | reg_addr_addr | Register address where single byte will be written. See stmpe811_reg_addr_t for more information about register addresses. |
[in] | value | Value that will be written to register address. |
Nothing. |
void stmpe811_gesture | ( | stmpe811_t * | ctx, |
tp_event_t * | event ) |
Since STMPE811 does not support gestures this function is purely for interfacing with the tp library. Gesture returned from the function is always no gesture.
[in] | ctx | Initialized STMPE811 context structure. See stmpe811_t for more information about the context structure. |
[out] | event | Touch panel gesture data, always TP_EVENT_GEST_NONE. See tp_event_t * definition for detailed explanation. |
Nothing. |
void stmpe811_get_calibration_data | ( | stmpe811_t * | ctx, |
stmpe811_calibration_data_t * | cdata ) |
Function copies data that's being e used for converting raw ADC values to actual pixel coordinates.
[in] | ctx | Initialized STMPE811 context structure. See stmpe811_t for more |
[out] | cdata | Pointer to memory where calibration data will be stored. |
tp_err_t stmpe811_init | ( | stmpe811_t * | ctx, |
stmpe811_cfg_t * | cfg, | ||
tp_drv_t * | drv ) |
This function initializes STMPE811 context object using configuration values from STMPE811 configuration object and allows touch panel driver interface object to be linked with STMPE811 driver functions.
[in] | ctx | Initialized STMPE811 context structure. See stmpe811_t for more information about the context structure. |
[in] | cfg | STMPE811 configuration object. See stmpe811_cfg_t structure definition for detailed explanation. |
[out] | drv | TP driver interface object. See tp_drv_t structure definition for detailed explanation. |
li TP_OK
OK,
TP_ERR_INIT_DRV
I2C driver init error, TP_ERR_UNSUPPORTED_PIN
Unsupported pin. See tp_err_t structure definition for detailed explanation. void stmpe811_press_coordinates | ( | stmpe811_t * | ctx, |
tp_touch_item_t * | touch_item ) |
This function is necessary for interfacing with touch panel library as it's address is stored in tp_drv_t driver structure during the STMPE811 context initialization.
[in] | ctx | Initialized STMPE811 context structure. See stmpe811_t for more information about the context structure. |
[out] | touch_item |
Nothing. |
tp_event_t stmpe811_press_detect | ( | stmpe811_t * | ctx | ) |
Retrives information about press detection from STMPE811.
[in] | ctx | Initialized STMPE811 context structure. See stmpe811_t for more information about the context structure. |
li TP_EVENT_PRESS_NOT_DET
- Touch pressure is not detected.
TP_EVENT_PRESS_DET
- Touch pressure is detected. See tp_err_t structure definition for detailed explanation. tp_err_t stmpe811_process | ( | stmpe811_t * | ctx | ) |
This function check if touch was detected and if it was reads and stores touch information in context structure and checks if it's touch down, up or move.
[in] | ctx | Initialized STMPE811 context structure. See stmpe811_t for more information about the context structure. |
Always | returns TP_OK. see tp_err_t for more details. |
void stmpe811_read_xyz | ( | stmpe811_t * | ctx, |
uint16_t * | x, | ||
uint16_t * | y, | ||
uint16_t * | z ) |
Reads coordinate date and converts x and y to appropriate pixel coordinates then clears the FIFO coordinate memory.
[in] | ctx | Initialized STMPE811 context structure. See stmpe811_t for more |
[out] | x | Pointer to memory where pixel x coordinate will be stored. |
[out] | y | Pointer to memory where pixel y coordinate will be stored. |
[out] | z | Pointer to memory where z value will be stored. |
Nothing. |
void stmpe811_read_xyz_raw | ( | stmpe811_t * | ctx, |
uint16_t * | x, | ||
uint16_t * | y, | ||
uint16_t * | z ) |
reads raw adc values of x,y and z without mapping them to screen coordinates then clears the FIFO coordinate memory.
[in] | ctx | Initialized STMPE811 context structure. See stmpe811_t for more |
[out] | x | Pointer to memory where raw x coordinate will be stored. |
[out] | y | Pointer to memory where raw y coordinate will be stored. |
[out] | z | Pointer to memory where z value will be stored. |
Nothing. |
void stmpe811_set_calibration_data | ( | stmpe811_t * | ctx, |
const stmpe811_calibration_data_t * | cdata ) |
Function copies data stored in data
. That information will be be used for converting raw ADC values to actual pixel coordinates.
[in] | ctx | Initialized STMPE811 context structure. See stmpe811_t for more |
[out] | cdata | Pointer to memory from where new calibration will be copied and set. |
|
extern |
Data useful for skipping calibration when working with MikroE hardware. Gives reasonable touch precision on any size resitive tft board.