赞
踩
参考博客如下:
1: https://blog.csdn.net/ZCShouCSDN/article/details/78936456
2: https://blog.csdn.net/gyzw_mx/article/details/115642075
3: https://blog.csdn.net/liao_512/article/details/100654476
4: https://blog.csdn.net/lutao614/article/details/88284922
开发环境:IAR
MCU:STM32F4xx
4G模块:NEOWAY
操作系统:FreeRTOS
0. 操作系统主要工作:开一个任务对模块进行读设备描述符、配置描述符、接口和端点配置等工作;当模块重启之后会产生中断使( phost->device.is_connected = 1);注意这是所有USB状态机后续操作的基础;
/* USER CODE END OTG_HS_IRQn 0 /
// counter++;
HAL_HCD_IRQHandler(&hhcd_USB_OTG_HS);
// printf("------COUNTER= %u\r\n",counter);
/ USER CODE BEGIN OTG_HS_IRQn 1 */
/* USER CODE END OTG_HS_IRQn 1 */
}
2)修改DM+、DM-的引脚配置,一般CUBE生成之后就不用改了,还有MCU-模块的RESET引脚;
3)一般CUBE生成的代码FREERTOS又包含了一层,可参考https://www.taterli.com/2940/ 剥离CMSIS-OS层;
4)剥离结束之后,重点修改一下三个内容:
/Communication Class codes/
//#define USB_CDC_CLASS 0x02
#define USB_CDC_CLASS 0xFF //厂商自定义classcode
#define COMMUNICATION_INTERFACE_CLASS_CODE 0x02
HOST_CHECK_CLASS状态下匹配设备描述符claacode;
*修改 static USBH_StatusTypeDef USBH_CDC_InterfaceInit (USBH_HandleTypeDef phost)函数,commitf使用interface2-EP0; dataitf使用interface4-EP0和EP1;
调试打印+(AT+GMR\r\n)信息如下:
[16:39:18.902]收←◆USB Device Attached
[16:39:19.005]收←◆PID: 4d12h
VID: 1782h
Address (#1) assigned.
Manufacturer : NEOWAY
Product : NEOWAY-N58
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
No registered class for this device.
[16:39:20.690]收←◆USB Device disconnected
[16:39:21.704]收←◆USB Device Attached
[16:39:21.809]收←◆PID: 7401h
VID: 2949h
Address (#1) assigned.
Manufacturer : NEOWAY
Product : NEOWAY-N58
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
Switching to Interface (#2)
Class : ffh
SubClass : 0h
Protocol : 0h
CDC class started.
[16:39:22.186]收←◆AT+GMR
+GMR: N58-R07-STD-BZ_V20-06
OK
[16:39:27.521]收←◆
+EUSIM:ERROR
问题:1.有方模块PID和VID在初始化时会有两种,按道理一般就CDC类别(PID=7401,VID=2949)?
2. 软件中操作RESET引脚之后获取的中断每次都不一样,导致设备识别状态机的处理无法正常往下走,不知道该怎么处理?有相似情况的小伙伴可以交流一下。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。