123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- #ifndef APP_USBD_DESCRIPTOR_H__
- #define APP_USBD_DESCRIPTOR_H__
- #include "nrf.h"
- #include "nrf_drv_usbd.h"
- #include "app_usbd_langid.h"
- #include "app_util_platform.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- ANON_UNIONS_ENABLE;
- #define APP_USBD_U16_TO_RAW_DSC(val) (uint8_t)(val), \
- (uint8_t)(((val) / (256)))
- #define APP_USBD_U24_TO_RAW_DSC(val) (uint8_t)(val), \
- (uint8_t)(((val) / (256))), \
- (uint8_t)(((val) / (256 * 256)))
- #define APP_USBD_U32_TO_RAW_DSC(val) (uint8_t)(val), \
- (uint8_t)(((val) / (256))), \
- (uint8_t)(((val) / (256 * 256))) \
- (uint8_t)(((val) / (256 * 256 * 256)))
- typedef enum
- {
- APP_USBD_DESCRIPTOR_DEVICE = 1,
- APP_USBD_DESCRIPTOR_CONFIGURATION = 2,
- APP_USBD_DESCRIPTOR_STRING = 3,
- APP_USBD_DESCRIPTOR_INTERFACE = 4,
- APP_USBD_DESCRIPTOR_ENDPOINT = 5,
- APP_USBD_DESCRIPTOR_DEVICE_QUALIFIER = 6,
- APP_USBD_DESCRIPTOR_OTHER_SPEED_CONFIGURATION = 7,
- APP_USBD_DESCRIPTOR_INTERFACE_POWER = 8,
- APP_USBD_DESCRIPTOR_OTG = 9,
- APP_USBD_DESCRIPTOR_DEBUG = 10,
- APP_USBD_DESCRIPTOR_INTERFACE_ASSOCIATION = 11,
- APP_USBD_DESCRIPTOR_REPORT = 34,
- APP_USBD_DESCRIPTOR_PHYSICAL = 35
- } app_usbd_descriptor_t;
- #pragma pack(push, 1)
- typedef struct
- {
- uint8_t bLength;
- uint8_t bDescriptorType;
-
- } app_usbd_descriptor_header_t;
- typedef struct
- {
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint16_t bcdUSB;
- uint8_t bDeviceClass;
-
- uint8_t bDeviceSubClass;
-
- uint8_t bDeviceProtocol;
-
- uint8_t bMaxPacketSize0;
- uint16_t idVendor;
- uint16_t idProduct;
- uint16_t bcdDevice;
- uint8_t iManufacturer;
- uint8_t iProduct;
- uint8_t iSerialNumber;
- uint8_t bNumConfigurations;
- } app_usbd_descriptor_device_t;
- typedef enum
- {
-
- APP_USBD_DESCRIPTOR_CONFIGURATION_ATTRIBUTE_ALWAYS_SET_MASK = 1U << 7,
-
- APP_USBD_DESCRIPTOR_CONFIGURATION_ATTRIBUTE_SELF_POWERED_MASK = 1U << 6,
-
- APP_USBD_DESCRIPTOR_CONFIGURATION_ATTRIBUTE_REMOTE_WAKEUP_MASK = 1U << 5
- } app_usbd_descriptor_configuration_attributes_t;
- typedef struct
- {
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint16_t wTotalLength;
- uint8_t bNumInterfaces;
- uint8_t bConfigurationValue;
- uint8_t iConfiguration;
- uint8_t bmAttributes;
- uint8_t bMaxPower;
- } app_usbd_descriptor_configuration_t;
- typedef struct
- {
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint16_t wLANGID[];
- } app_usbd_descriptor_string0_t;
- typedef struct
- {
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint16_t bString[];
- } app_usbd_descriptor_string_t;
- typedef struct
- {
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint8_t bInterfaceNumber;
- uint8_t bAlternateSetting;
- uint8_t bNumEndpoints;
- uint8_t bInterfaceClass;
- uint8_t bInterfaceSubClass;
- uint8_t bInterfaceProtocol;
- uint8_t iInterface;
- } app_usbd_descriptor_iface_t;
- #define APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_OFFSET 0
- #define APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_MASK BF_MASK(2, APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_OFFSET)
- #define APP_USBD_DESCRIPTOR_EP_ATTR_SYNC_OFFSET 2
- #define APP_USBD_DESCRIPTOR_EP_ATTR_SYNC_MASK BF_MASK(2, APP_USBD_DESCRIPTOR_EP_ATTR_SYNC_OFFSET)
- #define APP_USBD_DESCRIPTOR_EP_ATTR_USAGE_OFFSET 4
- #define APP_USBD_DESCRIPTOR_EP_ATTR_USAGE_MASK BF_MASK(2, APP_USBD_DESCRIPTOR_EP_ATTR_USAGE_OFFSET)
- typedef enum
- {
- APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_CONTROL = 0 << APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_OFFSET,
- APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_ISOCHRONOUS = 1 << APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_OFFSET,
- APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_BULK = 2 << APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_OFFSET,
- APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_INTERRUPT = 3 << APP_USBD_DESCRIPTOR_EP_ATTR_TYPE_OFFSET,
- APP_USBD_DESCRIPTOR_EP_ATTR_SYNC_NONE = 0 << APP_USBD_DESCRIPTOR_EP_ATTR_SYNC_OFFSET,
- APP_USBD_DESCRIPTOR_EP_ATTR_SYNC_ASYNCHRONOUS = 1 << APP_USBD_DESCRIPTOR_EP_ATTR_SYNC_OFFSET,
- APP_USBD_DESCRIPTOR_EP_ATTR_SYNC_ADAPTIVE = 2 << APP_USBD_DESCRIPTOR_EP_ATTR_SYNC_OFFSET,
- APP_USBD_DESCRIPTOR_EP_ATTR_SYNC_SYNCHRONOUS = 3 << APP_USBD_DESCRIPTOR_EP_ATTR_SYNC_OFFSET,
- APP_USBD_DESCRIPTOR_EP_ATTR_USAGE_DATA = 0 << APP_USBD_DESCRIPTOR_EP_ATTR_USAGE_OFFSET,
- APP_USBD_DESCRIPTOR_EP_ATTR_USAGE_FEEDBACK = 1 << APP_USBD_DESCRIPTOR_EP_ATTR_USAGE_OFFSET,
- APP_USBD_DESCRIPTOR_EP_ATTR_USAGE_IMPLICIT = 2 << APP_USBD_DESCRIPTOR_EP_ATTR_USAGE_OFFSET
- } app_usbd_descriptor_ep_attr_bitmap_t;
- typedef struct
- {
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint8_t bEndpointAddress;
- uint8_t bmAttributes;
- uint16_t wMaxPacketSize;
- uint8_t bInterval;
- } app_usbd_descriptor_ep_t;
- typedef struct
- {
- uint8_t bLength;
- uint8_t bDescriptorType;
- uint8_t bFirstInterface;
- uint8_t bInterfaceCount;
- uint8_t bFunctionClass;
- uint8_t bFunctionSubClass;
- uint8_t bFunctionProtocol;
- uint8_t iFunction;
- } app_usbd_descriptor_iad_t;
- #pragma pack(pop)
- ANON_UNIONS_DISABLE;
- #ifdef __cplusplus
- }
- #endif
- #endif
|