libusb_stm32 icon indicating copy to clipboard operation
libusb_stm32 copied to clipboard

STM32F401 problems

Open mrx23dot opened this issue 1 year ago • 2 comments

Readme says STM32F401 needs usbd_stm32f429_otghs.c but the entire file is guarded by

#if defined(USBD_STM32F429HS)

defining that macro would be misleading. Could we have usbd_stm32f401_otghs.c or universal usbd_stm32f4xx_otghs.c ?

I'm compiling not with GCC Error[Li005]: no definition for "usbd_otgfs" [referenced from cdc_loop.o]

mrx23dot avatar Feb 21 '25 11:02 mrx23dot

Also cdc_loop.c says IRQ mode is not supported in STM32F401, which is weird because it's very similar to STM32F411 which supports it.

#if defined(CDC_USE_IRQ)
#if defined(STM32L052xx) || defined(STM32F070xB) || \
	defined(STM32F042x6)
#define USB_HANDLER     USB_IRQHandler
    #define USB_NVIC_IRQ    USB_IRQn
#elif defined(STM32L100xC) || defined(STM32G4)
    #define USB_HANDLER     USB_LP_IRQHandler
    #define USB_NVIC_IRQ    USB_LP_IRQn
#elif defined(USBD_PRIMARY_OTGHS) && \
    (defined(STM32F446xx) || defined(STM32F429xx))
    #define USB_HANDLER     OTG_HS_IRQHandler
    #define USB_NVIC_IRQ    OTG_HS_IRQn
    /* WA. With __WFI/__WFE interrupt will not be fired
     * faced with F4 series and OTGHS only
     */
    #undef  __WFI
    #define __WFI __NOP
#elif defined(STM32L476xx) || defined(STM32F429xx) || \
      defined(STM32F105xC) || defined(STM32F107xC) || \
      defined(STM32F446xx) || defined(STM32F411xE) || \
      defined(STM32H743xx)
    #define USB_HANDLER     OTG_FS_IRQHandler
    #define USB_NVIC_IRQ    OTG_FS_IRQn
#elif defined(STM32F103x6)
    #define USB_HANDLER     USB_LP_CAN1_RX0_IRQHandler
    #define USB_NVIC_IRQ    USB_LP_CAN1_RX0_IRQn
#elif defined(STM32F103xE)
    #define USB_HANDLER     USB_LP_CAN1_RX0_IRQHandler
    #define USB_NVIC_IRQ    USB_LP_CAN1_RX0_IRQn
#else
    #error Not supported
#endif

mrx23dot avatar Feb 21 '25 11:02 mrx23dot

based on project https://github.com/gbm-ii/gbmUSBdevice

IRQ bindings for F401:

#define VCOM0_rx_IRQn	FPU_IRQn
#define VCOM0_rx_IRQHandler	FPU_IRQHandler

#define VCOM0_tx_IRQn	SDIO_IRQn
#define VCOM0_tx_IRQHandler	SDIO_IRQHandler

It would be a good idea to mention which target supports interrupt/polling mode in readme table.

mrx23dot avatar Feb 21 '25 11:02 mrx23dot