static uint8_t g_tp_recv_buf[FT6X46_INPUT_SIZE] = {0};
+osTimerId_t g_ft6x46_timer = NULL;
+
+static bool g_ft6x46_timer_is_running = false;
+
static void ft6x46_gpio_isr_handle(pin_t pin, uintptr_t param)
{
unused(pin);
return tp_ft6x46_i2c_data_write(addr, &val, 1);
}
+void ft6x46_check_error(void)
+{
+ uint8_t data_buf[3] = {0};
+ uint8_t cnt = 0;
+
+ tp_i2c_data_read(0x91, &data_buf[0], 1);
+ LOS_Mdelay(1);
+ tp_i2c_data_read(0x91, &data_buf[1], 1);
+ LOS_Mdelay(1);
+ tp_i2c_data_read(0x91, &data_buf[2], 1);
+ LOS_Mdelay(1);
+
+ if(data_buf[0] == data_buf[1] && data_buf[1] == data_buf[2])
+ {
+ // printf("ft6x46_check_error !!!! 0x%x \n",data_buf[0]);
+ ft6x46_resume_reset();
+ }
+
+}
ext_errno ft6x46_host_peripheral_init(ft6x46_ctrl_attr *attr)
{
g_ctrl_attr.i2c_id, g_ctrl_attr.i2c_speed, FT6X46_I2C_ADDR);
g_host_dev_init_flag = true;
+
+ g_ft6x46_timer = osTimerNew((osTimerFunc_t)ft6x46_check_error, osTimerPeriodic, NULL, NULL);
+
return EXT_ERR_SUCCESS;
}
osDelay(10);
uapi_gpio_set_val(FT6X46_RESET_GPIO, GPIO_LEVEL_HIGH);
/* delay 100ms */
- osDelay(200);
+ osDelay(100);
// uapi_gpio_set_dir(FT6X46_RESET_GPIO, GPIO_DIRECTION_INPUT);
}
+
+void ft6x46_check_error_timer_start(uint32_t rtc_ms)
+{
+ if (g_ft6x46_timer == NULL)
+ return;
+ if (g_ft6x46_timer_is_running)
+ osTimerStop(g_ft6x46_timer);
+ if (g_ft6x46_timer_is_running == true)
+ osTimerStart(g_ft6x46_timer, rtc_ms);
+ g_ft6x46_timer_is_running = true;
+}
+
+void ft6x46_check_error_timer_stop(void)
+{
+ if (g_ft6x46_timer == NULL)
+ return;
+ if (g_ft6x46_timer_is_running)
+ {
+ osTimerStop(g_ft6x46_timer);
+ g_ft6x46_timer_is_running = false;
+ }
+
+}
return ERRCODE_FAIL;
}
- if (fts_touch_process() != ERRCODE_SUCC)
- {
- fail_count ++ ;
- }else{
- fail_count = 0;
- }
- if (fail_count%50 == 49){
- tp_print("TOUCH:ft6x46_irq_callback fail to reset touch ");
- hal_custom_resume_touch();
- }
+ fts_touch_process();
+
+ // if (fts_touch_process() != ERRCODE_SUCC)
+ // {
+ // fail_count ++ ;
+ // }else{
+ // fail_count = 0;
+ // }
+ // if (fail_count%50 == 49){
+ // tp_print("TOUCH:ft6x46_irq_callback fail to reset touch ");
+ // hal_custom_resume_touch();
+ // }
mem_ret = memcpy_s(data_buf, sizeof(input_event_info), &(g_ft6x46_drv.touch_msg), sizeof(input_event_info));
if (mem_ret != EOK) {
ft6x46_set_irq_mode(FT6X46_IRQ_DISABLE, FT6X46_INT_MASK);
g_ft6x46_drv.work_status = FT6X46_WORK_SLEEP;
+ ft6x46_check_error_timer_stop();
+
return EXT_ERR_SUCCESS;
}
/* Enable Irq */
ft6x46_set_irq_mode(FT6X46_IRQ_ENABLE, FT6X46_INT_MASK);
+ ft6x46_check_error_timer_start(1000);
+
return EXT_ERR_SUCCESS;
resume_exit: