Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QTouch device driver for I2C interface

See Quick start guide for QTouch component.

This component driver provides low-level read/write access to the configuration and data registers on a QTouch device. It has only been tested on AT42QT2160 parts, but it should be easy to add support for other QTouch devices with I2C interface.

Modules

 Quick Start Guide(s)
 In this section you can find a list of all Quick Start guides related to the QTouch device driver for I2C interface.
 
 QT Device list support by the driver
 
 Definitions for Atmel AT42QT2160 device
 

Macros

#define BOARD_QT_DEVICE_ADDRESS   0 /* QTouch device address */
 
#define BOARD_QT_TWI_INSTANCE   0 /* TWI instance */
 Checking board configuration of the QTouch device. More...
 

Functions

enum status_code qt_get_comm_ready (void)
 Check communication is ready and able to read Chip ID. More...
 
enum status_code qt_get_status (struct qt_status *qt_status)
 Get all status from QT device. More...
 
void qt_hardware_reset (void)
 Perform a hardware reset of the QT device. More...
 
bool qt_is_change_line_low (void)
 Check if the CHANGE line is low level. More...
 
enum status_code qt_read_regs (uint8_t reg_addr, uint8_t *read_buffer, uint8_t length)
 Read registers content from QT device. More...
 
enum status_code qt_read_setup_block (struct qt_setup_block *setup_block)
 Read entire setup block from QT device. More...
 
enum status_code qt_write_regs (uint8_t reg_addr, uint8_t *write_buffer, uint8_t length)
 Write content to QT device registers. More...
 
enum status_code qt_write_setup_block (struct qt_setup_block *setup_block)
 Write entire setup block to QT device. More...
 
#define QT_COMM_TIMEOUT   10000
 Timeout for communication with QTouch device. More...
 
#define QT_CONTINUE_RW_DELAY   50
 Delay between two continue I2C read or write operation in microsecond. More...
 

#define BOARD_QT_DEVICE_ADDRESS   0 /* QTouch device address */

Referenced by qt_read_regs(), and qt_write_regs().

#define BOARD_QT_TWI_INSTANCE   0 /* TWI instance */

Checking board configuration of the QTouch device.

Referenced by qt_read_regs(), and qt_write_regs().

#define QT_COMM_TIMEOUT   10000

Timeout for communication with QTouch device.

Referenced by qt_get_comm_ready().

#define QT_CONTINUE_RW_DELAY   50

Delay between two continue I2C read or write operation in microsecond.

Referenced by qt_read_regs(), and qt_write_regs().

enum status_code qt_get_comm_ready ( void  )

Check communication is ready and able to read Chip ID.

Return values
STATUS_OKIf communication is ready.
ERR_IO_ERRORIf communication failed with the device.
ERR_UNSUPPORTED_DEVIf the device is not supported.

References ERR_IO_ERROR, ERR_UNSUPPORTED_DEV, QT_COMM_TIMEOUT, QT_DEVICE_ID, qt_read_regs(), QT_REG_CHIP_ID, and STATUS_OK.

enum status_code qt_get_status ( struct qt_status qt_status)

Get all status from QT device.

Parameters
qt_statusPointer to QT status buffer for read.
Return values
STATUS_OKIf read successful.
ERR_IO_ERRORIf communication failed with the device.

References qt_read_regs(), and QT_REG_GENERAL_STATUS.

void qt_hardware_reset ( void  )

Perform a hardware reset of the QT device.

Note
If RESET pin is defined, it will perform a hardware reset, Otherwise it will do nothing.

References delay_us, IOPORT_PIN_LEVEL_HIGH, IOPORT_PIN_LEVEL_LOW, and ioport_set_pin_level().

bool qt_is_change_line_low ( void  )

Check if the CHANGE line is low level.

Return values
trueThe CHANGE line is low level.
falseThe CHANGE line is high level.

References ioport_get_pin_level().

enum status_code qt_read_regs ( uint8_t  reg_addr,
uint8_t *  read_buffer,
uint8_t  length 
)

Read registers content from QT device.

Parameters
reg_addrStart register address.
read_bufferPointer to byte array for read data.
lengthRead data length.
Return values
STATUS_OKIf read successful.
ERR_IO_ERRORIf communication failed with the device.

References BOARD_QT_DEVICE_ADDRESS, BOARD_QT_TWI_INSTANCE, delay_us, ERR_IO_ERROR, QT_CONTINUE_RW_DELAY, STATUS_OK, twi_master_read(), twi_master_write(), and twi_package_t.

Referenced by qt_get_comm_ready(), qt_get_status(), and qt_read_setup_block().

enum status_code qt_read_setup_block ( struct qt_setup_block setup_block)

Read entire setup block from QT device.

Parameters
setup_blockPointer to setup block buffer for read.
Return values
STATUS_OKIf read successful.
ERR_IO_ERRORIf communication failed with the device.

References qt_read_regs(), and QT_SETUPS_BLOCK_ADDR.

enum status_code qt_write_regs ( uint8_t  reg_addr,
uint8_t *  write_buffer,
uint8_t  length 
)

Write content to QT device registers.

Parameters
reg_addrStart register address.
write_bufferPointer to byte array for write data.
lengthWrite data length.
Return values
STATUS_OKIf write successful.
ERR_IO_ERRORIf communication failed with the device.

References BOARD_QT_DEVICE_ADDRESS, BOARD_QT_TWI_INSTANCE, buffer, delay_us, ERR_IO_ERROR, QT_CONTINUE_RW_DELAY, STATUS_OK, twi_master_write(), and twi_package_t.

Referenced by qt_write_setup_block().

enum status_code qt_write_setup_block ( struct qt_setup_block setup_block)

Write entire setup block to QT device.

Parameters
setup_blockPointer to setup block buffer for write.
Return values
STATUS_OKIf write successful.
ERR_IO_ERRORIf communication failed with the device.

References QT_SETUPS_BLOCK_ADDR, and qt_write_regs().