116 lines
3.3 KiB
C
116 lines
3.3 KiB
C
/*----------------------------------------------------------------------------
|
|
* Copyright (c) TJD Technologies Co., Ltd. 2024. All rights reserved.
|
|
*
|
|
* Description: tp_api.c
|
|
*
|
|
* Author: luziquan@ss-tjd.com
|
|
*
|
|
* Create: 2024-04-18
|
|
*--------------------------------------------------------------------------*/
|
|
|
|
#include "tp_api.h"
|
|
#include "i2c.h"
|
|
#include "sys_config.h"
|
|
#include "touch_screen_def.h"
|
|
#include "tp_port_ctrl.h"
|
|
|
|
#include "tp_drv_cst820.h"
|
|
#include "tp_drv_ft6146.h"
|
|
|
|
#define ENABLE_PRINT_INFO 1
|
|
#if ENABLE_PRINT_INFO
|
|
#define static_print_info(...) sys_tp_log_i(__VA_ARGS__) // 一般信息打印宏控制
|
|
#define static_print_warn(...) sys_tp_log_w(__VA_ARGS__) // 警告信息打印一般常开
|
|
#define static_print_error(...) sys_tp_log_e(__VA_ARGS__) // 错误信息打印一般常开
|
|
#else
|
|
#define static_print_info(...)
|
|
#define static_print_warn(...)
|
|
#define static_print_error(...)
|
|
#endif
|
|
|
|
static uint32_t tp_set_open(uint8_t open)
|
|
{
|
|
if (open) {
|
|
tp_open();
|
|
} else {
|
|
tp_close();
|
|
}
|
|
return EXT_ERR_SUCCESS;
|
|
}
|
|
|
|
static tp_at_cmd_api g_tp_at_cmd_api[TP_CHIP_INVALID] = {
|
|
[TP_CHIP_FT6146] =
|
|
{
|
|
.set_open = tp_set_open,
|
|
.get_rawdata = ft6146_get_rawdata,
|
|
.get_chipid = ft6146_get_chip_id,
|
|
.get_version = ft6146_get_version,
|
|
.fwupg_auto_upgrade = fts_fwupg_auto_upgrade,
|
|
.set_power_mode = ft6146_set_power_mode,
|
|
},
|
|
[TP_CHIP_CST820] =
|
|
{
|
|
.set_open = tp_set_open,
|
|
.get_rawdata = cst820_get_rawdata,
|
|
.get_chipid = cst820_get_chip_id,
|
|
.get_version = cst820_get_version,
|
|
.fwupg_auto_upgrade = NULL,
|
|
.set_power_mode = cst820_set_power_mode,
|
|
},
|
|
};
|
|
|
|
void *tjd_driver_tp_get_at_cmd_api(void)
|
|
{
|
|
#if (TJD_TP_FT6146)
|
|
return ((void *)&g_tp_at_cmd_api[TP_CHIP_FT6146]);
|
|
#elif (TJD_TP_CST820)
|
|
return ((void *)&g_tp_at_cmd_api[TP_CHIP_CST820]);
|
|
#endif
|
|
}
|
|
|
|
static touch_peripheral_api g_tp_api[TP_CHIP_INVALID] = {
|
|
[TP_CHIP_FT6146] =
|
|
{
|
|
.touch_init = device_touch_init,
|
|
.touch_deinit = ft6146_deinit,
|
|
.touch_get_tpinfo = tp_irq_callback,
|
|
.touch_suspend = ft6146_suspend,
|
|
.touch_resume = ft6146_resume,
|
|
.touch_sleep = ft6146_sleep,
|
|
.register_callback = tp_register_handle,
|
|
.unregister_callback = tp_unregister_handle,
|
|
},
|
|
[TP_CHIP_CST820] =
|
|
{
|
|
.touch_init = device_touch_init,
|
|
.touch_deinit = cst820_deinit,
|
|
.touch_get_tpinfo = tp_irq_callback,
|
|
.touch_suspend = cst820_suspend,
|
|
.touch_resume = cst820_resume,
|
|
.touch_sleep = cst820_sleep,
|
|
.register_callback = tp_register_handle,
|
|
.unregister_callback = tp_unregister_handle,
|
|
},
|
|
};
|
|
|
|
void *tjd_driver_tp_get_api(void)
|
|
{
|
|
#if (TJD_TP_FT6146)
|
|
return ((void *)&g_tp_api[TP_CHIP_FT6146]);
|
|
#elif (TJD_TP_CST820)
|
|
return ((void *)&g_tp_api[TP_CHIP_CST820]);
|
|
#endif
|
|
}
|
|
|
|
tp_ctrl_ops g_tp_ctrl = {
|
|
.attr =
|
|
{
|
|
.int_gpio = TP_INT_GPIO,
|
|
.i2c_id = TP_I2C_BUS,
|
|
.i2c_speed = 400000,
|
|
},
|
|
.bus_init = (tp_bus_init)tp_host_peripheral_init,
|
|
};
|
|
|
|
void *tjd_driver_tp_get_peri_attr(void) { return ((void *)&g_tp_ctrl); }
|