USB VID/PID: Move check inside usb.h include guards
As the whitelist define can be set per compilation unit in all legitimate cases, the checks do not need to be run on every single usb.h inclusion. This is done for two reaons: * It is sufficient -- if any user C file includes usb.h, there's already a good chance that the user is doing something USB related manualy. (And conversely, the existing examples with boards that happen to pull in CDC-ACM or CDC-ECM do not include usb.h from an example C file). * Defining the USB_H_USER_IS_RIOT around legitimate uses of the header by other headers would allow accidental sidestepping: If a user includes a legitimate usb.h using header (say, board.h) and just forgets to include usb.h on their own, their application that'd mess with USB would still work as usb.h is transitively included, and the check for custom includes does not trigger.
This commit is contained in:
parent
e65f3f372b
commit
763ce7a9bf
@ -17,20 +17,6 @@
|
|||||||
* @author Koen Zandberg <koen@bergzand.net>
|
* @author Koen Zandberg <koen@bergzand.net>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* These checks are deliberately outside the include guards, as they depend on
|
|
||||||
* a define that only RIOT-internal users set */
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
||||||
#ifndef USB_H
|
#ifndef USB_H
|
||||||
#define USB_H
|
#define USB_H
|
||||||
|
|
||||||
@ -43,6 +29,18 @@ extern "C" {
|
|||||||
* @ingroup config
|
* @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
|
* @brief USB peripheral device vendor ID
|
||||||
*
|
*
|
||||||
@ -132,8 +130,10 @@ extern "C" {
|
|||||||
/**
|
/**
|
||||||
* @brief RIOT-internal USB peripheral clearance indicator
|
* @brief RIOT-internal USB peripheral clearance indicator
|
||||||
*
|
*
|
||||||
* This define must only be set by RIOT internal users of `usb.h`, and only when
|
* This define must only be set in compilation units that are RIOT internal,
|
||||||
* they implement peripherals that can be considered default RIOT peripherals.
|
* 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
|
* 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
|
* 0x1209/0x7D00 VID/PID pair unless explicit configuration using @ref
|
||||||
* CONFIG_USB_VID and @ref CONFIG_USB_PID say otherwise.
|
* CONFIG_USB_VID and @ref CONFIG_USB_PID say otherwise.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user