仔细分析这一段 /* initialize touch number and corrdinate */ *(p_instance_ctrl->pinfo.p_num_touch) = 0; *(p_instance_ctrl->pinfo.p_rx_coordinate) = TOUCH_OFF_VALUE; *(p_instance_ctrl->pinfo.p_tx_coordinate) = TOUCH_OFF_VALUE; /* Get local variable (TS number & data pinch) */ num_x = p_instance_ctrl->p_touch_cfg->p_ctsu_instance->p_cfg->num_rx; TOUCH_ERROR_RETURN(0 != num_x, FSP_ERR_ASSERTION); num_y = p_instance_ctrl->p_touch_cfg->p_ctsu_instance->p_cfg->num_tx; TOUCH_ERROR_RETURN(0 != num_y, FSP_ERR_ASSERTION); element_num = (uint16_t) (num_x * num_y); /* Data get */ err = p_instance_ctrl->p_ctsu_instance->p_api->dataGet(p_instance_ctrl->p_ctsu_instance->p_ctrl, g_touch_pad_buf); FSP_ERROR_RETURN(FSP_ERR_CTSU_SCANNING != err, FSP_ERR_CTSU_SCANNING); /* check for max touch */ if (*(p_instance_ctrl->pinfo.p_max_touch) > TOUCH_PAD_MONITOR_TOUCH_NUM_MAX) { max_touch = TOUCH_PAD_MONITOR_TOUCH_NUM_MAX; } else { max_touch = *(p_instance_ctrl->pinfo.p_max_touch); } /* make difference value = secondary - primary */ for (i = 0; i < element_num; i++) { /* save to buffer in the first half */ g_touch_pad_buf[i] = (uint16_t) (g_touch_pad_buf[(i * 2) + 1] - g_touch_pad_buf[i * 2]); }
时间: 2024-04-26 19:22:31 浏览: 167
这段代码是在初始化触摸板相关的变量和获取触摸数据。首先,它将触摸数和坐标值初始化为0和TOUCH_OFF_VALUE。然后,它从触摸板配置结构体中获取接收和发送通道的数量,并计算出元素数量。接下来,它调用dataGet函数来获取触摸数据,并将数据存储在g_touch_pad_buf数组中。如果获取数据时发现触摸板正在扫描,则返回FSP_ERR_CTSU_SCANNING错误。然后,它检查最大触摸数是否超过了最大值,如果超过了,则将最大触摸数设置为最大值,否则将最大触摸数设置为p_max_touch指针所指向的值。最后,它对每个元素进行处理,将其次级值减去主级值,并将结果保存在g_touch_pad_buf数组的前一半中。这个程序的目的是为了监控触摸板上的触摸情况,并将数据处理成差分形式方便后续使用。
阅读全文