Skip to content
Open
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
18 changes: 15 additions & 3 deletions cpu/stm32/include/periph/cpu_usbdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#pragma once

/**
* @ingroup cpu_stm32
* @ingroup cpu_stm32_usbdev
* @{
*
* @file
Expand Down Expand Up @@ -38,18 +38,30 @@ extern "C" {
*/
#define USBDEV_CPU_DMA_REQUIREMENTS __attribute__((aligned(USBDEV_CPU_DMA_ALIGNMENT)))

/**
* @name Flags used in @ref stm32_usbdev_fs_config_t
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @{
*/
/**
* @brief Indicates that logic levels are inverted compared to a GPIO connected
* directly via a 1.5 kOhm resistor to the USB D+ signal.
*/
#define STM32_USBDEV_FS_CONFIG_FLAG_DISCONN_INVERTED 0x01
/** @} */

/**
* @brief stm32 USB device FS configuration
*/
typedef struct {
uintptr_t base_addr; /**< USB peripheral base address */
uint32_t rcc_mask; /**< bit in clock enable register */
uint8_t irqn; /**< IRQ channel */
uint8_t apb; /**< APB bus */
gpio_t dm; /**< Data- gpio */
gpio_t dp; /**< Data+ gpio */
gpio_af_t af; /**< Alternative function */
gpio_t disconn; /**< GPIO if used for USB disconnect */
uint8_t irqn; /**< IRQ channel */
uint8_t apb; /**< APB bus */
uint8_t flags; /**< Configuration flags */
} stm32_usbdev_fs_config_t;

#ifdef __cplusplus
Expand Down
6 changes: 3 additions & 3 deletions cpu/stm32/periph/usbdev_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
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 {
Expand All @@ -240,7 +240,7 @@
/* In case the MCU has no internal D+ pullup, a GPIO is used to
* connect/disconnect from USB bus */
gpio_init(conf->disconn, GPIO_OUT);
gpio_clear(conf->disconn);
gpio_write(conf->disconn, (conf->flags & STM32_USBDEV_FS_CONFIG_FLAG_DISCONN_INVERTED));
}
}

Expand Down Expand Up @@ -283,7 +283,7 @@
#else
/* If configuration uses a GPIO for USB connect/disconnect */
if (conf->disconn != GPIO_UNDEF) {
gpio_set(conf->disconn);
gpio_write(conf->disconn, !(conf->flags & STM32_USBDEV_FS_CONFIG_FLAG_DISCONN_INVERTED));
}
#endif /* USB_BCDR_DPPU */
}
Expand All @@ -301,7 +301,7 @@
#else
/* If configuration uses a GPIO for USB connect/disconnect */
if (conf->disconn != GPIO_UNDEF) {
gpio_clear(conf->disconn);
gpio_write(conf->disconn, (conf->flags & STM32_USBDEV_FS_CONFIG_FLAG_DISCONN_INVERTED));
}
#endif
}
Expand Down