1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
环境:
开发版: M483KG usb转uart: PL 2303/ FT 232 目的: 如何使用HSUSBH_USBH_VCOM 读写PL 2303/ FT 232? 问题: 插拔PL2303/FR232装置,会显示Connect device, disconnect device 但是不知道如何传收资料。 讯息如下: +---------------------------------------------------------+ | M480 USB Host VCOM sample program | +---------------------------------------------------------+ | (NOTE: This sample supports only one CDC device, but | | driver supports multiple CDC devices. If you | | want to support multiple CDC devices, you | | have to modify this sample. | +---------------------------------------------------------+ USB static memory: 6/256, heap used: 0 Connect device => New full-speed device address 2 assigned. USB static memory: 7/256, heap used: 568 disconnect device... USB static memory: 6/256, heap used: 0 USB static memory: 6/256, heap used: 0 Connect device => New full-speed device address 3 assigned. USB static memory: 7/256, heap used: 568 disconnect device... USB static memory: 6/256, heap used: 0 USB static memory: 6/256, heap used: 0 Connect device => New full-speed device address 4 assigned. USB static memory: 7/256, heap used: 568 |
|
相关推荐
1个回答
|
|
|+---------------------------------------------------------+Connect Device!.............................................Disconnect Device!..........................................Device Descriptor: bLength = 18 bDescriptorType = 1 bcdUSB = 2.00 bDeviceClass = 0 bDeviceSubClass = 0 bDeviceProtocol = 0 bMaxPacketSize0 = 8 idVendor = 67B idProduct = 2303 bcdDevice = 3.00 iManufacturer = 1 iProduct = 2 iSerialNumber = 0 bNumConfigurations = 1Configuration Descriptor: bLength = 9 bDescriptorType = 2 wTotalLength = 39 bNumInterfaces = 1 bConfigurationValue = 1 iConfiguration = 4 bmAttributes = 0x80 bMaxPower = 2 mAInterface Descriptor: bLength = 9 bDescriptorType = 4 bInterfaceNumber = 0 bAlternateSetting = 0 bNumEndpoints = 2 bInterfaceClass = 0xff bInterfaceSubClass = 0xff bInterfaceProtocol = 0xff iInterface = 4Endpoint Descriptor: bLength = 7 bDescriptorType = 5 bEndpointAddress = 0x81 bmAttributes = 0x03 wMaxPacketSize = 64 bInterval = 0x00Endpoint Descriptor: bLength = 7 bDescriptorType = 5 bEndpointAddress = 0x01 bmAttributes = 0x03 wMaxPacketSize = 64 bInterval = 0x00
解答: 在使用HSUSBH_USBH_VCOM时,需要使用以下步骤来读写PL 2303/ FT 232: 1. 在初始化时,通过VID 和 PID 确认已连接设备。 ```c USBH_PL2303_Init(USBH_Pl2303VendorID, USBH_Pl2303ProductID); // 使用 VID 和 PID 初始化 PL 2303 ``` 2. 在USB设备连接后,可以通过 USBH_PL2303_IsConnected() 函数确认是否连接: ```c if(USBH_PL2303_IsConnected(&USB_OTG_Core_dev)) // 如果连接了 PL2303 { printf("PL2303 connected!rn"); // 打印设备已连接 } ``` 3. 通过USBH_PL2303_TransmitData() 函数进行数据写入: ```c USBH_PL2303_TransmitData(&USB_OTG_Core_dev, txbuf, strlen((const char *)txbuf)); // 发送数据 ``` 4. 使用USBH_PL2303_ReceiveData() 函数进行数据读取: ```c USBH_PL2303_ReceiveData(&USB_OTG_Core_dev, rxbuf, &rxlen); // 接收数据 ``` 5. 需要注意的是,USB转UART的芯片在使用时需要通过虚拟串口的方式进行操作,需要安装对应的驱动程序。同时,在使用PL2303/ FT 232时,需要在Windows设备管理器中查看虚拟串口的号码,然后使用对应的串口进行数据读写。 |
|
|
|
只有小组成员才能发言,加入小组>>
3310 浏览 9 评论
2991 浏览 16 评论
3492 浏览 1 评论
9055 浏览 16 评论
4086 浏览 18 评论
1175浏览 3评论
603浏览 2评论
const uint16_t Tab[10]={0}; const uint16_t *p; p = Tab;//报错是怎么回事?
596浏览 2评论
用NUC131单片机UART3作为打印口,但printf没有输出东西是什么原因?
2333浏览 2评论
NUC980DK61YC启动随机性出现Err-DDR是为什么?
1894浏览 2评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-21 23:54 , Processed in 1.357932 second(s), Total 77, Slave 58 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号