forked from espressif/arduino-esp32
Update TinyUSB
This commit is contained in:
@ -17,7 +17,6 @@
|
||||
#include <string.h>
|
||||
#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.
|
||||
|
@ -11,19 +11,20 @@
|
||||
// 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
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "tusb.h"
|
||||
|
||||
#define _PID_MAP(itf, n) ((CFG_TUD_##itf) << (n))
|
||||
|
||||
#define USB_ESPRESSIF_VID 0x303A
|
||||
|
||||
#if CONFIG_USB_USE_BUILTIN_DESCRIPTORS
|
||||
|
||||
#define _PID_MAP(itf, n) ((CFG_TUD_##itf) << (n))
|
||||
|
||||
#define USB_STRING_DESCRIPTOR_ARRAY_SIZE 10
|
||||
typedef char *tusb_desc_strarray_device_t[USB_STRING_DESCRIPTOR_ARRAY_SIZE];
|
||||
|
||||
@ -32,6 +33,7 @@ extern tusb_desc_strarray_device_t descriptor_str_tinyusb;
|
||||
|
||||
extern tusb_desc_device_t descriptor_kconfig;
|
||||
extern tusb_desc_strarray_device_t descriptor_str_kconfig;
|
||||
#endif /* CONFIG_USB_USE_BUILTIN_DESCRIPTORS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -74,79 +74,16 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
#if CONFIG_USB_USE_BUILTIN_DESCRIPTORS
|
||||
tusb_desc_device_t *descriptor;
|
||||
char **string_descriptor;
|
||||
#endif /* CONFIG_USB_USE_BUILTIN_DESCRIPTORS */
|
||||
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,11 +60,6 @@ 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
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// DEVICE CONFIGURATION
|
||||
|
@ -0,0 +1,53 @@
|
||||
// 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
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* USB Persistence API
|
||||
* */
|
||||
typedef enum {
|
||||
REBOOT_NO_PERSIST,
|
||||
REBOOT_PERSIST,
|
||||
REBOOT_BOOTLOADER,
|
||||
REBOOT_BOOTLOADER_DFU,
|
||||
REBOOT_TYPE_MAX
|
||||
} reboot_type_t;
|
||||
|
||||
/*
|
||||
* Init Persistence reboot system
|
||||
* */
|
||||
void tinyusb_persist_init(void);
|
||||
|
||||
/*
|
||||
* Enable Persistence reboot
|
||||
*
|
||||
* Note: Persistence should be enabled when ONLY CDC and DFU are being used
|
||||
* */
|
||||
void tinyusb_persist_set_enable(bool enable);
|
||||
|
||||
/*
|
||||
* Set Reboot mode. Call before esp_reboot();
|
||||
* */
|
||||
void tinyusb_persist_set_mode(reboot_type_t mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user