2018-08-23 14:41:11 +02:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2019-12-04 15:09:56 +01:00
|
|
|
/**
|
|
|
|
* @defgroup usb_conf USB peripheral compile time configurations
|
|
|
|
* @ingroup config
|
|
|
|
* @{
|
|
|
|
*/
|
2020-01-16 19:05:49 +01:00
|
|
|
|
|
|
|
#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
|
|
|
|
|
2018-08-23 14:41:11 +02:00
|
|
|
/**
|
|
|
|
* @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.
|
2018-08-23 14:41:11 +02:00
|
|
|
*/
|
2019-12-04 15:04:11 +01:00
|
|
|
#ifdef DOXYGEN
|
2019-12-05 13:17:30 +01:00
|
|
|
#define CONFIG_USB_VID
|
2019-12-04 15:04:11 +01:00
|
|
|
#endif
|
2018-08-23 14:41:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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.
|
2018-08-23 14:41:11 +02:00
|
|
|
*/
|
2019-12-04 15:04:11 +01:00
|
|
|
#ifdef DOXYGEN
|
2019-12-05 13:17:30 +01:00
|
|
|
#define CONFIG_USB_PID
|
2019-12-04 15:04:11 +01:00
|
|
|
#endif
|
2018-08-23 14:41:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief USB peripheral manufacturer string
|
|
|
|
*/
|
2019-12-05 13:17:30 +01:00
|
|
|
#ifndef CONFIG_USB_MANUF_STR
|
|
|
|
#define CONFIG_USB_MANUF_STR "RIOT-os.org"
|
2018-08-23 14:41:11 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief USB peripheral product string
|
|
|
|
*/
|
2019-12-05 13:17:30 +01:00
|
|
|
#ifndef CONFIG_USB_PRODUCT_STR
|
|
|
|
#define CONFIG_USB_PRODUCT_STR "USB device"
|
2018-08-23 14:41:11 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief USB peripheral configuration string
|
|
|
|
*/
|
2019-12-05 13:17:30 +01:00
|
|
|
#ifndef CONFIG_USB_CONFIGURATION_STR
|
|
|
|
#define CONFIG_USB_CONFIGURATION_STR "USB config"
|
2018-08-23 14:41:11 +02:00
|
|
|
#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
|
|
|
|
*/
|
2019-12-05 13:17:30 +01:00
|
|
|
#ifndef CONFIG_USB_PRODUCT_BCDVERSION
|
|
|
|
#define CONFIG_USB_PRODUCT_BCDVERSION 0x0100
|
2019-01-31 22:41:20 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief USB specification version
|
|
|
|
*/
|
2019-12-05 13:17:30 +01:00
|
|
|
#ifndef CONFIG_USB_SPEC_BCDVERSION
|
2019-12-05 13:22:36 +01:00
|
|
|
#if defined(CONFIG_USB_SPEC_BCDVERSION_1_1)
|
|
|
|
#define CONFIG_USB_SPEC_BCDVERSION 0x0110
|
|
|
|
#elif defined(CONFIG_USB_SPEC_BCDVERSION_2_0)
|
2019-12-05 13:17:30 +01:00
|
|
|
#define CONFIG_USB_SPEC_BCDVERSION 0x0200
|
2019-12-05 13:22:36 +01:00
|
|
|
#else
|
|
|
|
#define CONFIG_USB_SPEC_BCDVERSION 0x0200
|
|
|
|
#endif
|
2018-08-23 14:41:11 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief USB peripheral setting to indicate self powered devices.
|
|
|
|
*/
|
2019-12-05 13:17:30 +01:00
|
|
|
#ifndef CONFIG_USB_SELF_POWERED
|
|
|
|
#define CONFIG_USB_SELF_POWERED (0)
|
2018-08-23 14:41:11 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief USB device max power draw in mA, between 0 and 500mA
|
|
|
|
*/
|
2019-12-05 13:17:30 +01:00
|
|
|
#ifndef CONFIG_USB_MAX_POWER
|
|
|
|
#define CONFIG_USB_MAX_POWER (100)
|
2018-08-23 14:41:11 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Default LANG ID reported to the host
|
|
|
|
*/
|
2019-12-05 13:17:30 +01:00
|
|
|
#ifndef CONFIG_USB_DEFAULT_LANGID
|
|
|
|
#define CONFIG_USB_DEFAULT_LANGID 0x0409 /* EN-US */
|
2018-08-23 14:41:11 +02:00
|
|
|
#endif
|
2019-12-04 15:09:56 +01:00
|
|
|
/** @} */
|
2020-01-16 18:55:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief RIOT-internal USB peripheral clearance indicator
|
|
|
|
*
|
2020-01-16 19:05:49 +01:00
|
|
|
* 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.
|
|
|
|
*
|
2020-01-16 18:55:56 +01:00
|
|
|
* 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.
|
|
|
|
*
|
2020-01-16 19:32:43 +01:00
|
|
|
* 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).
|
|
|
|
*
|
2020-01-16 18:55:56 +01:00
|
|
|
* See http://pid.codes/1209/7D00/ for the allocation of that code.
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#ifdef DOXYGEN
|
|
|
|
#define USB_H_USER_IS_RIOT_INTERNAL
|
|
|
|
#endif
|
|
|
|
/** @} */
|
2018-08-23 14:41:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @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 */
|
|
|
|
/** @} */
|