diff --git a/cpu/nrf52/periph/usbdev.c b/cpu/nrf52/periph/usbdev.c index 2cc8ba7024..8e0b0a6be9 100644 --- a/cpu/nrf52/periph/usbdev.c +++ b/cpu/nrf52/periph/usbdev.c @@ -19,6 +19,9 @@ * @author Koen Zandberg * @} */ + +#define USB_H_USER_IS_RIOT_INTERNAL + #include #include #include diff --git a/cpu/sam0_common/periph/usbdev.c b/cpu/sam0_common/periph/usbdev.c index 23836a4a2b..9230371cfe 100644 --- a/cpu/sam0_common/periph/usbdev.c +++ b/cpu/sam0_common/periph/usbdev.c @@ -15,6 +15,9 @@ * @author Koen Zandberg * @} */ + +#define USB_H_USER_IS_RIOT_INTERNAL + #include #include #include diff --git a/drivers/periph_common/init.c b/drivers/periph_common/init.c index 73aeb4c499..099776e48c 100644 --- a/drivers/periph_common/init.c +++ b/drivers/periph_common/init.c @@ -20,6 +20,8 @@ * @} */ +#define USB_H_USER_IS_RIOT_INTERNAL + #ifdef MODULE_PERIPH_I2C #include "periph/i2c.h" #endif diff --git a/sys/auto_init/netif/auto_init_cdcecm.c b/sys/auto_init/netif/auto_init_cdcecm.c index 5bf9e2229c..617e85b2a4 100644 --- a/sys/auto_init/netif/auto_init_cdcecm.c +++ b/sys/auto_init/netif/auto_init_cdcecm.c @@ -19,6 +19,8 @@ #ifdef MODULE_USBUS_CDC_ECM +#define USB_H_USER_IS_RIOT_INTERNAL + #include "log.h" #include "usb/usbus/cdc/ecm.h" #include "net/gnrc/netif/ethernet.h" diff --git a/sys/auto_init/usb/auto_init_usb.c b/sys/auto_init/usb/auto_init_usb.c index 5c84350059..dfcabbd5d3 100644 --- a/sys/auto_init/usb/auto_init_usb.c +++ b/sys/auto_init/usb/auto_init_usb.c @@ -22,6 +22,8 @@ * @} */ +#define USB_H_USER_IS_RIOT_INTERNAL + #include "usb/usbus.h" #ifdef MODULE_USBUS_CDC_ECM diff --git a/sys/include/usb.h b/sys/include/usb.h index 77abd1aed9..30848cb4fd 100644 --- a/sys/include/usb.h +++ b/sys/include/usb.h @@ -29,18 +29,26 @@ extern "C" { * @ingroup config * @{ */ + +#if !(defined(CONFIG_USB_VID) && defined(CONFIG_USB_PID)) +#ifdef USB_H_USER_IS_RIOT_INTERNAL +/* Reserved for RIOT standard peripherals as per http://pid.codes/1209/7D00/ */ +#define CONFIG_USB_VID (0x1209) +#define CONFIG_USB_PID (0x7D00) +#else +#error Please configure your vendor and product IDs. For development, you may \ + set CONFIG_USB_VID=0x1209 CONFIG_USB_PID=0x7D01. +#endif +#endif + /** * @brief USB peripheral device vendor ID * * @note You must provide your own VID/PID combination when manufacturing a * device with USB. */ -#ifndef CONFIG_USB_VID #ifdef DOXYGEN #define CONFIG_USB_VID -#else -#error Please supply your vendor ID by setting CONFIG_USB_VID -#endif #endif /** @@ -49,12 +57,8 @@ extern "C" { * @note You must provide your own VID/PID combination when manufacturing a * device with USB. */ -#ifndef CONFIG_USB_PID #ifdef DOXYGEN #define CONFIG_USB_PID -#else -#error Please supply your vendor ID by setting CONFIG_USB_PID -#endif #endif /** @@ -123,6 +127,35 @@ extern "C" { #endif /** @} */ +/** + * @brief RIOT-internal USB peripheral clearance indicator + * + * This define must only be set in compilation units that are RIOT internal, + * and only when they implement peripherals that can be considered default RIOT + * peripherals. + * + * When this is defined in all uses of `usb.h`, the board can use the + * 0x1209/0x7D00 VID/PID pair unless explicit configuration using @ref + * CONFIG_USB_VID and @ref CONFIG_USB_PID say otherwise. + * + * There is no sharp characterization of what consititutes an internal + * peripheral; a good check is this: If an application can, just by switching + * between boards, can have a feature provided by either RIOT's USB stack or a + * different mechanism, the USB version is a default RIOT peripheral. + * + * Examples are stdio access (is provided by most boards using a UART and an + * external USB UART adapter), Ethernet (is provided by other boards using + * ethos) and firmware upload and reset (is provided by other boards using an + * on-board programmer). + * + * See http://pid.codes/1209/7D00/ for the allocation of that code. + * @{ + */ +#ifdef DOXYGEN +#define USB_H_USER_IS_RIOT_INTERNAL +#endif +/** @} */ + /** * @brief USB version definitions */ diff --git a/sys/usb/usbus/cdc/acm/cdc_acm.c b/sys/usb/usbus/cdc/acm/cdc_acm.c index f48509ce77..df79b99b0c 100644 --- a/sys/usb/usbus/cdc/acm/cdc_acm.c +++ b/sys/usb/usbus/cdc/acm/cdc_acm.c @@ -16,6 +16,8 @@ * @} */ +#define USB_H_USER_IS_RIOT_INTERNAL + #include #include "tsrb.h" diff --git a/sys/usb/usbus/cdc/acm/cdc_acm_stdio.c b/sys/usb/usbus/cdc/acm/cdc_acm_stdio.c index 35903ed033..f6b192e2a3 100644 --- a/sys/usb/usbus/cdc/acm/cdc_acm_stdio.c +++ b/sys/usb/usbus/cdc/acm/cdc_acm_stdio.c @@ -19,6 +19,8 @@ * @} */ +#define USB_H_USER_IS_RIOT_INTERNAL + #include #include "isrpipe.h" diff --git a/sys/usb/usbus/cdc/ecm/cdc_ecm.c b/sys/usb/usbus/cdc/ecm/cdc_ecm.c index 4065035f3b..752b850c76 100644 --- a/sys/usb/usbus/cdc/ecm/cdc_ecm.c +++ b/sys/usb/usbus/cdc/ecm/cdc_ecm.c @@ -15,6 +15,8 @@ * @} */ +#define USB_H_USER_IS_RIOT_INTERNAL + #include "event.h" #include "fmt.h" #include "kernel_defines.h" diff --git a/sys/usb/usbus/cdc/ecm/cdc_ecm_netdev.c b/sys/usb/usbus/cdc/ecm/cdc_ecm_netdev.c index cc2391e5b2..766e97a45e 100644 --- a/sys/usb/usbus/cdc/ecm/cdc_ecm_netdev.c +++ b/sys/usb/usbus/cdc/ecm/cdc_ecm_netdev.c @@ -15,6 +15,8 @@ * @} */ +#define USB_H_USER_IS_RIOT_INTERNAL + #include #include "kernel_defines.h" diff --git a/sys/usb/usbus/usbus.c b/sys/usb/usbus/usbus.c index f2fd74f90a..46e2d1c4d3 100644 --- a/sys/usb/usbus/usbus.c +++ b/sys/usb/usbus/usbus.c @@ -16,6 +16,8 @@ * @} */ +#define USB_H_USER_IS_RIOT_INTERNAL + #include "bitarithm.h" #include "event.h" #include "thread.h" diff --git a/sys/usb/usbus/usbus_control.c b/sys/usb/usbus/usbus_control.c index b1cd84d87b..ed280b6dcc 100644 --- a/sys/usb/usbus/usbus_control.c +++ b/sys/usb/usbus/usbus_control.c @@ -15,6 +15,9 @@ * @author Koen Zandberg * @} */ + +#define USB_H_USER_IS_RIOT_INTERNAL + #include "periph/usbdev.h" #include "usb/descriptor.h" #include "usb/usbus.h" diff --git a/sys/usb/usbus/usbus_control_slicer.c b/sys/usb/usbus/usbus_control_slicer.c index 31018c6283..ac30f0a863 100644 --- a/sys/usb/usbus/usbus_control_slicer.c +++ b/sys/usb/usbus/usbus_control_slicer.c @@ -16,6 +16,8 @@ * @} */ +#define USB_H_USER_IS_RIOT_INTERNAL + #include #include "periph/usbdev.h" #include "usb/usbus.h" diff --git a/sys/usb/usbus/usbus_fmt.c b/sys/usb/usbus/usbus_fmt.c index 5299169934..edeacbaf88 100644 --- a/sys/usb/usbus/usbus_fmt.c +++ b/sys/usb/usbus/usbus_fmt.c @@ -16,6 +16,8 @@ * @} */ +#define USB_H_USER_IS_RIOT_INTERNAL + #include #include #include "usb/descriptor.h"