forked from espressif/arduino-esp32
Update TinyUSB Lib
This commit is contained in:
@ -354,9 +354,12 @@
|
||||
#define CONFIG_SPIFFS_USE_MTIME 1
|
||||
#define CONFIG_USB_ENABLED 1
|
||||
#define CONFIG_USB_MAX_POWER_USAGE 500
|
||||
#define CONFIG_USB_DYNAMIC_DRIVER_LOADING 1
|
||||
#define CONFIG_USB_DYNAMIC_DRIVER_MAX 16
|
||||
#define CONFIG_USB_CDC_ENABLED 1
|
||||
#define CONFIG_USB_CDC_RX_BUFSIZE 1024
|
||||
#define CONFIG_USB_CDC_TX_BUFSIZE 1024
|
||||
#define CONFIG_USB_DFU_RT_ENABLED 1
|
||||
#define CONFIG_USB_MSC_ENABLED 1
|
||||
#define CONFIG_USB_MSC_BUFSIZE 512
|
||||
#define CONFIG_USB_HID_ENABLED 1
|
||||
@ -365,7 +368,6 @@
|
||||
#define CONFIG_USB_MIDI_RX_BUFSIZE 64
|
||||
#define CONFIG_USB_MIDI_TX_BUFSIZE 64
|
||||
#define CONFIG_USB_VENDOR_ENABLED 1
|
||||
#define CONFIG_USB_DFU_RT_ENABLED 1
|
||||
#define CONFIG_USB_DESC_USE_ESPRESSIF_VID 1
|
||||
#define CONFIG_USB_DESC_USE_DEFAULT_PID 1
|
||||
#define CONFIG_USB_DESC_BCDDEVICE 0x0100
|
||||
@ -373,6 +375,7 @@
|
||||
#define CONFIG_USB_DESC_PRODUCT_STRING "Espressif Device"
|
||||
#define CONFIG_USB_DESC_SERIAL_STRING "123456"
|
||||
#define CONFIG_USB_DESC_CDC_STRING "Espressif CDC Device"
|
||||
#define CONFIG_USB_DESC_DFU_RT_STRING "Espressif DFU Device"
|
||||
#define CONFIG_USB_DESC_MSC_STRING "Espressif MSC Device"
|
||||
#define CONFIG_USB_DESC_MIDI_STRING "Espressif MIDI Device"
|
||||
#define CONFIG_USB_DESC_HID_STRING "Espressif HID Device"
|
||||
|
@ -18,16 +18,17 @@
|
||||
#include "usb_descriptors.h"
|
||||
|
||||
|
||||
#if CONFIG_USB_USE_BUILTIN_DESCRIPTORS
|
||||
/* A combination of interfaces must have a unique product id, since PC will save device driver after the first plug.
|
||||
* Same VID/PID with different interface e.g MSC (first), then CDC (later) will possibly cause system error on PC.
|
||||
*
|
||||
* Auto ProductID layout's Bitmap:
|
||||
* [MSB] HID | MSC | CDC [LSB]
|
||||
*/
|
||||
#define EPNUM_MSC 0x01
|
||||
#define EPNUM_HID 0x02
|
||||
#define EPNUM_MIDI 0x04
|
||||
#define EPNUM_VENDOR 0x06
|
||||
#define EPNUM_MSC 0x02
|
||||
#define EPNUM_HID 0x03
|
||||
#define EPNUM_MIDI 0x06
|
||||
#define EPNUM_VENDOR 0x01
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -47,6 +48,10 @@ enum {
|
||||
ITF_NUM_CDC_DATA,
|
||||
# endif
|
||||
|
||||
# if CFG_TUD_DFU_RT
|
||||
ITF_NUM_DFU_RT,
|
||||
# endif
|
||||
|
||||
# if CFG_TUD_MSC
|
||||
ITF_NUM_MSC,
|
||||
# endif
|
||||
@ -68,7 +73,7 @@ enum {
|
||||
};
|
||||
|
||||
enum {
|
||||
CONFIG_TOTAL_LEN = TUD_CONFIG_DESC_LEN + CFG_TUD_CDC * TUD_CDC_DESC_LEN + CFG_TUD_MSC * TUD_MSC_DESC_LEN +
|
||||
CONFIG_TOTAL_LEN = TUD_CONFIG_DESC_LEN + CFG_TUD_CDC * TUD_CDC_DESC_LEN + CFG_TUD_DFU_RT * TUD_DFU_RT_DESC_LEN + CFG_TUD_MSC * TUD_MSC_DESC_LEN +
|
||||
CFG_TUD_HID * TUD_HID_DESC_LEN + CFG_TUD_VENDOR * TUD_VENDOR_DESC_LEN + CFG_TUD_MIDI * TUD_MIDI_DESC_LEN
|
||||
};
|
||||
|
||||
@ -81,3 +86,5 @@ void tusb_clear_descriptor(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_USB_USE_BUILTIN_DESCRIPTORS */
|
||||
|
@ -1,51 +0,0 @@
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// Espressif
|
||||
#include "driver/periph_ctrl.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp32s2/rom/gpio.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/usb_periph.h"
|
||||
#include "tusb_config.h"
|
||||
// TinyUSB
|
||||
#include "tusb_option.h"
|
||||
#include "descriptors_control.h"
|
||||
#include "device/dcd.h"
|
||||
|
||||
|
||||
#define USB_EP_DIRECTIONS 2
|
||||
#define USB_MAX_EP_NUM 16
|
||||
|
||||
typedef struct {
|
||||
uint8_t *buffer;
|
||||
uint16_t total_len;
|
||||
uint16_t queued_len;
|
||||
uint16_t max_size;
|
||||
bool short_packet;
|
||||
} xfer_ctl_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -74,14 +74,79 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
tusb_desc_device_t *descriptor;
|
||||
char **string_descriptor;
|
||||
bool external_phy;
|
||||
} tinyusb_config_t;
|
||||
|
||||
esp_err_t tinyusb_driver_install(const tinyusb_config_t *config);
|
||||
// TODO esp_err_t tinyusb_driver_uninstall(void); (IDF-1474)
|
||||
|
||||
/*
|
||||
* USB Persistence API
|
||||
* */
|
||||
typedef enum {
|
||||
REBOOT_NO_PERSIST,
|
||||
REBOOT_PERSIST,
|
||||
REBOOT_BOOTLOADER,
|
||||
REBOOT_BOOTLOADER_DFU
|
||||
} reboot_type_t;
|
||||
|
||||
/*
|
||||
* Enable Persist reboot
|
||||
*
|
||||
* Note: Persistence should be enabled when ONLY CDC and DFU are being used
|
||||
* */
|
||||
void tinyusb_persist_set_enable(bool enable);
|
||||
|
||||
/*
|
||||
* Set Persist reboot mode, if available, before calling esp_reboot();
|
||||
* */
|
||||
void tinyusb_persist_set_mode(reboot_type_t mode);
|
||||
|
||||
/*
|
||||
* TinyUSB Dynamic Driver Loading
|
||||
*
|
||||
* When enabled, usb drivers can be loaded at runtime, before calling tinyusb_driver_install()
|
||||
* */
|
||||
#if CFG_TUSB_DYNAMIC_DRIVER_LOAD
|
||||
#if CFG_TUSB_DEBUG >= 2
|
||||
#define DRIVER_NAME(_name) .name = _name,
|
||||
#else
|
||||
#define DRIVER_NAME(_name)
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
#if CFG_TUSB_DEBUG >= 2
|
||||
char const* name;
|
||||
#endif
|
||||
|
||||
void (* init ) (void);
|
||||
void (* reset ) (uint8_t rhport);
|
||||
uint16_t (* open ) (uint8_t rhport, tusb_desc_interface_t const * desc_intf, uint16_t max_len);
|
||||
bool (* control_request ) (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool (* control_complete ) (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool (* xfer_cb ) (uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||
void (* sof ) (uint8_t rhport); /* optional */
|
||||
} usbd_class_driver_t;
|
||||
|
||||
bool usbd_device_driver_load(const usbd_class_driver_t * driver);
|
||||
|
||||
#define STRINGIFY(x) #x
|
||||
#define TOSTRING(x) STRINGIFY(x)
|
||||
#define LOAD_DEFAULT_TUSB_DRIVER(name) \
|
||||
static usbd_class_driver_t name ## d_driver = { \
|
||||
DRIVER_NAME(TOSTRING(name)) \
|
||||
.init = name ## d_init, \
|
||||
.reset = name ## d_reset, \
|
||||
.open = name ## d_open, \
|
||||
.control_request = name ## d_control_request, \
|
||||
.control_complete = name ## d_control_complete, \
|
||||
.xfer_cb = name ## d_xfer_cb, \
|
||||
.sof = NULL \
|
||||
}; \
|
||||
TU_VERIFY (usbd_device_driver_load(&name ## d_driver));
|
||||
#endif /* CFG_TUSB_DYNAMIC_DRIVER_LOAD */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -60,6 +60,10 @@ extern "C" {
|
||||
# define CFG_TUSB_MEM_ALIGN TU_ATTR_ALIGNED(4)
|
||||
#endif
|
||||
|
||||
//Allow loading additional drivers
|
||||
#define CFG_TUSB_DYNAMIC_DRIVER_LOAD CONFIG_USB_DYNAMIC_DRIVER_LOADING
|
||||
#define CFG_TUSB_DYNAMIC_DRIVER_MAX CONFIG_USB_DYNAMIC_DRIVER_MAX
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
@ -93,10 +97,6 @@ extern "C" {
|
||||
# define CONFIG_USB_DFU_RT_ENABLED 0
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USB_NET_ENABLED
|
||||
# define CONFIG_USB_NET_ENABLED 0
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USB_VENDOR_ENABLED
|
||||
# define CONFIG_USB_VENDOR_ENABLED 0
|
||||
#endif
|
||||
@ -106,11 +106,11 @@ extern "C" {
|
||||
#define CFG_TUD_MSC CONFIG_USB_MSC_ENABLED
|
||||
#define CFG_TUD_HID CONFIG_USB_HID_ENABLED
|
||||
#define CFG_TUD_DFU_RT CONFIG_USB_DFU_RT_ENABLED
|
||||
#define CFG_TUD_NET CONFIG_USB_NET_ENABLED
|
||||
|
||||
#define CFG_TUD_MIDI CONFIG_USB_MIDI_ENABLED
|
||||
#define CFG_TUD_CUSTOM_CLASS CONFIG_USB_CUSTOM_CLASS_ENABLED
|
||||
|
||||
|
||||
#define CFG_TUD_VENDOR CONFIG_USB_VENDOR_ENABLED
|
||||
|
||||
// CDC FIFO size of TX and RX
|
||||
|
110
tools/sdk/esp32s2/include/tinyusb/tinyusb/src/class/bth/bth_device.h
Executable file
110
tools/sdk/esp32s2/include/tinyusb/tinyusb/src/class/bth/bth_device.h
Executable file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Jerzy Kasenberg
|
||||
*
|
||||
* 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 _TUSB_BTH_DEVICE_H_
|
||||
#define _TUSB_BTH_DEVICE_H_
|
||||
|
||||
#include <common/tusb_common.h>
|
||||
#include <device/usbd.h>
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Class Driver Configuration
|
||||
//--------------------------------------------------------------------+
|
||||
#ifndef CFG_TUD_BTH_EVENT_EPSIZE
|
||||
#define CFG_TUD_BTH_EVENT_EPSIZE 16
|
||||
#endif
|
||||
#ifndef CFG_TUD_BTH_DATA_EPSIZE
|
||||
#define CFG_TUD_BTH_DATA_EPSIZE 64
|
||||
#endif
|
||||
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint16_t op_code;
|
||||
uint8_t param_length;
|
||||
uint8_t param[255];
|
||||
} bt_hci_cmd_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Application Callback API (weak is optional)
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Invoked when HCI command was received over USB from Bluetooth host.
|
||||
// Detailed format is described in Bluetooth core specification Vol 2,
|
||||
// Part E, 5.4.1.
|
||||
// Length of the command is from 3 bytes (2 bytes for OpCode,
|
||||
// 1 byte for parameter total length) to 258.
|
||||
TU_ATTR_WEAK void tud_bt_hci_cmd_cb(void *hci_cmd, size_t cmd_len);
|
||||
|
||||
// Invoked when ACL data was received over USB from Bluetooth host.
|
||||
// Detailed format is described in Bluetooth core specification Vol 2,
|
||||
// Part E, 5.4.2.
|
||||
// Length is from 4 bytes, (12 bits for Handle, 4 bits for flags
|
||||
// and 16 bits for data total length) to endpoint size.
|
||||
TU_ATTR_WEAK void tud_bt_acl_data_received_cb(void *acl_data, uint16_t data_len);
|
||||
|
||||
// Called when event sent with tud_bt_event_send() was delivered to BT stack.
|
||||
// Controller can release/reuse buffer with Event packet at this point.
|
||||
TU_ATTR_WEAK void tud_bt_event_sent_cb(uint16_t sent_bytes);
|
||||
|
||||
// Called when ACL data that was sent with tud_bt_acl_data_send()
|
||||
// was delivered to BT stack.
|
||||
// Controller can release/reuse buffer with ACL packet at this point.
|
||||
TU_ATTR_WEAK void tud_bt_acl_data_sent_cb(uint16_t sent_bytes);
|
||||
|
||||
// Bluetooth controller calls this function when it wants to send even packet
|
||||
// as described in Bluetooth core specification Vol 2, Part E, 5.4.4.
|
||||
// Event has at least 2 bytes, first is Event code second contains parameter
|
||||
// total length. Controller can release/reuse event memory after
|
||||
// tud_bt_event_sent_cb() is called.
|
||||
bool tud_bt_event_send(void *event, uint16_t event_len);
|
||||
|
||||
// Bluetooth controller calls this to send ACL data packet
|
||||
// as described in Bluetooth core specification Vol 2, Part E, 5.4.2
|
||||
// Minimum length is 4 bytes, (12 bits for Handle, 4 bits for flags
|
||||
// and 16 bits for data total length). Upper limit is not limited
|
||||
// to endpoint size since buffer is allocate by controller
|
||||
// and must not be reused till tud_bt_acl_data_sent_cb() is called.
|
||||
bool tud_bt_acl_data_send(void *acl_data, uint16_t data_len);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Internal Class Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
void btd_init (void);
|
||||
void btd_reset (uint8_t rhport);
|
||||
uint16_t btd_open (uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
|
||||
bool btd_control_request (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool btd_control_complete (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool btd_xfer_cb (uint8_t rhport, uint8_t edpt_addr, xfer_result_t result, uint32_t xferred_bytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _TUSB_BTH_DEVICE_H_ */
|
@ -229,12 +229,12 @@ static inline uint32_t tud_cdc_write_available(void)
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL USBD-CLASS DRIVER API
|
||||
//--------------------------------------------------------------------+
|
||||
void cdcd_init (void);
|
||||
void cdcd_reset (uint8_t rhport);
|
||||
bool cdcd_open (uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length);
|
||||
bool cdcd_control_request (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool cdcd_control_complete (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool cdcd_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes);
|
||||
void cdcd_init (void);
|
||||
void cdcd_reset (uint8_t rhport);
|
||||
uint16_t cdcd_open (uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
|
||||
bool cdcd_control_request (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool cdcd_control_complete (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool cdcd_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -63,12 +63,12 @@ TU_ATTR_WEAK void tud_dfu_rt_reboot_to_dfu(void); // TODO rename to _cb conventi
|
||||
//--------------------------------------------------------------------+
|
||||
// Internal Class Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
void dfu_rtd_init(void);
|
||||
void dfu_rtd_reset(uint8_t rhport);
|
||||
bool dfu_rtd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length);
|
||||
bool dfu_rtd_control_request(uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool dfu_rtd_control_complete(uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool dfu_rtd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||
void dfu_rtd_init(void);
|
||||
void dfu_rtd_reset(uint8_t rhport);
|
||||
uint16_t dfu_rtd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
|
||||
bool dfu_rtd_control_request(uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool dfu_rtd_control_complete(uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool dfu_rtd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -300,12 +300,12 @@ TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t idle_rate);
|
||||
//--------------------------------------------------------------------+
|
||||
// Internal Class Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
void hidd_init (void);
|
||||
void hidd_reset (uint8_t rhport);
|
||||
bool hidd_open (uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length);
|
||||
bool hidd_control_request (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool hidd_control_complete (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool hidd_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||
void hidd_init (void);
|
||||
void hidd_reset (uint8_t rhport);
|
||||
uint16_t hidd_open (uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
|
||||
bool hidd_control_request (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool hidd_control_complete (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool hidd_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -136,12 +136,12 @@ static inline bool tud_midi_send (uint8_t const packet[4])
|
||||
//--------------------------------------------------------------------+
|
||||
// Internal Class Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
void midid_init (void);
|
||||
void midid_reset (uint8_t rhport);
|
||||
bool midid_open (uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length);
|
||||
bool midid_control_request (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool midid_control_complete (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool midid_xfer_cb (uint8_t rhport, uint8_t edpt_addr, xfer_result_t result, uint32_t xferred_bytes);
|
||||
void midid_init (void);
|
||||
void midid_reset (uint8_t rhport);
|
||||
uint16_t midid_open (uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
|
||||
bool midid_control_request (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool midid_control_complete (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool midid_xfer_cb (uint8_t rhport, uint8_t edpt_addr, xfer_result_t result, uint32_t xferred_bytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -151,12 +151,12 @@ TU_ATTR_WEAK bool tud_msc_is_writable_cb(uint8_t lun);
|
||||
//--------------------------------------------------------------------+
|
||||
// Internal Class Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
void mscd_init (void);
|
||||
void mscd_reset (uint8_t rhport);
|
||||
bool mscd_open (uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length);
|
||||
bool mscd_control_request (uint8_t rhport, tusb_control_request_t const * p_request);
|
||||
bool mscd_control_complete (uint8_t rhport, tusb_control_request_t const * p_request);
|
||||
bool mscd_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||
void mscd_init (void);
|
||||
void mscd_reset (uint8_t rhport);
|
||||
uint16_t mscd_open (uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
|
||||
bool mscd_control_request (uint8_t rhport, tusb_control_request_t const * p_request);
|
||||
bool mscd_control_complete (uint8_t rhport, tusb_control_request_t const * p_request);
|
||||
bool mscd_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -72,13 +72,13 @@ void tud_network_xmit(struct pbuf *p);
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL USBD-CLASS DRIVER API
|
||||
//--------------------------------------------------------------------+
|
||||
void netd_init (void);
|
||||
void netd_reset (uint8_t rhport);
|
||||
bool netd_open (uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length);
|
||||
bool netd_control_request (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool netd_control_complete (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool netd_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes);
|
||||
void netd_report (uint8_t *buf, uint16_t len);
|
||||
void netd_init (void);
|
||||
void netd_reset (uint8_t rhport);
|
||||
uint16_t netd_open (uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
|
||||
bool netd_control_request (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool netd_control_complete (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool netd_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes);
|
||||
void netd_report (uint8_t *buf, uint16_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -108,12 +108,12 @@ bool tud_usbtmc_start_bus_read(void);
|
||||
|
||||
/* "callbacks" from USB device core */
|
||||
|
||||
bool usbtmcd_open_cb(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length);
|
||||
void usbtmcd_reset_cb(uint8_t rhport);
|
||||
bool usbtmcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes);
|
||||
bool usbtmcd_control_request_cb(uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool usbtmcd_control_complete_cb(uint8_t rhport, tusb_control_request_t const * request);
|
||||
void usbtmcd_init_cb(void);
|
||||
uint16_t usbtmcd_open_cb(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
|
||||
void usbtmcd_reset_cb(uint8_t rhport);
|
||||
bool usbtmcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes);
|
||||
bool usbtmcd_control_request_cb(uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool usbtmcd_control_complete_cb(uint8_t rhport, tusb_control_request_t const * request);
|
||||
void usbtmcd_init_cb(void);
|
||||
|
||||
/************************************************************
|
||||
* USBTMC Descriptor Templates
|
||||
|
@ -118,10 +118,10 @@ static inline uint32_t tud_vendor_write_available (void)
|
||||
//--------------------------------------------------------------------+
|
||||
// Internal Class Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
void vendord_init(void);
|
||||
void vendord_reset(uint8_t rhport);
|
||||
bool vendord_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length);
|
||||
bool vendord_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||
void vendord_init(void);
|
||||
void vendord_reset(uint8_t rhport);
|
||||
uint16_t vendord_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
|
||||
bool vendord_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -228,6 +228,7 @@ void tu_print_var(uint8_t const* buf, uint32_t bufsize)
|
||||
for(uint32_t i=0; i<bufsize; i++) tu_printf("%02X ", buf[i]);
|
||||
}
|
||||
|
||||
|
||||
// Log with debug level 1
|
||||
#define TU_LOG1 tu_printf
|
||||
#define TU_LOG1_MEM tu_print_mem
|
||||
@ -235,6 +236,7 @@ void tu_print_var(uint8_t const* buf, uint32_t bufsize)
|
||||
#define TU_LOG1_INT(_x) tu_printf(#_x " = %ld\n", (uint32_t) (_x) )
|
||||
#define TU_LOG1_HEX(_x) tu_printf(#_x " = %lX\n", (uint32_t) (_x) )
|
||||
#define TU_LOG1_LOCATION() tu_printf("%s: %d:\r\n", __PRETTY_FUNCTION__, __LINE__)
|
||||
#define TU_LOG1_FAILED() tu_printf("%s: %d: Failed\r\n", __PRETTY_FUNCTION__, __LINE__)
|
||||
|
||||
// Log with debug level 2
|
||||
#if CFG_TUSB_DEBUG > 1
|
||||
@ -277,6 +279,7 @@ static inline char const* lookup_find(lookup_table_t const* p_table, uint32_t ke
|
||||
#define TU_LOG1_VAR(...)
|
||||
#define TU_LOG1_INT(...)
|
||||
#define TU_LOG1_HEX(...)
|
||||
#define TU_LOG1_FAILED()
|
||||
#endif
|
||||
|
||||
#ifndef TU_LOG2
|
||||
|
@ -68,6 +68,8 @@ static inline bool tud_ready(void)
|
||||
// Remote wake up host, only if suspended and enabled by host
|
||||
bool tud_remote_wakeup(void);
|
||||
|
||||
// Enable pull-up resistor on D+ D-
|
||||
// Return false on unsupported MCUs
|
||||
static inline bool tud_disconnect(void)
|
||||
{
|
||||
TU_VERIFY(dcd_disconnect);
|
||||
@ -75,6 +77,8 @@ static inline bool tud_disconnect(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Disable pull-up resistor on D+ D-
|
||||
// Return false on unsupported MCUs
|
||||
static inline bool tud_connect(void)
|
||||
{
|
||||
TU_VERIFY(dcd_connect);
|
||||
@ -110,6 +114,10 @@ uint8_t const * tud_descriptor_configuration_cb(uint8_t index);
|
||||
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
|
||||
uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid);
|
||||
|
||||
// Invoked when received GET DEVICE QUALIFIER DESCRIPTOR request
|
||||
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
|
||||
TU_ATTR_WEAK uint8_t const* tud_descriptor_device_qualifier_cb(void);
|
||||
|
||||
// Invoked when device is mounted (configured)
|
||||
TU_ATTR_WEAK void tud_mount_cb(void);
|
||||
|
||||
@ -125,6 +133,8 @@ TU_ATTR_WEAK void tud_resume_cb(void);
|
||||
|
||||
// Invoked when received control request with VENDOR TYPE
|
||||
TU_ATTR_WEAK bool tud_vendor_control_request_cb(uint8_t rhport, tusb_control_request_t const * request);
|
||||
|
||||
// Invoked when vendor control request is complete
|
||||
TU_ATTR_WEAK bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_request_t const * request);
|
||||
|
||||
|
||||
@ -438,6 +448,60 @@ TU_ATTR_WEAK bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_re
|
||||
/* Endpoint Out */\
|
||||
7, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0
|
||||
|
||||
//------------- BT Radio -------------//
|
||||
#define TUD_BT_APP_CLASS (TUSB_CLASS_WIRELESS_CONTROLLER)
|
||||
#define TUD_BT_APP_SUBCLASS 0x01
|
||||
#define TUD_BT_PROTOCOL_PRIMARY_CONTROLLER 0x01
|
||||
#define TUD_BT_PROTOCOL_AMP_CONTROLLER 0x02
|
||||
|
||||
#ifndef CFG_TUD_BTH_ISO_ALT_COUNT
|
||||
#define CFG_TUD_BTH_ISO_ALT_COUNT 0
|
||||
#endif
|
||||
|
||||
// Length of template descriptor: 30 bytes + number of ISO alternatives * 23
|
||||
#define TUD_BTH_DESC_LEN (9 + 7 + 7 + 7 + (CFG_TUD_BTH_ISO_ALT_COUNT) * (9 + 7 + 7))
|
||||
|
||||
/* Primary Interface */
|
||||
#define TUD_BTH_PRI_ITF(_itfnum, _stridx, _ep_evt, _ep_evt_size, _ep_evt_interval, _ep_in, _ep_out, _ep_size) \
|
||||
9, TUSB_DESC_INTERFACE, _itfnum, _stridx, 3, TUD_BT_APP_CLASS, TUD_BT_APP_SUBCLASS, TUD_BT_PROTOCOL_PRIMARY_CONTROLLER, 0, \
|
||||
/* Endpoint In for events */ \
|
||||
7, TUSB_DESC_ENDPOINT, _ep_evt, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_ep_evt_size), _ep_evt_interval, \
|
||||
/* Endpoint In for ACL data */ \
|
||||
7, TUSB_DESC_ENDPOINT, _ep_in, TUSB_XFER_BULK, U16_TO_U8S_LE(_ep_size), 1, \
|
||||
/* Endpoint Out for ACL data */ \
|
||||
7, TUSB_DESC_ENDPOINT, _ep_out, TUSB_XFER_BULK, U16_TO_U8S_LE(_ep_size), 1
|
||||
|
||||
#define TUD_BTH_ISO_ITF(_itfnum, _alt, _ep_in, _ep_out, _n) ,\
|
||||
/* Interface with 2 endpoints */ \
|
||||
9, TUSB_DESC_INTERFACE, _itfnum, _alt, 2, TUD_BT_APP_CLASS, TUD_BT_APP_SUBCLASS, TUD_BT_PROTOCOL_PRIMARY_CONTROLLER, 0, \
|
||||
/* Isochronous endpoints */ \
|
||||
7, TUSB_DESC_ENDPOINT, _ep_in, TUSB_XFER_ISOCHRONOUS, U16_TO_U8S_LE(_n), 1, \
|
||||
7, TUSB_DESC_ENDPOINT, _ep_out, TUSB_XFER_ISOCHRONOUS, U16_TO_U8S_LE(_n), 1
|
||||
|
||||
#define _FIRST(a, ...) a
|
||||
#define _REST(a, ...) __VA_ARGS__
|
||||
|
||||
#define TUD_BTH_ISO_ITF_0(_itfnum, ...)
|
||||
#define TUD_BTH_ISO_ITF_1(_itfnum, _ep_in, _ep_out, ...) TUD_BTH_ISO_ITF(_itfnum, (CFG_TUD_BTH_ISO_ALT_COUNT) - 1, _ep_in, _ep_out, _FIRST(__VA_ARGS__))
|
||||
#define TUD_BTH_ISO_ITF_2(_itfnum, _ep_in, _ep_out, ...) TUD_BTH_ISO_ITF(_itfnum, (CFG_TUD_BTH_ISO_ALT_COUNT) - 2, _ep_in, _ep_out, _FIRST(__VA_ARGS__)) \
|
||||
TUD_BTH_ISO_ITF_1(_itfnum, _ep_in, _ep_out, _REST(__VA_ARGS__))
|
||||
#define TUD_BTH_ISO_ITF_3(_itfnum, _ep_in, _ep_out, ...) TUD_BTH_ISO_ITF(_itfnum, (CFG_TUD_BTH_ISO_ALT_COUNT) - 3, _ep_in, _ep_out, _FIRST(__VA_ARGS__)) \
|
||||
TUD_BTH_ISO_ITF_2(_itfnum, _ep_in, _ep_out, _REST(__VA_ARGS__))
|
||||
#define TUD_BTH_ISO_ITF_4(_itfnum, _ep_in, _ep_out, ...) TUD_BTH_ISO_ITF(_itfnum, (CFG_TUD_BTH_ISO_ALT_COUNT) - 4, _ep_in, _ep_out, _FIRST(__VA_ARGS__)) \
|
||||
TUD_BTH_ISO_ITF_3(_itfnum, _ep_in, _ep_out, _REST(__VA_ARGS__))
|
||||
#define TUD_BTH_ISO_ITF_5(_itfnum, _ep_in, _ep_out, ...) TUD_BTH_ISO_ITF(_itfnum, (CFG_TUD_BTH_ISO_ALT_COUNT) - 5, _ep_in, _ep_out, _FIRST(__VA_ARGS__)) \
|
||||
TUD_BTH_ISO_ITF_4(_itfnum, _ep_in, _ep_out, _REST(__VA_ARGS__))
|
||||
#define TUD_BTH_ISO_ITF_6(_itfnum, _ep_in, _ep_out, ...) TUD_BTH_ISO_ITF(_itfnum, (CFG_TUD_BTH_ISO_ALT_COUNT) - 6, _ep_in, _ep_out, _FIRST(__VA_ARGS__)) \
|
||||
TUD_BTH_ISO_ITF_5(_itfnum, _ep_in, _ep_out, _REST(__VA_ARGS__))
|
||||
|
||||
#define TUD_BTH_ISO_ITFS(_itfnum, _ep_in, _ep_out, ...) \
|
||||
TU_XSTRCAT(TUD_BTH_ISO_ITF_, CFG_TUD_BTH_ISO_ALT_COUNT)(_itfnum, _ep_in, _ep_out, __VA_ARGS__)
|
||||
|
||||
// BT Primary controller descriptor
|
||||
// Interface number, string index, attributes, event endpoint, event endpoint size, interval, data in, data out, data endpoint size, iso endpoint sizes
|
||||
#define TUD_BTH_DESCRIPTOR(_itfnum, _stridx, _ep_evt, _ep_evt_size, _ep_evt_interval, _ep_in, _ep_out, _ep_size,...) \
|
||||
TUD_BTH_PRI_ITF(_itfnum, _stridx, _ep_evt, _ep_evt_size, _ep_evt_interval, _ep_in, _ep_out, _ep_size) \
|
||||
TUD_BTH_ISO_ITFS(_itfnum + 1, _ep_in + 1, _ep_out + 1, __VA_ARGS__)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -95,6 +95,10 @@
|
||||
#if CFG_TUD_NET
|
||||
#include "class/net/net_device.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_BTH
|
||||
#include "class/bth/bth_device.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -219,6 +219,10 @@
|
||||
#define CFG_TUD_NET 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_BTH
|
||||
#define CFG_TUD_BTH 0
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// HOST OPTIONS
|
||||
//--------------------------------------------------------------------
|
||||
|
Binary file not shown.
Binary file not shown.
@ -990,9 +990,12 @@ CONFIG_SPIFFS_USE_MTIME=y
|
||||
CONFIG_USB_ENABLED=y
|
||||
CONFIG_USB_MAX_POWER_USAGE=500
|
||||
# CONFIG_USB_USE_BUILTIN_DESCRIPTORS is not set
|
||||
CONFIG_USB_DYNAMIC_DRIVER_LOADING=y
|
||||
CONFIG_USB_DYNAMIC_DRIVER_MAX=16
|
||||
CONFIG_USB_CDC_ENABLED=y
|
||||
CONFIG_USB_CDC_RX_BUFSIZE=1024
|
||||
CONFIG_USB_CDC_TX_BUFSIZE=1024
|
||||
CONFIG_USB_DFU_RT_ENABLED=y
|
||||
CONFIG_USB_MSC_ENABLED=y
|
||||
CONFIG_USB_MSC_BUFSIZE=512
|
||||
CONFIG_USB_HID_ENABLED=y
|
||||
@ -1001,8 +1004,6 @@ CONFIG_USB_MIDI_ENABLED=y
|
||||
CONFIG_USB_MIDI_RX_BUFSIZE=64
|
||||
CONFIG_USB_MIDI_TX_BUFSIZE=64
|
||||
CONFIG_USB_VENDOR_ENABLED=y
|
||||
CONFIG_USB_DFU_RT_ENABLED=y
|
||||
# CONFIG_USB_NET_ENABLED is not set
|
||||
# CONFIG_USB_CUSTOM_CLASS_ENABLED is not set
|
||||
# CONFIG_USB_DEBUG is not set
|
||||
|
||||
@ -1016,6 +1017,7 @@ CONFIG_USB_DESC_MANUFACTURER_STRING="Espressif"
|
||||
CONFIG_USB_DESC_PRODUCT_STRING="Espressif Device"
|
||||
CONFIG_USB_DESC_SERIAL_STRING="123456"
|
||||
CONFIG_USB_DESC_CDC_STRING="Espressif CDC Device"
|
||||
CONFIG_USB_DESC_DFU_RT_STRING="Espressif DFU Device"
|
||||
CONFIG_USB_DESC_MSC_STRING="Espressif MSC Device"
|
||||
CONFIG_USB_DESC_MIDI_STRING="Espressif MIDI Device"
|
||||
CONFIG_USB_DESC_HID_STRING="Espressif HID Device"
|
||||
|
Reference in New Issue
Block a user