mirror of
https://github.com/apache/nuttx.git
synced 2026-08-22 14:08:30 +00:00
arm/stm32: Fix the USB reset sequence in arm_usbinitialize().
The code that claimed to "enable clocking to the USB peripheral" cleared RCC_APB1ENR_USBEN inside RCC_APB1RSTR. That is both the wrong register and the wrong bit: USBEN belongs to RCC_APB1ENR, while APB1RSTR holds RCC_APB1RSTR_USBRST. The peripheral clock is enabled by the RCC setup performed at boot, so the write had no useful effect and merely cleared an unrelated reset bit. Issue a proper reset pulse on RCC_APB1RSTR_USBRST instead, so the controller starts from a known state. On STM32L0 the D+/D- lines are connected to the USB transceiver automatically once the peripheral is enabled and there is no alternate function to select, so skip the GPIO configuration on that chip. The board GPIO_USB_DM/GPIO_USB_DP definitions do not exist there. Assisted-by: GitHub Copilot:claude-opus-5 Signed-off-by: jsanchez-2g <jsanchez@2g-eng.com>
This commit is contained in:
parent
fc05091e18
commit
d70725e4e0
1 changed files with 5 additions and 6 deletions
|
|
@ -3684,20 +3684,19 @@ void arm_usbinitialize(void)
|
|||
*/
|
||||
|
||||
struct stm32_usbdev_s *priv = &g_usbdev;
|
||||
uint32_t regval;
|
||||
|
||||
usbtrace(TRACE_DEVINIT, 0);
|
||||
|
||||
/* Configure USB GPIO alternate function pins */
|
||||
|
||||
#ifndef CONFIG_STM32_STM32L0
|
||||
stm32_configgpio(GPIO_USB_DM);
|
||||
stm32_configgpio(GPIO_USB_DP);
|
||||
#endif
|
||||
|
||||
/* Enable clocking to the USB peripheral */
|
||||
/* Reset the USB peripheral */
|
||||
|
||||
regval = getreg32(STM32_RCC_APB1RSTR);
|
||||
regval &= ~RCC_APB1ENR_USBEN;
|
||||
putreg32(regval, STM32_RCC_APB1RSTR);
|
||||
modifyreg32(STM32_RCC_APB1RSTR, 0, RCC_APB1RSTR_USBRST);
|
||||
modifyreg32(STM32_RCC_APB1RSTR, RCC_APB1RSTR_USBRST, 0);
|
||||
|
||||
/* Power up the USB controller, but leave it in the reset state */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue