From 15bd4897c1d55df134f121c290e6e97e70d3cb70 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Thu, 5 Dec 2019 13:17:30 +0100 Subject: [PATCH] usb: Move configuration macros to 'CONFIG_' namespace Macros that changed: USB_CONFIG_VID -> CONFIG_USB_VID USB_CONFIG_PID -> CONFIG_USB_PID USB_CONFIG_MANUF_STR -> CONFIG_USB_MANUF_STR USB_CONFIG_PRODUCT_STR -> CONFIG_USB_PRODUCT_STR USB_CONFIG_CONFIGURATION_STR -> CONFIG_USB_CONFIGURATION_STR USB_CONFIG_PRODUCT_BCDVERSION -> CONFIG_USB_PRODUCT_BCDVERSION USB_CONFIG_SPEC_BCDVERSION -> CONFIG_USB_SPEC_BCDVERSION USB_CONFIG_SELF_POWERED -> CONFIG_USB_SELF_POWERED USB_CONFIG_MAX_POWER -> CONFIG_USB_MAX_POWER USB_CONFIG_DEFAULT_LANGID -> CONFIG_USB_DEFAULT_LANGID --- examples/usbus_minimal/Makefile | 2 +- examples/usbus_minimal/README.md | 2 +- sys/include/usb.h | 44 +++++++++++++++--------------- sys/usb/usbus/usbus.c | 6 ++-- sys/usb/usbus/usbus_control.c | 2 +- sys/usb/usbus/usbus_fmt.c | 10 +++---- tests/usbus/Makefile | 2 +- tests/usbus_cdc_acm_stdio/Makefile | 2 +- tests/usbus_cdc_ecm/Makefile | 2 +- 9 files changed, 36 insertions(+), 36 deletions(-) diff --git a/examples/usbus_minimal/Makefile b/examples/usbus_minimal/Makefile index c33e574401..5b1e30247a 100644 --- a/examples/usbus_minimal/Makefile +++ b/examples/usbus_minimal/Makefile @@ -24,7 +24,7 @@ USB_PID ?= $(DEFAULT_PID) # Change this to 0 show compiler invocation lines by default: QUIET ?= 1 -CFLAGS += -DUSB_CONFIG_VID=0x$(USB_VID) -DUSB_CONFIG_PID=0x$(USB_PID) +CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID) -DCONFIG_USB_PID=0x$(USB_PID) include $(RIOTBASE)/Makefile.include diff --git a/examples/usbus_minimal/README.md b/examples/usbus_minimal/README.md index c879483756..4df46416ab 100644 --- a/examples/usbus_minimal/README.md +++ b/examples/usbus_minimal/README.md @@ -8,7 +8,7 @@ RIOT doesn't own any USB vendor and product ID. To compile this example, add your own vendor and product ID to the makefile: ``` -CFLAGS += -DUSB_CONFIG_VID=0xYOURVID -DUSB_CONFIG_PID=0xYOURPID +CFLAGS += -DCONFIG_USB_VID=0xYOURVID -DCONFIG_USB_PID=0xYOURPID ``` The example demonstrates basic USB communication between a host and a RIOT diff --git a/sys/include/usb.h b/sys/include/usb.h index 018c323030..c8b27d68fa 100644 --- a/sys/include/usb.h +++ b/sys/include/usb.h @@ -35,11 +35,11 @@ extern "C" { * @note You must provide your own VID/PID combination when manufacturing a * device with USB. */ -#ifndef USB_CONFIG_VID +#ifndef CONFIG_USB_VID #ifdef DOXYGEN -#define USB_CONFIG_VID +#define CONFIG_USB_VID #else -#error Please supply your vendor ID by setting USB_CONFIG_VID +#error Please supply your vendor ID by setting CONFIG_USB_VID #endif #endif @@ -49,33 +49,33 @@ extern "C" { * @note You must provide your own VID/PID combination when manufacturing a * device with USB. */ -#ifndef USB_CONFIG_PID +#ifndef CONFIG_USB_PID #ifdef DOXYGEN -#define USB_CONFIG_PID +#define CONFIG_USB_PID #else -#error Please supply your vendor ID by setting USB_CONFIG_PID +#error Please supply your vendor ID by setting CONFIG_USB_PID #endif #endif /** * @brief USB peripheral manufacturer string */ -#ifndef USB_CONFIG_MANUF_STR -#define USB_CONFIG_MANUF_STR "RIOT-os.org" +#ifndef CONFIG_USB_MANUF_STR +#define CONFIG_USB_MANUF_STR "RIOT-os.org" #endif /** * @brief USB peripheral product string */ -#ifndef USB_CONFIG_PRODUCT_STR -#define USB_CONFIG_PRODUCT_STR "USB device" +#ifndef CONFIG_USB_PRODUCT_STR +#define CONFIG_USB_PRODUCT_STR "USB device" #endif /** * @brief USB peripheral configuration string */ -#ifndef USB_CONFIG_CONFIGURATION_STR -#define USB_CONFIG_CONFIGURATION_STR "USB config" +#ifndef CONFIG_USB_CONFIGURATION_STR +#define CONFIG_USB_CONFIGURATION_STR "USB config" #endif /** @@ -84,36 +84,36 @@ extern "C" { * This is the version number of this peripheral * @note Not to be be confused with the USB version number */ -#ifndef USB_CONFIG_PRODUCT_BCDVERSION -#define USB_CONFIG_PRODUCT_BCDVERSION 0x0100 +#ifndef CONFIG_USB_PRODUCT_BCDVERSION +#define CONFIG_USB_PRODUCT_BCDVERSION 0x0100 #endif /** * @brief USB specification version */ -#ifndef USB_CONFIG_SPEC_BCDVERSION -#define USB_CONFIG_SPEC_BCDVERSION 0x0200 +#ifndef CONFIG_USB_SPEC_BCDVERSION +#define CONFIG_USB_SPEC_BCDVERSION 0x0200 #endif /** * @brief USB peripheral setting to indicate self powered devices. */ -#ifndef USB_CONFIG_SELF_POWERED -#define USB_CONFIG_SELF_POWERED (0) +#ifndef CONFIG_USB_SELF_POWERED +#define CONFIG_USB_SELF_POWERED (0) #endif /** * @brief USB device max power draw in mA, between 0 and 500mA */ -#ifndef USB_CONFIG_MAX_POWER -#define USB_CONFIG_MAX_POWER (100) +#ifndef CONFIG_USB_MAX_POWER +#define CONFIG_USB_MAX_POWER (100) #endif /** * @brief Default LANG ID reported to the host */ -#ifndef USB_CONFIG_DEFAULT_LANGID -#define USB_CONFIG_DEFAULT_LANGID 0x0409 /* EN-US */ +#ifndef CONFIG_USB_DEFAULT_LANGID +#define CONFIG_USB_DEFAULT_LANGID 0x0409 /* EN-US */ #endif /** @} */ diff --git a/sys/usb/usbus/usbus.c b/sys/usb/usbus/usbus.c index e688aec81a..f2fd74f90a 100644 --- a/sys/usb/usbus/usbus.c +++ b/sys/usb/usbus/usbus.c @@ -237,9 +237,9 @@ static void *_usbus_thread(void *args) usbdev_init(dev); usbus_add_string_descriptor(usbus, &usbus->config, - USB_CONFIG_CONFIGURATION_STR); - usbus_add_string_descriptor(usbus, &usbus->product, USB_CONFIG_PRODUCT_STR); - usbus_add_string_descriptor(usbus, &usbus->manuf, USB_CONFIG_MANUF_STR); + CONFIG_USB_CONFIGURATION_STR); + usbus_add_string_descriptor(usbus, &usbus->product, CONFIG_USB_PRODUCT_STR); + usbus_add_string_descriptor(usbus, &usbus->manuf, CONFIG_USB_MANUF_STR); usbus->state = USBUS_STATE_DISCONNECT; diff --git a/sys/usb/usbus/usbus_control.c b/sys/usb/usbus/usbus_control.c index c415ae0bff..b1cd84d87b 100644 --- a/sys/usb/usbus/usbus_control.c +++ b/sys/usb/usbus/usbus_control.c @@ -123,7 +123,7 @@ static int _req_str(usbus_t *usbus, uint16_t idx) desc.length = sizeof(uint16_t) + sizeof(usb_descriptor_string_t); usbus_control_slicer_put_bytes(usbus, (uint8_t *)&desc, sizeof(desc)); /* Only one language ID supported */ - uint16_t us = USB_CONFIG_DEFAULT_LANGID; + uint16_t us = CONFIG_USB_DEFAULT_LANGID; usbus_control_slicer_put_bytes(usbus, (uint8_t *)&us, sizeof(uint16_t)); res = 1; } diff --git a/sys/usb/usbus/usbus_fmt.c b/sys/usb/usbus/usbus_fmt.c index 069c09cc46..5299169934 100644 --- a/sys/usb/usbus/usbus_fmt.c +++ b/sys/usb/usbus/usbus_fmt.c @@ -248,12 +248,12 @@ size_t usbus_fmt_descriptor_conf(usbus_t *usbus) conf.total_length = sizeof(usb_descriptor_configuration_t); conf.val = 1; conf.attributes = USB_CONF_ATTR_RESERVED; - if (USB_CONFIG_SELF_POWERED) { + if (CONFIG_USB_SELF_POWERED) { conf.attributes |= USB_CONF_ATTR_SELF_POWERED; } /* TODO: upper bound */ /* USB max power is reported in increments of 2 mA */ - conf.max_power = USB_CONFIG_MAX_POWER / 2; + conf.max_power = CONFIG_USB_MAX_POWER / 2; conf.num_interfaces = _num_ifaces(usbus); len += sizeof(usb_descriptor_configuration_t); conf.total_length = _gen_config_descriptor_size(usbus); @@ -272,10 +272,10 @@ size_t usbus_fmt_descriptor_dev(usbus_t *usbus) memset(&desc, 0, sizeof(usb_descriptor_device_t)); desc.length = sizeof(usb_descriptor_device_t); desc.type = USB_TYPE_DESCRIPTOR_DEVICE; - desc.bcd_usb = USB_CONFIG_SPEC_BCDVERSION; + desc.bcd_usb = CONFIG_USB_SPEC_BCDVERSION; desc.max_packet_size = USBUS_EP0_SIZE; - desc.vendor_id = USB_CONFIG_VID; - desc.product_id = USB_CONFIG_PID; + desc.vendor_id = CONFIG_USB_VID; + desc.product_id = CONFIG_USB_PID; desc.manufacturer_idx = usbus->manuf.idx; desc.product_idx = usbus->product.idx; /* USBUS supports only a single config at the moment */ diff --git a/tests/usbus/Makefile b/tests/usbus/Makefile index e17c62f342..deecab8038 100644 --- a/tests/usbus/Makefile +++ b/tests/usbus/Makefile @@ -9,7 +9,7 @@ DEFAULT_PID = 0001 USB_VID ?= $(DEFAULT_VID) USB_PID ?= $(DEFAULT_PID) -CFLAGS += -DUSB_CONFIG_VID=0x$(USB_VID) -DUSB_CONFIG_PID=0x$(USB_PID) +CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID) -DCONFIG_USB_PID=0x$(USB_PID) include $(RIOTBASE)/Makefile.include diff --git a/tests/usbus_cdc_acm_stdio/Makefile b/tests/usbus_cdc_acm_stdio/Makefile index 711f6a2ea6..1e4fb8b017 100644 --- a/tests/usbus_cdc_acm_stdio/Makefile +++ b/tests/usbus_cdc_acm_stdio/Makefile @@ -13,7 +13,7 @@ DEFAULT_PID = 0001 USB_VID ?= $(DEFAULT_VID) USB_PID ?= $(DEFAULT_PID) -CFLAGS += -DUSB_CONFIG_VID=0x$(USB_VID) -DUSB_CONFIG_PID=0x$(USB_PID) +CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID) -DCONFIG_USB_PID=0x$(USB_PID) include $(RIOTBASE)/Makefile.include diff --git a/tests/usbus_cdc_ecm/Makefile b/tests/usbus_cdc_ecm/Makefile index 0bdb3c36bb..dbf633ba75 100644 --- a/tests/usbus_cdc_ecm/Makefile +++ b/tests/usbus_cdc_ecm/Makefile @@ -20,7 +20,7 @@ DEFAULT_PID = 0001 USB_VID ?= $(DEFAULT_VID) USB_PID ?= $(DEFAULT_PID) -CFLAGS += -DUSB_CONFIG_VID=0x$(USB_VID) -DUSB_CONFIG_PID=0x$(USB_PID) +CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID) -DCONFIG_USB_PID=0x$(USB_PID) include $(RIOTBASE)/Makefile.include