- static void touch(void *param)
- {
- struct rt_touch_data data[GT911_MAX_TOUCH];
- rt_size_t point_num;
- static rt_uint32_t touch_count = 0;
- /* 查找触摸设备 */
- touch_dev = rt_device_find("gt911");
- rt_kprintf("flag1n");
- if (touch_dev == RT_NULL)
- {
- rt_kprintf("[GT911] Error: Touch device not found!n");
- return -1;
- }
- rt_kprintf("flag2n");
- /* 打开触摸设备 */
- if (rt_touch_open(touch_dev, RT_DEVICE_FLAG_INT_RX) != RT_EOK)
- {
- rt_kprintf("[GT911] Error: Open device failed!n");
- return -1;
- }
- rt_kprintf("flag3n");
- rt_uint16_t x = 240;
- if (rt_touch_control(touch_dev, RT_TOUCH_CTRL_SET_X_RANGE, &x) != RT_EOK)
- {
- rt_kprintf("[GT911] Error: Set x failed!n");
- return -1;
- }
- rt_uint16_t y = 320;
- if (rt_touch_control(touch_dev, RT_TOUCH_CTRL_SET_Y_RANGE, &y) != RT_EOK)
- {
- rt_kprintf("[GT911] Error: Set y failed!n");
- return -1;
- }
- rt_kprintf("flag4n");
- // 信号量
- touch_sem = rt_sem_create("tsem", 0, RT_IPC_FLAG_PRIO);
- if (touch_sem == RT_NULL)
- {
- LOG_E("create dynamic semaphore failed.n");
- }
- if (rt_device_set_rx_indicate(touch_dev, touch_handler) != RT_EOK)
- {
- rt_kprintf("[GT911] Error: Set int handler failed!n");
- }
- if (rt_touch_control(touch_dev, RT_TOUCH_CTRL_ENABLE_INT, RT_NULL) != RT_EOK)
- {
- rt_kprintf("[GT911] Error: Enable int failed!n");
- }
- /* 获取触摸屏信息 */
- struct rt_touch_info info;
- if (rt_touch_control(touch_dev, RT_TOUCH_CTRL_GET_INFO, &info) != RT_EOK)
- {
- rt_kprintf("[GT911] Error: Get touch info failed!n");
- return -1;
- }
- rt_kprintf("n[GT911] Touch screen test startn");
- rt_kprintf("type :%dn", info.type); /* 类型:电容型/电阻型*/
- rt_kprintf("vendor :%sn", info.vendor); /* 厂商 */
- rt_kprintf("point_num :%dn", info.point_num); /* 支持的触点个数 */
- rt_kprintf("range_x :%dn", info.range_x); /* X 轴分辨率 */
- rt_kprintf("range_y :%dn", info.range_y); /* Y 轴分辨率*/
- rt_kprintf("[GT911] Press any point to test, press ESC to exitnn");
- gt911_thread = rt_thread_create("gt911", touch_callback, RT_NULL, 1024, 15, 10);
- if (gt911_thread != RT_NULL)
- {
- rt_thread_startup(gt911_thread);
- }
- //rt_touch_t touch_dev_1 = rt
- rt_touch_irq_init((rt_touch_t)touch_dev);
- rt_touch_irq_enable((rt_touch_t)touch_dev);
- return 0;
- }
以上为我创建的测试触摸的线程入口函数,使用open和control都使能了引脚中断,甚至在结尾又使用rt_touch_irq_init再次初始化了引脚中断,但是这个中断仍无法触发,给中断引脚手动输入高低电平也无法触发。
跪求大佬指点迷津