117 lines
2.6 KiB
C
117 lines
2.6 KiB
C
/*----------------------------------------------------------------------------
|
|
* Copyright (c) TJD Technologies Co., Ltd. 2024. All rights reserved.
|
|
*
|
|
* Description: ft6146_ctrl.h
|
|
*
|
|
* Author: luziquan@ss-tjd.com
|
|
*
|
|
* Create: 2024-04-18
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
#ifndef TP_PORT_CTRL_H
|
|
#define TP_PORT_CTRL_H
|
|
|
|
#include "platform_core.h"
|
|
#include "soc_errno.h"
|
|
#include "stdint.h"
|
|
#include "stdio.h"
|
|
|
|
typedef enum
|
|
{
|
|
TP_CHIP_FT6146 = 0,
|
|
TP_CHIP_CST820,
|
|
TP_CHIP_INVALID,
|
|
} tp_chip_type_t;
|
|
|
|
enum
|
|
{
|
|
EXT_WAKEUP_THRESHOLD = 0x90000001
|
|
};
|
|
|
|
/* host peripheral definitions */
|
|
#define FT6146_I2C_ADDR 0x38
|
|
#define CST820_I2C_ADDR 0x15
|
|
#define CST820_BOOT_I2C_ADDR 0x6A
|
|
|
|
#define TP_CMD_SEND_LEN 1
|
|
#define TP_REG_WRITE_LEN 2
|
|
#define TP_I2C_TIME_MAX 3
|
|
|
|
#define OFFSET_8_BITS 8
|
|
|
|
#define TP_I2C_SEND_INDEX0 0
|
|
#define TP_I2C_SEND_INDEX1 1
|
|
#define TP_I2C_SEND_INDEX3 2
|
|
#define TP_I2C_SEND_INDEX4 3
|
|
|
|
#define TP_INPUT_SIZE 156
|
|
|
|
#ifndef TD_TRUE
|
|
#define TD_TRUE 1
|
|
#endif
|
|
|
|
#ifndef TD_FALSE
|
|
#define TD_FALSE 0
|
|
#endif
|
|
|
|
typedef struct
|
|
{
|
|
uint32_t int_gpio;
|
|
i2c_bus_t i2c_id;
|
|
uint32_t i2c_speed;
|
|
} tp_ctrl_attr;
|
|
|
|
typedef ext_errno (*tp_bus_init)(tp_ctrl_attr *attr);
|
|
typedef ext_errno (*tp_esd_callback)(void);
|
|
|
|
typedef struct
|
|
{
|
|
tp_ctrl_attr attr;
|
|
tp_bus_init bus_init;
|
|
} tp_ctrl_ops;
|
|
|
|
typedef enum
|
|
{
|
|
TP_IRQ_DISABLE = 0,
|
|
TP_IRQ_ENABLE,
|
|
} tp_irq_status;
|
|
|
|
typedef enum
|
|
{
|
|
TP_WORK_NORMAL = 0,
|
|
TP_WORK_STANDBY,
|
|
TP_WORK_SLEEP,
|
|
TP_WORK_INVALID,
|
|
} tp_power_mode;
|
|
|
|
ext_errno device_touch_init(void *attr);
|
|
ext_errno tp_host_peripheral_init(tp_ctrl_attr *attr);
|
|
ext_errno tp_register_handle(const tp_ctrl_ops *peri_data, void *func);
|
|
ext_errno tp_unregister_handle(const tp_ctrl_ops *peri_data);
|
|
ext_errno tp_irq_callback(uint8_t *data_buf, uint8_t data_len);
|
|
|
|
void tp_reset(void);
|
|
void tp_open(void);
|
|
void tp_close(void);
|
|
void tp_delay(uint32_t ms);
|
|
|
|
typedef struct
|
|
{
|
|
uint8_t *send_buf;
|
|
uint32_t send_len;
|
|
} i2c_send_data_t;
|
|
|
|
typedef struct
|
|
{
|
|
uint8_t *receive_buf;
|
|
uint32_t receive_len;
|
|
} i2c_recv_data_t;
|
|
|
|
ext_errno tp_i2c_cmd_write(uint16_t dev_addr, uint8_t cmd);
|
|
ext_errno tp_i2c_reg_write(uint16_t dev_addr, uint32_t reg_addr, uint8_t reg_len, uint8_t reg_cfg);
|
|
ext_errno tp_i2c_data_write(uint16_t dev_addr, uint8_t reg_addr, uint8_t *data_buf, uint32_t data_len);
|
|
ext_errno tp_i2c_data_read(uint16_t dev_addr, uint32_t reg_addr, uint8_t reg_len, uint8_t *data_buf, uint16_t data_len);
|
|
ext_errno tp_i2c_package_write(uint16_t dev_addr, uint8_t *data_buf, uint32_t data_len);
|
|
|
|
#endif
|