mikroSDK Reference Manual
TSC2003 Touch Controller Driver

TSC2003 Touch Controller Driver API Reference. More...

Modules

 TSC2003 Slave Addresses
 I2C device address options.
 
 TSC2003 Pin Mapping
 Macro for mapping TSC2003 touch controller I2C pins.
 

Functions list

void tsc2003_cfg_setup (tsc2003_cfg_t *cfg)
 TSC2003 configuration object setup function. More...
 
tp_err_t tsc2003_init (tsc2003_t *ctx, tsc2003_cfg_t *cfg, tp_drv_t *drv)
 TSC2003 Initialization Function. More...
 
void tsc2003_default_cfg (tsc2003_t *ctx)
 TSC2003 Default Configuration Function. More...
 
void tsc2003_press_coordinates (tsc2003_t *ctx, tp_touch_item_t *touch_item)
 Copies touch information from context object to touch item object. More...
 
tp_event_t tsc2003_press_detect (tsc2003_t *ctx)
 Press detection function. More...
 
tp_err_t tsc2003_process (tsc2003_t *ctx)
 Function processing events. More...
 
void tsc2003_gesture (tsc2003_t *ctx, tp_event_t *event)
 Read gesture information. More...
 
void tsc2003_write_cmd (tsc2003_t *ctx, uint8_t reg_addr)
 Writes a generic command to the IC. More...
 
void tsc2003_generic_read (tsc2003_t *ctx, uint8_t reg_addr, uint8_t *data_buff, uint8_t len)
 Reads a number of bytes from a register. More...
 
void tsc2003_calibrate (tsc2003_t *ctx)
 Calibrates variables used for converting raw TSC2003 ADC values to pixel coordinates. More...
 
void tsc2003_get_calibration_data (tsc2003_t *ctx, tsc2003_calibration_data_t *cdata)
 Utility funciton used for getting a copy of current calibration data. More...
 
void tsc2003_set_calibration_data (tsc2003_t *ctx, const tsc2003_calibration_data_t *cdata)
 Utility funciton used for setting calibration data. More...
 
void tsc2003_set_pressure_threshold_level (tsc2003_cfg_t *cfg, tsc2003_pressure_threshold_t pressure)
 Utility funciton used for setting threshold levels. More...
 

Detailed Description

API for configuring and manipulating TSC2003 Touch Controller driver.

Function Documentation

◆ tsc2003_cfg_setup()

void tsc2003_cfg_setup ( tsc2003_cfg_t cfg)

This function initializes TSC2003 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 default defined values.

Parameters
[out]cfgTSC2003 configuration object.
Returns
Nothing.

◆ tsc2003_init()

tp_err_t tsc2003_init ( tsc2003_t ctx,
tsc2003_cfg_t cfg,
tp_drv_t drv 
)

This function initializes TSC2003 context object using configuration values from TSC2003 configuration object and allows touch panel driver interface object to be linked with TSC2003 driver functions.

Note
By default, TSC2003 stucture is initialized with calibration constants for MikroE harware, in case of different hardware tsc2003_set_calibration_data is available for seting already determined calibration constants and tsc2003_calibrate is available for determinig new calibraiton constants.
Parameters
[in]ctxInitialized TSC2003 context structure. See tsc2003_t for more information about the context structure.
[in]cfgTSC2003 configuration object. See tsc2003_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.

◆ tsc2003_default_cfg()

void tsc2003_default_cfg ( tsc2003_t ctx)

Configures the device by powering the module down initially.

Parameters
[in]ctxInitialized TSC2003 context structure. See tsc2003_t for more information about the context structure.
Returns
Nothing.

◆ tsc2003_press_coordinates()

void tsc2003_press_coordinates ( tsc2003_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 TSC2003 context initialization.

Parameters
[in]ctxInitialized TSC2003 context structure. See tsc2003_t for more information about the context structure.
[out]touch_item
Returns
Nothing.

◆ tsc2003_press_detect()

tp_event_t tsc2003_press_detect ( tsc2003_t ctx)

Retrives information about press detection from TSC2003.

Note
This function is necessary for interfacing with touch panel library as its address is stored in tp_drv_t driver structure during the TSC2003 context initialization.
Parameters
[in]ctxInitialized TSC2003 context structure. See tsc2003_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.

◆ tsc2003_process()

tp_err_t tsc2003_process ( tsc2003_t ctx)

This function checks if touch was detected and if it was, reads and stores touch information in context structure and checks if it's touch down or up.

Note
This function is necessary for interfacing with touch panel library as its address is stored in tp_drv_t driver structure during the TSC2003 context initialization.
Parameters
[in]ctxInitialized TSC2003 context structure. See tsc2003_t for more information about the context structure.
Returns
Always returns TP_OK. see tp_err_t for more details.

◆ tsc2003_gesture()

void tsc2003_gesture ( tsc2003_t ctx,
tp_event_t event 
)

Since TSC2003 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 TSC2003 context structure. See tsc2003_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 TSC2003 context initialization.
Parameters
[out]eventTouch panel gesture data, always TP_EVENT_GEST_NONE. See tp_event_t * definition for detailed explanation.
Returns
Nothing.

◆ tsc2003_write_cmd()

void tsc2003_write_cmd ( tsc2003_t ctx,
uint8_t  reg_addr 
)

This function provides easy write access to the TSC2003 IC.

Parameters
[in]ctxInitialized TSC2003 context structure. See tsc2003_t for more information about the context structure.
[in]reg_addrRegister address with adequate configuration.
Returns
Nothing.
Note
Register address is defined as follows: | C3 | C2 | C1 | C0 | PD1 | PD0 | M | X |
Where:
The formatted address will be ((Cx<<4) | (PDx<<2) | (M<<1)).

◆ tsc2003_generic_read()

void tsc2003_generic_read ( tsc2003_t ctx,
uint8_t  reg_addr,
uint8_t *  data_buff,
uint8_t  len 
)

This function provides easy read from a TSC2003 register.

Parameters
[in]ctxInitialized TSC2003 context structure. See tsc2003_t for more information about the context structure.
[in]reg_addrRegister address from which single byte will be read.
[out]data_buffBuffer for returning read data from IC.
[in]lenNumber of data to read from the IC.
Returns
Nothing.
Note
Register address is defined as follows: | C3 | C2 | C1 | C0 | PD1 | PD0 | M | X |
Where:
The formatted address will be ((Cx<<4) | (PDx<<2) | (M<<1)).

◆ tsc2003_calibrate()

void tsc2003_calibrate ( tsc2003_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 TSC2003 context structure. See tsc2003_t for more information about the context structure.
Returns
Nothing.

◆ tsc2003_get_calibration_data()

void tsc2003_get_calibration_data ( tsc2003_t ctx,
tsc2003_calibration_data_t cdata 
)

Function copies data that's being e used for converting raw ADC values to actual pixel coordinates.

Parameters
[in]ctxInitialized TSC2003 context structure. See tsc2003_t for more
[out]cdataPointer to memory where calibration data will be stored.
Returns
Nothing.

◆ tsc2003_set_calibration_data()

void tsc2003_set_calibration_data ( tsc2003_t ctx,
const tsc2003_calibration_data_t cdata 
)

Function copies data stored in cdata. That information will be be used for converting raw ADC values to actual pixel coordinates.

Parameters
[in]ctxInitialized TSC2003 context structure. See tsc2003_t for more information about the context structure.
[out]cdataPointer to memory from where new calibration will be copied and set.
Returns
Nothing.

◆ tsc2003_set_pressure_threshold_level()

void tsc2003_set_pressure_threshold_level ( tsc2003_cfg_t cfg,
tsc2003_pressure_threshold_t  pressure 
)

Function copies data stored in pressure. That information will be be used for checking if adquate pressure has been applied to the screen.

Parameters
[out]cfgInitialized TSC2003 context structure. See tsc2003_t for more
[in]pressureStructure with desired threshold levels set. See tsc2003_pressure_threshold_t for more information about the structure.
Returns
Nothing.