mikroSDK Reference Manual
tsc2003.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** Copyright (C) 2024 MikroElektronika d.o.o.
4** Contact: https://www.mikroe.com/contact
5**
6** This file is part of the mikroSDK package
7**
8** Commercial License Usage
9**
10** Licensees holding valid commercial NECTO compilers AI licenses may use this
11** file in accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The MikroElektronika Company.
14** For licensing terms and conditions see
15** https://www.mikroe.com/legal/software-license-agreement.
16** For further information use the contact form at
17** https://www.mikroe.com/contact.
18**
19**
20** GNU Lesser General Public License Usage
21**
22** Alternatively, this file may be used for
23** non-commercial projects under the terms of the GNU Lesser
24** General Public License version 3 as published by the Free Software
25** Foundation: https://www.gnu.org/licenses/lgpl-3.0.html.
26**
27** The above copyright notice and this permission notice shall be
28** included in all copies or substantial portions of the Software.
29**
30** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31** OF MERCHANTABILITY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
32** TO THE WARRANTIES FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
33** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
34** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
35** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
36** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37**
38****************************************************************************/
58#ifndef _TSC2003_H_
59#define _TSC2003_H_
60
61#ifdef __cplusplus
62extern "C"{
63#endif
64
65#include "drv_digital_out.h"
66#include "drv_i2c_master.h"
67#include "drv_digital_in.h"
68#include "drv_name.h"
69#include "tp.h"
70
90#define TSC2003_I2C_SLAVE_ADDR_FIXED (0x48)
91#define TSC2003_I2C_SLAVE_ADDR_A0 (0x1)
92#define TSC2003_I2C_SLAVE_ADDR_A1 (0x2)
93#define TSC2003_I2C_SLAVE_ADDR_0 (TSC2003_I2C_SLAVE_ADDR_FIXED)
94#define TSC2003_I2C_SLAVE_ADDR_1 (TSC2003_I2C_SLAVE_ADDR_FIXED | \
95 TSC2003_I2C_SLAVE_ADDR_A0)
96#define TSC2003_I2C_SLAVE_ADDR_2 (TSC2003_I2C_SLAVE_ADDR_FIXED | \
97 TSC2003_I2C_SLAVE_ADDR_A1)
98#define TSC2003_I2C_SLAVE_ADDR_3 (TSC2003_I2C_SLAVE_ADDR_FIXED | \
99 TSC2003_I2C_SLAVE_ADDR_A0 | \
100 TSC2003_I2C_SLAVE_ADDR_A1)
101#ifdef TSC2003_I2C_SLAVE_ADDR_DB
102#define TSC2003_I2C_SLAVE_ADDR_DEFAULT (TSC2003_I2C_SLAVE_ADDR_DB)
103#else
104#define TSC2003_I2C_SLAVE_ADDR_DEFAULT (TSC2003_I2C_SLAVE_ADDR_3)
105#endif
106 // tsc2003_slave_addresses
107
112#define configureData(c,pd,m) ((c<<4)|(pd<<2)|(m<<1))
113 // tsc2003_config_data
114
118#define TSC2003_MAP_PINS( cfg ) \
119 cfg.i2c_cfg.scl = CTP_SCL; \
120 cfg.i2c_cfg.sda = CTP_SDA; \
121 cfg.int_pin = CTP_INT
122
149 // tsc2003_bits_cfg
150
168 // tsc2003_bits_pd
169
185 // tsc2003_bits_m
186
191typedef struct {
193 uint16_t min_x;
195 uint16_t max_x;
197 uint16_t min_y;
199 uint16_t max_y;
201
209
216
237
268
278
300
309
320
333
345
359
379void tsc2003_write_cmd( tsc2003_t * ctx, uint8_t reg_addr );
380
402void tsc2003_generic_read( tsc2003_t * ctx, uint8_t reg_addr, uint8_t *data_buff, uint8_t len );
403
416
426
437
448
449 // middlewaregroup
450 // tsc2003
451
452#ifdef __cplusplus
453}
454#endif
455
456#endif // _TSC2003_H_
457
458// ------------------------------------------------------------------------ END
API for Digital input driver.
API for Digital output driver.
API for I2C master driver.
Pin and port name type definitions.
hal_pin_name_t pin_name_t
Definition drv_name.h:74
tsc2003_bits_pd
Definition tsc2003.h:162
@ tsc2003_bits_pd_int_ref_on_adc_off
Definition tsc2003.h:165
@ tsc2003_bits_pd_int_ref_on_adc_on
Definition tsc2003.h:166
@ tsc2003_bits_pd_power_down_between_conversion
Definition tsc2003.h:163
@ tsc2003_bits_pd_int_ref_off_adc_on
Definition tsc2003.h:164
tsc2003_bits_cfg
Definition tsc2003.h:134
@ tsc2003_bits_cfg_measure_activate_drivers_y
Definition tsc2003.h:142
@ tsc2003_bits_cfg_measure_position_z1
Definition tsc2003.h:146
@ tsc2003_bits_cfg_measure_in2
Definition tsc2003.h:140
@ tsc2003_bits_cfg_measure_temp0
Definition tsc2003.h:135
@ tsc2003_bits_cfg_measure_position_z2
Definition tsc2003.h:147
@ tsc2003_bits_cfg_measure_vbat1
Definition tsc2003.h:136
@ tsc2003_bits_cfg_measure_position_x
Definition tsc2003.h:144
@ tsc2003_bits_cfg_measure_activate_drivers_x
Definition tsc2003.h:141
@ tsc2003_bits_cfg_measure_temp1
Definition tsc2003.h:138
@ tsc2003_bits_cfg_measure_in1
Definition tsc2003.h:137
@ tsc2003_bits_cfg_measure_activate_drivers_x_y
Definition tsc2003.h:143
@ tsc2003_bits_cfg_measure_vbat2
Definition tsc2003.h:139
@ tsc2003_bits_cfg_measure_position_y
Definition tsc2003.h:145
Digital input driver context structure, consisted of the following fields :
Definition drv_digital_in.h:73
I2C Master initialization configuration structure, consisted of the following fields :
Definition drv_i2c_master.h:97
I2C Master driver context structure, consisted of the following fields :
Definition drv_i2c_master.h:121
Touch Panel Driver Interface Items.
Definition tp.h:199
Touch Item Definition.
Definition tp.h:151
Calibration data structure.
Definition tsc2003.h:191
uint16_t min_y
Definition tsc2003.h:197
uint16_t max_x
Definition tsc2003.h:195
uint16_t min_x
Definition tsc2003.h:193
TSC2003 Configuration Object.
Definition tsc2003.h:221
uint16_t height
Definition tsc2003.h:227
tsc2003_bits_pd power_down
Definition tsc2003.h:232
tsc2003_bits_m resolution
Definition tsc2003.h:231
uint16_t width
Definition tsc2003.h:226
pin_name_t int_pin
Definition tsc2003.h:222
uint8_t addr_sel
Definition tsc2003.h:229
i2c_master_config_t i2c_cfg
Definition tsc2003.h:224
Press intensity needed to register touch event.
Definition tsc2003.h:205
uint16_t tsc2003_pressure_threshold_upper
Definition tsc2003.h:207
uint16_t tsc2003_pressure_threshold_lower
Definition tsc2003.h:206
TSC2003 Context Object.
Definition tsc2003.h:245
tsc2003_pressure_threshold_t pressure_threshold_level
Definition tsc2003.h:263
digital_in_t int_pin
Definition tsc2003.h:246
tp_event_t gesture
Definition tsc2003.h:255
i2c_master_t i2c
Definition tsc2003.h:248
tsc2003_bits_m resolution
Definition tsc2003.h:259
bool pen_down
Definition tsc2003.h:257
uint16_t height
Definition tsc2003.h:251
tsc2003_bits_pd power_down
Definition tsc2003.h:260
uint16_t width
Definition tsc2003.h:250
tp_event_t press_det
Definition tsc2003.h:253
tp_touch_item_t touch
Definition tsc2003.h:254
tp_event_t
Touch Panel Event Code Definition.
Definition tp.h:81
tp_err_t
Touch Panel Error Code Definition.
Definition tp.h:65
const tsc2003_calibration_data_t TSC2003_CALIBRATION_DATA_DEFAULT
Default calibration data specific for MikroE resistive tft boards.
tp_err_t tsc2003_process(tsc2003_t *ctx)
Function processing events.
tsc2003_bits_m
Definition tsc2003.h:181
@ tsc2003_bits_m_8bit
Definition tsc2003.h:183
@ tsc2003_bits_m_12bit
Definition tsc2003.h:182
tp_event_t tsc2003_press_detect(tsc2003_t *ctx)
Press detection function.
void tsc2003_press_coordinates(tsc2003_t *ctx, tp_touch_item_t *touch_item)
Copies touch information from context object to touch item object.
void tsc2003_cfg_setup(tsc2003_cfg_t *cfg)
TSC2003 configuration object setup function.
void tsc2003_get_calibration_data(tsc2003_t *ctx, tsc2003_calibration_data_t *cdata)
Utility funciton used for getting a copy of current calibration data.
void tsc2003_gesture(tsc2003_t *ctx, tp_event_t *event)
Read gesture information.
void tsc2003_set_pressure_threshold_level(tsc2003_cfg_t *cfg, tsc2003_pressure_threshold_t pressure)
Utility funciton used for setting threshold levels.
void tsc2003_write_cmd(tsc2003_t *ctx, uint8_t reg_addr)
Writes a generic command to the IC.
void tsc2003_set_calibration_data(tsc2003_t *ctx, const tsc2003_calibration_data_t *cdata)
Utility funciton used for setting calibration data.
void tsc2003_calibrate(tsc2003_t *ctx)
Calibrates variables used for converting raw TSC2003 ADC values to pixel coordinates.
void tsc2003_default_cfg(tsc2003_t *ctx)
TSC2003 Default Configuration Function.
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.
tp_err_t tsc2003_init(tsc2003_t *ctx, tsc2003_cfg_t *cfg, tp_drv_t *drv)
TSC2003 Initialization Function.