在开发板上调试代码。 开发板上的PA9是浮动输入。 然后,贴补丁的时候,我们的板子应用了这个引线,设定为GPIO_MODE_OUTPUT_PP。
最后发生的问题是USB无法正常通信。
最后看手册,有以下说明。
note : whenvbussensingfeatureisenabled,pa9 shouldbeleftattheirdefaultstate (floating
input ),notasalternatefunction.atypical 200acurrentconsumptionoftheembedded
传感块(currenttovoltageconversiontodeterminethedifferentsessions ) can be
observedonpa9whenthefeatureisenabled。
最后必须修改代码。
usbd _ statustypedefusbd _ ll _ init (usbd _ handle typedef * pdev ) )
{
/* Init USB_IP */
if(pdev-id==device_fs ) {
/* Link The driver to the stack */
hpcd_USB_OTG_FS.pData=pdev;
pdev-pData=hpcd_USB_OTG_FS;
hpcd _ USB _ otg _ fs.instance=USB _ otg _ fs;
hpcd _ USB _ otg _ fs.init.dev _ end points=4;
hpcd _ USB _ otg _ fs.init.speed=PCD _ speed _ full;
hpcd _ USB _ otg _ fs.init.DMA _ enable=disable;
hpcd _ USB _ otg _ fs.init.ep0 _ MPs=de P0 CTL _ MPs _ 64;
hpcd _ USB _ otg _ fs.init.phy _ it face=PCD _ phy _ embedded;
hpcd _ USB _ otg _ fs.init.sof _ enable=disable;
hpcd _ USB _ otg _ fs.init.low _ power _ enable=disable;
hpcd _ USB _ otg _ fs.init.LPM _ enable=disable;
//hpcd _ USB _ otg _ fs.init.vbus _ sensing _ enable=enable;
hpcd _ USB _ otg _ fs.init.use _ dedicated _ ep1=disable;
if(Hal_PCD_init ) hpcd_USB_otg_fs!=HAL_OK )
{
Error_Handler (;
}
Hal _ PC dex _ setrxfifo (hpcd _ USB _ otg _ fs,0x80 );
Hal _ PC dex _ settxfifo (hpcd _ USB _ otg _ fs,0,0x 40 );
Hal _ PC dex _ settxfifo (hpcd _ USB _ otg _ fs,1,0x 80 );
}
return USBD_OK;
}
只要屏蔽红色部分,USB就可以正常通信。