Skip to content

Commit

Permalink
Merge pull request #20467 from dylad/pr/cpu/stm32/usbdev_fs/dont_auto…
Browse files Browse the repository at this point in the history
…pull_ztimer

cpu/stm32/periph/usbdev_fs: avoid using ztimer when not needed
  • Loading branch information
Teufelchen1 committed Mar 20, 2024
2 parents a344561 + df044f4 commit 30e745d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
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 @@ static void _enable_gpio(const stm32_usbdev_fs_config_t *conf)
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

0 comments on commit 30e745d

Please sign in to comment.