2022-02-03 09:13 AM
Googling around, this is unclear. The data suggests it is polled by USB code (using the ST library) for slave device presence (USB ID) but in my project I am not supporting OTG mode.
The reason OTG is not supported is because a) you need to provide adequate power for what customers might plug in and b) it is hard/impossible to fulfil customer expectations regarding what will actually work.
2022-02-03 11:58 AM
Yes, you can use PA8 as a GPIO if USB is not used. You will need to ensure the USB library doesn't reconfigure it or depend on it.
2022-02-04 09:22 AM
That is why I asked here : - )
I am not sure there is any way to check the huge ST USB library to find out what it does with it in a given situation.
What one can do is find out how it initialises it.
2022-02-08 02:55 AM
Does anyone know how this bit of STM software works?
2022-02-08 05:07 AM
PA8 is SOF output, this has nothing to do with OTG.
If it is not set to the OTG_FS's AF in respective GPIOx_AFR, then it's not controlled by OTG and is free to use. The GPIOs, as per UM1725 chapter 3.12 How to use HAL drivers are set up in HAL_PPP_Mspinit() (where PPP is abbreviation of peripheral, USB in peripheral mode is in Cube/HAL called PCD, so HAL_PCD_MspInit(), see https://github.com/STMicroelectronics/STM32CubeF4/blob/4aba24d78fef03d797a82b258f37dbc84728bbb5/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c#L159 ) - that function is provided by *you*, so you know exactly which pins do you set up for OTG_FS.
You can also check if the OTG stack sets OTG_FS_GCCFG.SOFOUTEN - if not, there's no point in setting up PA8.
I don't use Cube.
JW