Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
19471: drivers/periph_usbdev: fix set device address r=bergzand a=gschorcht ### Contribution description This PR allows to define when the device address is set on receipt of a SETUP with `SET ADDRESS Request`. It fixes the problem with enumeration of the Synopsys DWC2 USB OTG Core due to the wrong time of setting the device address. Especially, it fixes the problem that the enumeration fails completely for the `stm32f723e-disco` board with CDC ECM if CDC ACM is not used and the additional reset cycles during the enumeration for a couple of platforms such as ESP32-S2 and ESP32-S3. **Background** The address in the USB device can be set either directly after the SETUP stage on receipt of the `SET ADDRESS Request` or after the associated STATUS stage. When the USB device address has to be set depends on the hardware implementation. **Solution** To control the time of setting the device address, a new define `USBDEV_SET_ADDR_AFTER_STATUS` is introduced. If `USBDEV_SET_ADDR_AFTER_STATUS` has the value 1 (default), the address is set in the USB device after the STATUS stage. Since this is the default, existing `periph_usbdev` drivers shouldn't be affected. Overwriting `USBDEV_SET_ADDR_AFTER_STATUS` with 0 in `periph_cpu.h` or in driver header file let the address set directly after the SETUP stage. ### Testing procedure Use `tests/usbus_cdc_ecm`: For `stm32f723e-disco` the enumeration doesn't work at all without this PR and works reliable with this PR. ``` USEMODULE='periph_usbdev_hs_utmi' BOARD=stm32f723e-disco make -C tests/usbus_cdc_ecm flash ``` For any ESP32-S2 or ESP32-S3 board, the enumeration requires an addition reset cycle in every third or fourth enumeration without this PR and doesn't require any reset cycle with this PR. ``` BOARD=esp32s2-devkit make -C tests/usbus_cdc_ecm flash ``` Other platforms should still work with this PR, for example ATSAM platform: ``` BOARD=arduino-mkr1000 make -C tests/usbus_cdc_ecm flash ``` ### Issues/PRs references Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
- Loading branch information