Sync betaflight to Gitea
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
/*!
|
||||
\file usb_cdc.h
|
||||
\brief the header file of communication device class standard
|
||||
|
||||
\version 2024-12-20, V3.3.1, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (c) 2024, GigaDevice Semiconductor Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef USB_CDC_H
|
||||
#define USB_CDC_H
|
||||
|
||||
#include "usb_ch9_std.h"
|
||||
|
||||
/* communications device class code */
|
||||
#define USB_CLASS_CDC 0x02U
|
||||
|
||||
/* communications interface class control protocol codes */
|
||||
#define USB_CDC_PROTOCOL_NONE 0x00U /*!< CDC none protocol */
|
||||
#define USB_CDC_PROTOCOL_AT 0x01U /*!< CDC AT protocol */
|
||||
#define USB_CDC_PROTOCOL_VENDOR 0xFFU /*!< CDC vendor protocol */
|
||||
|
||||
/* data interface class code */
|
||||
#define USB_CLASS_DATA 0x0AU
|
||||
|
||||
#define USB_DESCTYPE_CDC_ACM 0x21U /*!< CDC descriptor type */
|
||||
#define USB_DESCTYPE_CS_INTERFACE 0x24U /*!< CDC interface descriptor type */
|
||||
|
||||
#define USB_CDC_ACM_CONFIG_DESC_SIZE 0x43U /*!< CDC configuration descriptor size */
|
||||
|
||||
/* class-specific notification codes for pstn subclasses */
|
||||
#define USB_CDC_NOTIFY_SERIAL_STATE 0x20U
|
||||
|
||||
/* class-specific request codes */
|
||||
#define SEND_ENCAPSULATED_COMMAND 0x00U /*!< send encapsulated command request */
|
||||
#define GET_ENCAPSULATED_RESPONSE 0x01U /*!< get encapsulated response request */
|
||||
#define SET_COMM_FEATURE 0x02U /*!< set command feature request */
|
||||
#define GET_COMM_FEATURE 0x03U /*!< get command feature request */
|
||||
#define CLEAR_COMM_FEATURE 0x04U /*!< clear command feature request */
|
||||
|
||||
#define SET_AUX_LINE_STATE 0x10U /*!< set AUX line state code */
|
||||
#define SET_HOOK_STATE 0x11U /*!< set hook state code */
|
||||
#define PULSE_SETUP 0x12U /*!< pulse setup code */
|
||||
#define SEND_PULSE 0x13U /*!< send pulse code */
|
||||
#define SET_PULSE_TIME 0x14U /*!< set pulse time code */
|
||||
#define RING_AUX_JACK 0x15U /*!< ring AUX jack code */
|
||||
|
||||
#define SET_LINE_CODING 0x20U /*!< set line coding request */
|
||||
#define GET_LINE_CODING 0x21U /*!< get line coding request */
|
||||
#define SET_CONTROL_LINE_STATE 0x22U /*!< set control line state request */
|
||||
#define SEND_BREAK 0x23U /*!< send break request */
|
||||
#define NO_CMD 0xFFU /*!< no command request */
|
||||
|
||||
#define SET_RINGER_PARMS 0x30U /*!< set ringer parameter */
|
||||
#define GET_RINGER_PARMS 0x31U /*!< get ringer parameter */
|
||||
#define SET_OPERATION_PARMS 0x32U /*!< set operation parameter */
|
||||
#define GET_OPERATION_PARMS 0x33U /*!< get ringer parameter */
|
||||
#define SET_LINE_PARMS 0x34U /*!< set line parameter */
|
||||
#define GET_LINE_PARMS 0x35U /*!< get ringer parameter */
|
||||
#define DIAL_DIGITS 0x36U /*!< dial digits */
|
||||
#define SET_UNIT_PARAMETER 0x37U /*!< set unit parameter */
|
||||
#define GET_UNIT_PARAMETER 0x38U /*!< get unit parameter */
|
||||
#define CLEAR_UNIT_PARAMETER 0x39U /*!< clear unit parameter */
|
||||
#define GET_PROFILE 0x3AU /*!< get profile */
|
||||
|
||||
#define SET_ETHERNET_MULTICAST_FILTERS 0x40U /*!< set ethernet muilcast filters */
|
||||
#define SET_ETHERNET_POWER_MANAGEMENT_PATTERN FILTER 0x41U /*!< set ethernet power management pattern filter */
|
||||
#define GET_ETHERNET_POWER_MANAGEMENT_PATTERN FILTER 0x42U /*!< get ethernet power management pattern filter */
|
||||
#define SET_ETHERNET_PACKET_FILTER 0x43U /*!< set ethernet power pocket filter */
|
||||
#define GET_ETHERNET_STATISTIC 0x44U /*!< get ethernet statistic */
|
||||
|
||||
#define SET_ATM_DATA_FORMAT 0x50U /*!< set ATM data format */
|
||||
#define GET_ATM_DEVICE_STATISTICS 0x51U /*!< get ATM device statistics */
|
||||
#define SET_ATM_DEFAULT_VC 0x52U /*!< set ATM default VC */
|
||||
#define GET_ATM_VC_STATISTICS 0x53U /*!< get ATM VC statistics */
|
||||
|
||||
/* wValue for set control line state */
|
||||
#define CDC_ACTIVATE_CARRIER_SIGNAL_RTS 0x0002U /*!< CDC activate carrier signal RTS */
|
||||
#define CDC_DEACTIVATE_CARRIER_SIGNAL_RTS 0x0000U /*!< CDC deactivate carrier signal RTS */
|
||||
#define CDC_ACTIVATE_SIGNAL_DTR 0x0001U /*!< CDC activate signal DTR */
|
||||
#define CDC_DEACTIVATE_SIGNAL_DTR 0x0000U /*!< CDC deactivate signal DTR */
|
||||
|
||||
/* CDC subclass code */
|
||||
enum usb_cdc_subclass {
|
||||
USB_CDC_SUBCLASS_RESERVED = 0U, /*!< reserved */
|
||||
USB_CDC_SUBCLASS_DLCM, /*!< direct line control mode */
|
||||
USB_CDC_SUBCLASS_ACM, /*!< abstract control mode */
|
||||
USB_CDC_SUBCLASS_TCM, /*!< telephone control mode */
|
||||
USB_CDC_SUBCLASS_MCM, /*!< multichannel control model */
|
||||
USB_CDC_SUBCLASS_CCM, /*!< CAPI control model */
|
||||
USB_CDC_SUBCLASS_ENCM, /*!< ethernet networking control model */
|
||||
USB_CDC_SUBCLASS_ANCM /*!< ATM networking control model */
|
||||
};
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
/* cdc acm line coding structure */
|
||||
typedef struct {
|
||||
uint32_t dwDTERate; /*!< data terminal rate */
|
||||
uint8_t bCharFormat; /*!< stop bits */
|
||||
uint8_t bParityType; /*!< parity */
|
||||
uint8_t bDataBits; /*!< data bits */
|
||||
} acm_line;
|
||||
|
||||
/* notification structure */
|
||||
typedef struct {
|
||||
uint8_t bmRequestType; /*!< type of request */
|
||||
uint8_t bNotification; /*!< communication interface class notifications */
|
||||
uint16_t wValue; /*!< value of notification */
|
||||
uint16_t wIndex; /*!< index of interface */
|
||||
uint16_t wLength; /*!< length of notification data */
|
||||
} acm_notification;
|
||||
|
||||
typedef struct {
|
||||
usb_desc_header header; /*!< descriptor header, including type and size. */
|
||||
uint8_t bDescriptorSubtype; /*!< bDescriptorSubtype: header function descriptor */
|
||||
uint16_t bcdCDC; /*!< bcdCDC: low byte of spec release number (CDC1.10) */
|
||||
} usb_desc_header_func;
|
||||
|
||||
typedef struct {
|
||||
usb_desc_header header; /*!< descriptor header, including type and size. */
|
||||
uint8_t bDescriptorSubtype; /*!< bDescriptorSubtype: call management function descriptor */
|
||||
uint8_t bmCapabilities; /*!< bmCapabilities: D0 is reset, D1 is ignored */
|
||||
uint8_t bDataInterface; /*!< bDataInterface: 1 interface used for call management */
|
||||
} usb_desc_call_managment_func;
|
||||
|
||||
typedef struct {
|
||||
usb_desc_header header; /*!< descriptor header, including type and size. */
|
||||
uint8_t bDescriptorSubtype; /*!< bDescriptorSubtype: abstract control management descriptor */
|
||||
uint8_t bmCapabilities; /*!< bmCapabilities: D1 */
|
||||
} usb_desc_acm_func;
|
||||
|
||||
typedef struct {
|
||||
usb_desc_header header; /*!< descriptor header, including type and size. */
|
||||
uint8_t bDescriptorSubtype; /*!< bDescriptorSubtype: union function descriptor */
|
||||
uint8_t bMasterInterface; /*!< bMasterInterface: communication class interface */
|
||||
uint8_t bSlaveInterface0; /*!< bSlaveInterface0: data class interface */
|
||||
} usb_desc_union_func;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
typedef struct {
|
||||
usb_desc_config config; /*!< configure descriptor */
|
||||
usb_desc_itf cmd_itf; /*!< CDC cmd interface descriptor */
|
||||
usb_desc_header_func cdc_header; /*!< CDC header function descriptor */
|
||||
usb_desc_call_managment_func cdc_call_managment; /*!< CDC call management descriptor */
|
||||
usb_desc_acm_func cdc_acm; /*!< CDC acm descriptor */
|
||||
usb_desc_union_func cdc_union; /*!< CDC union function descriptor */
|
||||
usb_desc_ep cdc_cmd_endpoint; /*!< CDC cmd endpoint descriptor */
|
||||
usb_desc_itf cdc_data_interface; /*!< CDC data interface descriptor */
|
||||
usb_desc_ep cdc_out_endpoint; /*!< CDC OUT endpoint descriptor */
|
||||
usb_desc_ep cdc_in_endpoint; /*!< CDC IN endpoint descriptor */
|
||||
} usb_cdc_desc_config_set;
|
||||
|
||||
#endif /* USB_CDC_H */
|
||||
@@ -0,0 +1,81 @@
|
||||
/*!
|
||||
\file usb_hid.h
|
||||
\brief definitions for the USB HID class
|
||||
|
||||
\version 2024-12-20, V3.3.1, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (c) 2024, GigaDevice Semiconductor Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef USB_HID_H
|
||||
#define USB_HID_H
|
||||
|
||||
#include "usb_ch9_std.h"
|
||||
|
||||
#define USB_HID_CLASS 0x03U /*!< HID class code */
|
||||
|
||||
#define USB_DESCTYPE_HID 0x21U /*!< HID descriptor type */
|
||||
#define USB_DESCTYPE_REPORT 0x22U /*!< report descriptor type */
|
||||
|
||||
/* HID subclass code */
|
||||
#define USB_HID_SUBCLASS_BOOT_ITF 0x01U
|
||||
|
||||
/* HID protocol codes */
|
||||
#define USB_HID_PROTOCOL_KEYBOARD 0x01U /*!< HID keyboard protocol */
|
||||
#define USB_HID_PROTOCOL_MOUSE 0x02U /*!< HID mouse protocol */
|
||||
|
||||
#define GET_REPORT 0x01U /*!< get report request */
|
||||
#define GET_IDLE 0x02U /*!< get idle request */
|
||||
#define GET_PROTOCOL 0x03U /*!< get protocol request */
|
||||
#define SET_REPORT 0x09U /*!< set report request */
|
||||
#define SET_IDLE 0x0AU /*!< set idle request */
|
||||
#define SET_PROTOCOL 0x0BU /*!< set protocol request */
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct {
|
||||
usb_desc_header header; /*!< regular descriptor header containing the descriptor's type and length */
|
||||
|
||||
uint16_t bcdHID; /*!< BCD encoded version that the HID descriptor and device complies to */
|
||||
uint8_t bCountryCode; /*!< country code of the localized device, or zero if universal */
|
||||
uint8_t bNumDescriptors; /*!< total number of HID report descriptors for the interface */
|
||||
uint8_t bDescriptorType; /*!< type of HID report */
|
||||
uint16_t wDescriptorLength; /*!< length of the associated HID report descriptor, in bytes */
|
||||
} usb_desc_hid;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
typedef struct {
|
||||
usb_desc_config config; /*!< configure descriptor */
|
||||
usb_desc_itf hid_itf; /*!< HID interface descriptor */
|
||||
usb_desc_hid hid_vendor; /*!< HID vendor descriptor */
|
||||
usb_desc_ep hid_epin; /*!< HID IN endpoint descriptor */
|
||||
usb_desc_ep hid_epout; /*!< HID OUT endpoint descriptor */
|
||||
}usb_hid_desc_config_set;
|
||||
|
||||
#endif /* USB_HID_H */
|
||||
@@ -0,0 +1,69 @@
|
||||
/*!
|
||||
\file msc_bbb.h
|
||||
\brief definitions for the USB MSC BBB(bulk/bulk/bulk) protocol
|
||||
|
||||
\version 2024-12-20, V3.3.1, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (c) 2024, GigaDevice Semiconductor Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MSC_BBB_H
|
||||
#define MSC_BBB_H
|
||||
|
||||
#include "usb_ch9_std.h"
|
||||
|
||||
#define BBB_CBW_SIGNATURE 0x43425355U /*!< MSC BBB CBW signature */
|
||||
#define BBB_CSW_SIGNATURE 0x53425355U /*!< MSC BBB CSW signature */
|
||||
#define BBB_CBW_LENGTH 31U /*!< MSC BBB CBW length */
|
||||
#define BBB_CSW_LENGTH 13U /*!< MSC BBB CSW length */
|
||||
|
||||
typedef struct {
|
||||
uint32_t dCBWSignature; /*!< CBW signature */
|
||||
uint32_t dCBWTag; /*!< CBW tag */
|
||||
uint32_t dCBWDataTransferLength; /*!< CBW signature */
|
||||
uint8_t bmCBWFlags; /*!< CBW flags */
|
||||
uint8_t bCBWLUN; /*!< CBW LUN */
|
||||
uint8_t bCBWCBLength; /*!< CBW length */
|
||||
uint8_t CBWCB[16]; /*!< CBW CB */
|
||||
} msc_bbb_cbw;
|
||||
|
||||
typedef struct {
|
||||
uint32_t dCSWSignature; /*!< CSW signature */
|
||||
uint32_t dCSWTag; /*!< CSW tag */
|
||||
uint32_t dCSWDataResidue; /*!< CSW data residue */
|
||||
uint8_t bCSWStatus; /*!< CSW status */
|
||||
} msc_bbb_csw;
|
||||
|
||||
/* CSW command status */
|
||||
enum msc_csw_status {
|
||||
CSW_CMD_PASSED = 0U, /*!< CSW passed command status */
|
||||
CSW_CMD_FAILED, /*!< CSW failed command status */
|
||||
CSW_PHASE_ERROR /*!< CSW phase error status */
|
||||
};
|
||||
|
||||
#endif /* MSC_BBB_H */
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
/*!
|
||||
\file msc_scsi.h
|
||||
\brief definitions for the USB MSC SCSI commands
|
||||
|
||||
\version 2024-12-20, V3.3.1, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (c) 2024, GigaDevice Semiconductor Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef MSC_SCSI_H
|
||||
#define MSC_SCSI_H
|
||||
|
||||
#include "usb_ch9_std.h"
|
||||
|
||||
/* SCSI commands */
|
||||
#define SCSI_FORMAT_UNIT 0x04U /*!< MSC SCSI format unit */
|
||||
#define SCSI_INQUIRY 0x12U /*!< MSC SCSI inquiry */
|
||||
#define SCSI_MODE_SELECT6 0x15U /*!< MSC SCSI select6 mode */
|
||||
#define SCSI_MODE_SELECT10 0x55U /*!< MSC SCSI select10 mode */
|
||||
#define SCSI_MODE_SENSE6 0x1AU /*!< MSC SCSI sense6 mode */
|
||||
#define SCSI_READ_TOC_DATA 0x43U /*!< MSC SCSI read TOC data */
|
||||
#define SCSI_MODE_SENSE10 0x5AU /*!< MSC SCSI sense10 mode */
|
||||
#define SCSI_ALLOW_MEDIUM_REMOVAL 0x1EU /*!< MSC SCSI allow medium removal */
|
||||
#define SCSI_READ6 0x08U /*!< MSC SCSI read6 */
|
||||
#define SCSI_READ10 0x28U /*!< MSC SCSI read10 */
|
||||
#define SCSI_READ12 0xA8U /*!< MSC SCSI read12 */
|
||||
#define SCSI_READ16 0x88U /*!< MSC SCSI read16 */
|
||||
|
||||
#define SCSI_READ_CAPACITY10 0x25U /*!< MSC SCSI read capacity10 */
|
||||
#define SCSI_READ_CAPACITY16 0x9EU /*!< MSC SCSI read capacity16 */
|
||||
|
||||
#define SCSI_REQUEST_SENSE 0x03U /*!< MSC SCSI request sense */
|
||||
#define SCSI_START_STOP_UNIT 0x1BU /*!< MSC SCSI start stop unit */
|
||||
#define SCSI_TEST_UNIT_READY 0x00U /*!< MSC SCSI test unit ready */
|
||||
#define SCSI_WRITE6 0x0AU /*!< MSC SCSI write6 */
|
||||
#define SCSI_WRITE10 0x2AU /*!< MSC SCSI write10 */
|
||||
#define SCSI_WRITE12 0xAAU /*!< MSC SCSI write12 */
|
||||
#define SCSI_WRITE16 0x8AU /*!< MSC SCSI write16 */
|
||||
|
||||
#define SCSI_VERIFY10 0x2FU /*!< MSC SCSI verify10 */
|
||||
#define SCSI_VERIFY12 0xAFU /*!< MSC SCSI verify12 */
|
||||
#define SCSI_VERIFY16 0x8FU /*!< MSC SCSI verify16 */
|
||||
|
||||
#define SCSI_SEND_DIAGNOSTIC 0x1DU /*!< MSC SCSI send diagnostic */
|
||||
#define SCSI_READ_FORMAT_CAPACITIES 0x23U /*!< MSC SCSI read format capacities */
|
||||
|
||||
#define INVALID_CDB 0x20U /*!< invalid CDB */
|
||||
#define INVALID_FIELD_IN_COMMAND 0x24U /*!< invalid field in command */
|
||||
#define PARAMETER_LIST_LENGTH_ERROR 0x1AU /*!< parameter list length error */
|
||||
#define INVALID_FIELD_IN_PARAMETER_LIST 0x26U /*!< invalid field in parameter list */
|
||||
#define ADDRESS_OUT_OF_RANGE 0x21U /*!< address out of range */
|
||||
#define MEDIUM_NOT_PRESENT 0x3AU /*!< medium not present */
|
||||
#define MEDIUM_HAVE_CHANGED 0x28U /*!< medium have changed */
|
||||
#define WRITE_PROTECTED 0x27U /*!< write protected */
|
||||
#define UNRECOVERED_READ_ERROR 0x11U /*!< unrecovered read error */
|
||||
#define WRITE_FAULT 0x03U /*!< write fault */
|
||||
|
||||
#define READ_FORMAT_CAPACITY_DATA_LEN 0x0CU /*!< read format capacity data length */
|
||||
#define READ_CAPACITY10_DATA_LEN 0x08U /*!< read capacity10 data length */
|
||||
#define MODE_SENSE10_DATA_LEN 0x08U /*!< sense10 mode data length */
|
||||
#define MODE_SENSE6_DATA_LEN 0x04U /*!< sense6 mode data length */
|
||||
#define READ_TOC_CMD_LEN 0x14U /*!< read TOC command length */
|
||||
#define REQUEST_SENSE_DATA_LEN 0x12U /*!< request sense data length */
|
||||
#define STANDARD_INQUIRY_DATA_LEN 0x24U /*!< standard inquiry data length */
|
||||
#define BLKVFY 0x04U /*!< block verify */
|
||||
|
||||
enum sense_state {
|
||||
NO_SENSE = 0U, /*!< MSC SCSI Sense NO_SENSE state */
|
||||
RECOVERED_ERROR, /*!< MSC SCSI Sense RECOVERED_ERROR */
|
||||
NOT_READY, /*!< MSC SCSI Sense NOT READY state*/
|
||||
MEDIUM_ERROR, /*!< MSC SCSI Sense MEDIUM ERROR state*/
|
||||
HARDWARE_ERROR, /*!< MSC SCSI Sense HARDWARE ERROR state*/
|
||||
ILLEGAL_REQUEST, /*!< MSC SCSI Sense ILLEGAL REQUEST state*/
|
||||
UNIT_ATTENTION, /*!< MSC SCSI Sense UNIT ATTENTION state*/
|
||||
DATA_PROTECT, /*!< MSC SCSI Sense DATA PROTECT state*/
|
||||
BLANK_CHECK, /*!< MSC SCSI Sense BLANK CHECK state*/
|
||||
VENDOR_SPECIFIC, /*!< MSC SCSI Sense VENDOR SPECIFIC state*/
|
||||
COPY_ABORTED, /*!< MSC SCSI Sense COPY ABORTED state*/
|
||||
ABORTED_COMMAND, /*!< MSC SCSI Sense ABORTED COMMAND state*/
|
||||
RESERVED, /*!< MSC SCSI Sense RESERVED state*/
|
||||
VOLUME_OVERFLOW, /*!< MSC SCSI Sense VOLUME OVERFLOW state*/
|
||||
MISCOMPARE /*!< MSC SCSI Sense MISCOMPARE state*/
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint8_t SenseKey; /*!< MSC SCSI SenseKey */
|
||||
uint32_t Information; /*!< MSC SCSI sense Information */
|
||||
uint8_t ASC; /*!< MSC SCSI sense ASC */
|
||||
uint8_t ASCQ; /*!< MSC SCSI sense ASCQ */
|
||||
} msc_scsi_sense;
|
||||
|
||||
#endif /* MSC_SCSI_H */
|
||||
@@ -0,0 +1,68 @@
|
||||
/*!
|
||||
\file usb_msc.h
|
||||
\brief definitions for the USB MSC class
|
||||
|
||||
\version 2024-12-20, V3.3.1, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (c) 2024, GigaDevice Semiconductor Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef USB_MSC_H
|
||||
#define USB_MSC_H
|
||||
|
||||
#include "usb_ch9_std.h"
|
||||
|
||||
/* mass storage device class code */
|
||||
#define USB_CLASS_MSC 0x08U
|
||||
|
||||
/* mass storage subclass code */
|
||||
#define USB_MSC_SUBCLASS_RBC 0x01U /*!< MSC RBC subclass */
|
||||
#define USB_MSC_SUBCLASS_ATAPI 0x02U /*!< MSC ATAPI subclass */
|
||||
#define USB_MSC_SUBCLASS_UFI 0x04U /*!< MSC UFI subclass */
|
||||
#define USB_MSC_SUBCLASS_SCSI 0x06U /*!< MSC SCSI subclass */
|
||||
#define USB_MSC_SUBCLASS_LOCKABLE 0x07U /*!< MSC LOCKABLE subclass */
|
||||
#define USB_MSC_SUBCLASS_IEEE1667 0x08U /*!< MSC IEEE1667 subclass */
|
||||
|
||||
/* mass storage interface class control protocol codes */
|
||||
#define USB_MSC_PROTOCOL_CBI 0x00U /*!< MSC CBI protocol */
|
||||
#define USB_MSC_PROTOCOL_CBI_ALT 0x01U /*!< MSC CBI ALT protocol */
|
||||
#define USB_MSC_PROTOCOL_BBB 0x50U /*!< MSC BBB protocol */
|
||||
|
||||
/* mass storage request codes */
|
||||
#define USB_MSC_REQ_CODES_ADSC 0x00U /*!< MSC ADSC request */
|
||||
#define USB_MSC_REQ_CODES_GET 0xFCU /*!< MSC GET request */
|
||||
#define USB_MSC_REQ_CODES_PUT 0xFDU /*!< MSC PUT request */
|
||||
#define USB_MSC_REQ_CODES_GML 0xFEU /*!< MSC GML request */
|
||||
#define USB_MSC_REQ_CODES_BOMSR 0xFFU /*!< MSC BOMSR request */
|
||||
|
||||
#define BBB_GET_MAX_LUN 0xFEU /*!< MSC BBB get maximum LUN */
|
||||
#define BBB_RESET 0xFFU /*!< MSC BBB reset */
|
||||
|
||||
#define SCSI_CMD_LENGTH 16U /*!< MSC SCSI command length */
|
||||
|
||||
#endif /* USB_MSC_H */
|
||||
+248
@@ -0,0 +1,248 @@
|
||||
/*!
|
||||
\file usb_ch9_std.h
|
||||
\brief USB 2.0 standard defines
|
||||
|
||||
\version 2024-12-20, V3.3.1, firmware for GD32F4xx
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright (c) 2024, GigaDevice Semiconductor Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software without
|
||||
specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef USB_CH9_STD_H
|
||||
#define USB_CH9_STD_H
|
||||
|
||||
#include "usb_conf.h"
|
||||
|
||||
#define USB_DEV_QUALIFIER_DESC_LEN 0x0AU /*!< USB device qualifier descriptor length */
|
||||
#define USB_DEV_DESC_LEN 0x12U /*!< USB device descriptor length */
|
||||
#define USB_CFG_DESC_LEN 0x09U /*!< USB configuration descriptor length */
|
||||
#define USB_ITF_DESC_LEN 0x09U /*!< USB interface descriptor length */
|
||||
#define USB_EP_DESC_LEN 0x07U /*!< USB endpoint descriptor length */
|
||||
#define USB_IAD_DESC_LEN 0x08U /*!< USB IAD descriptor length */
|
||||
#define USB_OTG_DESC_LEN 0x03U /*!< USB device OTG descriptor length */
|
||||
|
||||
#define USB_SETUP_PACKET_LEN 0x08U /*!< USB SETUP packet length */
|
||||
|
||||
/* bit 7 of bmRequestType: data phase transfer direction */
|
||||
#define USB_TRX_MASK 0x80U /*!< USB transfer direction mask */
|
||||
#define USB_TRX_OUT 0x00U /*!< USB transfer OUT direction */
|
||||
#define USB_TRX_IN 0x80U /*!< USB transfer IN direction */
|
||||
|
||||
/* bit 6..5 of bmRequestType: request type */
|
||||
#define USB_REQTYPE_STRD 0x00U /*!< USB standard request */
|
||||
#define USB_REQTYPE_CLASS 0x20U /*!< USB class request */
|
||||
#define USB_REQTYPE_VENDOR 0x40U /*!< USB vendor request */
|
||||
#define USB_REQTYPE_MASK 0x60U /*!< USB request mask */
|
||||
|
||||
#define USBD_BUS_POWERED 0x00U /*!< USB bus power supply */
|
||||
#define USBD_SELF_POWERED 0x01U /*!< USB self power supply */
|
||||
|
||||
#define USB_STATUS_REMOTE_WAKEUP 2U /*!< USB is in remote wakeup status */
|
||||
#define USB_STATUS_SELF_POWERED 1U /*!< USB is in self powered status */
|
||||
|
||||
/* bit 4..0 of bmRequestType: recipient type */
|
||||
enum _usb_recp_type {
|
||||
USB_RECPTYPE_DEV = 0x0U, /*!< USB device request type */
|
||||
USB_RECPTYPE_ITF = 0x1U, /*!< USB interface request type */
|
||||
USB_RECPTYPE_EP = 0x2U, /*!< USB endpoint request type */
|
||||
USB_RECPTYPE_MASK = 0x3U /*!< USB request type mask */
|
||||
};
|
||||
|
||||
/* bRequest value */
|
||||
enum _usb_request {
|
||||
USB_GET_STATUS = 0x0U, /*!< USB get status request */
|
||||
USB_CLEAR_FEATURE = 0x1U, /*!< USB clear feature request */
|
||||
USB_RESERVED2 = 0x2U,
|
||||
USB_SET_FEATURE = 0x3U, /*!< USB set feature request */
|
||||
USB_RESERVED4 = 0x4U,
|
||||
USB_SET_ADDRESS = 0x5U, /*!< USB set address request */
|
||||
USB_GET_DESCRIPTOR = 0x6U, /*!< USB get descriptor request */
|
||||
USB_SET_DESCRIPTOR = 0x7U, /*!< USB set descriptor request */
|
||||
USB_GET_CONFIGURATION = 0x8U, /*!< USB get configuration request */
|
||||
USB_SET_CONFIGURATION = 0x9U, /*!< USB set configuration request */
|
||||
USB_GET_INTERFACE = 0xAU, /*!< USB get interface request */
|
||||
USB_SET_INTERFACE = 0xBU, /*!< USB set interface request */
|
||||
USB_SYNCH_FRAME = 0xCU /*!< USB synchronize frame request */
|
||||
};
|
||||
|
||||
/* descriptor types of USB specifications */
|
||||
enum _usb_desctype {
|
||||
USB_DESCTYPE_DEV = 0x1U, /*!< USB device descriptor type */
|
||||
USB_DESCTYPE_CONFIG = 0x2U, /*!< USB configuration descriptor type */
|
||||
USB_DESCTYPE_STR = 0x3U, /*!< USB string descriptor type */
|
||||
USB_DESCTYPE_ITF = 0x4U, /*!< USB interface descriptor type */
|
||||
USB_DESCTYPE_EP = 0x5U, /*!< USB endpoint descriptor type */
|
||||
USB_DESCTYPE_DEV_QUALIFIER = 0x6U, /*!< USB device qualifier descriptor type */
|
||||
USB_DESCTYPE_OTHER_SPD_CONFIG = 0x7U, /*!< USB other speed configuration descriptor type */
|
||||
USB_DESCTYPE_ITF_POWER = 0x8U, /*!< USB interface power descriptor type */
|
||||
USB_DESCTYPE_IAD = 0xBU, /*!< USB interface association descriptor type */
|
||||
USB_DESCTYPE_BOS = 0xFU /*!< USB BOS descriptor type */
|
||||
};
|
||||
|
||||
/* USB Endpoint Descriptor bmAttributes bit definitions */
|
||||
/* bits 1..0 : transfer type */
|
||||
enum _usbx_type {
|
||||
USB_EP_ATTR_CTL = 0x0U, /*!< USB control transfer type */
|
||||
USB_EP_ATTR_ISO = 0x1U, /*!< USB Isochronous transfer type */
|
||||
USB_EP_ATTR_BULK = 0x2U, /*!< USB Bulk transfer type */
|
||||
USB_EP_ATTR_INT = 0x3U /*!< USB Interrupt transfer type */
|
||||
};
|
||||
|
||||
/* bits 3..2 : Sync type (only if ISOCHRONOUS) */
|
||||
#define USB_EP_ATTR_NOSYNC 0x00U /*!< No Synchronization */
|
||||
#define USB_EP_ATTR_ASYNC 0x04U /*!< Asynchronous */
|
||||
#define USB_EP_ATTR_ADAPTIVE 0x08U /*!< Adaptive */
|
||||
#define USB_EP_ATTR_SYNC 0x0CU /*!< Synchronous */
|
||||
#define USB_EP_ATTR_SYNCTYPE 0x0CU /*!< Synchronous type */
|
||||
|
||||
/* bits 5..4 : usage type (only if ISOCHRONOUS) */
|
||||
#define USB_EP_ATTR_DATA 0x00U /*!< Data endpoint */
|
||||
#define USB_EP_ATTR_FEEDBACK 0x10U /*!< Feedback endpoint */
|
||||
#define USB_EP_ATTR_IMPLICIT_FEEDBACK_DATA 0x20U /*!< Implicit feedback Data endpoint */
|
||||
#define USB_EP_ATTR_USAGETYPE 0x30U /*!< Usage type */
|
||||
|
||||
/* endpoint max packet size bits12..11 */
|
||||
#define USB_EP_MPS_ADD_0 (0x00 << 11) /*!< None(1 transaction per microframe */
|
||||
#define USB_EP_MPS_ADD_1 (0x01 << 11) /*!< 1 additional(2 transaction per microframe */
|
||||
#define USB_EP_MPS_ADD_2 (0x02 << 11) /*!< 2 additional(3 transaction per microframe */
|
||||
|
||||
#define FEATURE_SELECTOR_EP 0x00U /*!< USB endpoint feature selector */
|
||||
#define FEATURE_SELECTOR_DEV 0x01U /*!< USB device feature selector */
|
||||
#define FEATURE_SELECTOR_REMOTEWAKEUP 0x01U /*!< USB feature selector remote wakeup */
|
||||
|
||||
#define BYTE_SWAP(addr) (((uint16_t)(*((uint8_t *)(addr)))) + \
|
||||
(uint16_t)(((uint16_t)(*(((uint8_t *)(addr)) + 1U))) << 8))
|
||||
|
||||
#define BYTE_LOW(x) ((uint8_t)((x) & 0x00FFU))
|
||||
#define BYTE_HIGH(x) ((uint8_t)(((x) & 0xFF00U) >> 8))
|
||||
|
||||
#define USB_MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
#define USB_DEFAULT_CONFIG 0U
|
||||
|
||||
/* USB classes */
|
||||
#define USB_CLASS_HID 0x03U /*!< USB HID class */
|
||||
#define USB_CLASS_MSC 0x08U /*!< USB MSC class */
|
||||
|
||||
/* use the following values when USB host need to get descriptor */
|
||||
#define USBH_DESC(x) (((x)<< 8) & 0xFF00U)
|
||||
|
||||
/* as per USB specs 9.2.6.4 :standard request with data request timeout: 5sec
|
||||
standard request with no data stage timeout : 50ms */
|
||||
#define DATA_STAGE_TIMEOUT 5000U /*!< USB data stage timeout*/
|
||||
#define NODATA_STAGE_TIMEOUT 50U /*!< USB no data stage timeout*/
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
/* USB standard device request structure */
|
||||
typedef struct _usb_req {
|
||||
uint8_t bmRequestType; /*!< type of request */
|
||||
uint8_t bRequest; /*!< request of SETUP packet */
|
||||
uint16_t wValue; /*!< value of SETUP packet */
|
||||
uint16_t wIndex; /*!< index of SETUP packet */
|
||||
uint16_t wLength; /*!< length of SETUP packet */
|
||||
} usb_req;
|
||||
|
||||
/* USB SETUP packet define */
|
||||
typedef union _usb_setup {
|
||||
uint8_t data[8]; /*!< the data of USB SETUP packet */
|
||||
|
||||
usb_req req; /*!< USB standard device request */
|
||||
} usb_setup;
|
||||
|
||||
/* USB descriptor defines */
|
||||
|
||||
typedef struct _usb_desc_header {
|
||||
uint8_t bLength; /*!< size of the descriptor */
|
||||
uint8_t bDescriptorType; /*!< type of the descriptor */
|
||||
} usb_desc_header;
|
||||
|
||||
typedef struct _usb_desc_dev {
|
||||
usb_desc_header header; /*!< descriptor header, including type and size */
|
||||
|
||||
uint16_t bcdUSB; /*!< BCD of the supported USB specification */
|
||||
uint8_t bDeviceClass; /*!< USB device class */
|
||||
uint8_t bDeviceSubClass; /*!< USB device subclass */
|
||||
uint8_t bDeviceProtocol; /*!< USB device protocol */
|
||||
uint8_t bMaxPacketSize0; /*!< size of the control (address 0) endpoint's bank in bytes */
|
||||
uint16_t idVendor; /*!< vendor ID for the USB product */
|
||||
uint16_t idProduct; /*!< unique product ID for the USB product */
|
||||
uint16_t bcdDevice; /*!< product release (version) number */
|
||||
uint8_t iManufacturer; /*!< string index for the manufacturer's name */
|
||||
uint8_t iProduct; /*!< string index for the product name/details */
|
||||
uint8_t iSerialNumber; /*!< string index for the product's globally unique hexadecimal serial number */
|
||||
uint8_t bNumberConfigurations; /*!< total number of configurations supported by the device */
|
||||
} usb_desc_dev;
|
||||
|
||||
typedef struct _usb_desc_config {
|
||||
usb_desc_header header; /*!< descriptor header, including type and size */
|
||||
|
||||
uint16_t wTotalLength; /*!< size of the configuration descriptor header,and all sub descriptors inside the configuration */
|
||||
uint8_t bNumInterfaces; /*!< total number of interfaces in the configuration */
|
||||
uint8_t bConfigurationValue; /*!< configuration index of the current configuration */
|
||||
uint8_t iConfiguration; /*!< index of a string descriptor describing the configuration */
|
||||
uint8_t bmAttributes; /*!< configuration attributes */
|
||||
uint8_t bMaxPower; /*!< maximum power consumption of the device while in the current configuration */
|
||||
} usb_desc_config;
|
||||
|
||||
typedef struct _usb_desc_itf {
|
||||
usb_desc_header header; /*!< descriptor header, including type and size */
|
||||
|
||||
uint8_t bInterfaceNumber; /*!< index of the interface in the current configuration */
|
||||
uint8_t bAlternateSetting; /*!< alternate setting for the interface number */
|
||||
uint8_t bNumEndpoints; /*!< total number of endpoints in the interface */
|
||||
uint8_t bInterfaceClass; /*!< interface class ID */
|
||||
uint8_t bInterfaceSubClass; /*!< interface subclass ID */
|
||||
uint8_t bInterfaceProtocol; /*!< interface protocol ID */
|
||||
uint8_t iInterface; /*!< index of the string descriptor describing the interface */
|
||||
} usb_desc_itf;
|
||||
|
||||
typedef struct _usb_desc_ep {
|
||||
usb_desc_header header; /*!< descriptor header, including type and size. */
|
||||
|
||||
uint8_t bEndpointAddress; /*!< logical address of the endpoint */
|
||||
uint8_t bmAttributes; /*!< endpoint attributes */
|
||||
uint16_t wMaxPacketSize; /*!< size of the endpoint bank, in bytes */
|
||||
uint8_t bInterval; /*!< polling interval in milliseconds for the endpoint if it is an INTERRUPT or ISOCHRONOUS type */
|
||||
} usb_desc_ep;
|
||||
|
||||
typedef struct _usb_desc_LANGID {
|
||||
usb_desc_header header; /*!< descriptor header, including type and size. */
|
||||
uint16_t wLANGID; /*!< LANGID code */
|
||||
} usb_desc_LANGID;
|
||||
|
||||
typedef struct _usb_desc_str {
|
||||
usb_desc_header header; /*!< descriptor header, including type and size. */
|
||||
uint16_t unicode_string[128]; /*!< unicode string data */
|
||||
} usb_desc_str;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/* compute string descriptor length */
|
||||
#define USB_STRING_LEN(unicode_chars) (sizeof(usb_desc_header) + ((unicode_chars) << 1))
|
||||
|
||||
#endif /* USB_CH9_STD_H */
|
||||
Reference in New Issue
Block a user