STM32 电容触摸屏I2C转USB实现

本文介绍将电容式触摸屏转化为标准USB HID TP设备的过程,包括使用USBlyzer抓取ReportDescriptor,配置ConfigDescriptor,以及将TP数据通过串口输出到MCU的方法。最后,计划将程序移植到性价比更高的STM32F070。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近有个需求要把一个电容式触摸屏转为标准USB HID TP设备,同时需要把TP数据通过串口输出到MCU。市面方案大多采用CH554E做I2C USB转换,没有多余的UART口。问了几家供应商都说做不了,只好自己搞了。

能偷懒就偷懒,下载USBlyzer,把原屏的ReportDescriptor抓下来直接用了:

然后跟供应商要到接口文档和初始化寄存器配置:

 

配置ConfigDescriptor:

 

 

 

用USBlyzer抓了下触摸数据:

与ReportDescriptor一致

    Usage (Finger)09 22 
    Collection (Logical)A1 02 
        Usage (Tip Switch)09 42 
        Logical Minimum (0)15 00 
        Logical Maximum (1)25 01 
        Report Size (1)75 01 
        Report Count (1)95 01 
        Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)81 02 
        Report Count (1)95 01 
        Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit)81 03 
        Report Count (6)95 06 
        Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit)81 03 
        Report Size (8)75 08 
        Usage (Contact Identifier)09 51 
        Report Count (1)95 01 
        Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)81 02 
        Usage Page (Generic Desktop)05 01 
        Logical Maximum (2048)26 00 08 
        Report Size (16)75 10 
        Unit Exponent (-2)55 0E 
        Unit (SI Lin: Length (cm))65 11 
        Usage (X)09 30 
        Physical Minimum (0)35 00 
        Physical Maximum (2169)46 79 08 
        Report Count (1)95 01 
        Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)81 02 
        Physical Minimum (1)35 01 
        Physical Minimum (0)35 00 
        Physical Maximum (1356)46 4C 05 
        Logical Maximum (2048)26 00 08 
        Usage (Y)09 31 
        Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)81 02 
        Physical Minimum (1)35 01 
        Physical Minimum (0)35 00 
        Usage Page (Digitizer)05 0D 
        Logical Maximum (255)26 FF 00 
        Physical Maximum (255)46 FF 00 
        Report Count (1)95 01 
        Usage (Width)09 48 
        Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)81 02 
    End CollectionC0 

把TP的I2C接口调好就OK了,测试了一下OK。

下一步是把程序移植到STM32F070,价格不错,比汇顶提供的CH554还要便宜!

 

评论 15
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值