mikroSDK Reference Manual
STMPE811 Touch Controllers Driver

STMPE811 Touch Controller Driver API Reference. More...

Modules

 STMPE811 Slave Addresses
 
 STMPE811 Pin Mapping
 
 STMPE811 Registers
 
 STMPE811 FIFO_CTRL_STA Register Bits
 
 STMPE811 TSC_CTRL Register Bits
 
 STMPE811 INT_CTRL Register Bits
 
 STMPE811 SYS_CTRL2 Register Bits
 
 STMPE811 INT_STA Register Bits
 
 STMPE811 ADC_CTRL2 Register Bits
 
 STMPE811 ADC_CTRL1 Register Bits
 
 STMPE811 TSC_CFG Register Bits
 

Functions list

void stmpe811_cfg_setup (stmpe811_cfg_t *cfg)
 STMPE811 configuration object setup function. More...
 
tp_err_t stmpe811_init (stmpe811_t *ctx, stmpe811_cfg_t *cfg, tp_drv_t *drv)
 STMPE811 Initialization Function. More...
 
void stmpe811_default_cfg (stmpe811_t *ctx)
 STMPE811 Default Configuration Function. More...
 
void stmpe811_press_coordinates (stmpe811_t *ctx, tp_touch_item_t *touch_item)
 Copies touch information from context object to touch item object. More...
 
tp_event_t stmpe811_press_detect (stmpe811_t *ctx)
 Press detection function. More...
 
tp_err_t stmpe811_process (stmpe811_t *ctx)
 Function processing events. More...
 
void stmpe811_gesture (stmpe811_t *ctx, tp_event_t *event)
 Read gesture information. More...
 
uint8_t stmpe811_generic_read_byte (stmpe811_t *ctx, uint8_t reg_addr)
 Reads a single byte from a register. More...
 
void stmpe811_generic_write_byte (stmpe811_t *ctx, uint8_t reg_addr, uint8_t val)
 Writes a single byte to a register. More...
 
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. More...
 
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. More...
 
void stmpe811_calibrate (stmpe811_t *ctx)
 Calibrates variables used for converting raw stmpe811 ADC values to pixel coordinates. More...
 
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. More...
 
void stmpe811_read_xyz_raw (stmpe811_t *ctx, uint16_t *x, uint16_t *y, uint16_t *z)
 Utility funciton used for calibration. More...
 
void stmpe811_get_calibration_data (stmpe811_t *ctx, stmpe811_calibration_data_t *cdata)
 Utility funciton used for getting a copy of current calibration data. More...
 
void stmpe811_set_calibration_data (stmpe811_t *ctx, const stmpe811_calibration_data_t *cdata)
 Utility funciton used for setting calibration data. More...
 

Detailed Description

API for configuring and manipulating STMPE811 Touch Controller driver.

Function Documentation

◆ 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.
Returns
Nothing.

◆ 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.
Returns
  • 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_default_cfg()

void stmpe811_default_cfg ( stmpe811_t ctx)

Configures the device according to http://www.bdtic.com/download/ST/AN2807.pdf

  • turns off GPIO and temperature sensor
  • sets interrupt on touch detect and fifo threshold
  • sets single point reading mode
  • sets settling time to 500us, touch delay to 500us and 12 bit ADC mode
  • configures coordinate mode to X, Y and Z mode
    Parameters
    [in]ctxInitialized STMPE811 context structure. See stmpe811_t for more information about the context structure.
    Returns
    Nothing.

◆ 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
Returns
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.
Returns
  • 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.
Returns
Always returns TP_OK. see tp_err_t for more details.

◆ 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.
Returns
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 Registers for more information about register addresses.
Returns
Register value.

◆ 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_addrRegister address where single byte will be written. See STMPE811 Registers for more information about register addresses.
[in]valValue that will be written to register address.
Returns
Nothing.

◆ 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. Usefull 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.
Returns
Nothing.

◆ 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. Usefull 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.
Returns
Nothing.

◆ 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.
Returns
Nothing.

◆ 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.
Returns
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.
Returns
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_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.