1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

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

Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
This commit is contained in:
Dylan Laduranty 2024-03-13 21:39:07 +01:00
parent db51ad76d6
commit df044f4f56
2 changed files with 18 additions and 3 deletions

View File

@ -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)))

View File

@ -32,6 +32,7 @@
#include "usbdev_stm32.h"
#include "pm_layered.h"
#include "ztimer.h"
#include "busy_wait.h"
#include <string.h>
/**
@ -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)) {
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) {