1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 15:03:53 +01:00

Merge pull request #13374 from leandrolanzieri/pr/kconfig_migrate/sys/usbus

sys/usbus: Expose configurations to Kconfig
This commit is contained in:
Cenk Gündoğan 2020-04-03 15:19:22 +02:00 committed by GitHub
commit fca7548762
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 74 additions and 13 deletions

View File

@ -29,6 +29,7 @@
#include "clist.h"
#include "event.h"
#include "kernel_types.h"
#include "kernel_defines.h"
#include "msg.h"
#include "thread.h"
@ -62,12 +63,14 @@ extern "C" {
/**
* @brief USBUS auto attach setting
*
* When set, the USBUS thread will automatically enable the USB pull-up
* When set to 1, the USBUS thread will automatically enable the USB pull-up
* resistor after initializing the thread. This will signal to the host
* that the USB peripheral is ready for use.
*/
#ifndef USBUS_AUTO_ATTACH
#define USBUS_AUTO_ATTACH (1)
#ifndef CONFIG_USBUS_AUTO_ATTACH
#if !IS_ACTIVE(KCONFIG_MODULE_USBUS)
#define CONFIG_USBUS_AUTO_ATTACH 1
#endif
#endif
/**
@ -77,8 +80,18 @@ extern "C" {
* large amount of data often over the control endpoint, a minimal size should
* be sufficient
*/
#ifndef USBUS_EP0_SIZE
#define USBUS_EP0_SIZE 64
#if IS_ACTIVE(CONFIG_USBUS_EP0_SIZE_8)
#define CONFIG_USBUS_EP0_SIZE 8
#elif IS_ACTIVE(CONFIG_USBUS_EP0_SIZE_16)
#define CONFIG_USBUS_EP0_SIZE 16
#elif IS_ACTIVE(CONFIG_USBUS_EP0_SIZE_32)
#define CONFIG_USBUS_EP0_SIZE 32
#elif IS_ACTIVE(CONFIG_USBUS_EP0_SIZE_64)
#define CONFIG_USBUS_EP0_SIZE 64
#endif
#ifndef CONFIG_USBUS_EP0_SIZE
#define CONFIG_USBUS_EP0_SIZE 64
#endif
/** @} */

View File

@ -79,4 +79,6 @@ config USB_DEFAULT_LANGID
help
The default value is EN-US (0x0409).
rsource "usbus/Kconfig"
endif # KCONFIG_USB

45
sys/usb/usbus/Kconfig Normal file
View File

@ -0,0 +1,45 @@
# Copyright (c) 2020 HAW Hamburg
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#
menuconfig KCONFIG_MODULE_USBUS
bool "Configure USB Unified Stack (USBUS)"
depends on MODULE_USBUS
help
Configure the USBUS module via Kconfig.
if KCONFIG_MODULE_USBUS
config USBUS_AUTO_ATTACH
bool "Auto attach"
default y
help
When set, the USBUS thread will automatically enable the USB pull-up
resistor after initializing the thread. This will signal to the host
that the USB peripheral is ready for use.
choice
bool "Endpoint 0 buffer size"
default USBUS_EP0_SIZE_64
help
This configures the buffer size of the control endpoint. Unless you
transfer large amount of data often over the control endpoint, a minimal
size should be sufficient.
config USBUS_EP0_SIZE_8
bool "8"
config USBUS_EP0_SIZE_16
bool "16"
config USBUS_EP0_SIZE_32
bool "32"
config USBUS_EP0_SIZE_64
bool "64"
endchoice
endif # KCONFIG_MODULE_USBUS

View File

@ -18,6 +18,7 @@
#define USB_H_USER_IS_RIOT_INTERNAL
#include "kernel_defines.h"
#include "bitarithm.h"
#include "event.h"
#include "thread.h"
@ -248,11 +249,11 @@ static void *_usbus_thread(void *args)
/* Initialize handlers */
_usbus_init_handlers(usbus);
#if (USBUS_AUTO_ATTACH)
static const usbopt_enable_t _enable = USBOPT_ENABLE;
usbdev_set(dev, USBOPT_ATTACH, &_enable,
sizeof(usbopt_enable_t));
#endif
if (IS_ACTIVE(CONFIG_USBUS_AUTO_ATTACH)) {
static const usbopt_enable_t _enable = USBOPT_ENABLE;
usbdev_set(dev, USBOPT_ATTACH, &_enable,
sizeof(usbopt_enable_t));
}
while (1) {
thread_flags_t flags = thread_flags_wait_any(

View File

@ -331,9 +331,9 @@ static void _init(usbus_t *usbus, usbus_handler_t *handler)
ep0_handler->control_request_state = USBUS_CONTROL_REQUEST_STATE_READY;
ep0_handler->in = usbus_add_endpoint(usbus, NULL, USB_EP_TYPE_CONTROL,
USB_EP_DIR_IN, USBUS_EP0_SIZE)->ep;
USB_EP_DIR_IN, CONFIG_USBUS_EP0_SIZE)->ep;
ep0_handler->out = usbus_add_endpoint(usbus, NULL, USB_EP_TYPE_CONTROL,
USB_EP_DIR_OUT, USBUS_EP0_SIZE)->ep;
USB_EP_DIR_OUT, CONFIG_USBUS_EP0_SIZE)->ep;
}
static int _handle_tr_complete(usbus_t *usbus,

View File

@ -275,7 +275,7 @@ size_t usbus_fmt_descriptor_dev(usbus_t *usbus)
desc.length = sizeof(usb_descriptor_device_t);
desc.type = USB_TYPE_DESCRIPTOR_DEVICE;
desc.bcd_usb = CONFIG_USB_SPEC_BCDVERSION;
desc.max_packet_size = USBUS_EP0_SIZE;
desc.max_packet_size = CONFIG_USBUS_EP0_SIZE;
desc.vendor_id = CONFIG_USB_VID;
desc.product_id = CONFIG_USB_PID;
desc.manufacturer_idx = usbus->manuf.idx;