添加了大量调试log,新增了dwt计时宏,增加了USB软件复位防止主控复位后上位机无法连接usb

This commit is contained in:
NeoZng
2023-06-22 21:52:46 +08:00
parent ea6163a48d
commit 4a45331d31
31 changed files with 247 additions and 275 deletions

View File

@@ -11,16 +11,17 @@
#include "bsp_usb.h"
#include "bsp_log.h"
#include "bsp_dwt.h"
static uint8_t *bsp_usb_rx_buffer; // 接收到的数据会被放在这里,buffer size为2048
// 注意usb单个数据包(Full speed模式下)最大为64byte,超出可能会出现丢包情况
uint8_t *USBInit(USB_Init_Config_s usb_conf)
{
// 上电后重新枚举usb设备
LOGINFO("USB init success");
// usb的软件复位(模拟拔插)在usbd_conf.c中的HAL_PCD_MspInit()中
bsp_usb_rx_buffer = CDCInitRxbufferNcallback(usb_conf.tx_cbk, usb_conf.rx_cbk); // 获取接收数据指针
// usb的接收回调函数会在这里被设置,并将数据保存在bsp_usb_rx_buffer中
LOGINFO("USB init success");
return bsp_usb_rx_buffer;
}