Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/stm32/periph/usbdev_fs: avoid using ztimer when not needed #20467

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions cpu/stm32/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,26 @@ ifneq (,$(filter periph_usbdev,$(FEATURES_USED)))
ifneq (,$(filter f2 f4 f7 h7 u5,$(CPU_FAM)))
# Whole STM32 families F2, F4, F7, H7 and U5 use the Synopsys DWC2 USB OTG core
USEMODULE += usbdev_synopsys_dwc2
USEMODULE += ztimer
USEMODULE += ztimer_msec
else ifneq (,$(filter stm32f105% stm32f107%,$(CPU_MODEL)))
# STM32F105xx and STM32F107xx also use the Synopsys DWC2 USB OTG core
USEMODULE += usbdev_synopsys_dwc2
USEMODULE += ztimer
USEMODULE += ztimer_msec
else ifneq (,$(filter stm32l47% stm32l48% stm32l49%,$(CPU_MODEL)))
# STM32L475xx, STM32L476xx, STM32L485xx, STM32L486xx and STM32L496xx
# also use the Synopsys DWC2 USB OTG core
USEMODULE += usbdev_synopsys_dwc2
USEMODULE += ztimer
USEMODULE += ztimer_msec
else ifneq (,$(filter stm32l4a% stm32l4p% stm32l4q% stm32l4r% stm32l4s%,$(CPU_MODEL)))
# STM32L4Axxx, STM32L4Pxxx, STM32L4Qxxx, STM32L4Rxxx and STM32L4Sxxx
# also use the Synopsys DWC2 USB OTG core
USEMODULE += usbdev_synopsys_dwc2
USEMODULE += ztimer
USEMODULE += ztimer_msec
endif
USEMODULE += ztimer
USEMODULE += ztimer_msec
endif

ifneq (,$(filter periph_uart_nonblocking,$(USEMODULE)))
Expand Down
11 changes: 10 additions & 1 deletion cpu/stm32/periph/usbdev_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "usbdev_stm32.h"
#include "pm_layered.h"
#include "ztimer.h"
#include "busy_wait.h"

#include <string.h>
/**
Expand Down Expand Up @@ -218,7 +219,15 @@
gpio_init(conf->dp, GPIO_OUT);
gpio_clear(conf->dp);
/* wait a 1 ms */
ztimer_sleep(ZTIMER_MSEC, 1);
if (IS_USED(MODULE_ZTIMER_MSEC)) {
ztimer_sleep(ZTIMER_MSEC, 1);
}
else if(IS_USED(MODULE_ZTIMER_USEC)) {

Check warning on line 225 in cpu/stm32/periph/usbdev_fs.c

View workflow job for this annotation

GitHub Actions / static-tests

keyword 'if' not followed by a single space
ztimer_sleep(ZTIMER_USEC, 1 * US_PER_MS);
}
else {
busy_wait_us(1 * US_PER_MS);
}
gpio_init(conf->dp, GPIO_IN);
}
if (conf->af != GPIO_AF_UNDEF) {
Expand Down
Loading