Back to original
This commit is contained in:
@@ -1729,7 +1729,7 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
|
||||
// Find correct interface
|
||||
if (tu_desc_type(p_desc) == TUSB_DESC_INTERFACE && ((tusb_desc_interface_t const * )p_desc)->bInterfaceNumber == itf && ((tusb_desc_interface_t const * )p_desc)->bAlternateSetting == alt)
|
||||
{
|
||||
#if CFG_TUD_AUDIO_ENABLE_ENCODING || CFG_TUD_AUDIO_ENABLE_DECODING || CFG_TUD_AUDIO_EP_IN_FLOW_CONTROL
|
||||
#if (CFG_TUD_AUDIO_ENABLE_EP_IN && (CFG_TUD_AUDIO_EP_IN_FLOW_CONTROL || CFG_TUD_AUDIO_ENABLE_ENCODING)) || (CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_DECODING)
|
||||
uint8_t const * p_desc_parse_for_params = p_desc;
|
||||
#endif
|
||||
// From this point forward follow the EP descriptors associated to the current alternate setting interface - Open EPs if necessary
|
||||
|
||||
@@ -136,8 +136,7 @@ typedef enum{
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
/// Communication Interface Management Element Request Codes
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
CDC_REQUEST_SEND_ENCAPSULATED_COMMAND = 0x00, ///< is used to issue a command in the format of the supported control protocol of the Communications Class interface
|
||||
CDC_REQUEST_GET_ENCAPSULATED_RESPONSE = 0x01, ///< is used to request a response in the format of the supported control protocol of the Communications Class interface.
|
||||
CDC_REQUEST_SET_COMM_FEATURE = 0x02,
|
||||
@@ -180,39 +179,38 @@ typedef enum
|
||||
CDC_REQUEST_GET_ATM_VC_STATISTICS = 0x53,
|
||||
|
||||
CDC_REQUEST_MDLM_SEMANTIC_MODEL = 0x60,
|
||||
}cdc_management_request_t;
|
||||
} cdc_management_request_t;
|
||||
|
||||
enum {
|
||||
typedef enum {
|
||||
CDC_CONTROL_LINE_STATE_DTR = 0x01,
|
||||
CDC_CONTROL_LINE_STATE_RTS = 0x02,
|
||||
};
|
||||
} cdc_control_line_state_t;
|
||||
|
||||
enum {
|
||||
typedef enum {
|
||||
CDC_LINE_CODING_STOP_BITS_1 = 0, // 1 bit
|
||||
CDC_LINE_CODING_STOP_BITS_1_5 = 1, // 1.5 bits
|
||||
CDC_LINE_CODING_STOP_BITS_2 = 2, // 2 bits
|
||||
};
|
||||
} cdc_line_coding_stopbits_t;
|
||||
|
||||
// TODO Backward compatible for typos. Maybe removed in the future release
|
||||
#define CDC_LINE_CONDING_STOP_BITS_1 CDC_LINE_CODING_STOP_BITS_1
|
||||
#define CDC_LINE_CONDING_STOP_BITS_1_5 CDC_LINE_CODING_STOP_BITS_1_5
|
||||
#define CDC_LINE_CONDING_STOP_BITS_2 CDC_LINE_CODING_STOP_BITS_2
|
||||
|
||||
enum {
|
||||
typedef enum {
|
||||
CDC_LINE_CODING_PARITY_NONE = 0,
|
||||
CDC_LINE_CODING_PARITY_ODD = 1,
|
||||
CDC_LINE_CODING_PARITY_EVEN = 2,
|
||||
CDC_LINE_CODING_PARITY_MARK = 3,
|
||||
CDC_LINE_CODING_PARITY_SPACE = 4,
|
||||
};
|
||||
} cdc_line_coding_parity_t;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Management Element Notification (Notification Endpoint)
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
/// 6.3 Notification Codes
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
CDC_NOTIF_NETWORK_CONNECTION = 0x00, ///< This notification allows the device to notify the host about network connection status.
|
||||
CDC_NOTIF_RESPONSE_AVAILABLE = 0x01, ///< This notification allows the device to notify the hostthat a response is available. This response can be retrieved with a subsequent \ref CDC_REQUEST_GET_ENCAPSULATED_RESPONSE request.
|
||||
CDC_NOTIF_AUX_JACK_HOOK_STATE = 0x08,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -148,8 +148,11 @@ bool tuh_cdc_set_control_line_state(uint8_t idx, uint16_t line_state, tuh_xfer_c
|
||||
// Request to set baudrate
|
||||
bool tuh_cdc_set_baudrate(uint8_t idx, uint32_t baudrate, tuh_xfer_cb_t complete_cb, uintptr_t user_data);
|
||||
|
||||
// Request to Set Line Coding (ACM only)
|
||||
// Should only use if you don't work with serial devices such as FTDI/CP210x
|
||||
// Request to set data format
|
||||
bool tuh_cdc_set_data_format(uint8_t idx, uint8_t stop_bits, uint8_t parity, uint8_t data_bits, tuh_xfer_cb_t complete_cb, uintptr_t user_data);
|
||||
|
||||
// Request to Set Line Coding = baudrate + data format
|
||||
// Note: only implemented by ACM and CH34x, not supported by FTDI and CP210x yet
|
||||
bool tuh_cdc_set_line_coding(uint8_t idx, cdc_line_coding_t const* line_coding, tuh_xfer_cb_t complete_cb, uintptr_t user_data);
|
||||
|
||||
// Request to Get Line Coding (ACM only)
|
||||
@@ -159,15 +162,13 @@ bool tuh_cdc_set_line_coding(uint8_t idx, cdc_line_coding_t const* line_coding,
|
||||
|
||||
// Connect by set both DTR, RTS
|
||||
TU_ATTR_ALWAYS_INLINE static inline
|
||||
bool tuh_cdc_connect(uint8_t idx, tuh_xfer_cb_t complete_cb, uintptr_t user_data)
|
||||
{
|
||||
bool tuh_cdc_connect(uint8_t idx, tuh_xfer_cb_t complete_cb, uintptr_t user_data) {
|
||||
return tuh_cdc_set_control_line_state(idx, CDC_CONTROL_LINE_STATE_DTR | CDC_CONTROL_LINE_STATE_RTS, complete_cb, user_data);
|
||||
}
|
||||
|
||||
// Disconnect by clear both DTR, RTS
|
||||
TU_ATTR_ALWAYS_INLINE static inline
|
||||
bool tuh_cdc_disconnect(uint8_t idx, tuh_xfer_cb_t complete_cb, uintptr_t user_data)
|
||||
{
|
||||
bool tuh_cdc_disconnect(uint8_t idx, tuh_xfer_cb_t complete_cb, uintptr_t user_data) {
|
||||
return tuh_cdc_set_control_line_state(idx, 0x00, complete_cb, user_data);
|
||||
}
|
||||
|
||||
|
||||
84
src/class/cdc/serial/ch34x.h
Normal file
84
src/class/cdc/serial/ch34x.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2023 Heiko Kuester
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* This file is part of the TinyUSB stack.
|
||||
*/
|
||||
|
||||
#ifndef _CH34X_H_
|
||||
#define _CH34X_H_
|
||||
|
||||
// There is no official documentation for the CH34x (CH340, CH341) chips. Reference can be found
|
||||
// - https://github.com/WCHSoftGroup/ch341ser_linux
|
||||
// - https://github.com/torvalds/linux/blob/master/drivers/usb/serial/ch341.c
|
||||
// - https://github.com/freebsd/freebsd-src/blob/main/sys/dev/usb/serial/uchcom.c
|
||||
|
||||
// set line_coding @ enumeration
|
||||
#ifdef CFG_TUH_CDC_LINE_CODING_ON_ENUM
|
||||
#define CFG_TUH_CDC_LINE_CODING_ON_ENUM_CH34X CFG_TUH_CDC_LINE_CODING_ON_ENUM
|
||||
#else // this default is necessary to work properly
|
||||
#define CFG_TUH_CDC_LINE_CODING_ON_ENUM_CH34X { 9600, CDC_LINE_CONDING_STOP_BITS_1, CDC_LINE_CODING_PARITY_NONE, 8 }
|
||||
#endif
|
||||
|
||||
// USB requests
|
||||
#define CH34X_REQ_READ_VERSION 0x5F // dec 95
|
||||
#define CH34X_REQ_WRITE_REG 0x9A // dec 154
|
||||
#define CH34X_REQ_READ_REG 0x95 // dec 149
|
||||
#define CH34X_REQ_SERIAL_INIT 0xA1 // dec 161
|
||||
#define CH34X_REQ_MODEM_CTRL 0xA4 // dev 164
|
||||
|
||||
// registers
|
||||
#define CH34X_REG_BREAK 0x05
|
||||
#define CH34X_REG_PRESCALER 0x12
|
||||
#define CH34X_REG_DIVISOR 0x13
|
||||
#define CH34X_REG_LCR 0x18
|
||||
#define CH34X_REG_LCR2 0x25
|
||||
#define CH34X_REG_MCR_MSR 0x06
|
||||
#define CH34X_REG_MCR_MSR2 0x07
|
||||
#define CH34X_NBREAK_BITS 0x01
|
||||
|
||||
#define CH341_REG_0x0F 0x0F // undocumented register
|
||||
#define CH341_REG_0x2C 0x2C // undocumented register
|
||||
#define CH341_REG_0x27 0x27 // hardware flow control (cts/rts)
|
||||
|
||||
#define CH34X_REG16_DIVISOR_PRESCALER TU_U16(CH34X_REG_DIVISOR, CH34X_REG_PRESCALER)
|
||||
#define CH32X_REG16_LCR2_LCR TU_U16(CH34X_REG_LCR2, CH34X_REG_LCR)
|
||||
|
||||
// modem control bits
|
||||
#define CH34X_BIT_RTS ( 1 << 6 )
|
||||
#define CH34X_BIT_DTR ( 1 << 5 )
|
||||
|
||||
// line control bits
|
||||
#define CH34X_LCR_ENABLE_RX 0x80
|
||||
#define CH34X_LCR_ENABLE_TX 0x40
|
||||
#define CH34X_LCR_MARK_SPACE 0x20
|
||||
#define CH34X_LCR_PAR_EVEN 0x10
|
||||
#define CH34X_LCR_ENABLE_PAR 0x08
|
||||
#define CH34X_LCR_PAR_MASK 0x38 // all parity bits
|
||||
#define CH34X_LCR_STOP_BITS_2 0x04
|
||||
#define CH34X_LCR_CS8 0x03
|
||||
#define CH34X_LCR_CS7 0x02
|
||||
#define CH34X_LCR_CS6 0x01
|
||||
#define CH34X_LCR_CS5 0x00
|
||||
#define CH34X_LCR_CS_MASK 0x03 // all CSx bits
|
||||
|
||||
#endif /* _CH34X_H_ */
|
||||
@@ -50,6 +50,7 @@ typedef struct
|
||||
uint8_t itf_num;
|
||||
uint8_t ep_in;
|
||||
uint8_t ep_out;
|
||||
bool mounted; // Enumeration is complete
|
||||
|
||||
uint8_t itf_protocol; // None, Keyboard, Mouse
|
||||
uint8_t protocol_mode; // Boot (0) or Report protocol (1)
|
||||
@@ -139,7 +140,8 @@ uint8_t tuh_hid_itf_get_total_count(void)
|
||||
bool tuh_hid_mounted(uint8_t daddr, uint8_t idx)
|
||||
{
|
||||
hidh_interface_t* p_hid = get_hid_itf(daddr, idx);
|
||||
return p_hid != NULL;
|
||||
TU_VERIFY(p_hid);
|
||||
return p_hid->mounted;
|
||||
}
|
||||
|
||||
bool tuh_hid_itf_get_info(uint8_t daddr, uint8_t idx, tuh_itf_info_t* info)
|
||||
@@ -463,6 +465,7 @@ void hidh_close(uint8_t daddr)
|
||||
TU_LOG_DRV(" HIDh close addr = %u index = %u\r\n", daddr, i);
|
||||
if(tuh_hid_umount_cb) tuh_hid_umount_cb(daddr, i);
|
||||
p_hid->daddr = 0;
|
||||
p_hid->mounted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -632,6 +635,7 @@ static void config_driver_mount_complete(uint8_t daddr, uint8_t idx, uint8_t con
|
||||
{
|
||||
hidh_interface_t* p_hid = get_hid_itf(daddr, idx);
|
||||
TU_VERIFY(p_hid, );
|
||||
p_hid->mounted = true;
|
||||
|
||||
// enumeration is complete
|
||||
if (tuh_hid_mount_cb) tuh_hid_mount_cb(daddr, idx, desc_report, desc_len);
|
||||
|
||||
8
src/class/vendor/vendor_device.c
vendored
8
src/class/vendor/vendor_device.c
vendored
@@ -49,10 +49,8 @@ typedef struct
|
||||
uint8_t rx_ff_buf[CFG_TUD_VENDOR_RX_BUFSIZE];
|
||||
uint8_t tx_ff_buf[CFG_TUD_VENDOR_TX_BUFSIZE];
|
||||
|
||||
#if CFG_FIFO_MUTEX
|
||||
osal_mutex_def_t rx_ff_mutex;
|
||||
osal_mutex_def_t tx_ff_mutex;
|
||||
#endif
|
||||
OSAL_MUTEX_DEF(rx_ff_mutex);
|
||||
OSAL_MUTEX_DEF(tx_ff_mutex);
|
||||
|
||||
// Endpoint Transfer buffer
|
||||
CFG_TUSB_MEM_ALIGN uint8_t epout_buf[CFG_TUD_VENDOR_EPSIZE];
|
||||
@@ -183,10 +181,8 @@ void vendord_init(void)
|
||||
tu_fifo_config(&p_itf->rx_ff, p_itf->rx_ff_buf, CFG_TUD_VENDOR_RX_BUFSIZE, 1, false);
|
||||
tu_fifo_config(&p_itf->tx_ff, p_itf->tx_ff_buf, CFG_TUD_VENDOR_TX_BUFSIZE, 1, false);
|
||||
|
||||
#if CFG_FIFO_MUTEX
|
||||
tu_fifo_config_mutex(&p_itf->rx_ff, NULL, osal_mutex_create(&p_itf->rx_ff_mutex));
|
||||
tu_fifo_config_mutex(&p_itf->tx_ff, osal_mutex_create(&p_itf->tx_ff_mutex), NULL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
|
||||
#include "common/tusb_common.h"
|
||||
|
||||
enum {
|
||||
VIDEO_BCD_1_50 = 0x0150,
|
||||
};
|
||||
|
||||
// Table 3-19 Color Matching Descriptor
|
||||
typedef enum {
|
||||
VIDEO_COLOR_PRIMARIES_UNDEFINED = 0x00,
|
||||
@@ -198,55 +202,98 @@ typedef enum {
|
||||
} video_terminal_type_t;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Descriptors
|
||||
// Video Control (VC) Descriptors
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
/* 2.3.4.2 */
|
||||
#define tusb_desc_video_control_header_nitf_t(_nitf) \
|
||||
struct TU_ATTR_PACKED { \
|
||||
uint8_t bLength; \
|
||||
uint8_t bDescriptorType; \
|
||||
uint8_t bDescriptorSubType; \
|
||||
uint16_t bcdUVC; \
|
||||
uint16_t wTotalLength; \
|
||||
uint32_t dwClockFrequency; /* deprecated */ \
|
||||
uint8_t bInCollection; \
|
||||
uint8_t baInterfaceNr[_nitf]; \
|
||||
}
|
||||
|
||||
typedef tusb_desc_video_control_header_nitf_t() tusb_desc_video_control_header_t;
|
||||
typedef tusb_desc_video_control_header_nitf_t(1) tusb_desc_video_control_header_1itf_t;
|
||||
typedef tusb_desc_video_control_header_nitf_t(2) tusb_desc_video_control_header_2itf_t;
|
||||
typedef tusb_desc_video_control_header_nitf_t(3) tusb_desc_video_control_header_3itf_t;
|
||||
typedef tusb_desc_video_control_header_nitf_t(4) tusb_desc_video_control_header_4itf_t;
|
||||
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint16_t bcdUVC;
|
||||
uint16_t wTotalLength;
|
||||
uint32_t dwClockFrequency;
|
||||
uint8_t bInCollection;
|
||||
uint8_t baInterfaceNr[];
|
||||
} tusb_desc_cs_video_ctl_itf_hdr_t;
|
||||
uint8_t bTerminalID;
|
||||
uint16_t wTerminalType;
|
||||
uint8_t bAssocTerminal;
|
||||
uint8_t iTerminal;
|
||||
} tusb_desc_video_control_input_terminal_t;
|
||||
|
||||
TU_VERIFY_STATIC(sizeof(tusb_desc_video_control_input_terminal_t) == 8, "size is not correct");
|
||||
|
||||
/* 2.4.3.3 */
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bHeaderLength;
|
||||
union {
|
||||
uint8_t bmHeaderInfo;
|
||||
struct {
|
||||
uint8_t FrameID: 1;
|
||||
uint8_t EndOfFrame: 1;
|
||||
uint8_t PresentationTime: 1;
|
||||
uint8_t SourceClockReference: 1;
|
||||
uint8_t PayloadSpecific: 1;
|
||||
uint8_t StillImage: 1;
|
||||
uint8_t Error: 1;
|
||||
uint8_t EndOfHeader: 1;
|
||||
};
|
||||
};
|
||||
} tusb_video_payload_header_t;
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bTerminalID;
|
||||
uint16_t wTerminalType;
|
||||
uint8_t bAssocTerminal;
|
||||
uint8_t bSourceID;
|
||||
uint8_t iTerminal;
|
||||
} tusb_desc_video_control_output_terminal_t;
|
||||
|
||||
TU_VERIFY_STATIC(sizeof(tusb_desc_video_control_output_terminal_t) == 9, "size is not correct");
|
||||
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bTerminalID;
|
||||
uint16_t wTerminalType;
|
||||
uint8_t bAssocTerminal;
|
||||
uint8_t iTerminal;
|
||||
|
||||
uint16_t wObjectiveFocalLengthMin;
|
||||
uint16_t wObjectiveFocalLengthMax;
|
||||
uint16_t wOcularFocalLength;
|
||||
uint8_t bControlSize;
|
||||
uint8_t bmControls[3];
|
||||
} tusb_desc_video_control_camera_terminal_t;
|
||||
|
||||
TU_VERIFY_STATIC(sizeof(tusb_desc_video_control_camera_terminal_t) == 18, "size is not correct");
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Video Streaming (VS) Descriptors
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
/* 3.9.2.1 */
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bNumFormats;
|
||||
uint16_t wTotalLength;
|
||||
uint8_t bEndpointAddress;
|
||||
uint8_t bmInfo;
|
||||
uint8_t bTerminalLink;
|
||||
uint8_t bStillCaptureMethod;
|
||||
uint8_t bTriggerSupport;
|
||||
uint8_t bTriggerUsage;
|
||||
uint8_t bControlSize;
|
||||
uint8_t bmaControls[];
|
||||
} tusb_desc_cs_video_stm_itf_in_hdr_t;
|
||||
#define tusb_desc_video_streaming_input_header_nbyte_t(_nb) \
|
||||
struct TU_ATTR_PACKED { \
|
||||
uint8_t bLength; \
|
||||
uint8_t bDescriptorType; \
|
||||
uint8_t bDescriptorSubType; \
|
||||
uint8_t bNumFormats; /* Number of video payload Format descriptors for this interface */ \
|
||||
uint16_t wTotalLength; \
|
||||
uint8_t bEndpointAddress; \
|
||||
uint8_t bmInfo; /* Bit 0: dynamic format change supported */ \
|
||||
uint8_t bTerminalLink; \
|
||||
uint8_t bStillCaptureMethod; \
|
||||
uint8_t bTriggerSupport; /* Hardware trigger supported */ \
|
||||
uint8_t bTriggerUsage; \
|
||||
uint8_t bControlSize; /* sizeof of each control item */ \
|
||||
uint8_t bmaControls[_nb]; \
|
||||
}
|
||||
|
||||
typedef tusb_desc_video_streaming_input_header_nbyte_t() tusb_desc_video_streaming_input_header_t;
|
||||
typedef tusb_desc_video_streaming_input_header_nbyte_t(1) tusb_desc_video_streaming_input_header_1byte_t;
|
||||
typedef tusb_desc_video_streaming_input_header_nbyte_t(2) tusb_desc_video_streaming_input_header_2byte_t;
|
||||
typedef tusb_desc_video_streaming_input_header_nbyte_t(3) tusb_desc_video_streaming_input_header_3byte_t;
|
||||
typedef tusb_desc_video_streaming_input_header_nbyte_t(4) tusb_desc_video_streaming_input_header_4byte_t;
|
||||
|
||||
/* 3.9.2.2 */
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
@@ -259,7 +306,7 @@ typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bTerminalLink;
|
||||
uint8_t bControlSize;
|
||||
uint8_t bmaControls[];
|
||||
} tusb_desc_cs_video_stm_itf_out_hdr_t;
|
||||
} tusb_desc_video_streaming_output_header_t;
|
||||
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength;
|
||||
@@ -285,14 +332,33 @@ typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bmaControls[];
|
||||
} output;
|
||||
};
|
||||
} tusb_desc_cs_video_stm_itf_hdr_t;
|
||||
} tusb_desc_video_streaming_inout_header_t;
|
||||
|
||||
// 3.9.2.6 Color Matching Descriptor
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bColorPrimaries;
|
||||
uint8_t bTransferCharacteristics;
|
||||
uint8_t bMatrixCoefficients;
|
||||
} tusb_desc_video_streaming_color_matching_t;
|
||||
|
||||
TU_VERIFY_STATIC(sizeof(tusb_desc_video_streaming_color_matching_t) == 6, "size is not correct");
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Format and Frame Descriptor
|
||||
// Note: bFormatIndex & bFrameIndex are 1-based index
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
//------------- Uncompressed -------------//
|
||||
// Uncompressed payload specs: 3.1.1 format descriptor
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFormatIndex;
|
||||
uint8_t bNumFrameDescriptors;
|
||||
uint8_t bNumFrameDescriptors; // Number of frame descriptors for this format
|
||||
uint8_t guidFormat[16];
|
||||
uint8_t bBitsPerPixel;
|
||||
uint8_t bDefaultFrameIndex;
|
||||
@@ -300,22 +366,65 @@ typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bAspectRatioY;
|
||||
uint8_t bmInterlaceFlags;
|
||||
uint8_t bCopyProtect;
|
||||
} tusb_desc_cs_video_fmt_uncompressed_t;
|
||||
} tusb_desc_video_format_uncompressed_t;
|
||||
|
||||
// Uncompressed payload specs: 3.1.2 frame descriptor
|
||||
#define tusb_desc_video_frame_uncompressed_nint_t(_nint) \
|
||||
struct TU_ATTR_PACKED { \
|
||||
uint8_t bLength; \
|
||||
uint8_t bDescriptorType; \
|
||||
uint8_t bDescriptorSubType; \
|
||||
uint8_t bFrameIndex; \
|
||||
uint8_t bmCapabilities; \
|
||||
uint16_t wWidth; \
|
||||
uint16_t wHeight; \
|
||||
uint32_t dwMinBitRate; \
|
||||
uint32_t dwMaxBitRate; \
|
||||
uint32_t dwMaxVideoFrameBufferSize; /* deprecated in 1.5 */ \
|
||||
uint32_t dwDefaultFrameInterval; \
|
||||
uint8_t bFrameIntervalType; \
|
||||
uint32_t dwFrameInterval[_nint]; \
|
||||
}
|
||||
|
||||
typedef tusb_desc_video_frame_uncompressed_nint_t() tusb_desc_video_frame_uncompressed_t;
|
||||
typedef tusb_desc_video_frame_uncompressed_nint_t(1) tusb_desc_video_frame_uncompressed_1int_t;
|
||||
typedef tusb_desc_video_frame_uncompressed_nint_t(2) tusb_desc_video_frame_uncompressed_2int_t;
|
||||
typedef tusb_desc_video_frame_uncompressed_nint_t(3) tusb_desc_video_frame_uncompressed_3int_t;
|
||||
typedef tusb_desc_video_frame_uncompressed_nint_t(4) tusb_desc_video_frame_uncompressed_4int_t;
|
||||
|
||||
// continuous = 3 intervals: min, max, step
|
||||
typedef tusb_desc_video_frame_uncompressed_3int_t tusb_desc_video_frame_uncompressed_continuous_t;
|
||||
|
||||
TU_VERIFY_STATIC(sizeof(tusb_desc_video_frame_uncompressed_continuous_t) == 38, "size is not correct");
|
||||
|
||||
//------------- MJPEG -------------//
|
||||
// MJPEG payload specs: 3.1.1 format descriptor
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFormatIndex;
|
||||
uint8_t bNumFrameDescriptors;
|
||||
uint8_t bmFlags;
|
||||
uint8_t bmFlags; // Bit 0: fixed size samples (1 = yes)
|
||||
uint8_t bDefaultFrameIndex;
|
||||
uint8_t bAspectRatioX;
|
||||
uint8_t bAspectRatioY;
|
||||
uint8_t bmInterlaceFlags;
|
||||
uint8_t bCopyProtect;
|
||||
} tusb_desc_cs_video_fmt_mjpeg_t;
|
||||
} tusb_desc_video_format_mjpeg_t;
|
||||
|
||||
// MJPEG payload specs: 3.1.2 frame descriptor (same as uncompressed)
|
||||
typedef tusb_desc_video_frame_uncompressed_t tusb_desc_video_frame_mjpeg_t;
|
||||
typedef tusb_desc_video_frame_uncompressed_1int_t tusb_desc_video_frame_mjpeg_1int_t;
|
||||
typedef tusb_desc_video_frame_uncompressed_2int_t tusb_desc_video_frame_mjpeg_2int_t;
|
||||
typedef tusb_desc_video_frame_uncompressed_3int_t tusb_desc_video_frame_mjpeg_3int_t;
|
||||
typedef tusb_desc_video_frame_uncompressed_4int_t tusb_desc_video_frame_mjpeg_4int_t;
|
||||
|
||||
// continuous = 3 intervals: min, max, step
|
||||
typedef tusb_desc_video_frame_mjpeg_3int_t tusb_desc_video_frame_mjpeg_continuous_t;
|
||||
|
||||
//------------- DV -------------//
|
||||
// DV payload specs: 3.1.1
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
@@ -323,8 +432,9 @@ typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bFormatIndex;
|
||||
uint32_t dwMaxVideoFrameBufferSize; /* deprecated */
|
||||
uint8_t bFormatType;
|
||||
} tusb_desc_cs_video_fmt_dv_t;
|
||||
} tusb_desc_video_format_dv_t;
|
||||
|
||||
// Frame Based payload specs: 3.1.1
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
@@ -339,25 +449,7 @@ typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bmInterlaceFlags;
|
||||
uint8_t bCopyProtect;
|
||||
uint8_t bVaribaleSize;
|
||||
} tusb_desc_cs_video_fmt_frame_based_t;
|
||||
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubType;
|
||||
uint8_t bFrameIndex;
|
||||
uint8_t bmCapabilities;
|
||||
uint16_t wWidth;
|
||||
uint16_t wHeight;
|
||||
uint32_t dwMinBitRate;
|
||||
uint32_t dwMaxBitRate;
|
||||
uint32_t dwMaxVideoFrameBufferSize; /* deprecated */
|
||||
uint32_t dwDefaultFrameInterval;
|
||||
uint8_t bFrameIntervalType;
|
||||
uint32_t dwFrameInterval[];
|
||||
} tusb_desc_cs_video_frm_uncompressed_t;
|
||||
|
||||
typedef tusb_desc_cs_video_frm_uncompressed_t tusb_desc_cs_video_frm_mjpeg_t;
|
||||
} tusb_desc_video_format_framebased_t;
|
||||
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength;
|
||||
@@ -373,12 +465,30 @@ typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bFrameIntervalType;
|
||||
uint32_t dwBytesPerLine;
|
||||
uint32_t dwFrameInterval[];
|
||||
} tusb_desc_cs_video_frm_frame_based_t;
|
||||
} tusb_desc_video_frame_framebased_t;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Requests
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
/* 2.4.3.3 */
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bHeaderLength;
|
||||
union {
|
||||
uint8_t bmHeaderInfo;
|
||||
struct {
|
||||
uint8_t FrameID: 1;
|
||||
uint8_t EndOfFrame: 1;
|
||||
uint8_t PresentationTime: 1;
|
||||
uint8_t SourceClockReference: 1;
|
||||
uint8_t PayloadSpecific: 1;
|
||||
uint8_t StillImage: 1;
|
||||
uint8_t Error: 1;
|
||||
uint8_t EndOfHeader: 1;
|
||||
};
|
||||
};
|
||||
} tusb_video_payload_header_t;
|
||||
|
||||
/* 4.3.1.1 */
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
union {
|
||||
@@ -537,7 +647,7 @@ TU_VERIFY_STATIC( sizeof(video_probe_and_commit_control_t) == 48, "size is not c
|
||||
/* Motion-JPEG 3.1.1 Table 3-2 and 3-4 */
|
||||
#define TUD_VIDEO_DESC_CS_VS_FRM_MJPEG_DISC(_frmidx, _cap, _width, _height, _minbr, _maxbr, _maxfrmbufsz, _frminterval, ...) \
|
||||
TUD_VIDEO_DESC_CS_VS_FRM_MJPEG_DISC_LEN + (TU_ARGS_NUM(__VA_ARGS__)) * 4, \
|
||||
TUSB_DESC_CS_INTERFACE, VIDEO_CS_VS_INTERFACE_FRAME_MJPEG, \
|
||||
TUSB_DESC_CS_INTERFACE, VIDEO_CS_ITF_VS_FRAME_MJPEG, \
|
||||
_frmidx, _cap, U16_TO_U8S_LE(_width), U16_TO_U8S_LE(_height), U32_TO_U8S_LE(_minbr), U32_TO_U8S_LE(_maxbr), \
|
||||
U32_TO_U8S_LE(_maxfrmbufsz), U32_TO_U8S_LE(_frminterval), (TU_ARGS_NUM(__VA_ARGS__)), __VA_ARGS__
|
||||
|
||||
|
||||
@@ -50,17 +50,17 @@
|
||||
|
||||
typedef struct {
|
||||
tusb_desc_interface_t std;
|
||||
tusb_desc_cs_video_ctl_itf_hdr_t ctl;
|
||||
tusb_desc_video_control_header_t ctl;
|
||||
} tusb_desc_vc_itf_t;
|
||||
|
||||
typedef struct {
|
||||
tusb_desc_interface_t std;
|
||||
tusb_desc_cs_video_stm_itf_hdr_t stm;
|
||||
tusb_desc_video_streaming_inout_header_t stm;
|
||||
} tusb_desc_vs_itf_t;
|
||||
|
||||
typedef union {
|
||||
tusb_desc_cs_video_ctl_itf_hdr_t ctl;
|
||||
tusb_desc_cs_video_stm_itf_hdr_t stm;
|
||||
tusb_desc_video_control_header_t ctl;
|
||||
tusb_desc_video_streaming_inout_header_t stm;
|
||||
} tusb_desc_video_itf_hdr_t;
|
||||
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
@@ -78,9 +78,9 @@ typedef union {
|
||||
uint8_t bFormatIndex;
|
||||
uint8_t bNumFrameDescriptors;
|
||||
};
|
||||
tusb_desc_cs_video_fmt_uncompressed_t uncompressed;
|
||||
tusb_desc_cs_video_fmt_mjpeg_t mjpeg;
|
||||
tusb_desc_cs_video_fmt_frame_based_t frame_based;
|
||||
tusb_desc_video_format_uncompressed_t uncompressed;
|
||||
tusb_desc_video_format_mjpeg_t mjpeg;
|
||||
tusb_desc_video_format_framebased_t frame_based;
|
||||
} tusb_desc_cs_video_fmt_t;
|
||||
|
||||
typedef union {
|
||||
@@ -93,9 +93,9 @@ typedef union {
|
||||
uint16_t wWidth;
|
||||
uint16_t wHeight;
|
||||
};
|
||||
tusb_desc_cs_video_frm_uncompressed_t uncompressed;
|
||||
tusb_desc_cs_video_frm_mjpeg_t mjpeg;
|
||||
tusb_desc_cs_video_frm_frame_based_t frame_based;
|
||||
tusb_desc_video_frame_uncompressed_t uncompressed;
|
||||
tusb_desc_video_frame_mjpeg_t mjpeg;
|
||||
tusb_desc_video_frame_framebased_t frame_based;
|
||||
} tusb_desc_cs_video_frm_t;
|
||||
|
||||
/* video streaming interface */
|
||||
@@ -434,8 +434,9 @@ static bool _update_streaming_parameters(videod_streaming_interface_t const *stm
|
||||
uint_fast32_t interval_ms = interval / 10000;
|
||||
TU_ASSERT(interval_ms);
|
||||
uint_fast32_t payload_size = (frame_size + interval_ms - 1) / interval_ms + 2;
|
||||
if (CFG_TUD_VIDEO_STREAMING_EP_BUFSIZE < payload_size)
|
||||
if (CFG_TUD_VIDEO_STREAMING_EP_BUFSIZE < payload_size) {
|
||||
payload_size = CFG_TUD_VIDEO_STREAMING_EP_BUFSIZE;
|
||||
}
|
||||
param->dwMaxPayloadTransferSize = payload_size;
|
||||
return true;
|
||||
}
|
||||
@@ -577,8 +578,9 @@ static bool _negotiate_streaming_parameters(videod_streaming_interface_t const *
|
||||
} else {
|
||||
payload_size = (frame_size + interval_ms - 1) / interval_ms + 2;
|
||||
}
|
||||
if (CFG_TUD_VIDEO_STREAMING_EP_BUFSIZE < payload_size)
|
||||
if (CFG_TUD_VIDEO_STREAMING_EP_BUFSIZE < payload_size) {
|
||||
payload_size = CFG_TUD_VIDEO_STREAMING_EP_BUFSIZE;
|
||||
}
|
||||
param->dwMaxPayloadTransferSize = payload_size;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#define TU_ARRAY_SIZE(_arr) ( sizeof(_arr) / sizeof(_arr[0]) )
|
||||
#define TU_MIN(_x, _y) ( ( (_x) < (_y) ) ? (_x) : (_y) )
|
||||
#define TU_MAX(_x, _y) ( ( (_x) > (_y) ) ? (_x) : (_y) )
|
||||
#define TU_DIV_CEIL(n, d) (((n) + (d) - 1) / (d))
|
||||
|
||||
#define TU_U16(_high, _low) ((uint16_t) (((_high) << 8) | (_low)))
|
||||
#define TU_U16_HIGH(_u16) ((uint8_t) (((_u16) >> 8) & 0x00ff))
|
||||
|
||||
@@ -44,43 +44,38 @@
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
/// defined base on EHCI specs value for Endpoint Speed
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
TUSB_SPEED_FULL = 0,
|
||||
TUSB_SPEED_LOW = 1,
|
||||
TUSB_SPEED_HIGH = 2,
|
||||
TUSB_SPEED_INVALID = 0xff,
|
||||
}tusb_speed_t;
|
||||
} tusb_speed_t;
|
||||
|
||||
/// defined base on USB Specs Endpoint's bmAttributes
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
TUSB_XFER_CONTROL = 0 ,
|
||||
TUSB_XFER_ISOCHRONOUS ,
|
||||
TUSB_XFER_BULK ,
|
||||
TUSB_XFER_INTERRUPT
|
||||
}tusb_xfer_type_t;
|
||||
} tusb_xfer_type_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
TUSB_DIR_OUT = 0,
|
||||
TUSB_DIR_IN = 1,
|
||||
|
||||
TUSB_DIR_IN_MASK = 0x80
|
||||
}tusb_dir_t;
|
||||
} tusb_dir_t;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
TUSB_EPSIZE_BULK_FS = 64,
|
||||
TUSB_EPSIZE_BULK_HS= 512,
|
||||
TUSB_EPSIZE_BULK_HS = 512,
|
||||
|
||||
TUSB_EPSIZE_ISO_FS_MAX = 1023,
|
||||
TUSB_EPSIZE_ISO_HS_MAX = 1024,
|
||||
};
|
||||
|
||||
/// Isochronous End Point Attributes
|
||||
typedef enum
|
||||
{
|
||||
/// Isochronous Endpoint Attributes
|
||||
typedef enum {
|
||||
TUSB_ISO_EP_ATT_NO_SYNC = 0x00,
|
||||
TUSB_ISO_EP_ATT_ASYNCHRONOUS = 0x04,
|
||||
TUSB_ISO_EP_ATT_ADAPTIVE = 0x08,
|
||||
@@ -88,11 +83,10 @@ typedef enum
|
||||
TUSB_ISO_EP_ATT_DATA = 0x00, ///< Data End Point
|
||||
TUSB_ISO_EP_ATT_EXPLICIT_FB = 0x10, ///< Feedback End Point
|
||||
TUSB_ISO_EP_ATT_IMPLICIT_FB = 0x20, ///< Data endpoint that also serves as an implicit feedback
|
||||
}tusb_iso_ep_attribute_t;
|
||||
} tusb_iso_ep_attribute_t;
|
||||
|
||||
/// USB Descriptor Types
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
TUSB_DESC_DEVICE = 0x01,
|
||||
TUSB_DESC_CONFIGURATION = 0x02,
|
||||
TUSB_DESC_STRING = 0x03,
|
||||
@@ -119,10 +113,9 @@ typedef enum
|
||||
|
||||
TUSB_DESC_SUPERSPEED_ENDPOINT_COMPANION = 0x30,
|
||||
TUSB_DESC_SUPERSPEED_ISO_ENDPOINT_COMPANION = 0x31
|
||||
}tusb_desc_type_t;
|
||||
} tusb_desc_type_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
TUSB_REQ_GET_STATUS = 0 ,
|
||||
TUSB_REQ_CLEAR_FEATURE = 1 ,
|
||||
TUSB_REQ_RESERVED = 2 ,
|
||||
@@ -136,25 +129,22 @@ typedef enum
|
||||
TUSB_REQ_GET_INTERFACE = 10 ,
|
||||
TUSB_REQ_SET_INTERFACE = 11 ,
|
||||
TUSB_REQ_SYNCH_FRAME = 12
|
||||
}tusb_request_code_t;
|
||||
} tusb_request_code_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
TUSB_REQ_FEATURE_EDPT_HALT = 0,
|
||||
TUSB_REQ_FEATURE_REMOTE_WAKEUP = 1,
|
||||
TUSB_REQ_FEATURE_TEST_MODE = 2
|
||||
}tusb_request_feature_selector_t;
|
||||
} tusb_request_feature_selector_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
TUSB_REQ_TYPE_STANDARD = 0,
|
||||
TUSB_REQ_TYPE_CLASS,
|
||||
TUSB_REQ_TYPE_VENDOR,
|
||||
TUSB_REQ_TYPE_INVALID
|
||||
} tusb_request_type_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
TUSB_REQ_RCPT_DEVICE =0,
|
||||
TUSB_REQ_RCPT_INTERFACE,
|
||||
TUSB_REQ_RCPT_ENDPOINT,
|
||||
@@ -162,8 +152,7 @@ typedef enum
|
||||
} tusb_request_recipient_t;
|
||||
|
||||
// https://www.usb.org/defined-class-codes
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
TUSB_CLASS_UNSPECIFIED = 0 ,
|
||||
TUSB_CLASS_AUDIO = 1 ,
|
||||
TUSB_CLASS_CDC = 2 ,
|
||||
@@ -187,26 +176,23 @@ typedef enum
|
||||
TUSB_CLASS_MISC = 0xEF ,
|
||||
TUSB_CLASS_APPLICATION_SPECIFIC = 0xFE ,
|
||||
TUSB_CLASS_VENDOR_SPECIFIC = 0xFF
|
||||
}tusb_class_code_t;
|
||||
} tusb_class_code_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MISC_SUBCLASS_COMMON = 2
|
||||
}misc_subclass_type_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
MISC_PROTOCOL_IAD = 1
|
||||
}misc_protocol_type_t;
|
||||
} misc_protocol_type_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
APP_SUBCLASS_USBTMC = 0x03,
|
||||
APP_SUBCLASS_DFU_RUNTIME = 0x01
|
||||
} app_subclass_type_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
DEVICE_CAPABILITY_WIRELESS_USB = 0x01,
|
||||
DEVICE_CAPABILITY_USB20_EXTENSION = 0x02,
|
||||
DEVICE_CAPABILITY_SUPERSPEED_USB = 0x03,
|
||||
@@ -223,7 +209,7 @@ typedef enum
|
||||
DEVICE_CAPABILITY_AUTHENTICATION = 0x0E,
|
||||
DEVICE_CAPABILITY_BILLBOARD_EX = 0x0F,
|
||||
DEVICE_CAPABILITY_CONFIGURATION_SUMMARY = 0x10
|
||||
}device_capability_type_t;
|
||||
} device_capability_type_t;
|
||||
|
||||
enum {
|
||||
TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP = TU_BIT(5),
|
||||
@@ -235,28 +221,25 @@ enum {
|
||||
//--------------------------------------------------------------------+
|
||||
//
|
||||
//--------------------------------------------------------------------+
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
XFER_RESULT_SUCCESS = 0,
|
||||
XFER_RESULT_FAILED,
|
||||
XFER_RESULT_STALLED,
|
||||
XFER_RESULT_TIMEOUT,
|
||||
XFER_RESULT_INVALID
|
||||
}xfer_result_t;
|
||||
} xfer_result_t;
|
||||
|
||||
enum // TODO remove
|
||||
{
|
||||
// TODO remove
|
||||
enum {
|
||||
DESC_OFFSET_LEN = 0,
|
||||
DESC_OFFSET_TYPE = 1
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
INTERFACE_INVALID_NUMBER = 0xff
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
MS_OS_20_SET_HEADER_DESCRIPTOR = 0x00,
|
||||
MS_OS_20_SUBSET_HEADER_CONFIGURATION = 0x01,
|
||||
MS_OS_20_SUBSET_HEADER_FUNCTION = 0x02,
|
||||
@@ -268,16 +251,14 @@ typedef enum
|
||||
MS_OS_20_FEATURE_VENDOR_REVISION = 0x08
|
||||
} microsoft_os_20_type_t;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
CONTROL_STAGE_IDLE,
|
||||
CONTROL_STAGE_SETUP,
|
||||
CONTROL_STAGE_DATA,
|
||||
CONTROL_STAGE_ACK
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
TUSB_INDEX_INVALID_8 = 0xFFu
|
||||
};
|
||||
|
||||
@@ -290,8 +271,7 @@ TU_ATTR_PACKED_BEGIN
|
||||
TU_ATTR_BIT_FIELD_ORDER_BEGIN
|
||||
|
||||
/// USB Device Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength ; ///< Size of this descriptor in bytes.
|
||||
uint8_t bDescriptorType ; ///< DEVICE Descriptor Type.
|
||||
uint16_t bcdUSB ; ///< BUSB Specification Release Number in Binary-Coded Decimal (i.e., 2.10 is 210H). This field identifies the release of the USB Specification with which the device and its descriptors are compliant.
|
||||
@@ -314,8 +294,7 @@ typedef struct TU_ATTR_PACKED
|
||||
TU_VERIFY_STATIC( sizeof(tusb_desc_device_t) == 18, "size is not correct");
|
||||
|
||||
// USB Binary Device Object Store (BOS) Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength ; ///< Size of this descriptor in bytes
|
||||
uint8_t bDescriptorType ; ///< CONFIGURATION Descriptor Type
|
||||
uint16_t wTotalLength ; ///< Total length of data returned for this descriptor
|
||||
@@ -325,8 +304,7 @@ typedef struct TU_ATTR_PACKED
|
||||
TU_VERIFY_STATIC( sizeof(tusb_desc_bos_t) == 5, "size is not correct");
|
||||
|
||||
/// USB Configuration Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength ; ///< Size of this descriptor in bytes
|
||||
uint8_t bDescriptorType ; ///< CONFIGURATION Descriptor Type
|
||||
uint16_t wTotalLength ; ///< Total length of data returned for this configuration. Includes the combined length of all descriptors (configuration, interface, endpoint, and class- or vendor-specific) returned for this configuration.
|
||||
@@ -341,8 +319,7 @@ typedef struct TU_ATTR_PACKED
|
||||
TU_VERIFY_STATIC( sizeof(tusb_desc_configuration_t) == 9, "size is not correct");
|
||||
|
||||
/// USB Interface Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength ; ///< Size of this descriptor in bytes
|
||||
uint8_t bDescriptorType ; ///< INTERFACE Descriptor Type
|
||||
|
||||
@@ -358,8 +335,7 @@ typedef struct TU_ATTR_PACKED
|
||||
TU_VERIFY_STATIC( sizeof(tusb_desc_interface_t) == 9, "size is not correct");
|
||||
|
||||
/// USB Endpoint Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength ; // Size of this descriptor in bytes
|
||||
uint8_t bDescriptorType ; // ENDPOINT Descriptor Type
|
||||
|
||||
@@ -379,8 +355,7 @@ typedef struct TU_ATTR_PACKED
|
||||
TU_VERIFY_STATIC( sizeof(tusb_desc_endpoint_t) == 7, "size is not correct");
|
||||
|
||||
/// USB Other Speed Configuration Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength ; ///< Size of descriptor
|
||||
uint8_t bDescriptorType ; ///< Other_speed_Configuration Type
|
||||
uint16_t wTotalLength ; ///< Total length of data returned
|
||||
@@ -393,8 +368,7 @@ typedef struct TU_ATTR_PACKED
|
||||
} tusb_desc_other_speed_t;
|
||||
|
||||
/// USB Device Qualifier Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength ; ///< Size of descriptor
|
||||
uint8_t bDescriptorType ; ///< Device Qualifier Type
|
||||
uint16_t bcdUSB ; ///< USB specification version number (e.g., 0200H for V2.00)
|
||||
@@ -411,8 +385,7 @@ typedef struct TU_ATTR_PACKED
|
||||
TU_VERIFY_STATIC( sizeof(tusb_desc_device_qualifier_t) == 10, "size is not correct");
|
||||
|
||||
/// USB Interface Association Descriptor (IAD ECN)
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength ; ///< Size of descriptor
|
||||
uint8_t bDescriptorType ; ///< Other_speed_Configuration Type
|
||||
|
||||
@@ -426,17 +399,17 @@ typedef struct TU_ATTR_PACKED
|
||||
uint8_t iFunction ; ///< Index of the string descriptor describing the interface association.
|
||||
} tusb_desc_interface_assoc_t;
|
||||
|
||||
TU_VERIFY_STATIC( sizeof(tusb_desc_interface_assoc_t) == 8, "size is not correct");
|
||||
|
||||
// USB String Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength ; ///< Size of this descriptor in bytes
|
||||
uint8_t bDescriptorType ; ///< Descriptor Type
|
||||
uint16_t unicode_string[];
|
||||
} tusb_desc_string_t;
|
||||
|
||||
// USB Binary Device Object Store (BOS)
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType ;
|
||||
uint8_t bDevCapabilityType;
|
||||
@@ -445,9 +418,8 @@ typedef struct TU_ATTR_PACKED
|
||||
uint8_t CapabilityData[];
|
||||
} tusb_desc_bos_platform_t;
|
||||
|
||||
// USB WebuSB URL Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
// USB WebUSB URL Descriptor
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bScheme;
|
||||
@@ -455,8 +427,7 @@ typedef struct TU_ATTR_PACKED
|
||||
} tusb_desc_webusb_url_t;
|
||||
|
||||
// DFU Functional Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
|
||||
@@ -481,7 +452,7 @@ typedef struct TU_ATTR_PACKED
|
||||
//
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
typedef struct TU_ATTR_PACKED{
|
||||
typedef struct TU_ATTR_PACKED {
|
||||
union {
|
||||
struct TU_ATTR_PACKED {
|
||||
uint8_t recipient : 5; ///< Recipient type tusb_request_recipient_t.
|
||||
@@ -500,7 +471,6 @@ typedef struct TU_ATTR_PACKED{
|
||||
|
||||
TU_VERIFY_STATIC( sizeof(tusb_control_request_t) == 8, "size is not correct");
|
||||
|
||||
|
||||
TU_ATTR_PACKED_END // End of all packed definitions
|
||||
TU_ATTR_BIT_FIELD_ORDER_END
|
||||
|
||||
@@ -509,36 +479,30 @@ TU_ATTR_BIT_FIELD_ORDER_END
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Get direction from Endpoint address
|
||||
TU_ATTR_ALWAYS_INLINE static inline tusb_dir_t tu_edpt_dir(uint8_t addr)
|
||||
{
|
||||
TU_ATTR_ALWAYS_INLINE static inline tusb_dir_t tu_edpt_dir(uint8_t addr) {
|
||||
return (addr & TUSB_DIR_IN_MASK) ? TUSB_DIR_IN : TUSB_DIR_OUT;
|
||||
}
|
||||
|
||||
// Get Endpoint number from address
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_edpt_number(uint8_t addr)
|
||||
{
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_edpt_number(uint8_t addr) {
|
||||
return (uint8_t)(addr & (~TUSB_DIR_IN_MASK));
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_edpt_addr(uint8_t num, uint8_t dir)
|
||||
{
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_edpt_addr(uint8_t num, uint8_t dir) {
|
||||
return (uint8_t)(num | (dir ? TUSB_DIR_IN_MASK : 0));
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_edpt_packet_size(tusb_desc_endpoint_t const* desc_ep)
|
||||
{
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_edpt_packet_size(tusb_desc_endpoint_t const* desc_ep) {
|
||||
return tu_le16toh(desc_ep->wMaxPacketSize) & TU_GENMASK(10, 0);
|
||||
}
|
||||
|
||||
#if CFG_TUSB_DEBUG
|
||||
TU_ATTR_ALWAYS_INLINE static inline const char *tu_edpt_dir_str(tusb_dir_t dir)
|
||||
{
|
||||
TU_ATTR_ALWAYS_INLINE static inline const char *tu_edpt_dir_str(tusb_dir_t dir) {
|
||||
tu_static const char *str[] = {"out", "in"};
|
||||
return str[dir];
|
||||
}
|
||||
|
||||
TU_ATTR_ALWAYS_INLINE static inline const char *tu_edpt_type_str(tusb_xfer_type_t t)
|
||||
{
|
||||
TU_ATTR_ALWAYS_INLINE static inline const char *tu_edpt_type_str(tusb_xfer_type_t t) {
|
||||
tu_static const char *str[] = {"control", "isochronous", "bulk", "interrupt"};
|
||||
return str[t];
|
||||
}
|
||||
@@ -549,21 +513,18 @@ TU_ATTR_ALWAYS_INLINE static inline const char *tu_edpt_type_str(tusb_xfer_type_
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// return next descriptor
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t const * tu_desc_next(void const* desc)
|
||||
{
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t const * tu_desc_next(void const* desc) {
|
||||
uint8_t const* desc8 = (uint8_t const*) desc;
|
||||
return desc8 + desc8[DESC_OFFSET_LEN];
|
||||
}
|
||||
|
||||
// get descriptor type
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_type(void const* desc)
|
||||
{
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_type(void const* desc) {
|
||||
return ((uint8_t const*) desc)[DESC_OFFSET_TYPE];
|
||||
}
|
||||
|
||||
// get descriptor length
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_len(void const* desc)
|
||||
{
|
||||
TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_len(void const* desc) {
|
||||
return ((uint8_t const*) desc)[DESC_OFFSET_LEN];
|
||||
}
|
||||
|
||||
|
||||
@@ -1130,8 +1130,8 @@ void dcd_int_handler(uint8_t rhport) {
|
||||
dwc2->gotgint = otg_int;
|
||||
}
|
||||
|
||||
if (int_status & GINTSTS_SOF) {
|
||||
dwc2->gotgint = GINTSTS_SOF;
|
||||
if(int_status & GINTSTS_SOF) {
|
||||
dwc2->gintsts = GINTSTS_SOF;
|
||||
|
||||
if (_sof_en) {
|
||||
uint32_t frame = (dwc2->dsts & (DSTS_FNSOF)) >> 8;
|
||||
|
||||
@@ -472,6 +472,23 @@
|
||||
{0x10C4, 0xEA60}, {0x10C4, 0xEA70}
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUH_CDC_CH34X
|
||||
// CH34X is not part of CDC class, only to re-use CDC driver API
|
||||
#define CFG_TUH_CDC_CH34X 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUH_CDC_CH34X_VID_PID_LIST
|
||||
// List of product IDs that can use the CH34X CDC driver
|
||||
#define CFG_TUH_CDC_CH34X_VID_PID_LIST \
|
||||
{ 0x1a86, 0x5523 }, /* ch341 chip */ \
|
||||
{ 0x1a86, 0x7522 }, /* ch340k chip */ \
|
||||
{ 0x1a86, 0x7523 }, /* ch340 chip */ \
|
||||
{ 0x1a86, 0xe523 }, /* ch330 chip */ \
|
||||
{ 0x4348, 0x5523 }, /* ch340 custom chip */ \
|
||||
{ 0x2184, 0x0057 }, /* overtaken from Linux Kernel driver /drivers/usb/serial/ch341.c */ \
|
||||
{ 0x9986, 0x7523 } /* overtaken from Linux Kernel driver /drivers/usb/serial/ch341.c */
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUH_HID
|
||||
#define CFG_TUH_HID 0
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user