mikroSDK Reference Manual
STMPE811 Touch Controllers Driver

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...
 

Macros

#define STMPE811_MAP_PINS(cfg)
 STMPE811 Pin Mapping.
 
#define STMPE811_REG_ADDR_CHIP_ID   ((uint8_t)0x00)
 Enumeration holding all STMPE811 register adresses.
 
#define STMPE811_REG_ADDR_ID_VER   ((uint8_t)0x02)
 
#define STMPE811_REG_ADDR_SYS_CTRL1   ((uint8_t)0x03)
 
#define STMPE811_REG_ADDR_SYS_CTRL2   ((uint8_t)0x04)
 
#define STMPE811_REG_ADDR_SPI_CFG   ((uint8_t)0x08)
 
#define STMPE811_REG_ADDR_INT_CTRL   ((uint8_t)0x09)
 
#define STMPE811_REG_ADDR_INT_EN   ((uint8_t)0x0A)
 
#define STMPE811_REG_ADDR_INT_STA   ((uint8_t)0x0B)
 
#define STMPE811_REG_ADDR_GPIO_EN   ((uint8_t)0x0C)
 
#define STMPE811_REG_ADDR_GPIO_INT_STA   ((uint8_t)0x0D)
 
#define STMPE811_REG_ADDR_ADC_INT_EN   ((uint8_t)0x0E)
 
#define STMPE811_REG_ADDR_ADC_INT_STA   ((uint8_t)0x0F)
 
#define STMPE811_REG_ADDR_GPIO_SET_PIN   ((uint8_t)0x10)
 
#define STMPE811_REG_ADDR_GPIO_CLR_PIN   ((uint8_t)0x11)
 
#define STMPE811_REG_ADDR_GPIO_MP_STA   ((uint8_t)0x12)
 
#define STMPE811_REG_ADDR_GPIO_DIR   ((uint8_t)0x13)
 
#define STMPE811_REG_ADDR_GPIO_ED   ((uint8_t)0x14)
 
#define STMPE811_REG_ADDR_GPIO_RE   ((uint8_t)0x15)
 
#define STMPE811_REG_ADDR_GPIO_FE   ((uint8_t)0x16)
 
#define STMPE811_REG_ADDR_GPIO_AF   ((uint8_t)0x17)
 
#define STMPE811_REG_ADDR_ADC_CTRL1   ((uint8_t)0x20)
 
#define STMPE811_REG_ADDR_ADC_CTRL2   ((uint8_t)0x21)
 
#define STMPE811_REG_ADDR_ADC_CAPT   ((uint8_t)0x22)
 
#define STMPE811_REG_ADDR_ADC_DATA_CH0   ((uint8_t)0x30)
 
#define STMPE811_REG_ADDR_ADC_DATA_CH1   ((uint8_t)0x32)
 
#define STMPE811_REG_ADDR_ADC_DATA_CH2   ((uint8_t)0x34)
 
#define STMPE811_REG_ADDR_ADC_DATA_CH3   ((uint8_t)0x36)
 
#define STMPE811_REG_ADDR_ADC_DATA_CH4   ((uint8_t)0x38)
 
#define STMPE811_REG_ADDR_ADC_DATA_CH5   ((uint8_t)0x3A)
 
#define STMPE811_REG_ADDR_ADC_DATA_CH6   ((uint8_t)0x3C)
 
#define STMPE811_REG_ADDR_ADC_DATA_CH7   ((uint8_t)0x3E)
 
#define STMPE811_REG_ADDR_TSC_CTRL   ((uint8_t)0x40)
 
#define STMPE811_REG_ADDR_TSC_CFG   ((uint8_t)0x41)
 
#define STMPE811_REG_ADDR_WDW_TR_X   ((uint8_t)0x42)
 
#define STMPE811_REG_ADDR_WDW_TR_Y   ((uint8_t)0x44)
 
#define STMPE811_REG_ADDR_WDW_BL_X   ((uint8_t)0x46)
 
#define STMPE811_REG_ADDR_WDW_BL_Y   ((uint8_t)0x48)
 
#define STMPE811_REG_ADDR_FIFO_TH   ((uint8_t)0x4A)
 
#define STMPE811_REG_ADDR_FIFO_STA   ((uint8_t)0x4B)
 
#define STMPE811_REG_ADDR_FIFO_SIZE   ((uint8_t)0x4C)
 
#define STMPE811_REG_ADDR_TSC_DATA_X   ((uint8_t)0x4D)
 
#define STMPE811_REG_ADDR_TSC_DATA_Y   ((uint8_t)0x4F)
 
#define STMPE811_REG_ADDR_TSC_DATA_Z   ((uint8_t)0x51)
 
#define STMPE811_REG_ADDR_TSC_DATA_XYZ   ((uint8_t)0x52)
 
#define STMPE811_REG_ADDR_TSC_FRACTION_Z   ((uint8_t)0x56)
 
#define STMPE811_REG_ADDR_TSC_DATA   ((uint8_t)0x57)
 
#define STMPE811_REG_ADDR_TSC_I_DRIVE   ((uint8_t)0x58)
 
#define STMPE811_REG_ADDR_TSC_SHIELD   ((uint8_t)0x59)
 
#define STMPE811_REG_ADDR_TEMP_CTRL   ((uint8_t)0x60)
 
#define STMPE811_REG_ADDR_TEMP_DATA   ((uint8_t)0x61)
 
#define STMPE811_REG_ADDR_TEMP_TH   ((uint8_t)0x62)
 

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.
 

Macro Definition Documentation

◆ STMPE811_MAP_PINS

#define STMPE811_MAP_PINS ( cfg)
Value:
cfg.i2c_cfg.scl = CTP_SCL; \
cfg.i2c_cfg.sda = CTP_SDA; \
cfg.int_pin = CTP_INT

Utility macro for mapping STMPE811 touch controllers.

◆ STMPE811_REG_ADDR_ADC_CAPT

#define STMPE811_REG_ADDR_ADC_CAPT   ((uint8_t)0x22)

8 bit read/write xFF To initiate ADC data acquisition.

◆ STMPE811_REG_ADDR_ADC_CTRL1

#define STMPE811_REG_ADDR_ADC_CTRL1   ((uint8_t)0x20)

8 bit read/write 0x1C ADC control register.

◆ STMPE811_REG_ADDR_ADC_CTRL2

#define STMPE811_REG_ADDR_ADC_CTRL2   ((uint8_t)0x21)

8 bit read/write 0x01 ADC control register.

◆ STMPE811_REG_ADDR_ADC_DATA_CH0

#define STMPE811_REG_ADDR_ADC_DATA_CH0   ((uint8_t)0x30)

16 bit read only register for ADC channel 0.

◆ STMPE811_REG_ADDR_ADC_DATA_CH1

#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.

◆ STMPE811_REG_ADDR_ADC_DATA_CH2

#define STMPE811_REG_ADDR_ADC_DATA_CH2   ((uint8_t)0x34)

16 bit read only register for ADC channel 2.

◆ STMPE811_REG_ADDR_ADC_DATA_CH3

#define STMPE811_REG_ADDR_ADC_DATA_CH3   ((uint8_t)0x36)

16 bit read only register for ADC channel 3.

◆ STMPE811_REG_ADDR_ADC_DATA_CH4

#define STMPE811_REG_ADDR_ADC_DATA_CH4   ((uint8_t)0x38)

16 bit read only register for ADC channel 4.

◆ STMPE811_REG_ADDR_ADC_DATA_CH5

#define STMPE811_REG_ADDR_ADC_DATA_CH5   ((uint8_t)0x3A)

16 bit read only register for ADC channel 5.

◆ STMPE811_REG_ADDR_ADC_DATA_CH6

#define STMPE811_REG_ADDR_ADC_DATA_CH6   ((uint8_t)0x3C)

16 bit read only register for ADC channel 6.

◆ STMPE811_REG_ADDR_ADC_DATA_CH7

#define STMPE811_REG_ADDR_ADC_DATA_CH7   ((uint8_t)0x3E)

16 bit read only register for ADC channel 7.

◆ STMPE811_REG_ADDR_ADC_INT_EN

#define STMPE811_REG_ADDR_ADC_INT_EN   ((uint8_t)0x0E)

8 bit read/write ADC interrupt enable register.

◆ STMPE811_REG_ADDR_ADC_INT_STA

#define STMPE811_REG_ADDR_ADC_INT_STA   ((uint8_t)0x0F)

8 bit read only ADC interrupt status register.

◆ STMPE811_REG_ADDR_CHIP_ID

#define STMPE811_REG_ADDR_CHIP_ID   ((uint8_t)0x00)

16 bit read only only register Device identification. Value after reset: 0x0811

◆ STMPE811_REG_ADDR_FIFO_SIZE

#define STMPE811_REG_ADDR_FIFO_SIZE   ((uint8_t)0x4C)

8 bit read only Current filled level of FIFO.

◆ STMPE811_REG_ADDR_FIFO_STA

#define STMPE811_REG_ADDR_FIFO_STA   ((uint8_t)0x4B)

8 bit read/write Current status of FIFO. Value after reset: 0x20

◆ STMPE811_REG_ADDR_FIFO_TH

#define STMPE811_REG_ADDR_FIFO_TH   ((uint8_t)0x4A)

8 bit read/write FIFO level to generate interrupt. Value after reset: 0x00

◆ STMPE811_REG_ADDR_GPIO_AF

#define STMPE811_REG_ADDR_GPIO_AF   ((uint8_t)0x17)

8 bit read/write Alternate function register.

◆ STMPE811_REG_ADDR_GPIO_CLR_PIN

#define STMPE811_REG_ADDR_GPIO_CLR_PIN   ((uint8_t)0x11)

8 bit read/write GPIO clear pin register.

◆ STMPE811_REG_ADDR_GPIO_DIR

#define STMPE811_REG_ADDR_GPIO_DIR   ((uint8_t)0x13)

8 bit read/write GPIO direction register.

◆ STMPE811_REG_ADDR_GPIO_ED

#define STMPE811_REG_ADDR_GPIO_ED   ((uint8_t)0x14)

8 bit read/write GPIO edge detect register.

◆ STMPE811_REG_ADDR_GPIO_EN

#define STMPE811_REG_ADDR_GPIO_EN   ((uint8_t)0x0C)

8 bit read/write GPIO interrupt enable register.

◆ STMPE811_REG_ADDR_GPIO_FE

#define STMPE811_REG_ADDR_GPIO_FE   ((uint8_t)0x16)

8 bit read/write GPIO falling edge register.

◆ STMPE811_REG_ADDR_GPIO_INT_STA

#define STMPE811_REG_ADDR_GPIO_INT_STA   ((uint8_t)0x0D)

8 bit read only GPIO interrupt status register.

◆ STMPE811_REG_ADDR_GPIO_MP_STA

#define STMPE811_REG_ADDR_GPIO_MP_STA   ((uint8_t)0x12)

8 bit read/write GPIO monitor pin state register.

◆ STMPE811_REG_ADDR_GPIO_RE

#define STMPE811_REG_ADDR_GPIO_RE   ((uint8_t)0x15)

8 bit read/write GPIO rising edge register.

◆ STMPE811_REG_ADDR_GPIO_SET_PIN

#define STMPE811_REG_ADDR_GPIO_SET_PIN   ((uint8_t)0x10)

8 bit read/write GPIO set pin register.

◆ STMPE811_REG_ADDR_ID_VER

#define STMPE811_REG_ADDR_ID_VER   ((uint8_t)0x02)

8 bit read only register for revision number engineering sample final silicon, value : 0x03.

◆ STMPE811_REG_ADDR_INT_CTRL

#define STMPE811_REG_ADDR_INT_CTRL   ((uint8_t)0x09)

8 bit read/write interrupt control register.

◆ STMPE811_REG_ADDR_INT_EN

#define STMPE811_REG_ADDR_INT_EN   ((uint8_t)0x0A)

8 bit read/write interrupt enable register.

◆ STMPE811_REG_ADDR_INT_STA

#define STMPE811_REG_ADDR_INT_STA   ((uint8_t)0x0B)

8 bit read only interrupt status register.

◆ STMPE811_REG_ADDR_SPI_CFG

#define STMPE811_REG_ADDR_SPI_CFG   ((uint8_t)0x08)

8 bit read/write register for SPI interface configuration. Value after reset 0x01

◆ STMPE811_REG_ADDR_SYS_CTRL1

#define STMPE811_REG_ADDR_SYS_CTRL1   ((uint8_t)0x03)

8 bit read/write register for reset control. Value after reset 0x00

◆ STMPE811_REG_ADDR_SYS_CTRL2

#define STMPE811_REG_ADDR_SYS_CTRL2   ((uint8_t)0x04)

8 bit read/write register for clock control. Value after reset: 0x0F.

◆ STMPE811_REG_ADDR_TEMP_CTRL

#define STMPE811_REG_ADDR_TEMP_CTRL   ((uint8_t)0x60)

8 bit read/write register. Temperature sensor setup. Value after reset: 0x00

◆ STMPE811_REG_ADDR_TEMP_DATA

#define STMPE811_REG_ADDR_TEMP_DATA   ((uint8_t)0x61)

8 bit read only register. Temperature data access port. Value after reset: 0x00

◆ STMPE811_REG_ADDR_TEMP_TH

#define STMPE811_REG_ADDR_TEMP_TH   ((uint8_t)0x62)

8 bit read/write register. Threshold for temperature controlled interrupt. Value after reset: 0x00::define

◆ STMPE811_REG_ADDR_TSC_CFG

#define STMPE811_REG_ADDR_TSC_CFG   ((uint8_t)0x41)

8 bit read/write Touchscreen controller configuration. Value after reset: 0x00

◆ STMPE811_REG_ADDR_TSC_CTRL

#define STMPE811_REG_ADDR_TSC_CTRL   ((uint8_t)0x40)

8 bit read/write 4-wire touchscreen controller setup. Value after reset: 0x90

◆ STMPE811_REG_ADDR_TSC_DATA

#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

◆ STMPE811_REG_ADDR_TSC_DATA_X

#define STMPE811_REG_ADDR_TSC_DATA_X   ((uint8_t)0x4D)

16 bit read only Data port for touchscreen controller data access.

◆ STMPE811_REG_ADDR_TSC_DATA_XYZ

#define STMPE811_REG_ADDR_TSC_DATA_XYZ   ((uint8_t)0x52)

32 bit read only Data port for touchscreen controller data access.

◆ STMPE811_REG_ADDR_TSC_DATA_Y

#define STMPE811_REG_ADDR_TSC_DATA_Y   ((uint8_t)0x4F)

16 bit read only Data port for touchscreen controller data access.

◆ STMPE811_REG_ADDR_TSC_DATA_Z

#define STMPE811_REG_ADDR_TSC_DATA_Z   ((uint8_t)0x51)

8 bit read only Data port for touchscreen controller data access.

◆ STMPE811_REG_ADDR_TSC_FRACTION_Z

#define STMPE811_REG_ADDR_TSC_FRACTION_Z   ((uint8_t)0x56)

8 bit Touchscreen controller FRACTION_Z. Value after reset: 0x00

◆ STMPE811_REG_ADDR_TSC_I_DRIVE

#define STMPE811_REG_ADDR_TSC_I_DRIVE   ((uint8_t)0x58)

8 bit read/write register. Touchscreen controller drive I. Value after reset: 0x00

◆ STMPE811_REG_ADDR_TSC_SHIELD

#define STMPE811_REG_ADDR_TSC_SHIELD   ((uint8_t)0x59)

8 bit read/write register. Touchscreen controller shield. Value after reset: 0x00

◆ STMPE811_REG_ADDR_WDW_BL_X

#define STMPE811_REG_ADDR_WDW_BL_X   ((uint8_t)0x46)

16 bit read/write Window setup for bottom left X. Value after reset: 0x0000

◆ STMPE811_REG_ADDR_WDW_BL_Y

#define STMPE811_REG_ADDR_WDW_BL_Y   ((uint8_t)0x48)

16 bit read/write Window setup for bottom left Y. Value after reset: 0x0000

◆ STMPE811_REG_ADDR_WDW_TR_X

#define STMPE811_REG_ADDR_WDW_TR_X   ((uint8_t)0x42)

16 bit read/write Window setup for top right X. Value after reset: 0x0fff

◆ STMPE811_REG_ADDR_WDW_TR_Y

#define STMPE811_REG_ADDR_WDW_TR_Y   ((uint8_t)0x44)

16 bit read/write Window setup for top right Y. Value after reset: 0x0fff

Function Documentation

◆ stmpe811_calibrate()

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.

Parameters
[in]ctxInitialized STMPE811 context structure. See stmpe811_t for more information about the context structure.
Return values
Nothing.

◆ stmpe811_cfg_setup()

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

Parameters
[out]cfgSTMPE811 configuration object.
Return values
Nothing.

◆ stmpe811_default_cfg()

◆ stmpe811_generic_read()

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.

Parameters
[in]ctxInitialized STMPE811 context structure. See stmpe811_t for more information about the context structure.
[in]reg_addrRegister address from where reading will start.
[out]buffBuffer where read data will be stored.
[in]lenLength of data to be read.
Return values
Nothing.

◆ stmpe811_generic_read_byte()

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.

Parameters
[in]ctxInitialized STMPE811 context structure. See stmpe811_t for more information about the context structure.
[in]reg_addrRegister address from which single byte will be read. See stmpe811_reg_addr_t for more information about register addresses.
Return values
Registervalue.

◆ stmpe811_generic_write()

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.

Parameters
[in]ctxInitialized STMPE811 context structure. See stmpe811_t for more information about the context structure.
[in]reg_addrRegister address from where writing will start.
[in]buffData that will be written to register address.
[in]lenLength of data to be written.
Return values
Nothing.

◆ stmpe811_generic_write_byte()

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.

Parameters
[in]ctxInitialized STMPE811 context structure. See stmpe811_t for more information about the context structure.
[in]reg_addr_addrRegister address where single byte will be written. See stmpe811_reg_addr_t for more information about register addresses.
[in]valueValue that will be written to register address.
Return values
Nothing.

◆ stmpe811_gesture()

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.

Parameters
[in]ctxInitialized STMPE811 context structure. See stmpe811_t for more information about the context structure.
Note
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.
Parameters
[out]eventTouch panel gesture data, always TP_EVENT_GEST_NONE. See tp_event_t * definition for detailed explanation.
Return values
Nothing.

◆ stmpe811_get_calibration_data()

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.

Parameters
[in]ctxInitialized STMPE811 context structure. See stmpe811_t for more
[out]cdataPointer to memory where calibration data will be stored.

◆ stmpe811_init()

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.

Note
By default, STMPE811 stucture is initialized with calibration constants for MikroE harware, in case of different hardware stmpe811_set_calibration_data is available for seting already determined calibration constants and stmpe811_calibrate is available for determinig new calibraiton constants.
Parameters
[in]ctxInitialized STMPE811 context structure. See stmpe811_t for more information about the context structure.
[in]cfgSTMPE811 configuration object. See stmpe811_cfg_t structure definition for detailed explanation.
[out]drvTP driver interface object. See tp_drv_t structure definition for detailed explanation.
Return values

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.

◆ stmpe811_press_coordinates()

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.

Parameters
[in]ctxInitialized STMPE811 context structure. See stmpe811_t for more information about the context structure.
[out]touch_item
Return values
Nothing.

◆ stmpe811_press_detect()

tp_event_t stmpe811_press_detect ( stmpe811_t * ctx)

Retrives information about press detection from STMPE811.

Note
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.
Parameters
[in]ctxInitialized STMPE811 context structure. See stmpe811_t for more information about the context structure.
Return values

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.

◆ stmpe811_process()

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.

Note
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.
Function needs STMPE811 to be configured to trigger interupt on touch det since it relies on polling the interrupt pin.
Parameters
[in]ctxInitialized STMPE811 context structure. See stmpe811_t for more information about the context structure.
Return values
Alwaysreturns TP_OK. see tp_err_t for more details.

◆ stmpe811_read_xyz()

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.

Parameters
[in]ctxInitialized STMPE811 context structure. See stmpe811_t for more
Note
STMPE811 should be configured for x,y,z operation mode in order to read all values.
Parameters
[out]xPointer to memory where pixel x coordinate will be stored.
[out]yPointer to memory where pixel y coordinate will be stored.
[out]zPointer to memory where z value will be stored.
Return values
Nothing.

◆ stmpe811_read_xyz_raw()

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.

Parameters
[in]ctxInitialized STMPE811 context structure. See stmpe811_t for more
[out]xPointer to memory where raw x coordinate will be stored.
[out]yPointer to memory where raw y coordinate will be stored.
[out]zPointer to memory where z value will be stored.
Return values
Nothing.

◆ stmpe811_set_calibration_data()

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.

Parameters
[in]ctxInitialized STMPE811 context structure. See stmpe811_t for more
[out]cdataPointer to memory from where new calibration will be copied and set.

Variable Documentation

◆ STMPE811_DEFAULT_CALIBRATION_DATA

const stmpe811_calibration_data_t STMPE811_DEFAULT_CALIBRATION_DATA
extern

Data useful for skipping calibration when working with MikroE hardware. Gives reasonable touch precision on any size resitive tft board.