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

201 lines
5.0 KiB
C
Raw Normal View History

/*
* Copyright (C) 2018 Koen Zandberg <koen@bergzand.net>
*
* 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.
*/
/**
* @defgroup usb USB
* @ingroup sys
* @brief Configuration defines for USB peripheral devices.
* @{
*
* @file
* @brief Definition of global compile time configuration options
*
* @author Koen Zandberg <koen@bergzand.net>
*/
#ifndef USB_H
#define USB_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup usb_conf USB peripheral compile time configurations
* @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
2019-12-04 15:04:11 +01:00
*
* @note You must provide your own VID/PID combination when manufacturing a
* device with USB.
*/
2019-12-04 15:04:11 +01:00
#ifdef DOXYGEN
#define CONFIG_USB_VID
2019-12-04 15:04:11 +01:00
#endif
/**
* @brief USB peripheral device product ID
*
2019-12-04 15:04:11 +01:00
* @note You must provide your own VID/PID combination when manufacturing a
* device with USB.
*/
2019-12-04 15:04:11 +01:00
#ifdef DOXYGEN
#define CONFIG_USB_PID
2019-12-04 15:04:11 +01:00
#endif
/**
* @brief USB peripheral manufacturer string
*/
#ifndef CONFIG_USB_MANUF_STR
#define CONFIG_USB_MANUF_STR "RIOT-os.org"
#endif
/**
* @brief USB peripheral product string
*/
#ifndef CONFIG_USB_PRODUCT_STR
#define CONFIG_USB_PRODUCT_STR "USB device"
#endif
/**
* @brief USB peripheral configuration string
*/
#ifndef CONFIG_USB_CONFIGURATION_STR
#define CONFIG_USB_CONFIGURATION_STR "USB config"
#endif
/**
* @brief USB peripheral device version
*
* This is the version number of this peripheral
* @note Not to be be confused with the USB version number
*/
#ifndef CONFIG_USB_PRODUCT_BCDVERSION
#define CONFIG_USB_PRODUCT_BCDVERSION 0x0100
#endif
/**
* @brief USB specification version
*/
#ifndef CONFIG_USB_SPEC_BCDVERSION
#if defined(CONFIG_USB_SPEC_BCDVERSION_1_1)
#define CONFIG_USB_SPEC_BCDVERSION 0x0110
#elif defined(CONFIG_USB_SPEC_BCDVERSION_2_0)
#define CONFIG_USB_SPEC_BCDVERSION 0x0200
#else
#define CONFIG_USB_SPEC_BCDVERSION 0x0200
#endif
#endif
/**
* @brief USB peripheral setting to indicate self powered devices.
*/
#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 CONFIG_USB_MAX_POWER
#define CONFIG_USB_MAX_POWER (100)
#endif
/**
* @brief Default LANG ID reported to the host
*/
#ifndef CONFIG_USB_DEFAULT_LANGID
#define CONFIG_USB_DEFAULT_LANGID 0x0409 /* EN-US */
#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
*/
typedef enum {
USB_VERSION_1x, /* USB 1.0 or 1.1 device */
USB_VERSION_20, /* USB 2.0 device */
} usb_version_t;
/**
* @brief USB speed definitions
*/
typedef enum {
USB_SPEED_LOW, /* Low speed (1.5Mbit/s) */
USB_SPEED_FULL, /* Full speed (12Mbit/s) */
USB_SPEED_HIGH, /* High speed (480Mbit/s) */
} usb_speed_t;
/**
* @brief USB endpoint types
*/
typedef enum {
USB_EP_TYPE_NONE = 0, /**< Unused endpoint */
USB_EP_TYPE_CONTROL, /**< Control type */
USB_EP_TYPE_INTERRUPT, /**< Interrupt type */
USB_EP_TYPE_BULK, /**< Bulk type */
USB_EP_TYPE_ISOCHRONOUS, /**< Isochronous type */
} usb_ep_type_t;
/**
* @brief USB endpoint directions
*/
typedef enum {
USB_EP_DIR_OUT, /**< Host out, device in */
USB_EP_DIR_IN, /**< Host in, device out */
} usb_ep_dir_t;
#ifdef __cplusplus
}
#endif
#endif /* USB_H */
/** @} */