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

sys/usb: Rework usb kconfig model

This commit is contained in:
MrKevinWeiss 2023-04-05 15:07:01 +02:00
parent adff099d61
commit d419898d6a
No known key found for this signature in database
GPG Key ID: 4B69974722CBEEAE
7 changed files with 57 additions and 22 deletions

View File

@ -68,7 +68,8 @@ extern "C" {
* that the USB peripheral is ready for use.
*/
#ifndef CONFIG_USBUS_AUTO_ATTACH
#if !IS_ACTIVE(KCONFIG_MODULE_USBUS)
/* Check for Kconfig usage */
#if !IS_ACTIVE(CONFIG_MODULE_USBUS)
#define CONFIG_USBUS_AUTO_ATTACH 1
#endif
#endif

View File

@ -5,13 +5,24 @@
# directory for more details.
#
menuconfig KCONFIG_USB
bool "Configure USB"
depends on MODULE_USBUS || PACKAGE_TINYUSB
bool "USB device"
depends on HAS_PERIPH_USBDEV || HAS_TINYUSB_DEVICE || MODULE_USBDEV_MOCK
depends on TEST_KCONFIG
help
Configure the USB peripheral via Kconfig.
Enable the USB device peripheral.
if KCONFIG_USB
choice USB_IMPLEMENTATION
bool "USB implementation"
help
Select the USB implementation.
endchoice
rsource "usbus/Kconfig"
menu "Power management"
config USB_MAX_POWER
@ -42,16 +53,26 @@ config USB_SPEC_BCDVERSION_1_1
endchoice
config CUSTOM_USB_VID_PID
bool "Use custom VID and PID"
help
If using in USB in application then one must set a VID and PID.
If RIOT is internally using the USB, say for STDIO, then the VID and
PID depending in the internal peripheral configuration used.
config USB_PID
hex "Product ID"
depends on CUSTOM_USB_VID_PID
range 0x0000 0xFFFF
default 0x7D01
# default 0x7002 if MODULE_RIOTBOOT_DFU
default 0x7001
help
You must provide your own PID.
config USB_VID
hex "Vendor ID"
range 0x0000 0xFFFF
depends on CUSTOM_USB_VID_PID
default 0x1209
help
You must provide your own VID.
@ -109,5 +130,3 @@ comment "WARNING: The serial string is empty!"
depends on USB_SERIAL_STR = "" && USB_CUSTOM_SERIAL_STR
endif # KCONFIG_USB
rsource "usbus/Kconfig"

View File

@ -4,6 +4,7 @@
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#
choice USB_IMPLEMENTATION
menuconfig MODULE_USBUS
bool "USB Unified Stack (USBUS)"
@ -13,8 +14,11 @@ menuconfig MODULE_USBUS
select MODULE_EVENT
select MODULE_LUID
select MODULE_FMT
select MODULE_USBUS_CDC_ACM if REQUIRES_USB_STDIO
select MODULE_PERIPH_USBDEV if HAS_PERIPH_USBDEV && !MODULE_USBDEV_MOCK
endchoice
if MODULE_USBUS
config MODULE_AUTO_INIT_USBUS
@ -31,7 +35,7 @@ menuconfig KCONFIG_USEMODULE_USBUS
help
Configure the USBUS module via Kconfig.
if KCONFIG_USEMODULE_USBUS
if KCONFIG_USEMODULE_USBUS || MODULE_USBUS
config USBUS_AUTO_ATTACH
bool "Auto attach"
@ -63,7 +67,7 @@ config USBUS_EP0_SIZE_64
endchoice
endif # KCONFIG_USEMODULE_USBUS
endif # KCONFIG_USEMODULE_USBUS || MODULE_USBUS
rsource "cdc/Kconfig"
rsource "dfu/Kconfig"

View File

@ -11,13 +11,19 @@ menuconfig KCONFIG_USEMODULE_USBUS_CDC_ACM
help
Configure the USBUS CDC ACM module via Kconfig.
if KCONFIG_USEMODULE_USBUS_CDC_ACM
menuconfig MODULE_USBUS_CDC_ACM
bool "Configure USBUS CDC ACM"
depends on MODULE_USBUS
help
Configure the USBUS CDC ACM module via Kconfig.
if MODULE_USBUS_CDC_ACM || KCONFIG_USEMODULE_USBUS_CDC_ACM
config USBUS_CDC_ACM_STDIO_BUF_SIZE_EXP
int "Buffer size for STDIN and STDOUT data (as exponent of 2^n)"
depends on USEMODULE_STDIO_CDC_ACM || MODULE_STDIO_CDC_ACM
default 7
range 0 31
depends on USEMODULE_STDIO_CDC_ACM
help
As buffer size ALWAYS needs to be power of two, this changes this option
represents the exponent of 2^n, which will be used as the size of the
@ -44,18 +50,14 @@ config USBUS_CDC_ACM_BULK_EP_SIZE_64
endchoice
endif # KCONFIG_USEMODULE_USBUS_CDC_ACM
config MODULE_USBUS_CDC_ACM
bool "USB CDC ACM support"
depends on MODULE_USBUS
select MODULE_TSRB
endif # MODULE_USBUS_CDC_ACM
# extend STDIO options
choice STDIO_IMPLEMENTATION
config MODULE_STDIO_CDC_ACM
bool "CDC ACM"
depends on MODULE_USBUS || KCONFIG_USEMODULE_USBUS
depends on MODULE_USBUS_CDC_ACM && !MODULE_TINYUSB_DEVICE
select MODULE_ISRPIPE
select MODULE_STDIO_AVAILABLE

View File

@ -11,7 +11,13 @@ menuconfig KCONFIG_USEMODULE_USBUS_CDC_ECM
help
Configure the USBUS CDC ECM module via Kconfig.
if KCONFIG_USEMODULE_USBUS_CDC_ECM
menuconfig MODULE_USBUS_CDC_ECM
bool "Configure USBUS CDC ECM"
depends on MODULE_USBUS
help
Configure the USBUS CDC ECM module via Kconfig.
if KCONFIG_USEMODULE_USBUS_CDC_ECM || MODULE_USBUS_CDC_ECM
config USBUS_CDC_ECM_CONFIG_SPEED_IND
bool "Configure upload and download speeds independently"
@ -41,4 +47,4 @@ config USBUS_CDC_ECM_CONFIG_SPEED_UPSTREAM
This is the link upload speed, defined in bits/second, that the USB
peripheral will report to the host.
endif # KCONFIG_USEMODULE_USBUS_CDC_ECM
endif # KCONFIG_USEMODULE_USBUS_CDC_ECM || MODULE_USBUS_CDC_ECM

View File

@ -9,10 +9,14 @@ menuconfig KCONFIG_USEMODULE_USBUS_DFU
bool "Configure USBUS DFU"
depends on USEMODULE_USBUS_DFU
depends on KCONFIG_USEMODULE_USBUS
menuconfig MODULE_USBUS_DFU
bool "Configure USBUS DFU"
depends on MODULE_USBUS
help
Configure the USBUS DFU module via Kconfig.
if KCONFIG_USEMODULE_USBUS_DFU
if KCONFIG_USEMODULE_USBUS_DFU || MODULE_USBUS_DFU
config USB_DFU_DETACH_TIMEOUT_MS
int
@ -33,4 +37,4 @@ config RIOTBOOT_MAGIC_ADDR
int "DFU magic address"
depends on CUSTOM_RIOTBOOT_MAGIC_ADDR
endif # KCONFIG_USEMODULE_USBUS_DFU
endif # KCONFIG_USEMODULE_USBUS_DFU || MODULE_USBUS_DFU

View File

@ -7,7 +7,6 @@
menuconfig MODULE_USBUS_HID
bool "USB HID support"
depends on TEST_KCONFIG
depends on MODULE_USBUS
select MODULE_ISRPIPE_READ_TIMEOUT