1、解决偶发触摸卡问题:将ST触摸芯片的软件复位全部改成硬件复位。

2、增加版本号打印和BIN文件版本
3、增加校准状态回读;
4、将ST触摸软件复位全部更改为硬件复位;
5、ST 触摸报错F3后启动硬件复位,无需判断是否是 F3 02 00;
This commit is contained in:
“苏飞源” 2023-07-14 13:56:55 +08:00
parent 70c5c996be
commit 71b954cce5
15 changed files with 12495 additions and 5047 deletions

View File

@ -50,7 +50,7 @@
<InvalidFlash>1</InvalidFlash>
</TargetStatus>
<OutputDirectory>.\Objects\</OutputDirectory>
<OutputName>WL368_NOTE20_CSOT667</OutputName>
<OutputName>WL368_NOTE20_CSOT667_V100_20230714</OutputName>
<CreateExecutable>1</CreateExecutable>
<CreateLib>0</CreateLib>
<CreateHexFile>1</CreateHexFile>
@ -454,6 +454,16 @@
</FileArmAds>
</FileOption>
</File>
<File>
<FileName>ap_demo_version.txt</FileName>
<FileType>5</FileType>
<FilePath>..\..\src\app\demo\ap_demo_version.txt</FilePath>
</File>
<File>
<FileName>app_tp_st_touch.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\src\app\demo\app_tp_st_touch.c</FilePath>
</File>
</Files>
</Group>
<Group>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
; generated by Component: ARM Compiler 5.06 update 6 (build 750) Tool: ArmCC [4d3637]
; commandline ArmCC [--c99 --list --split_sections --debug -c --asm --interleave --gnu -o.\objects\board.o --asm_dir=.\Listings\ --list_dir=.\Listings\ --depend=.\objects\board.d --cpu=Cortex-M0 --apcs=interwork -O3 --diag_suppress=9931 -I..\..\src -I..\..\src\board -I..\..\src\common -I..\..\src\sdk\include -I..\..\src\app\demo -I..\..\src\sdk\include\M0 -I..\..\src\app -I..\..\src\app\module_demo -I..\..\src\app\touch -I..\..\src\app\S8 -I..\..\src\app\S9 -I..\CVWL368 -I.\RTE\_ISP_368 -IC:\Users\ASUS\AppData\Local\Arm\Packs\ARM\CMSIS\5.5.1\CMSIS\Core\Include -IC:\Users\ASUS\AppData\Local\Arm\Packs\ARM\CMSIS\5.5.1\Device\ARM\ARMCM0\Include -D__MICROLIB -D__UVISION_VERSION=528 -D_RTE_ -DARMCM0 -DISP_368 --omf_browse=.\objects\board.crf ..\..\src\board\board.c]
; commandline ArmCC [--c99 --list --split_sections --debug -c --asm --interleave --gnu -o.\objects\board.o --asm_dir=.\Listings\ --list_dir=.\Listings\ --depend=.\objects\board.d --cpu=Cortex-M0 --apcs=interwork -O3 --diag_suppress=9931 -I..\..\src -I..\..\src\board -I..\..\src\common -I..\..\src\sdk\include -I..\..\src\app\demo -I..\..\src\sdk\include\M0 -I..\..\src\app -I..\..\src\app\module_demo -I..\..\src\app\touch -I..\..\src\app\S8 -I..\..\src\app\S9 -I..\CVWL368 -I.\RTE\_ISP_368 -IC:\Keil_v5\ARM\PACK\ARM\CMSIS\5.5.1\CMSIS\Core\Include -IC:\Keil_v5\ARM\PACK\ARM\CMSIS\5.5.1\Device\ARM\ARMCM0\Include -D__MICROLIB -D__UVISION_VERSION=528 -D_RTE_ -DARMCM0 -DISP_368 --omf_browse=.\objects\board.crf ..\..\src\board\board.c]
THUMB
AREA ||i.board_Init||, CODE, READONLY, ALIGN=2
@ -42,7 +42,7 @@
AREA ||.rev16_text||, CODE
THUMB
EXPORT |__asm___7_board_c_bcd01269____REV16|
#line 467 "C:\\Users\\ASUS\\AppData\\Local\\Arm\\Packs\\ARM\\CMSIS\\5.5.1\\CMSIS\\Core\\Include\\cmsis_armcc.h"
#line 467 "C:\\Keil_v5\\ARM\\PACK\\ARM\\CMSIS\\5.5.1\\CMSIS\\Core\\Include\\cmsis_armcc.h"
|__asm___7_board_c_bcd01269____REV16| PROC
#line 468

View File

@ -1,5 +1,5 @@
; generated by Component: ARM Compiler 5.06 update 6 (build 750) Tool: ArmCC [4d3637]
; commandline ArmCC [--c99 --list --split_sections --debug -c --asm --interleave --gnu -o.\objects\main.o --asm_dir=.\Listings\ --list_dir=.\Listings\ --depend=.\objects\main.d --cpu=Cortex-M0 --apcs=interwork -O3 --diag_suppress=9931 -I..\..\src -I..\..\src\board -I..\..\src\common -I..\..\src\sdk\include -I..\..\src\app\demo -I..\..\src\sdk\include\M0 -I..\..\src\app -I..\..\src\app\module_demo -I..\..\src\app\touch -I..\..\src\app\S8 -I..\..\src\app\S9 -I..\CVWL368 -I.\RTE\_ISP_368 -IC:\Users\ASUS\AppData\Local\Arm\Packs\ARM\CMSIS\5.5.1\CMSIS\Core\Include -IC:\Users\ASUS\AppData\Local\Arm\Packs\ARM\CMSIS\5.5.1\Device\ARM\ARMCM0\Include -D__MICROLIB -D__UVISION_VERSION=528 -D_RTE_ -DARMCM0 -DISP_368 --omf_browse=.\objects\main.crf ..\..\src\app\main.c]
; commandline ArmCC [--c99 --list --split_sections --debug -c --asm --interleave --gnu -o.\objects\main.o --asm_dir=.\Listings\ --list_dir=.\Listings\ --depend=.\objects\main.d --cpu=Cortex-M0 --apcs=interwork -O3 --diag_suppress=9931 -I..\..\src -I..\..\src\board -I..\..\src\common -I..\..\src\sdk\include -I..\..\src\app\demo -I..\..\src\sdk\include\M0 -I..\..\src\app -I..\..\src\app\module_demo -I..\..\src\app\touch -I..\..\src\app\S8 -I..\..\src\app\S9 -I..\CVWL368 -I.\RTE\_ISP_368 -IC:\Keil_v5\ARM\PACK\ARM\CMSIS\5.5.1\CMSIS\Core\Include -IC:\Keil_v5\ARM\PACK\ARM\CMSIS\5.5.1\Device\ARM\ARMCM0\Include -D__MICROLIB -D__UVISION_VERSION=528 -D_RTE_ -DARMCM0 -DISP_368 --omf_browse=.\objects\main.crf ..\..\src\app\main.c]
THUMB
AREA ||i.main||, CODE, READONLY, ALIGN=1
@ -32,7 +32,7 @@
AREA ||.rev16_text||, CODE
THUMB
EXPORT |__asm___6_main_c_main____REV16|
#line 467 "C:\\Users\\ASUS\\AppData\\Local\\Arm\\Packs\\ARM\\CMSIS\\5.5.1\\CMSIS\\Core\\Include\\cmsis_armcc.h"
#line 467 "C:\\Keil_v5\\ARM\\PACK\\ARM\\CMSIS\\5.5.1\\CMSIS\\Core\\Include\\cmsis_armcc.h"
|__asm___6_main_c_main____REV16| PROC
#line 468

View File

@ -21,7 +21,7 @@
#include "hal_system.h"
#include "hal_gpio.h"
#include "hal_pwm.h"
#include "app_tp_st_touch.h"
#include "app_tp_transfer.h"
#ifdef LOG_TAG
@ -128,6 +128,7 @@ static uint32_t g_run_test_cnt = 0; //leo
static volatile bool start_display_on = true;
static bool g_need_enter_sleep_mode = false;
static bool g_exit_sleep_mode = false;
extern bool s_screen_init_complate;
static bool g_power_on_flag = false;
static bool g_en_adj_bl = false;
@ -150,6 +151,7 @@ uint16_t phone_DisplayOFF_count=0;
uint8_t phone_DisplayOFF_flag=0;
#endif
uint32_t s_heartbeat = 0;
#if ENABLE_TP_WAKE_UP
static void ap_reset_cb(void *data)
@ -195,7 +197,10 @@ static bool ap_dcs_read(uint8_t data_type, uint8_t dcs_cmd, uint8_t param)
DSI_VC_0,
1, 0x04);
}
else if (dcs_cmd == 0x01)
{
ap_get_tp_calibration_status_01(g_rx_ctrl_handle, param);
}
else if (dcs_cmd == 0x0A)
{
static uint8_t cmd_0a_flag = 0;
@ -1362,17 +1367,6 @@ static bool ap_get_reg_df(hal_dsi_rx_ctrl_handle_t *handler, hal_dcs_packet_t *d
return true;
}
#if ADD_TP_CALIBRATION
static bool ap_set_tp_calibration_04(hal_dsi_rx_ctrl_handle_t *handler, hal_dcs_packet_t *dcs_packet)
{
if( (dcs_packet->packet_param[0] == 0x01) && (dcs_packet->packet_param[1] == 0x01) && (dcs_packet->packet_param[1] == 0x01) )
{
g_calibration_flag = true;
}
return true;
}
#endif
/* 客制化DCS command 处理函数表格 */
static const hal_dcs_execute_entry_t g_cus_rx_dcs_execute_table[] =
@ -2597,21 +2591,29 @@ static void soft_timer3_cb(void *data)
}
#endif
#if ADD_TP_CALIBRATION
void app_tp_calibration_exec(void)
void tp_heartbeat_exec(void)
{
if(g_calibration_flag)
if (s_screen_init_complate)
{
if (g_exit_sleep_mode)
if(hal_gpio_get_input_data(IO_PAD_TD_INT))
{
g_calibration_flag = false;
ap_tp_calibration();
TAU_LOGD("calibration successful \n");
s_heartbeat = 0;
}
else
{
if(s_heartbeat < (65536/50)) // 65536*3 = 900ms 65536/50 = 6ms
{
s_heartbeat ++;
}else
{
TAU_LOGD("hb...");
s_heartbeat = 0;
// ap_tp_st_touch_software_reset();
ap_tp_st_touch_hardware_reset();
}
}
}
}
#endif
void ap_demo(void)
@ -2621,7 +2623,8 @@ void ap_demo(void)
hal_gpio_init_output(IO_PAD_ADCIN, IO_LVL_LOW);
hal_gpio_init_output(IO_PAD_PWMEN, IO_LVL_LOW); // LED_ON
TAU_LOGD("Note20 368 CSOT667 [%s %s]", __DATE__, __TIME__);
// TAU_LOGD("Note20 368 CSOT667 [%s %s]", __DATE__, __TIME__);
TAU_LOGD("Note20 V100 20230714");
// delayMs(20);
/* mipi rx初始化 */
open_mipi_rx();
@ -2690,9 +2693,11 @@ void ap_demo(void)
}
}
#if ADD_TP_CALIBRATION
#if ADD_TP_CALIBRATION
tp_heartbeat_exec();
app_tp_calibration_exec();
#endif
ap_tp_st_touch_scan_point_record_event_exec();
#endif
#ifndef DISABLE_TDDI_I2C_FUNCTION
/* 等待屏 TP 中断上报做TP 协议转换 */

View File

@ -0,0 +1,19 @@
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
WL368_Note20_NT37701AH_CSOT667_V100_20230714
1、解决偶发触摸卡问题将ST触摸芯片的软件复位全部改成硬件复位。
2、增加版本号打印和BIN文件版本
3、增加校准状态回读
4、将ST触摸软件复位全部更改为硬件复位
5、ST 触摸报错F3后启动硬件复位无需判断是否是 F3 02 00
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,571 @@
/*******************************************************************************
*
*
* File: app_tp_st_touch.c信
* Description ST touch
* Version V0.1
* Date 2023-03-13
* Author sfy
* Description ST touch
* Version V0.2
* Date 2023-03-22
* Author sfy
*******************************************************************************/
#include "test_cfg_global.h"
#include "app_tp_transfer.h"
#include "hal_i2c_master.h"
#include "hal_i2c_slave.h"
#include "hal_spi_master.h"
#include "hal_spi_slave.h"
#include "tau_log.h"
#include "app_tp_st_touch.h"
#define ST_TP_CALIBRATION_SUCCESS 0x5A // 校准成功标志
static volatile bool s_calibration_flag = false;
static volatile uint8_t s_calibration_correct_flag = false;
st_tp_scan_data tp_scan_data;
uint8_t st_touch_init_sensor_off[3] = {0xA0,0x00,0x00}; //2 sensor OFF
uint8_t st_touch_init_sensor_on[3] = {0xA0,0x00,0x01}; //2 sensor on
uint8_t st_touch_tp_tuning_reset[3] = {0xA4,0x00,0x00}; // 3 System Reset
uint8_t st_touch_tp_tuning_FpnlInit[3] = {0xA4,0x00,0x03}; // FPnl Init
uint8_t st_touch_tp_tuning_PnlInit[3] = {0xA4,0x00,0x02}; // Pnl Init
uint8_t st_touch_tp_tuning_TuneM[4] = {0xA4,0x03,0x13,0x00}; // TuneM
uint8_t st_touch_tp_tuning_TuneS[4] = {0xA4,0x03,0x0C,0x00}; // TuneS
uint8_t st_touch_tp_tuning_SvCfg[3] = {0xA4,0x05,0x01}; // SvCfg
uint8_t st_touch_tp_tuning_SvCx[3] = {0xA4,0x05,0x02}; // SvCx
uint8_t st_touch_tp_tuning_SvPnl[3] = {0xA4,0x05,0x04}; // SvPnl
uint8_t st_touch_tp_tuning_clearfifo[3] = {0xA4,0x00,0x01}; // 1 clear fifo
uint8_t st_touch_tp_tuning_clkreset[3] = {0xA4,0x00,0x05}; // clk reset
/**************************************************************************
* @name : ap_tp_st_touch_get_calibration_success_mark
* @brief : st touch
* @param[in] :
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_get_calibration_success_mark(void)
{
uint8_t cali_send_buff[6] = {0xFA,0x20,0x01,0x00,0x00,0x00};
uint8_t cali_send_buff1[3] = {0xA4,0x06,0x01};
uint8_t cali_read_buff[40] = {0};
uint8_t i = 0;
app_tp_m_read(cali_send_buff, 5, cali_read_buff, 4);
while(!hal_i2c_m_transfer_complate());
delayMs(1);
app_tp_m_write(cali_send_buff1, 3);
while(!hal_i2c_m_transfer_complate());
delayMs(1);
app_tp_m_read(cali_send_buff, 5, cali_read_buff, 4);
while(!hal_i2c_m_transfer_complate());
delayMs(1);
app_tp_m_read(cali_send_buff, 5, cali_read_buff, 32);
while(!hal_i2c_m_transfer_complate());
if((cali_read_buff[20] == 0xFF) && (cali_read_buff[21] == 0xFF))
{
s_calibration_correct_flag = ST_TP_CALIBRATION_SUCCESS; // 校准成功
}
else
{
s_calibration_correct_flag = 0x00; // 校准失败
}
/*
for(i=0;i<32;i++)
{
printf("%02x ",cali_read_buff[i]);
}
*/
}
/**************************************************************************
* @name : ap_tp_st_touch_calibration
* @brief : st touch
* @param[in] :
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_calibration(void)
{
// app_tp_m_write(st_touch_tp_tuning_reset, sizeof(st_touch_tp_tuning_reset)); // System Reset
// while(!hal_i2c_m_transfer_complate());
// delayMs(10);
app_tp_m_write(st_touch_tp_tuning_FpnlInit, sizeof(st_touch_tp_tuning_FpnlInit)); // FPnl Init
while(!hal_i2c_m_transfer_complate());
delayMs(1);
app_tp_m_write(st_touch_tp_tuning_PnlInit, sizeof(st_touch_tp_tuning_PnlInit)); // Pnl Init
while(!hal_i2c_m_transfer_complate());
delayMs(1);
app_tp_m_write(st_touch_tp_tuning_TuneM, sizeof(st_touch_tp_tuning_TuneM)); // TuneM
while(!hal_i2c_m_transfer_complate());
delayMs(1);
app_tp_m_write(st_touch_tp_tuning_TuneS, sizeof(st_touch_tp_tuning_TuneS)); // TuneS
while(!hal_i2c_m_transfer_complate());
delayMs(1);
app_tp_m_write(st_touch_tp_tuning_SvCfg, sizeof(st_touch_tp_tuning_SvCfg)); // SvCfg
while(!hal_i2c_m_transfer_complate());
delayMs(1);
app_tp_m_write(st_touch_tp_tuning_SvCx, sizeof(st_touch_tp_tuning_SvCx)); // SvCx
while(!hal_i2c_m_transfer_complate());
delayMs(1);
app_tp_m_write(st_touch_tp_tuning_SvPnl, sizeof(st_touch_tp_tuning_SvPnl)); // SvPnl
while(!hal_i2c_m_transfer_complate());
delayMs(1);
}
const unsigned short wCRCTalbeAbs[] =
{
0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401,
0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400,
};
/**************************************************************************
* @name : CRC16_2
* @brief : CRC
* @param[in] :pchMsg ; wDataLen CRC
* @return : 16CRC值
* @retval :
**************************************************************************/
unsigned short CRC16_2(unsigned char *pchMsg, unsigned short wDataLen)
{
unsigned short wCRC = 0xFFFF;
unsigned short i;
unsigned char chChar;
for (i = 0; i < wDataLen; i++)
{
chChar = *pchMsg++;
wCRC = wCRCTalbeAbs[(chChar ^ wCRC) & 15] ^ (wCRC >> 4);
wCRC = wCRCTalbeAbs[((chChar >> 4) ^ wCRC) & 15] ^ (wCRC >> 4);
}
return wCRC;
}
/**************************************************************************
* @name : ap_set_tp_calibration_04
* @brief : 04 02gamma校准等功能
* @param[in] :handler rx handler; dcs_packet
* @return : true
* @retval :
**************************************************************************/
bool ap_set_tp_calibration_04(hal_dsi_rx_ctrl_handle_t *handler, hal_dcs_packet_t *dcs_packet)
{
uint8_t i,crch,crcl,command,param[30] = {0};
unsigned short crc;
// 计算CRC值
for(i=0;i<dcs_packet->param_length;i++)
{
param[i+1] = dcs_packet->packet_param[i];
printf("%02x ",dcs_packet->packet_param[i]);
}
param[0] = 0x04;
crc = CRC16_2(param,dcs_packet->param_length-1);
crch = (crc>>8);
crcl = crc;
// CRC校验判断
// if(crch == dcs_packet->packet_param[dcs_packet->param_length-2] && crcl == dcs_packet->packet_param[dcs_packet->param_length-1])
{
command = param[3];
switch(command)
{
case CMD_TP_CABLIBRATION: // Touch校准
if( (param[4] == 0x01) && (param[5] == 0x01) && (param[6] == 0x01) )
{
s_calibration_flag = true;
s_calibration_correct_flag = false;
}
/* if( (param[4] == 0xA5) && (param[5] == 0x5A) && (param[6] == 0xA5) )
{
if(s_calibration_correct_flag) // 校准成功
{
hal_dsi_rx_ctrl_send_ack_cmd(handler,
DSI_ACK_DT_GEN_LONG_RESPONSE, //xxx
DSI_VC_0,
0x7, 0x04,0x02,0x07,0x2A,ST_TP_CALIBRATION_SUCCESS,0x00,0x00);
printf("cali. send ok ");
}
else // 校准失败
{
hal_dsi_rx_ctrl_send_ack_cmd(handler,
DSI_ACK_DT_GEN_LONG_RESPONSE, //xxx
DSI_VC_0,
0x7, 0x04,0x02,0x07,0x2A,0x00,0x00,0x00);
}
printf("%02x ",s_calibration_correct_flag);
}
*/
break;
case CMD_SET_IMAGE_RGB: // Image RGB发送
break;
case CMD_SEND_COMMAND: // Command Send
break;
case CMD_WRITE_GAMMA: // Gamma校正写入
break;
case CMD_START_GAMMA:
break;
default:
break;
}
}
// 兼容旧版本tp calibration
if( (dcs_packet->packet_param[0] == 0x01) && (dcs_packet->packet_param[1] == 0x01) && (dcs_packet->packet_param[2] == 0x01) )
{
s_calibration_flag = true;
s_calibration_correct_flag = false;
}
/*
if( (dcs_packet->packet_param[0] == 0xA5) && (dcs_packet->packet_param[1] == 0x5A) && (dcs_packet->packet_param[2] == 0xA5) )
{
if(s_calibration_correct_flag) // 校准成功
{
hal_dsi_rx_ctrl_send_ack_cmd(handler,
DSI_ACK_DT_GEN_LONG_RESPONSE, //xxx
DSI_VC_0,
0x7, 0x04,0x02,0x07,0x2A,ST_TP_CALIBRATION_SUCCESS,0x00,0x00);
}
else // 校准失败
{
hal_dsi_rx_ctrl_send_ack_cmd(handler,
DSI_ACK_DT_GEN_LONG_RESPONSE, //xxx
DSI_VC_0,
0x7, 0x04,0x02,0x07,0x2A,0x00,0x00,0x00);
}
}
*/
return true;
}
/**************************************************************************
* @name : ap_get_tp_calibration_status_01
* @brief :
* @param[in] :param 01
* @return : true
* @retval :
**************************************************************************/
bool ap_get_tp_calibration_status_01(hal_dsi_rx_ctrl_handle_t *handler, uint8_t param)
{
// if( param == 0x5A )
{
if(s_calibration_correct_flag) // 校准成功
{
hal_dsi_rx_ctrl_send_ack_cmd(handler,
DSI_ACK_DT_DSC_SHORT_RESPONSE_1B, //xxx
DSI_VC_0,
1,ST_TP_CALIBRATION_SUCCESS);
}
else // 校准失败
{
hal_dsi_rx_ctrl_send_ack_cmd(handler,
DSI_ACK_DT_DSC_SHORT_RESPONSE_1B, //xxx
DSI_VC_0,
1,0x00);
}
}
return true;
}
/**************************************************************************
* @name : app_tp_calibration_exec
* @brief : st touch
* @param[in] :
* @return :
* @retval :
**************************************************************************/
void app_tp_calibration_exec(void)
{
uint8_t i = 0;
if(s_calibration_flag)
{
s_calibration_flag = false;
for(i=0;i<2;i++)
{
ap_tp_st_touch_calibration();
delayMs(4000);
ap_tp_st_touch_get_calibration_success_mark();
if(s_calibration_correct_flag == ST_TP_CALIBRATION_SUCCESS)
{
TAU_LOGD("calibration successful \n");
break;
}
else
{
TAU_LOGD("calibration failure \n");
}
}
}
}
/**************************************************************************
* @name : ap_tp_st_touch_scan_point_init
* @brief : st touch tp_scan_data结构体初始化
* @param[in] :
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_scan_point_init(void)
{
uint8_t i=0;
for(i=0;i<ST_TP_SCAN_POINT_NUMBER_MAX;i++)
tp_scan_data.tp_point_buffer[i] = 0;
tp_scan_data.tp_point_up_error_flag = 0;
tp_scan_data.tp_read_point_counter = 0;
tp_scan_data.tp_point_error_time_counter = 0;
}
/**************************************************************************
* @name : ap_tp_st_touch_simulate_finger_release_event
* @brief : st touch ST
* @param[in] :
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_simulate_finger_release_event(void)
{
uint8_t i,temp=0,ap_tp_release_buf[8] = {0x33,0x01,0x00,0x00,0x00,0x00,0x00,0x00};
for(i=0;i<5;i++)
{
temp = i;
ap_tp_release_buf[1] = (temp<<4)|0x01;
app_tp_screen_analysis_int(0, ap_tp_release_buf,8);
delayMs(6);
}
}
/**************************************************************************
* @name : ap_tp_st_touch_software_reset
* @brief : st touch
* @param[in] :
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_software_reset(void)
{
TAU_LOGD("st_touch_software_reset \n");
ap_tp_st_touch_simulate_finger_release_event();
ap_tp_st_touch_scan_point_init();
app_tp_m_write(st_touch_tp_tuning_clkreset, sizeof(st_touch_tp_tuning_clkreset)); // clk reset
while(!hal_i2c_m_transfer_complate());
delayMs(5);
app_tp_m_write(st_touch_tp_tuning_reset, sizeof(st_touch_tp_tuning_reset)); // System Reset A4 00 00
while(!hal_i2c_m_transfer_complate());
delayMs(5);
app_tp_m_write(st_touch_tp_tuning_clearfifo, sizeof(st_touch_tp_tuning_clearfifo));//0xA4,0x00,0x01
while(!hal_i2c_m_transfer_complate());
delayMs(5);
app_tp_m_write(st_touch_init_sensor_on, sizeof(st_touch_init_sensor_on));//0xA0,0x00,0x01
while(!hal_i2c_m_transfer_complate());
delayMs(5);
// app_tp_screen_reset();
}
/**************************************************************************
* @name : app_tp_st_touch_hardware_reset
* @brief : st touch
* @param[in] :
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_hardware_reset(void)
{
TAU_LOGD("st_touch_hardware_reset \n");
ap_tp_st_touch_simulate_finger_release_event();
ap_tp_st_touch_scan_point_init();
hal_gpio_set_output_data(g_screen_input_rst_pad, IO_LVL_HIGH);
delayMs(2);
hal_gpio_set_output_data(g_screen_input_rst_pad, IO_LVL_LOW);
delayMs(2);
hal_gpio_set_output_data(g_screen_input_rst_pad, IO_LVL_HIGH);
delayMs(2);
app_tp_m_write(st_touch_tp_tuning_clearfifo, sizeof(st_touch_tp_tuning_clearfifo));//0xA4,0x00,0x01}
while(!hal_i2c_m_transfer_complate());
delayMs(5);
app_tp_m_write(st_touch_init_sensor_off, sizeof(st_touch_init_sensor_off));//0xA0,0x00,0x00
while(!hal_i2c_m_transfer_complate());
delayMs(5);
app_tp_m_write(st_touch_init_sensor_on, sizeof(st_touch_init_sensor_on));//0xA0,0x00,0x01
while(!hal_i2c_m_transfer_complate());
delayMs(5);
}
/**************************************************************************
* @name : ap_tp_st_touch_scan_point_record_event
* @brief : st touch
* @param[in] : screendata buflen
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_scan_point_record_event(uint8_t* screendata,uint8_t len)
{
uint8_t i = 0, j,flag = 0,eventdata=0,eventid=0;
for(i=0;i<len;i++)
{
eventdata = screendata[i];
eventid = (screendata[i+1]>>4)+1;
i+=7;
if(eventdata == 0x13) // 按下事件
{
for(j=0;j<ST_TP_SCAN_POINT_NUMBER_MAX;j++)
{
if(tp_scan_data.tp_point_buffer[j] == eventid)
{
flag = 1;
break;
}
}
if(flag==0) // 轮询没有该ID需要保存
{
for(j=0;j<ST_TP_SCAN_POINT_NUMBER_MAX;j++) //寻找空位
{
if(tp_scan_data.tp_point_buffer[j] == 0x00)
{
tp_scan_data.tp_point_buffer[j] = eventid;
tp_scan_data.tp_read_point_counter++;
break;
}
}
}
}
if(eventdata == 0x33 && (tp_scan_data.tp_read_point_counter>0)) // 释放事件
{
for(j=0;j<ST_TP_SCAN_POINT_NUMBER_MAX;j++)
{
if(tp_scan_data.tp_point_buffer[j] == eventid) // 有该事件需要释放
{
tp_scan_data.tp_point_buffer[j] = 0;
tp_scan_data.tp_read_point_counter--;
break;
}
}
tp_scan_data.tp_point_up_error_flag = 1;
tp_scan_data.tp_point_error_time_counter = 0;
}
if(eventdata == 0x23) // 移动MOVE事件
{
tp_scan_data.tp_point_up_error_flag = 1;
tp_scan_data.tp_point_error_time_counter = 0;
}
}
}
/**************************************************************************
* @name : ap_tp_st_touch_scan_point_record_event_exec
* @brief : st touch while(1)
* @param[in] :
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_scan_point_record_event_exec(void)
{
if(tp_scan_data.tp_point_up_error_flag == 1)
{
if(tp_scan_data.tp_point_error_time_counter < (65536/10)) // 65536*3 = 900ms 65536/10 = 30ms
{
tp_scan_data.tp_point_error_time_counter ++;
}
else // 没有收到move 或者release 时间超时
{
if(tp_scan_data.tp_read_point_counter>0) // 有残留点
{
printf("release finger %2d\n",tp_scan_data.tp_read_point_counter);
tp_scan_data.tp_read_point_counter = 0;
ap_tp_st_touch_simulate_finger_release_event();
}
ap_tp_st_touch_scan_point_init();
}
}
}
/**************************************************************************
* @name : ap_tp_st_touch_error_handler_F3
* @brief : st touch F3 02
* @param[in] : screendata
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_error_handler_F3(uint8_t* screendata)
{
// 收到 TP 异常回复 0xF3 0x02 0x00 0x00 0x00 0x00 0x00 0x00
// if(screendata[0] == 0xF3 && screendata[1] == 0x02 && screendata[2] == 0x00)
if(screendata[0] == 0xF3 )
{
// ap_tp_st_touch_software_reset();
ap_tp_st_touch_hardware_reset();
}
}
/**************************************************************************
* @name : ap_tp_st_touch_error_handler_F3
* @brief : st touch FF FF
* @param[in] : screendata
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_error_handler_FF(uint8_t* screendata)
{
// 收到 TP 异常回复 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
if(screendata[1] == 0xFF && screendata[2] == 0xFF&& screendata[3] == 0xFF&&screendata[4] == 0xFF)
{
// ap_tp_st_touch_software_reset();
ap_tp_st_touch_hardware_reset();
}
}

View File

@ -0,0 +1,170 @@
/*******************************************************************************
*
*
* File: app_tp_st_touch.h
* Description ST touch
* Version V0.1
* Date 2023-03-13
* Author sfy
*******************************************************************************/
#ifndef __APP_TP_ST_TOUCH_H__
#define __APP_TP_ST_TOUCH_H__
#include "string.h"
#include "tau_device_datatype.h"
#include "tau_common.h"
#include "hal_dsi_rx_ctrl.h"
typedef enum
{
CMD_TP_CABLIBRATION = 0x2A,
CMD_SET_IMAGE_RGB = 0x2B,
CMD_SEND_COMMAND = 0x2C,
CMD_WRITE_GAMMA = 0x2D,
CMD_START_GAMMA = 0x2E
} st_tp_calibration_command;
#define ST_TP_SCAN_POINT_NUMBER_MAX 6 // TP 报点最大个数
typedef struct
{
uint8_t tp_point_buffer[ST_TP_SCAN_POINT_NUMBER_MAX]; // 记录TP报点ID
uint8_t tp_read_point_counter; // 报点ID个数统计
uint8_t tp_point_up_error_flag; // 记录需要执行UP事件标记
uint32_t tp_point_error_time_counter; // 没有收到move事件或者release事件时间计算
} st_tp_scan_data;
/**************************************************************************
* @name : ap_tp_st_touch_calibration
* @brief : st touch
* @param[in] :
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_calibration(void);
/**************************************************************************
* @name : app_tp_calibration_exec
* @brief : st touch
* @param[in] :
* @return :
* @retval :
**************************************************************************/
void app_tp_calibration_exec(void);
/**************************************************************************
* @name : ap_tp_st_touch_get_calibration_success_mark
* @brief : st touch
* @param[in] :
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_get_calibration_success_mark(void);
/**************************************************************************
* @name : ap_set_tp_calibration_04
* @brief : 04 02gamma校准等功能
* @param[in] :handler rx handler; dcs_packet
* @return : true
* @retval :
**************************************************************************/
bool ap_set_tp_calibration_04(hal_dsi_rx_ctrl_handle_t *handler, hal_dcs_packet_t *dcs_packet);
/**************************************************************************
* @name : ap_get_tp_calibration_status_01
* @brief :
* @param[in] :param 01
* @return : true
* @retval :
**************************************************************************/
bool ap_get_tp_calibration_status_01(hal_dsi_rx_ctrl_handle_t *handler, uint8_t param);
/**************************************************************************
* @name : ap_tp_st_touch_scan_point_init
* @brief : st touch tp_scan_data结构体初始化
* @param[in] :
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_scan_point_init(void);
/**************************************************************************
* @name : ap_tp_st_touch_simulate_finger_release_event
* @brief : st touch ST
* @param[in] :
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_simulate_finger_release_event(void);
/**************************************************************************
* @name : ap_tp_st_touch_software_reset
* @brief : st touch
* @param[in] :
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_software_reset(void);
/**************************************************************************
* @name : app_tp_st_touch_hardware_reset
* @brief : st touch
* @param[in] :
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_hardware_reset(void);
/**************************************************************************
* @name : ap_tp_st_touch_scan_point_record_event
* @brief : st touch
* @param[in] : screendata buflen
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_scan_point_record_event(uint8_t* screendata,uint8_t len);
/**************************************************************************
* @name : ap_tp_st_touch_scan_point_record_event_exec
* @brief : st touch while(1)
* @param[in] :
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_scan_point_record_event_exec(void);
/**************************************************************************
* @name : ap_tp_st_touch_error_handler_F3
* @brief : st touch F3 02
* @param[in] : screendata
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_error_handler_F3(uint8_t* screendata);
/**************************************************************************
* @name : ap_tp_st_touch_error_handler_F3
* @brief : st touch FF FF
* @param[in] : screendata
* @return :
* @retval :
**************************************************************************/
void ap_tp_st_touch_error_handler_FF(uint8_t* screendata);
#endif

View File

@ -15,7 +15,7 @@
#include "hal_spi_slave.h"
#include "tau_log.h"
#include "tau_delay.h"
#include "app_tp_st_touch.h"
#if 1//def AP_TP_TRANSFER
uint8_t read_point; //当前要读的报点数。一个报点8BYTE数据
uint8_t s_screen_number[2];
@ -270,7 +270,7 @@ bool app_tp_s_transfer_complate(void)
* @return :
* @retval :
**************************************************************************/
static void app_tp_m_write(const uint8_t *txbuffer, size_t buffer_size)
void app_tp_m_write(const uint8_t *txbuffer, size_t buffer_size)
{
#if SCREEN_MASTER_TRANSFER_I2C
hal_i2c_m_dma_write(txbuffer, buffer_size);
@ -290,7 +290,7 @@ static void app_tp_m_write(const uint8_t *txbuffer, size_t buffer_size)
* @return :
* @retval :
**************************************************************************/
static void app_tp_m_read(const uint8_t *cmd, size_t cmd_size, uint8_t *data_buffer, size_t data_size)
void app_tp_m_read(const uint8_t *cmd, size_t cmd_size, uint8_t *data_buffer, size_t data_size)
{
#if SCREEN_MASTER_TRANSFER_I2C
uint8_t i = 0;
@ -444,41 +444,6 @@ void S20_Start_init(void)
}
}
/**************************************************************************
* @name : ap_tp_calibration
* @brief : <EFBFBD><EFBFBD><EFBFBD><EFBFBD>У׼<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param[in] :
* @return :
* @retval :
**************************************************************************/
void ap_tp_calibration(void)
{
// app_tp_m_write(MI10_PRO_TP_Tuning_data1, sizeof(MI10_PRO_TP_Tuning_data1)); // System Reset
// while(!hal_i2c_m_transfer_complate());
// delayMs(10);
app_tp_m_write(MI10_PRO_TP_Tuning_data2, sizeof(MI10_PRO_TP_Tuning_data2)); // FPnl Init
while(!hal_i2c_m_transfer_complate());
delayMs(1);
app_tp_m_write(MI10_PRO_TP_Tuning_data3, sizeof(MI10_PRO_TP_Tuning_data3)); // Pnl Init
while(!hal_i2c_m_transfer_complate());
delayMs(1);
app_tp_m_write(MI10_PRO_TP_Tuning_data4, sizeof(MI10_PRO_TP_Tuning_data4)); // TuneM
while(!hal_i2c_m_transfer_complate());
delayMs(1);
app_tp_m_write(MI10_PRO_TP_Tuning_data5, sizeof(MI10_PRO_TP_Tuning_data5)); // TuneS
while(!hal_i2c_m_transfer_complate());
delayMs(1);
app_tp_m_write(MI10_PRO_TP_Tuning_data6, sizeof(MI10_PRO_TP_Tuning_data6)); // SvCfg
while(!hal_i2c_m_transfer_complate());
delayMs(1);
app_tp_m_write(MI10_PRO_TP_Tuning_data7, sizeof(MI10_PRO_TP_Tuning_data7)); // SvCx
while(!hal_i2c_m_transfer_complate());
delayMs(1);
app_tp_m_write(MI10_PRO_TP_Tuning_data8, sizeof(MI10_PRO_TP_Tuning_data8)); // SvPnl
while(!hal_i2c_m_transfer_complate());
delayMs(1);
}
/**************************************************************************
* @name : app_tp_transfer_screen_const
@ -784,6 +749,9 @@ void app_tp_transfer_screen_int(void)
}
}
#endif
ap_tp_st_touch_scan_point_record_event(s_screen_read_buffer, len+8);
ap_tp_st_touch_error_handler_FF(s_screen_read_buffer);
ap_tp_st_touch_error_handler_F3(s_screen_read_buffer);
app_tp_screen_analysis_int(screen_int_transfer_count, s_screen_read_buffer,screen_reg_int_data[2].rxbuffer_size);
}
/**** 3. 解析本次通信数据并准备下一次通信的buffer ****/

View File

@ -25,9 +25,6 @@
* @retval :
**************************************************************************/
void ap_tp_calibration(void);
/**************************************************************************
* @name : app_tp_screen_init
* @brief : screen IO
@ -101,5 +98,9 @@ void app_tp_s_write(const uint8_t *txbuffer, size_t buffer_size);
**************************************************************************/
bool app_tp_enter_sleep_on(void);
void app_tp_m_write(const uint8_t *txbuffer, size_t buffer_size);
void app_tp_m_read(const uint8_t *cmd, size_t cmd_size, uint8_t *data_buffer, size_t data_size);
#endif