update tinyusb stack to support vendor
This commit is contained in:
1 parent
e873acdd55
commit
d04f9ae3eb
23 files changed
+748
-374
No files matched your search
@@ -115,4 +115,3 @@ The following libraries are used:
|
||||
- [tinyusb](https://github.com/hathach/tinyusb) as usb stack
|
||||
- [nrfx](https://github.com/NordicSemiconductor/nrfx) for peripherals driver
|
||||
- [littlefs](https://github.com/ARMmbed/littlefs) for internal file system
|
||||
- [fatfs by elm-chan](http://elm-chan.org/fsw/ff/00index_e.html) for external file system
|
||||
@@ -300,7 +300,7 @@ bool cdcd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t
|
||||
|
||||
// Invoked when class request DATA stage is finished.
|
||||
// return false to stall control endpoint (e.g Host send non-sense DATA)
|
||||
bool cdcd_control_request_complete(uint8_t rhport, tusb_control_request_t const * request)
|
||||
bool cdcd_control_complete(uint8_t rhport, tusb_control_request_t const * request)
|
||||
{
|
||||
(void) rhport;
|
||||
|
||||
@@ -334,11 +334,11 @@ bool cdcd_control_request(uint8_t rhport, tusb_control_request_t const * request
|
||||
switch ( request->bRequest )
|
||||
{
|
||||
case CDC_REQUEST_SET_LINE_CODING:
|
||||
usbd_control_xfer(rhport, request, &p_cdc->line_coding, sizeof(cdc_line_coding_t));
|
||||
tud_control_xfer(rhport, request, &p_cdc->line_coding, sizeof(cdc_line_coding_t));
|
||||
break;
|
||||
|
||||
case CDC_REQUEST_GET_LINE_CODING:
|
||||
usbd_control_xfer(rhport, request, &p_cdc->line_coding, sizeof(cdc_line_coding_t));
|
||||
tud_control_xfer(rhport, request, &p_cdc->line_coding, sizeof(cdc_line_coding_t));
|
||||
break;
|
||||
|
||||
case CDC_REQUEST_SET_CONTROL_LINE_STATE:
|
||||
@@ -349,7 +349,7 @@ bool cdcd_control_request(uint8_t rhport, tusb_control_request_t const * request
|
||||
// This signal corresponds to V.24 signal 105 and RS-232 signal RTS (Request to Send)
|
||||
p_cdc->line_state = (uint8_t) request->wValue;
|
||||
|
||||
usbd_control_status(rhport, request);
|
||||
tud_control_status(rhport, request);
|
||||
|
||||
// Invoke callback
|
||||
if ( tud_cdc_line_state_cb) tud_cdc_line_state_cb(itf, tu_bit_test(request->wValue, 0), tu_bit_test(request->wValue, 1));
|
||||
@@ -370,7 +370,7 @@ bool cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
|
||||
uint8_t const itf = 0;
|
||||
cdcd_interface_t* p_cdc = &_cdcd_itf[itf];
|
||||
|
||||
// receive new data
|
||||
// Received new data
|
||||
if ( ep_addr == p_cdc->ep_out )
|
||||
{
|
||||
for(uint32_t i=0; i<xferred_bytes; i++)
|
||||
@@ -391,7 +391,9 @@ bool cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
|
||||
_prep_out_transaction(itf);
|
||||
}
|
||||
|
||||
// sent data
|
||||
// Data sent to host, we could continue to fetch data tx fifo to send.
|
||||
// But it will cause incorrect baudrate set in line coding.
|
||||
// Though maybe the baudrate is not really important !!!
|
||||
// if ( ep_addr == p_cdc->ep_in )
|
||||
// {
|
||||
//
|
||||
|
||||
@@ -176,12 +176,12 @@ static inline bool tud_cdc_write_flush (void)
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL USBD-CLASS DRIVER API
|
||||
//--------------------------------------------------------------------+
|
||||
void cdcd_init (void);
|
||||
bool cdcd_open (uint8_t rhport, tusb_desc_interface_t const * p_interface_desc, uint16_t *p_length);
|
||||
bool cdcd_control_request (uint8_t rhport, tusb_control_request_t const * p_request);
|
||||
bool cdcd_control_request_complete (uint8_t rhport, tusb_control_request_t const * p_request);
|
||||
bool cdcd_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes);
|
||||
void cdcd_reset (uint8_t rhport);
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "tusb_option.h"
|
||||
|
||||
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_CUSTOM_CLASS)
|
||||
|
||||
#include "common/tusb_common.h"
|
||||
#include "custom_device.h"
|
||||
#include "device/usbd_pvt.h"
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* MACRO TYPEDEF CONSTANT ENUM
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* VARIABLE DECLARATION
|
||||
*------------------------------------------------------------------*/
|
||||
typedef struct {
|
||||
uint8_t itf_num;
|
||||
|
||||
uint8_t ep_in;
|
||||
uint8_t ep_out;
|
||||
|
||||
} cusd_interface_t;
|
||||
|
||||
static cusd_interface_t _cusd_itf;
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* FUNCTION DECLARATION
|
||||
*------------------------------------------------------------------*/
|
||||
void cusd_init(void)
|
||||
{
|
||||
tu_varclr(&_cusd_itf);
|
||||
}
|
||||
|
||||
bool cusd_open(uint8_t rhport, tusb_desc_interface_t const * p_desc_itf, uint16_t *p_len)
|
||||
{
|
||||
cusd_interface_t* p_itf = &_cusd_itf;
|
||||
|
||||
// Open endpoint pair with usbd helper
|
||||
tusb_desc_endpoint_t const *p_desc_ep = (tusb_desc_endpoint_t const *) tu_desc_next(p_desc_itf);
|
||||
TU_ASSERT( usbd_open_edpt_pair(rhport, p_desc_ep, TUSB_XFER_BULK, &p_itf->ep_out, &p_itf->ep_in) );
|
||||
|
||||
p_itf->itf_num = p_desc_itf->bInterfaceNumber;
|
||||
|
||||
(*p_len) = sizeof(tusb_desc_interface_t) + 2*sizeof(tusb_desc_endpoint_t);
|
||||
|
||||
// TODO Prepare for incoming data
|
||||
// TU_ASSERT( usbd_edpt_xfer(rhport, p_itf->ep_out, (uint8_t*) &p_msc->cbw, sizeof(msc_cbw_t)) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cusd_control_request(uint8_t rhport, tusb_control_request_t const * p_request)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cusd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void cusd_reset(uint8_t rhport)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
||||
*
|
||||
* 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_CUSTOM_DEVICE_H_
|
||||
#define _TUSB_CUSTOM_DEVICE_H_
|
||||
|
||||
#include "common/tusb_common.h"
|
||||
#include "device/usbd.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION API (Multiple Root Ports)
|
||||
// Should be used only with MCU that support more than 1 ports
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION API (Single Port)
|
||||
// Should be used with MCU supporting only 1 USB port for code simplicity
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION CALLBACK API (WEAK is optional)
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Internal Class Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
void cusd_init(void);
|
||||
bool cusd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length);
|
||||
bool cusd_control_request_st(uint8_t rhport, tusb_control_request_t const * p_request);
|
||||
bool cusd_control_request_complete (uint8_t rhport, tusb_control_request_t const * p_request);
|
||||
bool cusd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||
void cusd_reset(uint8_t rhport);
|
||||
|
||||
#endif /* _TUSB_CUSTOM_DEVICE_H_ */
|
||||
@@ -205,7 +205,7 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * p_reque
|
||||
if (p_request->bRequest == TUSB_REQ_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_REPORT)
|
||||
{
|
||||
uint8_t const * desc_report = tud_hid_descriptor_report_cb();
|
||||
usbd_control_xfer(rhport, p_request, (void*) desc_report, p_hid->reprot_desc_len);
|
||||
tud_control_xfer(rhport, p_request, (void*) desc_report, p_hid->reprot_desc_len);
|
||||
}else
|
||||
{
|
||||
return false; // stall unsupported request
|
||||
@@ -225,12 +225,12 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * p_reque
|
||||
uint16_t xferlen = tud_hid_get_report_cb(report_id, (hid_report_type_t) report_type, p_hid->epin_buf, p_request->wLength);
|
||||
TU_ASSERT( xferlen > 0 );
|
||||
|
||||
usbd_control_xfer(rhport, p_request, p_hid->epin_buf, xferlen);
|
||||
tud_control_xfer(rhport, p_request, p_hid->epin_buf, xferlen);
|
||||
}
|
||||
break;
|
||||
|
||||
case HID_REQ_CONTROL_SET_REPORT:
|
||||
usbd_control_xfer(rhport, p_request, p_hid->epout_buf, p_request->wLength);
|
||||
tud_control_xfer(rhport, p_request, p_hid->epout_buf, p_request->wLength);
|
||||
break;
|
||||
|
||||
case HID_REQ_CONTROL_SET_IDLE:
|
||||
@@ -241,18 +241,18 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * p_reque
|
||||
if ( !tud_hid_set_idle_cb(p_hid->idle_rate) ) return false;
|
||||
}
|
||||
|
||||
usbd_control_status(rhport, p_request);
|
||||
tud_control_status(rhport, p_request);
|
||||
break;
|
||||
|
||||
case HID_REQ_CONTROL_GET_IDLE:
|
||||
// TODO idle rate of report
|
||||
usbd_control_xfer(rhport, p_request, &p_hid->idle_rate, 1);
|
||||
tud_control_xfer(rhport, p_request, &p_hid->idle_rate, 1);
|
||||
break;
|
||||
|
||||
case HID_REQ_CONTROL_GET_PROTOCOL:
|
||||
{
|
||||
uint8_t protocol = 1-p_hid->boot_mode; // 0 is Boot, 1 is Report protocol
|
||||
usbd_control_xfer(rhport, p_request, &protocol, 1);
|
||||
tud_control_xfer(rhport, p_request, &protocol, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -261,7 +261,7 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * p_reque
|
||||
|
||||
if (tud_hid_boot_mode_cb) tud_hid_boot_mode_cb(p_hid->boot_mode);
|
||||
|
||||
usbd_control_status(rhport, p_request);
|
||||
tud_control_status(rhport, p_request);
|
||||
break;
|
||||
|
||||
default: return false; // stall unsupported request
|
||||
@@ -276,7 +276,7 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * p_reque
|
||||
|
||||
// Invoked when class request DATA stage is finished.
|
||||
// return false to stall control endpoint (e.g Host send non-sense DATA)
|
||||
bool hidd_control_request_complete(uint8_t rhport, tusb_control_request_t const * p_request)
|
||||
bool hidd_control_complete(uint8_t rhport, tusb_control_request_t const * p_request)
|
||||
{
|
||||
(void) rhport;
|
||||
hidd_interface_t* p_hid = get_interface_by_itfnum( (uint8_t) p_request->wIndex );
|
||||
|
||||
@@ -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);
|
||||
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 * p_request);
|
||||
bool hidd_control_request_complete (uint8_t rhport, tusb_control_request_t const * p_request);
|
||||
bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||
void hidd_reset(uint8_t rhport);
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ typedef struct
|
||||
uint8_t ep_in;
|
||||
uint8_t ep_out;
|
||||
|
||||
/*------------- From this point, data is not cleared by bus reset -------------*/
|
||||
// FIFO
|
||||
tu_fifo_t rx_ff;
|
||||
tu_fifo_t tx_ff;
|
||||
@@ -77,7 +78,7 @@ CFG_TUSB_MEM_SECTION midid_interface_t _midid_itf[CFG_TUD_MIDI];
|
||||
bool tud_midi_n_mounted (uint8_t itf)
|
||||
{
|
||||
midid_interface_t* midi = &_midid_itf[itf];
|
||||
return midi->itf_num != 0;
|
||||
return midi->ep_in && midi->ep_out;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -127,7 +128,8 @@ void midi_rx_done_cb(midid_interface_t* midi, uint8_t const* buffer, uint32_t bu
|
||||
|
||||
static bool maybe_transmit(midid_interface_t* midi, uint8_t itf_index)
|
||||
{
|
||||
TU_VERIFY( !usbd_edpt_busy(TUD_OPT_RHPORT, midi->ep_in) ); // skip if previous transfer not complete
|
||||
// skip if previous transfer not complete
|
||||
TU_VERIFY( !usbd_edpt_busy(TUD_OPT_RHPORT, midi->ep_in) );
|
||||
|
||||
uint16_t count = tu_fifo_read_n(&midi->tx_ff, midi->epin_buf, CFG_TUD_MIDI_EPSIZE);
|
||||
if (count > 0)
|
||||
@@ -222,6 +224,7 @@ void midid_init(void)
|
||||
// config fifo
|
||||
tu_fifo_config(&midi->rx_ff, midi->rx_ff_buf, CFG_TUD_MIDI_RX_BUFSIZE, 1, true);
|
||||
tu_fifo_config(&midi->tx_ff, midi->tx_ff_buf, CFG_TUD_MIDI_TX_BUFSIZE, 1, true);
|
||||
|
||||
#if CFG_FIFO_MUTEX
|
||||
tu_fifo_config_mutex(&midi->rx_ff, osal_mutex_create(&midi->rx_ff_mutex));
|
||||
tu_fifo_config_mutex(&midi->tx_ff, osal_mutex_create(&midi->tx_ff_mutex));
|
||||
@@ -275,7 +278,8 @@ bool midid_open(uint8_t rhport, tusb_desc_interface_t const * p_interface_desc,
|
||||
(*p_length) = sizeof(tusb_desc_interface_t);
|
||||
|
||||
uint8_t found_endpoints = 0;
|
||||
while (found_endpoints < p_interface_desc->bNumEndpoints) {
|
||||
while (found_endpoints < p_interface_desc->bNumEndpoints)
|
||||
{
|
||||
if ( TUSB_DESC_ENDPOINT == p_desc[DESC_OFFSET_TYPE])
|
||||
{
|
||||
TU_ASSERT( dcd_edpt_open(rhport, (tusb_desc_endpoint_t const *) p_desc), false);
|
||||
@@ -300,7 +304,7 @@ bool midid_open(uint8_t rhport, tusb_desc_interface_t const * p_interface_desc,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool midid_control_request_complete(uint8_t rhport, tusb_control_request_t const * p_request)
|
||||
bool midid_control_complete(uint8_t rhport, tusb_control_request_t const * p_request)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -313,20 +317,20 @@ bool midid_control_request(uint8_t rhport, tusb_control_request_t const * p_requ
|
||||
return false;
|
||||
}
|
||||
|
||||
bool midid_xfer_cb(uint8_t rhport, uint8_t edpt_addr, xfer_result_t result, uint32_t xferred_bytes)
|
||||
bool midid_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes)
|
||||
{
|
||||
// TODO Support multiple interfaces
|
||||
uint8_t const itf = 0;
|
||||
midid_interface_t* p_midi = &_midid_itf[itf];
|
||||
|
||||
// receive new data
|
||||
if ( edpt_addr == p_midi->ep_out )
|
||||
if ( ep_addr == p_midi->ep_out )
|
||||
{
|
||||
midi_rx_done_cb(p_midi, p_midi->epout_buf, xferred_bytes);
|
||||
|
||||
// prepare for next
|
||||
TU_ASSERT( usbd_edpt_xfer(rhport, p_midi->ep_out, p_midi->epout_buf, CFG_TUD_MIDI_EPSIZE), false );
|
||||
} else if ( edpt_addr == p_midi->ep_in ) {
|
||||
} else if ( ep_addr == p_midi->ep_in ) {
|
||||
maybe_transmit(p_midi, itf);
|
||||
}
|
||||
|
||||
|
||||
@@ -121,12 +121,12 @@ static inline uint32_t tudi_midi_write24 (uint8_t jack_id, uint8_t b1, uint8_t b
|
||||
//--------------------------------------------------------------------+
|
||||
// Internal Class Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
void midid_init (void);
|
||||
bool midid_open (uint8_t rhport, tusb_desc_interface_t const * p_interface_desc, uint16_t *p_length);
|
||||
bool midid_control_request (uint8_t rhport, tusb_control_request_t const * p_request);
|
||||
bool midid_control_request_complete (uint8_t rhport, tusb_control_request_t const * p_request);
|
||||
bool midid_xfer_cb (uint8_t rhport, uint8_t edpt_addr, xfer_result_t result, uint32_t xferred_bytes);
|
||||
void midid_reset (uint8_t rhport);
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ bool tud_msc_set_sense(uint8_t lun, uint8_t sense_key, uint8_t add_sense_code, u
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USBD-CLASS API
|
||||
// USBD Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
void mscd_init(void)
|
||||
{
|
||||
@@ -154,7 +154,7 @@ bool mscd_control_request(uint8_t rhport, tusb_control_request_t const * p_reque
|
||||
{
|
||||
case MSC_REQ_RESET:
|
||||
// TODO: Actually reset interface.
|
||||
usbd_control_status(rhport, p_request);
|
||||
tud_control_status(rhport, p_request);
|
||||
break;
|
||||
|
||||
case MSC_REQ_GET_MAX_LUN:
|
||||
@@ -166,7 +166,7 @@ bool mscd_control_request(uint8_t rhport, tusb_control_request_t const * p_reque
|
||||
// MAX LUN is minus 1 by specs
|
||||
maxlun--;
|
||||
|
||||
usbd_control_xfer(rhport, p_request, &maxlun, 1);
|
||||
tud_control_xfer(rhport, p_request, &maxlun, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -178,10 +178,10 @@ bool mscd_control_request(uint8_t rhport, tusb_control_request_t const * p_reque
|
||||
|
||||
// Invoked when class request DATA stage is finished.
|
||||
// return false to stall control endpoint (e.g Host send non-sense DATA)
|
||||
bool mscd_control_request_complete(uint8_t rhport, tusb_control_request_t const * p_request)
|
||||
bool mscd_control_complete(uint8_t rhport, tusb_control_request_t const * request)
|
||||
{
|
||||
(void) rhport;
|
||||
(void) p_request;
|
||||
(void) request;
|
||||
|
||||
// nothing to do
|
||||
return true;
|
||||
@@ -200,7 +200,7 @@ int32_t proc_builtin_scsi(uint8_t lun, uint8_t const scsi_cmd[16], uint8_t* buff
|
||||
resplen = 0;
|
||||
if ( !tud_msc_test_unit_ready_cb(lun) )
|
||||
{
|
||||
// not ready response with Failed status and sense key = not ready
|
||||
// Failed status response
|
||||
resplen = - 1;
|
||||
|
||||
// If sense key is not set by callback, default to Logical Unit Not Ready, Cause Not Reportable
|
||||
@@ -214,7 +214,14 @@ int32_t proc_builtin_scsi(uint8_t lun, uint8_t const scsi_cmd[16], uint8_t* buff
|
||||
if (tud_msc_start_stop_cb)
|
||||
{
|
||||
scsi_start_stop_unit_t const * start_stop = (scsi_start_stop_unit_t const *) scsi_cmd;
|
||||
tud_msc_start_stop_cb(lun, start_stop->power_condition, start_stop->start, start_stop->load_eject);
|
||||
if ( !tud_msc_start_stop_cb(lun, start_stop->power_condition, start_stop->start, start_stop->load_eject) )
|
||||
{
|
||||
// Failed status response
|
||||
resplen = - 1;
|
||||
|
||||
// If sense key is not set by callback, default to Logical Unit Not Ready, Cause Not Reportable
|
||||
if ( _mscd_itf.sense_key == 0 ) tud_msc_set_sense(lun, SCSI_SENSE_NOT_READY, 0x04, 0x00);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -417,7 +424,7 @@ bool mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t
|
||||
// failed but senskey is not set: default to Illegal Request
|
||||
if ( p_msc->sense_key == 0 ) tud_msc_set_sense(p_cbw->lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
|
||||
|
||||
/// Stall bulk In if needed
|
||||
// Stall bulk In if needed
|
||||
if (p_cbw->total_bytes) usbd_edpt_stall(rhport, p_msc->ep_in);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -131,7 +131,7 @@ TU_ATTR_WEAK uint8_t tud_msc_get_maxlun_cb(void);
|
||||
// Invoked when received Start Stop Unit command
|
||||
// - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage
|
||||
// - Start = 1 : active mode, if load_eject = 1 : load disk storage
|
||||
TU_ATTR_WEAK void tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject);
|
||||
TU_ATTR_WEAK bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject);
|
||||
|
||||
// Invoked when Read10 command is complete
|
||||
TU_ATTR_WEAK void tud_msc_read10_complete_cb(uint8_t lun);
|
||||
@@ -151,12 +151,12 @@ TU_ATTR_WEAK bool tud_msc_is_writable_cb(uint8_t lun);
|
||||
//--------------------------------------------------------------------+
|
||||
// Internal Class Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
void mscd_init(void);
|
||||
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_request_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_reset(uint8_t rhport);
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "tusb_option.h"
|
||||
|
||||
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_VENDOR)
|
||||
|
||||
#include "vendor_device.h"
|
||||
#include "device/usbd_pvt.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF
|
||||
//--------------------------------------------------------------------+
|
||||
typedef struct
|
||||
{
|
||||
uint8_t itf_num;
|
||||
uint8_t ep_in;
|
||||
uint8_t ep_out;
|
||||
|
||||
/*------------- From this point, data is not cleared by bus reset -------------*/
|
||||
tu_fifo_t rx_ff;
|
||||
tu_fifo_t tx_ff;
|
||||
|
||||
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
|
||||
|
||||
// Endpoint Transfer buffer
|
||||
CFG_TUSB_MEM_ALIGN uint8_t epout_buf[CFG_TUD_VENDOR_EPSIZE];
|
||||
CFG_TUSB_MEM_ALIGN uint8_t epin_buf[CFG_TUD_VENDOR_EPSIZE];
|
||||
} vendord_interface_t;
|
||||
|
||||
CFG_TUSB_MEM_SECTION static vendord_interface_t _vendord_itf[CFG_TUD_VENDOR];
|
||||
|
||||
#define ITF_MEM_RESET_SIZE offsetof(vendord_interface_t, rx_ff)
|
||||
|
||||
|
||||
|
||||
bool tud_vendor_n_mounted (uint8_t itf)
|
||||
{
|
||||
return _vendord_itf[itf].ep_in && _vendord_itf[itf].ep_out;
|
||||
}
|
||||
|
||||
uint32_t tud_vendor_n_available (uint8_t itf)
|
||||
{
|
||||
return tu_fifo_count(&_vendord_itf[itf].rx_ff);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Read API
|
||||
//--------------------------------------------------------------------+
|
||||
static void _prep_out_transaction (vendord_interface_t* p_itf)
|
||||
{
|
||||
// skip if previous transfer not complete
|
||||
if ( usbd_edpt_busy(TUD_OPT_RHPORT, p_itf->ep_out) ) return;
|
||||
|
||||
// Prepare for incoming data but only allow what we can store in the ring buffer.
|
||||
uint16_t max_read = tu_fifo_remaining(&p_itf->rx_ff);
|
||||
if ( max_read >= CFG_TUD_VENDOR_EPSIZE )
|
||||
{
|
||||
usbd_edpt_xfer(TUD_OPT_RHPORT, p_itf->ep_out, p_itf->epout_buf, CFG_TUD_VENDOR_EPSIZE);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t tud_vendor_n_read (uint8_t itf, void* buffer, uint32_t bufsize)
|
||||
{
|
||||
vendord_interface_t* p_itf = &_vendord_itf[itf];
|
||||
uint32_t num_read = tu_fifo_read_n(&p_itf->rx_ff, buffer, bufsize);
|
||||
_prep_out_transaction(p_itf);
|
||||
return num_read;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Write API
|
||||
//--------------------------------------------------------------------+
|
||||
static bool maybe_transmit(vendord_interface_t* p_itf)
|
||||
{
|
||||
// skip if previous transfer not complete
|
||||
TU_VERIFY( !usbd_edpt_busy(TUD_OPT_RHPORT, p_itf->ep_in) );
|
||||
|
||||
uint16_t count = tu_fifo_read_n(&p_itf->tx_ff, p_itf->epin_buf, CFG_TUD_VENDOR_EPSIZE);
|
||||
if (count > 0)
|
||||
{
|
||||
TU_ASSERT( usbd_edpt_xfer(TUD_OPT_RHPORT, p_itf->ep_in, p_itf->epin_buf, count) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t tud_vendor_n_write (uint8_t itf, void const* buffer, uint32_t bufsize)
|
||||
{
|
||||
vendord_interface_t* p_itf = &_vendord_itf[itf];
|
||||
uint16_t ret = tu_fifo_write_n(&p_itf->tx_ff, buffer, bufsize);
|
||||
maybe_transmit(p_itf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USBD Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
void vendord_init(void)
|
||||
{
|
||||
tu_memclr(_vendord_itf, sizeof(_vendord_itf));
|
||||
|
||||
for(uint8_t i=0; i<CFG_TUD_VENDOR; i++)
|
||||
{
|
||||
vendord_interface_t* p_itf = &_vendord_itf[i];
|
||||
|
||||
// config fifo
|
||||
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, osal_mutex_create(&p_itf->rx_ff_mutex));
|
||||
tu_fifo_config_mutex(&p_itf->tx_ff, osal_mutex_create(&p_itf->tx_ff_mutex));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void vendord_reset(uint8_t rhport)
|
||||
{
|
||||
(void) rhport;
|
||||
|
||||
for(uint8_t i=0; i<CFG_TUD_VENDOR; i++)
|
||||
{
|
||||
vendord_interface_t* p_itf = &_vendord_itf[i];
|
||||
|
||||
tu_memclr(p_itf, ITF_MEM_RESET_SIZE);
|
||||
tu_fifo_clear(&p_itf->rx_ff);
|
||||
tu_fifo_clear(&p_itf->tx_ff);
|
||||
}
|
||||
}
|
||||
|
||||
bool vendord_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_len)
|
||||
{
|
||||
// Find available interface
|
||||
vendord_interface_t* p_vendor = NULL;
|
||||
for(uint8_t i=0; i<CFG_TUD_VENDOR; i++)
|
||||
{
|
||||
if ( _vendord_itf[i].ep_in == 0 && _vendord_itf[i].ep_out == 0 )
|
||||
{
|
||||
p_vendor = &_vendord_itf[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
TU_VERIFY(p_vendor);
|
||||
|
||||
// Open endpoint pair with usbd helper
|
||||
TU_ASSERT(usbd_open_edpt_pair(rhport, tu_desc_next(itf_desc), 2, TUSB_XFER_BULK, &p_vendor->ep_out, &p_vendor->ep_in));
|
||||
|
||||
p_vendor->itf_num = itf_desc->bInterfaceNumber;
|
||||
(*p_len) = sizeof(tusb_desc_interface_t) + 2*sizeof(tusb_desc_endpoint_t);
|
||||
|
||||
// Prepare for incoming data
|
||||
TU_ASSERT(usbd_edpt_xfer(rhport, p_vendor->ep_out, p_vendor->epout_buf, sizeof(p_vendor->epout_buf)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool vendord_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes)
|
||||
{
|
||||
(void) rhport;
|
||||
(void) result;
|
||||
|
||||
// TODO Support multiple interfaces
|
||||
uint8_t const itf = 0;
|
||||
vendord_interface_t* p_itf = &_vendord_itf[itf];
|
||||
|
||||
if ( ep_addr == p_itf->ep_out )
|
||||
{
|
||||
// Receive new data
|
||||
tu_fifo_write_n(&p_itf->rx_ff, p_itf->epout_buf, xferred_bytes);
|
||||
|
||||
// Invoked callback if any
|
||||
if (tud_vendor_rx_cb) tud_vendor_rx_cb(itf);
|
||||
|
||||
_prep_out_transaction(p_itf);
|
||||
}
|
||||
else if ( ep_addr == p_itf->ep_in )
|
||||
{
|
||||
// Send complete, try to send more if possible
|
||||
maybe_transmit(p_itf);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
||||
*
|
||||
* 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_VENDOR_DEVICE_H_
|
||||
#define _TUSB_VENDOR_DEVICE_H_
|
||||
|
||||
#include "common/tusb_common.h"
|
||||
#include "device/usbd.h"
|
||||
|
||||
#ifndef CFG_TUD_VENDOR_EPSIZE
|
||||
#define CFG_TUD_VENDOR_EPSIZE 64
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_VENDOR_RX_BUFSIZE
|
||||
#define CFG_TUD_VENDOR_RX_BUFSIZE 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_VENDOR_TX_BUFSIZE
|
||||
#define CFG_TUD_VENDOR_TX_BUFSIZE 0
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Application API (Multiple Interfaces)
|
||||
//--------------------------------------------------------------------+
|
||||
bool tud_vendor_n_mounted (uint8_t itf);
|
||||
uint32_t tud_vendor_n_available (uint8_t itf);
|
||||
uint32_t tud_vendor_n_read (uint8_t itf, void* buffer, uint32_t bufsize);
|
||||
uint32_t tud_vendor_n_write (uint8_t itf, void const* buffer, uint32_t bufsize);
|
||||
|
||||
static inline uint32_t tud_vendor_n_write_str (uint8_t itf, char const* str);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Application API (Single Port)
|
||||
//--------------------------------------------------------------------+
|
||||
static inline bool tud_vendor_mounted (void);
|
||||
static inline uint32_t tud_vendor_available (void);
|
||||
static inline uint32_t tud_vendor_read (void* buffer, uint32_t bufsize);
|
||||
static inline uint32_t tud_vendor_write (void const* buffer, uint32_t bufsize);
|
||||
static inline uint32_t tud_vendor_write_str (char const* str);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Application Callback API (weak is optional)
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Invoked when received new data
|
||||
TU_ATTR_WEAK void tud_vendor_rx_cb(uint8_t itf);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Inline Functions
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
static inline uint32_t tud_vendor_n_write_str (uint8_t itf, char const* str)
|
||||
{
|
||||
return tud_vendor_n_write(itf, str, strlen(str));
|
||||
}
|
||||
|
||||
static inline bool tud_vendor_mounted (void)
|
||||
{
|
||||
return tud_vendor_n_mounted(0);
|
||||
}
|
||||
|
||||
static inline uint32_t tud_vendor_available (void)
|
||||
{
|
||||
return tud_vendor_n_available(0);
|
||||
}
|
||||
|
||||
static inline uint32_t tud_vendor_read (void* buffer, uint32_t bufsize)
|
||||
{
|
||||
return tud_vendor_n_read(0, buffer, bufsize);
|
||||
}
|
||||
|
||||
static inline uint32_t tud_vendor_write (void const* buffer, uint32_t bufsize)
|
||||
{
|
||||
return tud_vendor_n_write(0, buffer, bufsize);
|
||||
}
|
||||
|
||||
static inline uint32_t tud_vendor_write_str (char const* str)
|
||||
{
|
||||
return tud_vendor_n_write_str(0, str);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// 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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _TUSB_VENDOR_DEVICE_H_ */
|
||||
@@ -146,9 +146,10 @@ static inline bool tu_bit_test (uint32_t value, uint8_t n) { return (value &
|
||||
* Nth position is the same as the number of arguments
|
||||
* - ##__VA_ARGS__ is used to deal with 0 paramerter (swallows comma)
|
||||
*------------------------------------------------------------------*/
|
||||
#ifndef VA_ARGS_NUM_
|
||||
#ifndef TU_ARGS_NUM
|
||||
|
||||
#define TU_ARGS_NUM(...) NARG_(_0, ##__VA_ARGS__,_RSEQ_N())
|
||||
|
||||
#define VA_ARGS_NUM_(...) NARG_(_0, ##__VA_ARGS__,_RSEQ_N())
|
||||
#define NARG_(...) _GET_NTH_ARG(__VA_ARGS__)
|
||||
#define _GET_NTH_ARG( \
|
||||
_1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \
|
||||
|
||||
@@ -68,8 +68,7 @@ typedef enum
|
||||
TUSB_DIR_IN_MASK = 0x80
|
||||
}tusb_dir_t;
|
||||
|
||||
|
||||
/// USB Descriptor Types (section 9.4 table 9-5)
|
||||
/// USB Descriptor Types
|
||||
typedef enum
|
||||
{
|
||||
TUSB_DESC_DEVICE = 0x01,
|
||||
@@ -84,29 +83,35 @@ typedef enum
|
||||
TUSB_DESC_DEBUG = 0x0A,
|
||||
TUSB_DESC_INTERFACE_ASSOCIATION = 0x0B,
|
||||
|
||||
TUSB_DESC_BOS = 0x0F,
|
||||
TUSB_DESC_DEVICE_CAPABILITY = 0x10,
|
||||
|
||||
// Class Specific Descriptor
|
||||
TUSB_DESC_CS_DEVICE = 0x21,
|
||||
TUSB_DESC_CS_CONFIGURATION = 0x22,
|
||||
TUSB_DESC_CS_STRING = 0x23,
|
||||
TUSB_DESC_CS_INTERFACE = 0x24,
|
||||
TUSB_DESC_CS_ENDPOINT = 0x25,
|
||||
|
||||
TUSB_DESC_SUPERSPEED_ENDPOINT_COMPANION = 0x30,
|
||||
TUSB_DESC_SUPERSPEED_ISO_ENDPOINT_COMPANION = 0x31
|
||||
}tusb_desc_type_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TUSB_REQ_GET_STATUS =0 , ///< 0
|
||||
TUSB_REQ_CLEAR_FEATURE , ///< 1
|
||||
TUSB_REQ_RESERVED , ///< 2
|
||||
TUSB_REQ_SET_FEATURE , ///< 3
|
||||
TUSB_REQ_RESERVED2 , ///< 4
|
||||
TUSB_REQ_SET_ADDRESS , ///< 5
|
||||
TUSB_REQ_GET_DESCRIPTOR , ///< 6
|
||||
TUSB_REQ_SET_DESCRIPTOR , ///< 7
|
||||
TUSB_REQ_GET_CONFIGURATION , ///< 8
|
||||
TUSB_REQ_SET_CONFIGURATION , ///< 9
|
||||
TUSB_REQ_GET_INTERFACE , ///< 10
|
||||
TUSB_REQ_SET_INTERFACE , ///< 11
|
||||
TUSB_REQ_SYNCH_FRAME ///< 12
|
||||
TUSB_REQ_GET_STATUS = 0 ,
|
||||
TUSB_REQ_CLEAR_FEATURE = 1 ,
|
||||
TUSB_REQ_RESERVED = 2 ,
|
||||
TUSB_REQ_SET_FEATURE = 3 ,
|
||||
TUSB_REQ_RESERVED2 = 4 ,
|
||||
TUSB_REQ_SET_ADDRESS = 5 ,
|
||||
TUSB_REQ_GET_DESCRIPTOR = 6 ,
|
||||
TUSB_REQ_SET_DESCRIPTOR = 7 ,
|
||||
TUSB_REQ_GET_CONFIGURATION = 8 ,
|
||||
TUSB_REQ_SET_CONFIGURATION = 9 ,
|
||||
TUSB_REQ_GET_INTERFACE = 10 ,
|
||||
TUSB_REQ_SET_INTERFACE = 11 ,
|
||||
TUSB_REQ_SYNCH_FRAME = 12
|
||||
}tusb_request_code_t;
|
||||
|
||||
typedef enum
|
||||
@@ -168,6 +173,26 @@ typedef enum
|
||||
MISC_PROTOCOL_IAD = 1
|
||||
}misc_protocol_type_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DEVICE_CAPABILITY_WIRELESS_USB = 0x01,
|
||||
DEVICE_CAPABILITY_USB20_EXTENSION = 0x02,
|
||||
DEVICE_CAPABILITY_SUPERSPEED_USB = 0x03,
|
||||
DEVICE_CAPABILITY_CONTAINER_id = 0x04,
|
||||
DEVICE_CAPABILITY_PLATFORM = 0x05,
|
||||
DEVICE_CAPABILITY_POWER_DELIVERY = 0x06,
|
||||
DEVICE_CAPABILITY_BATTERY_INFO = 0x07,
|
||||
DEVICE_CAPABILITY_PD_CONSUMER_PORT = 0x08,
|
||||
DEVICE_CAPABILITY_PD_PROVIDER_PORT = 0x09,
|
||||
DEVICE_CAPABILITY_SUPERSPEED_PLUS = 0x0A,
|
||||
DEVICE_CAPABILITY_PRECESION_TIME_MEASUREMENT = 0x0B,
|
||||
DEVICE_CAPABILITY_WIRELESS_USB_EXT = 0x0C,
|
||||
DEVICE_CAPABILITY_BILLBOARD = 0x0D,
|
||||
DEVICE_CAPABILITY_AUTHENTICATION = 0x0E,
|
||||
DEVICE_CAPABILITY_BILLBOARD_EX = 0x0F,
|
||||
DEVICE_CAPABILITY_CONFIGURATION_SUMMARY = 0x10
|
||||
}device_capability_type_t;
|
||||
|
||||
enum {
|
||||
TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP = TU_BIT(5),
|
||||
TUSB_DESC_CONFIG_ATT_SELF_POWERED = TU_BIT(6),
|
||||
@@ -201,11 +226,25 @@ enum
|
||||
INTERFACE_INVALID_NUMBER = 0xff
|
||||
};
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MS_OS_20_SET_HEADER_DESCRIPTOR = 0x00,
|
||||
MS_OS_20_SUBSET_HEADER_CONFIGURATION = 0x01,
|
||||
MS_OS_20_SUBSET_HEADER_FUNCTION = 0x02,
|
||||
MS_OS_20_FEATURE_COMPATBLE_ID = 0x03,
|
||||
MS_OS_20_FEATURE_REG_PROPERTY = 0x04,
|
||||
MS_OS_20_FEATURE_MIN_RESUME_TIME = 0x05,
|
||||
MS_OS_20_FEATURE_MODEL_ID = 0x06,
|
||||
MS_OS_20_FEATURE_CCGP_DEVICE = 0x07,
|
||||
MS_OS_20_FEATURE_VENDOR_REVISION = 0x08
|
||||
} microsoft_os_20_type_t;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// STANDARD DESCRIPTORS
|
||||
// USB Descriptors
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
/// USB Standard Device Descriptor (section 9.6.1, table 9-8)
|
||||
/// USB Device Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength ; ///< Size of this descriptor in bytes.
|
||||
@@ -227,7 +266,16 @@ typedef struct TU_ATTR_PACKED
|
||||
uint8_t bNumConfigurations ; ///< Number of possible configurations.
|
||||
} tusb_desc_device_t;
|
||||
|
||||
/// USB Standard Configuration Descriptor (section 9.6.1 table 9-10) */
|
||||
// USB Binary Device Object Store (BOS) Descriptor
|
||||
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
|
||||
uint8_t bNumDeviceCaps ; ///< Number of device capability descriptors in the BOS
|
||||
} tusb_desc_bos_t;
|
||||
|
||||
/// USB Configuration Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength ; ///< Size of this descriptor in bytes
|
||||
@@ -241,7 +289,7 @@ typedef struct TU_ATTR_PACKED
|
||||
uint8_t bMaxPower ; ///< Maximum power consumption of the USB device from the bus in this specific configuration when the device is fully operational. Expressed in 2 mA units (i.e., 50 = 100 mA).
|
||||
} tusb_desc_configuration_t;
|
||||
|
||||
/// USB Standard Interface Descriptor (section 9.6.1 table 9-12)
|
||||
/// USB Interface Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength ; ///< Size of this descriptor in bytes
|
||||
@@ -256,7 +304,7 @@ typedef struct TU_ATTR_PACKED
|
||||
uint8_t iInterface ; ///< Index of string descriptor describing this interface
|
||||
} tusb_desc_interface_t;
|
||||
|
||||
/// USB Standard Endpoint Descriptor (section 9.6.1 table 9-13)
|
||||
/// USB Endpoint Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength ; ///< Size of this descriptor in bytes
|
||||
@@ -280,7 +328,7 @@ typedef struct TU_ATTR_PACKED
|
||||
uint8_t bInterval ; ///< Interval for polling endpoint for data transfers. Expressed in frames or microframes depending on the device operating speed (i.e., either 1 millisecond or 125 us units). \n- For full-/high-speed isochronous endpoints, this value must be in the range from 1 to 16. The bInterval value is used as the exponent for a \f$ 2^(bInterval-1) \f$ value; e.g., a bInterval of 4 means a period of 8 (\f$ 2^(4-1) \f$). \n- For full-/low-speed interrupt endpoints, the value of this field may be from 1 to 255. \n- For high-speed interrupt endpoints, the bInterval value is used as the exponent for a \f$ 2^(bInterval-1) \f$ value; e.g., a bInterval of 4 means a period of 8 (\f$ 2^(4-1) \f$) . This value must be from 1 to 16. \n- For high-speed bulk/control OUT endpoints, the bInterval must specify the maximum NAK rate of the endpoint. A value of 0 indicates the endpoint never NAKs. Other values indicate at most 1 NAK each bInterval number of microframes. This value must be in the range from 0 to 255. \n Refer to Chapter 5 of USB 2.0 specification for more information.
|
||||
} tusb_desc_endpoint_t;
|
||||
|
||||
/// USB Other Speed Configuration Descriptor (section 9.6.1 table 9-11)
|
||||
/// USB Other Speed Configuration Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength ; ///< Size of descriptor
|
||||
@@ -294,7 +342,7 @@ typedef struct TU_ATTR_PACKED
|
||||
uint8_t bMaxPower ; ///< Same as Configuration descriptor
|
||||
} tusb_desc_other_speed_t;
|
||||
|
||||
/// USB Device Qualifier Descriptor (section 9.6.1 table 9-9)
|
||||
/// USB Device Qualifier Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength ; ///< Size of descriptor
|
||||
@@ -325,13 +373,7 @@ typedef struct TU_ATTR_PACKED
|
||||
uint8_t iFunction ; ///< Index of the string descriptor describing the interface association.
|
||||
} tusb_desc_interface_assoc_t;
|
||||
|
||||
/// USB Header Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength ; ///< Size of this descriptor in bytes
|
||||
uint8_t bDescriptorType ; ///< Descriptor Type
|
||||
} tusb_desc_header_t;
|
||||
|
||||
// USB String Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength ; ///< Size of this descriptor in bytes
|
||||
@@ -339,6 +381,25 @@ typedef struct TU_ATTR_PACKED
|
||||
uint16_t unicode_string[];
|
||||
} tusb_desc_string_t;
|
||||
|
||||
// USB Binary Device Object Store (BOS)
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType ;
|
||||
uint8_t bDevCapabilityType;
|
||||
uint8_t bReserved;
|
||||
uint8_t PlatformCapabilityUUID[16];
|
||||
uint8_t CapabilityData[];
|
||||
} tusb_desc_bos_platform_t;
|
||||
|
||||
// USB WebuSB URL Descriptor
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bScheme;
|
||||
char url[];
|
||||
} tusb_desc_webusb_url_t;
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Types
|
||||
@@ -415,7 +476,7 @@ static inline uint8_t tu_desc_len(void const* desc)
|
||||
#define TUD_DESC_STR_HEADER(_chr_count) ( (uint16_t) ( (TUSB_DESC_STRING << 8 ) | TUD_DESC_STRLEN(_chr_count)) )
|
||||
|
||||
// Convert comma-separated string to descriptor unicode format
|
||||
#define TUD_DESC_STRCONV( ... ) (const uint16_t[]) { TUD_DESC_STR_HEADER(VA_ARGS_NUM_(__VA_ARGS__)), __VA_ARGS__ }
|
||||
#define TUD_DESC_STRCONV( ... ) (const uint16_t[]) { TUD_DESC_STR_HEADER(TU_ARGS_NUM(__VA_ARGS__)), __VA_ARGS__ }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@
|
||||
//--------------------------------------------------------------------+
|
||||
#if CFG_TUSB_DEBUG
|
||||
#include <stdio.h>
|
||||
#define _MESS_ERR(_err) printf("%s: %d: failed, error = %s\n", __func__, __LINE__, tusb_strerr[_err])
|
||||
#define _MESS_FAILED() printf("%s: %d: failed\n", __func__, __LINE__)
|
||||
#define _MESS_ERR(_err) printf("%s: %d: failed, error = %s\n", __func__, __LINE__, tusb_strerr[_err])
|
||||
#define _MESS_FAILED() printf("%s: %d: failed\n", __func__, __LINE__)
|
||||
#else
|
||||
#define _MESS_ERR(_err)
|
||||
#define _MESS_FAILED()
|
||||
@@ -61,11 +61,11 @@
|
||||
// Halt CPU (breakpoint) when hitting error, only apply for Cortex M3, M4, M7
|
||||
#if defined(__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__)
|
||||
|
||||
#define TU_BREAKPOINT() \
|
||||
do {\
|
||||
volatile uint32_t* ARM_CM_DHCSR = ((volatile uint32_t*) 0xE000EDF0UL); /* Cortex M CoreDebug->DHCSR */ \
|
||||
if ( (*ARM_CM_DHCSR) & 1UL ) __asm("BKPT #0\n"); /* Only halt mcu if debugger is attached */\
|
||||
} while(0)
|
||||
#define TU_BREAKPOINT() do \
|
||||
{ \
|
||||
volatile uint32_t* ARM_CM_DHCSR = ((volatile uint32_t*) 0xE000EDF0UL); /* Cortex M CoreDebug->DHCSR */ \
|
||||
if ( (*ARM_CM_DHCSR) & 1UL ) __asm("BKPT #0\n"); /* Only halt mcu if debugger is attached */ \
|
||||
} while(0)
|
||||
|
||||
#else
|
||||
#define TU_BREAKPOINT()
|
||||
@@ -80,22 +80,23 @@
|
||||
#define GET_4TH_ARG(arg1, arg2, arg3, arg4, ...) arg4
|
||||
|
||||
/*------------- Generator for TU_VERIFY and TU_VERIFY_HDLR -------------*/
|
||||
#define TU_VERIFY_DEFINE(_cond, _handler, _ret) do { if ( !(_cond) ) { _handler; return _ret; } } while(0)
|
||||
#define TU_VERIFY_DEFINE(_cond, _handler, _ret) do \
|
||||
{ \
|
||||
if ( !(_cond) ) { _handler; return _ret; } \
|
||||
} while(0)
|
||||
|
||||
/*------------- Generator for TU_VERIFY_ERR and TU_VERIFY_ERR_HDLR -------------*/
|
||||
#define TU_VERIFY_ERR_DEF2(_error, _handler) \
|
||||
do { \
|
||||
uint32_t _err = (uint32_t)(_error); \
|
||||
if ( 0 != _err ) { _MESS_ERR(_err); _handler; return _err; }\
|
||||
} while(0)
|
||||
|
||||
#define TU_VERIFY_ERR_DEF3(_error, _handler, _ret) \
|
||||
do { \
|
||||
uint32_t _err = (uint32_t)(_error); \
|
||||
if ( 0 != _err ) { _MESS_ERR(_err); _handler; return _ret; }\
|
||||
} while(0)
|
||||
|
||||
#define TU_VERIFY_ERR_DEF2(_error, _handler) do \
|
||||
{ \
|
||||
uint32_t _err = (uint32_t)(_error); \
|
||||
if ( 0 != _err ) { _MESS_ERR(_err); _handler; return _err; } \
|
||||
} while(0)
|
||||
|
||||
#define TU_VERIFY_ERR_DEF3(_error, _handler, _ret) do \
|
||||
{ \
|
||||
uint32_t _err = (uint32_t)(_error); \
|
||||
if ( 0 != _err ) { _MESS_ERR(_err); _handler; return _ret; } \
|
||||
} while(0)
|
||||
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
@@ -141,7 +142,6 @@
|
||||
#define TU_VERIFY_ERR_HDLR(...) GET_4TH_ARG(__VA_ARGS__, TU_VERIFY_ERR_HDLR_3ARGS, TU_VERIFY_ERR_HDLR_2ARGS)(__VA_ARGS__)
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* ASSERT
|
||||
* basically TU_VERIFY with TU_BREAKPOINT() as handler
|
||||
|
||||
@@ -43,20 +43,20 @@
|
||||
typedef struct {
|
||||
struct TU_ATTR_PACKED
|
||||
{
|
||||
volatile uint8_t connected : 1;
|
||||
volatile uint8_t configured : 1;
|
||||
volatile uint8_t suspended : 1;
|
||||
volatile uint8_t connected : 1;
|
||||
volatile uint8_t configured : 1;
|
||||
volatile uint8_t suspended : 1;
|
||||
|
||||
uint8_t remote_wakeup_en : 1; // enable/disable by host
|
||||
uint8_t remote_wakeup_support : 1; // configuration descriptor's attribute
|
||||
uint8_t self_powered : 1; // configuration descriptor's attribute
|
||||
uint8_t remote_wakeup_en : 1; // enable/disable by host
|
||||
uint8_t remote_wakeup_support : 1; // configuration descriptor's attribute
|
||||
uint8_t self_powered : 1; // configuration descriptor's attribute
|
||||
};
|
||||
|
||||
uint8_t ep_busy_map[2]; // bit mask for busy endpoint
|
||||
uint8_t ep_stall_map[2]; // bit map for stalled endpoint
|
||||
|
||||
uint8_t itf2drv[16]; // map interface number to driver (0xff is invalid)
|
||||
uint8_t ep2drv[8][2]; // map endpoint to driver ( 0xff is invalid )
|
||||
uint8_t itf2drv[16]; // map interface number to driver (0xff is invalid)
|
||||
uint8_t ep2drv[8][2]; // map endpoint to driver ( 0xff is invalid )
|
||||
}usbd_device_t;
|
||||
|
||||
static usbd_device_t _usbd_dev = { 0 };
|
||||
@@ -67,80 +67,80 @@ static usbd_device_t _usbd_dev = { 0 };
|
||||
typedef struct {
|
||||
uint8_t class_code;
|
||||
|
||||
void (* init ) (void);
|
||||
bool (* open ) (uint8_t rhport, tusb_desc_interface_t const * desc_intf, uint16_t* p_length);
|
||||
bool (* control_request ) (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool (* control_request_complete ) (uint8_t rhport, tusb_control_request_t const * request);
|
||||
bool (* xfer_cb ) (uint8_t rhport, uint8_t ep_addr, xfer_result_t, uint32_t);
|
||||
void (* sof ) (uint8_t rhport);
|
||||
void (* reset ) (uint8_t);
|
||||
void (* init ) (void);
|
||||
void (* reset ) (uint8_t rhport);
|
||||
bool (* open ) (uint8_t rhport, tusb_desc_interface_t const * desc_intf, uint16_t* p_length);
|
||||
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);
|
||||
} usbd_class_driver_t;
|
||||
|
||||
static usbd_class_driver_t const usbd_class_drivers[] =
|
||||
{
|
||||
#if CFG_TUD_CDC
|
||||
{
|
||||
.class_code = TUSB_CLASS_CDC,
|
||||
.init = cdcd_init,
|
||||
.open = cdcd_open,
|
||||
.control_request = cdcd_control_request,
|
||||
.control_request_complete = cdcd_control_request_complete,
|
||||
.xfer_cb = cdcd_xfer_cb,
|
||||
.sof = NULL,
|
||||
.reset = cdcd_reset
|
||||
},
|
||||
{
|
||||
.class_code = TUSB_CLASS_CDC,
|
||||
.init = cdcd_init,
|
||||
.reset = cdcd_reset,
|
||||
.open = cdcd_open,
|
||||
.control_request = cdcd_control_request,
|
||||
.control_complete = cdcd_control_complete,
|
||||
.xfer_cb = cdcd_xfer_cb,
|
||||
.sof = NULL
|
||||
},
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_MSC
|
||||
{
|
||||
.class_code = TUSB_CLASS_MSC,
|
||||
.init = mscd_init,
|
||||
.open = mscd_open,
|
||||
.control_request = mscd_control_request,
|
||||
.control_request_complete = mscd_control_request_complete,
|
||||
.xfer_cb = mscd_xfer_cb,
|
||||
.sof = NULL,
|
||||
.reset = mscd_reset
|
||||
},
|
||||
{
|
||||
.class_code = TUSB_CLASS_MSC,
|
||||
.init = mscd_init,
|
||||
.reset = mscd_reset,
|
||||
.open = mscd_open,
|
||||
.control_request = mscd_control_request,
|
||||
.control_complete = mscd_control_complete,
|
||||
.xfer_cb = mscd_xfer_cb,
|
||||
.sof = NULL
|
||||
},
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_HID
|
||||
{
|
||||
.class_code = TUSB_CLASS_HID,
|
||||
.init = hidd_init,
|
||||
.open = hidd_open,
|
||||
.control_request = hidd_control_request,
|
||||
.control_request_complete = hidd_control_request_complete,
|
||||
.xfer_cb = hidd_xfer_cb,
|
||||
.sof = NULL,
|
||||
.reset = hidd_reset
|
||||
},
|
||||
{
|
||||
.class_code = TUSB_CLASS_HID,
|
||||
.init = hidd_init,
|
||||
.reset = hidd_reset,
|
||||
.open = hidd_open,
|
||||
.control_request = hidd_control_request,
|
||||
.control_complete = hidd_control_complete,
|
||||
.xfer_cb = hidd_xfer_cb,
|
||||
.sof = NULL
|
||||
},
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_MIDI
|
||||
{
|
||||
.class_code = TUSB_CLASS_AUDIO,
|
||||
.init = midid_init,
|
||||
.open = midid_open,
|
||||
.control_request = midid_control_request,
|
||||
.control_request_complete = midid_control_request_complete,
|
||||
.xfer_cb = midid_xfer_cb,
|
||||
.sof = NULL,
|
||||
.reset = midid_reset
|
||||
},
|
||||
{
|
||||
.class_code = TUSB_CLASS_AUDIO,
|
||||
.init = midid_init,
|
||||
.open = midid_open,
|
||||
.reset = midid_reset,
|
||||
.control_request = midid_control_request,
|
||||
.control_complete = midid_control_complete,
|
||||
.xfer_cb = midid_xfer_cb,
|
||||
.sof = NULL
|
||||
},
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_CUSTOM_CLASS
|
||||
{
|
||||
.class_code = TUSB_CLASS_VENDOR_SPECIFIC,
|
||||
.init = cusd_init,
|
||||
.open = cusd_open,
|
||||
.control_request = cusd_control_request,
|
||||
.control_request_complete = cusd_control_request_complete,
|
||||
.xfer_cb = cusd_xfer_cb,
|
||||
.sof = NULL,
|
||||
.reset = cusd_reset
|
||||
},
|
||||
#if CFG_TUD_VENDOR
|
||||
{
|
||||
.class_code = TUSB_CLASS_VENDOR_SPECIFIC,
|
||||
.init = vendord_init,
|
||||
.reset = vendord_reset,
|
||||
.open = vendord_open,
|
||||
.control_request = tud_vendor_control_request_cb,
|
||||
.control_complete = tud_vendor_control_complete_cb,
|
||||
.xfer_cb = vendord_xfer_cb,
|
||||
.sof = NULL
|
||||
},
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -237,7 +237,6 @@ static void usbd_reset(uint8_t rhport)
|
||||
while(1) // the mainloop
|
||||
{
|
||||
application_code();
|
||||
|
||||
tud_task(); // tinyusb device task
|
||||
}
|
||||
}
|
||||
@@ -347,6 +346,15 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
{
|
||||
usbd_control_set_complete_callback(NULL);
|
||||
|
||||
// Vendor request
|
||||
if ( p_request->bmRequestType_bit.type == TUSB_REQ_TYPE_VENDOR )
|
||||
{
|
||||
TU_VERIFY(tud_vendor_control_request_cb);
|
||||
|
||||
if (tud_vendor_control_complete_cb) usbd_control_set_complete_callback(tud_vendor_control_complete_cb);
|
||||
return tud_vendor_control_request_cb(rhport, p_request);
|
||||
}
|
||||
|
||||
switch ( p_request->bmRequestType_bit.recipient )
|
||||
{
|
||||
//------------- Device Requests e.g in enumeration -------------//
|
||||
@@ -370,7 +378,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
case TUSB_REQ_GET_CONFIGURATION:
|
||||
{
|
||||
uint8_t cfgnum = _usbd_dev.configured ? 1 : 0;
|
||||
usbd_control_xfer(rhport, p_request, &cfgnum, 1);
|
||||
tud_control_xfer(rhport, p_request, &cfgnum, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -382,7 +390,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
_usbd_dev.configured = cfg_num ? 1 : 0;
|
||||
|
||||
if ( cfg_num ) TU_ASSERT( process_set_config(rhport, cfg_num) );
|
||||
usbd_control_status(rhport, p_request);
|
||||
tud_control_status(rhport, p_request);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -396,7 +404,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
|
||||
// Host may enable remote wake up before suspending especially HID device
|
||||
_usbd_dev.remote_wakeup_en = true;
|
||||
usbd_control_status(rhport, p_request);
|
||||
tud_control_status(rhport, p_request);
|
||||
break;
|
||||
|
||||
case TUSB_REQ_CLEAR_FEATURE:
|
||||
@@ -405,7 +413,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
|
||||
// Host may disable remote wake up after resuming
|
||||
_usbd_dev.remote_wakeup_en = false;
|
||||
usbd_control_status(rhport, p_request);
|
||||
tud_control_status(rhport, p_request);
|
||||
break;
|
||||
|
||||
case TUSB_REQ_GET_STATUS:
|
||||
@@ -414,7 +422,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
// - Bit 0: Self Powered
|
||||
// - Bit 1: Remote Wakeup enabled
|
||||
uint16_t status = (_usbd_dev.self_powered ? 1 : 0) | (_usbd_dev.remote_wakeup_en ? 2 : 0);
|
||||
usbd_control_xfer(rhport, p_request, &status, 2);
|
||||
tud_control_xfer(rhport, p_request, &status, 2);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -431,10 +439,34 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
|
||||
TU_VERIFY(drvid < USBD_CLASS_DRIVER_COUNT);
|
||||
|
||||
usbd_control_set_complete_callback(usbd_class_drivers[drvid].control_request_complete );
|
||||
switch ( p_request->bRequest )
|
||||
{
|
||||
case TUSB_REQ_GET_INTERFACE:
|
||||
{
|
||||
// TODO not support alternate interface yet
|
||||
uint8_t alternate = 0;
|
||||
tud_control_xfer(rhport, p_request, &alternate, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
// stall control endpoint if driver return false
|
||||
return usbd_class_drivers[drvid].control_request(rhport, p_request);
|
||||
case TUSB_REQ_SET_INTERFACE:
|
||||
{
|
||||
uint8_t alternate = (uint8_t) p_request->wValue;
|
||||
|
||||
// TODO not support alternate interface yet
|
||||
TU_ASSERT(alternate == 0);
|
||||
|
||||
tud_control_status(rhport, p_request);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// forward to class driver
|
||||
// stall control endpoint if driver return false
|
||||
usbd_control_set_complete_callback(usbd_class_drivers[drvid].control_complete);
|
||||
TU_ASSERT(usbd_class_drivers[drvid].control_request(rhport, p_request));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -448,7 +480,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
case TUSB_REQ_GET_STATUS:
|
||||
{
|
||||
uint16_t status = usbd_edpt_stalled(rhport, tu_u16_low(p_request->wIndex)) ? 0x0001 : 0x0000;
|
||||
usbd_control_xfer(rhport, p_request, &status, 2);
|
||||
tud_control_xfer(rhport, p_request, &status, 2);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -457,7 +489,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
{
|
||||
usbd_edpt_clear_stall(rhport, tu_u16_low(p_request->wIndex));
|
||||
}
|
||||
usbd_control_status(rhport, p_request);
|
||||
tud_control_status(rhport, p_request);
|
||||
break;
|
||||
|
||||
case TUSB_REQ_SET_FEATURE:
|
||||
@@ -465,7 +497,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
{
|
||||
usbd_edpt_stall(rhport, tu_u16_low(p_request->wIndex));
|
||||
}
|
||||
usbd_control_status(rhport, p_request);
|
||||
tud_control_status(rhport, p_request);
|
||||
break;
|
||||
|
||||
// Unknown/Unsupported request
|
||||
@@ -520,7 +552,7 @@ static bool process_set_config(uint8_t rhport, uint8_t cfg_num)
|
||||
_usbd_dev.itf2drv[desc_itf->bInterfaceNumber] = drv_id;
|
||||
|
||||
uint16_t itf_len=0;
|
||||
TU_ASSERT( usbd_class_drivers[drv_id].open( rhport, desc_itf, &itf_len ) );
|
||||
TU_ASSERT( usbd_class_drivers[drv_id].open(rhport, desc_itf, &itf_len) );
|
||||
TU_ASSERT( itf_len >= sizeof(tusb_desc_interface_t) );
|
||||
|
||||
mark_interface_endpoint(_usbd_dev.ep2drv, p_desc, itf_len, drv_id);
|
||||
@@ -563,13 +595,29 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
|
||||
switch(desc_type)
|
||||
{
|
||||
case TUSB_DESC_DEVICE:
|
||||
return usbd_control_xfer(rhport, p_request, (void*) tud_descriptor_device_cb(), sizeof(tusb_desc_device_t));
|
||||
return tud_control_xfer(rhport, p_request, (void*) tud_descriptor_device_cb(), sizeof(tusb_desc_device_t));
|
||||
break;
|
||||
|
||||
case TUSB_DESC_BOS:
|
||||
{
|
||||
// requested by host if USB > 2.0 ( i.e 2.1 or 3.x )
|
||||
if (!tud_descriptor_bos_cb) return false;
|
||||
|
||||
tusb_desc_bos_t const* desc_bos = (tusb_desc_bos_t const*) tud_descriptor_bos_cb();
|
||||
uint16_t total_len;
|
||||
memcpy(&total_len, &desc_bos->wTotalLength, 2); // possibly mis-aligned memory
|
||||
|
||||
return tud_control_xfer(rhport, p_request, (void*) desc_bos, total_len);
|
||||
}
|
||||
break;
|
||||
|
||||
case TUSB_DESC_CONFIGURATION:
|
||||
{
|
||||
tusb_desc_configuration_t const* desc_config = (tusb_desc_configuration_t const*) tud_descriptor_configuration_cb(desc_index);
|
||||
return usbd_control_xfer(rhport, p_request, (void*) desc_config, desc_config->wTotalLength);
|
||||
uint16_t total_len;
|
||||
memcpy(&total_len, &desc_config->wTotalLength, 2); // possibly mis-aligned memory
|
||||
|
||||
return tud_control_xfer(rhport, p_request, (void*) desc_config, total_len);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -577,8 +625,8 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
|
||||
// String Descriptor always uses the desc set from user
|
||||
if ( desc_index == 0xEE )
|
||||
{
|
||||
// The 0xEE index string is a Microsoft USB extension.
|
||||
// It can be used to tell Windows what driver it should use for the device !!!
|
||||
// The 0xEE index string is a Microsoft OS Descriptors.
|
||||
// https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
@@ -586,7 +634,7 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
|
||||
TU_ASSERT(desc_str);
|
||||
|
||||
// first byte of descriptor is its size
|
||||
return usbd_control_xfer(rhport, p_request, (void*) desc_str, desc_str[0]);
|
||||
return tud_control_xfer(rhport, p_request, (void*) desc_str, desc_str[0]);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -59,6 +59,14 @@ static inline bool tud_ready(void)
|
||||
// Remote wake up host, only if suspended and enabled by host
|
||||
bool tud_remote_wakeup(void);
|
||||
|
||||
// Carry out Data and Status stage of control transfer
|
||||
// - If len = 0, it is equivalent to sending status only
|
||||
// - If len > wLength : it will be truncated
|
||||
bool tud_control_xfer(uint8_t rhport, tusb_control_request_t const * request, void* buffer, uint16_t len);
|
||||
|
||||
// Send STATUS (zero length) packet
|
||||
bool tud_control_status(uint8_t rhport, tusb_control_request_t const * request);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Application Callbacks (WEAK is optional)
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -67,6 +75,10 @@ bool tud_remote_wakeup(void);
|
||||
// Application return pointer to descriptor
|
||||
uint8_t const * tud_descriptor_device_cb(void);
|
||||
|
||||
// Invoked when received GET BOS DESCRIPTOR request
|
||||
// Application return pointer to descriptor
|
||||
TU_ATTR_WEAK uint8_t const * tud_descriptor_bos_cb(void);
|
||||
|
||||
// Invoked when received GET CONFIGURATION DESCRIPTOR request
|
||||
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
|
||||
uint8_t const * tud_descriptor_configuration_cb(uint8_t index);
|
||||
@@ -88,10 +100,56 @@ TU_ATTR_WEAK void tud_suspend_cb(bool remote_wakeup_en);
|
||||
// Invoked when usb bus is resumed
|
||||
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);
|
||||
TU_ATTR_WEAK bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_request_t const * request);
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Interface Descriptor Template
|
||||
// Binary Device Object Store (BOS) Descriptor Templates
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
#define TUD_BOS_DESC_LEN 5
|
||||
|
||||
// total length, number of device caps
|
||||
#define TUD_BOS_DESCRIPTOR(_total_len, _caps_num) \
|
||||
5, TUSB_DESC_BOS, U16_TO_U8S_LE(_total_len), _caps_num
|
||||
|
||||
// Device Capability Platform 128-bit UUID + Data
|
||||
#define TUD_BOS_PLATFORM_DESCRIPTOR(...) \
|
||||
4+TU_ARGS_NUM(__VA_ARGS__), TUSB_DESC_DEVICE_CAPABILITY, DEVICE_CAPABILITY_PLATFORM, 0x00, __VA_ARGS__
|
||||
|
||||
//------------- WebUSB BOS Platform -------------//
|
||||
|
||||
// Descriptor Length
|
||||
#define TUD_BOS_WEBUSB_DESC_LEN 24
|
||||
|
||||
// Vendor Code, iLandingPage
|
||||
#define TUD_BOS_WEBUSB_DESCRIPTOR(_vendor_code, _ipage) \
|
||||
TUD_BOS_PLATFORM_DESCRIPTOR(TUD_BOS_WEBUSB_UUID, U16_TO_U8S_LE(0x0100), _vendor_code, _ipage)
|
||||
|
||||
#define TUD_BOS_WEBUSB_UUID \
|
||||
0x38, 0xB6, 0x08, 0x34, 0xA9, 0x09, 0xA0, 0x47, \
|
||||
0x8B, 0xFD, 0xA0, 0x76, 0x88, 0x15, 0xB6, 0x65
|
||||
|
||||
//------------- Microsoft OS 2.0 Platform -------------//
|
||||
|
||||
#define TUD_BOS_MICROSOFT_OS_DESC_LEN 28
|
||||
|
||||
// Total Length of descriptor set, vendor code
|
||||
#define TUD_BOS_MS_OS_20_DESCRIPTOR(_desc_set_len, _vendor_code) \
|
||||
TUD_BOS_PLATFORM_DESCRIPTOR(TUD_BOS_MS_OS_20_UUID, U32_TO_U8S_LE(0x06030000), U16_TO_U8S_LE(_desc_set_len), _vendor_code, 0)
|
||||
|
||||
#define TUD_BOS_MS_OS_20_UUID \
|
||||
0xDF, 0x60, 0xDD, 0xD8, 0x89, 0x45, 0xC7, 0x4C, \
|
||||
0x9C, 0xD2, 0x65, 0x9D, 0x9E, 0x64, 0x8A, 0x9F
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Configuration & Interface Descriptor Templates
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
//------------- Configuration -------------//
|
||||
#define TUD_CONFIG_DESC_LEN (9)
|
||||
|
||||
// Interface count, string index, total length, attribute, power in mA
|
||||
@@ -160,16 +218,16 @@ TU_ATTR_WEAK void tud_resume_cb(void);
|
||||
#define TUD_HID_INOUT_DESC_LEN (9 + 9 + 7 + 7)
|
||||
|
||||
// HID Input & Output descriptor
|
||||
// Interface number, string index, protocol, report descriptor len, EP In & Out address, size & polling interval
|
||||
#define TUD_HID_INOUT_DESCRIPTOR(_itfnum, _stridx, _boot_protocol, _report_desc_len, _epin, _epout, _epsize, _ep_interval) \
|
||||
// Interface number, string index, protocol, report descriptor len, EP OUT & IN address, size & polling interval
|
||||
#define TUD_HID_INOUT_DESCRIPTOR(_itfnum, _stridx, _boot_protocol, _report_desc_len, _epout, _epin, _epsize, _ep_interval) \
|
||||
/* Interface */\
|
||||
9, TUSB_DESC_INTERFACE, _itfnum, 0, 2, TUSB_CLASS_HID, (_boot_protocol) ? HID_SUBCLASS_BOOT : 0, _boot_protocol, _stridx,\
|
||||
/* HID descriptor */\
|
||||
9, HID_DESC_TYPE_HID, U16_TO_U8S_LE(0x0111), 0, 1, HID_DESC_TYPE_REPORT, U16_TO_U8S_LE(_report_desc_len),\
|
||||
/* Endpoint In */\
|
||||
7, TUSB_DESC_ENDPOINT, _epin, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_epsize), _ep_interval,\
|
||||
/* Endpoint Out */\
|
||||
7, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_epsize), _ep_interval
|
||||
7, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_epsize), _ep_interval, \
|
||||
/* Endpoint In */\
|
||||
7, TUSB_DESC_ENDPOINT, _epin, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_epsize), _ep_interval
|
||||
|
||||
//------------- MIDI -------------//
|
||||
|
||||
@@ -205,6 +263,18 @@ TU_ATTR_WEAK void tud_resume_cb(void);
|
||||
/* MS Endpoint (connected to embedded jack out) */\
|
||||
5, TUSB_DESC_CS_ENDPOINT, MIDI_CS_ENDPOINT_GENERAL, 1, 3
|
||||
|
||||
//------------- Vendor -------------//
|
||||
#define TUD_VENDOR_DESC_LEN (9+7+7)
|
||||
|
||||
// Interface number, string index, EP Out & IN address, EP size
|
||||
#define TUD_VENDOR_DESCRIPTOR(_itfnum, _stridx, _epout, _epin, _epsize) \
|
||||
/* Interface */\
|
||||
9, TUSB_DESC_INTERFACE, _itfnum, 0, 2, TUSB_CLASS_VENDOR_SPECIFIC, 0x00, 0x00, _stridx,\
|
||||
/* Endpoint Out */\
|
||||
7, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0,\
|
||||
/* Endpoint In */\
|
||||
7, TUSB_DESC_ENDPOINT, _epin, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ void usbd_control_reset (uint8_t rhport)
|
||||
tu_varclr(&_control_state);
|
||||
}
|
||||
|
||||
bool usbd_control_status(uint8_t rhport, tusb_control_request_t const * request)
|
||||
bool tud_control_status(uint8_t rhport, tusb_control_request_t const * request)
|
||||
{
|
||||
// status direction is reversed to one in the setup packet
|
||||
return dcd_edpt_xfer(rhport, request->bmRequestType_bit.direction ? EDPT_CTRL_OUT : EDPT_CTRL_IN, NULL, 0);
|
||||
@@ -87,7 +87,7 @@ void usbd_control_set_complete_callback( bool (*fp) (uint8_t, tusb_control_reque
|
||||
_control_state.complete_cb = fp;
|
||||
}
|
||||
|
||||
bool usbd_control_xfer(uint8_t rhport, tusb_control_request_t const * request, void* buffer, uint16_t len)
|
||||
bool tud_control_xfer(uint8_t rhport, tusb_control_request_t const * request, void* buffer, uint16_t len)
|
||||
{
|
||||
_control_state.request = (*request);
|
||||
_control_state.buffer = buffer;
|
||||
@@ -103,7 +103,7 @@ bool usbd_control_xfer(uint8_t rhport, tusb_control_request_t const * request, v
|
||||
}else
|
||||
{
|
||||
// Status stage
|
||||
TU_ASSERT( usbd_control_status(rhport, request) );
|
||||
TU_ASSERT( tud_control_status(rhport, request) );
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -139,7 +139,7 @@ bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t result
|
||||
if ( is_ok )
|
||||
{
|
||||
// Send status
|
||||
TU_ASSERT( usbd_control_status(rhport, &_control_state.request) );
|
||||
TU_ASSERT( tud_control_status(rhport, &_control_state.request) );
|
||||
}else
|
||||
{
|
||||
// Stall both IN and OUT control endpoint
|
||||
|
||||
@@ -39,19 +39,13 @@ bool usbd_init (void);
|
||||
// USBD Endpoint API
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Carry out Data and Status stage of control transfer
|
||||
// - If len = 0, it is equivalent to sending status only
|
||||
// - If len > wLength : it will be truncated
|
||||
bool usbd_control_xfer(uint8_t rhport, tusb_control_request_t const * request, void* buffer, uint16_t len);
|
||||
|
||||
// Send STATUS (zero length) packet
|
||||
bool usbd_control_status(uint8_t rhport, tusb_control_request_t const * request);
|
||||
//bool usbd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc);
|
||||
|
||||
// Submit a usb transfer
|
||||
bool usbd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes);
|
||||
bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes);
|
||||
|
||||
// Check if endpoint transferring is complete
|
||||
bool usbd_edpt_busy (uint8_t rhport, uint8_t ep_addr);
|
||||
bool usbd_edpt_busy(uint8_t rhport, uint8_t ep_addr);
|
||||
|
||||
void usbd_edpt_stall(uint8_t rhport, uint8_t ep_addr);
|
||||
void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr);
|
||||
|
||||
@@ -54,8 +54,8 @@
|
||||
#include "class/cdc/cdc_host.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUSB_HOST_CUSTOM_CLASS
|
||||
#include "class/custom_host.h"
|
||||
#if CFG_TUH_VENDOR
|
||||
#include "class/vendor/vendor_host.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -80,8 +80,8 @@
|
||||
#include "class/midi/midi_device.h"
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_CUSTOM_CLASS
|
||||
#include "class/custom/custom_device.h"
|
||||
#if CFG_TUD_VENDOR
|
||||
#include "class/vendor/vendor_device.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -27,11 +27,10 @@
|
||||
#ifndef _TUSB_OPTION_H_
|
||||
#define _TUSB_OPTION_H_
|
||||
|
||||
#define TUSB_VERSION_YEAR 00
|
||||
#define TUSB_VERSION_MONTH 00
|
||||
#define TUSB_VERSION_WEEK 0
|
||||
#define TUSB_VERSION_NAME "alpha"
|
||||
#define TUSB_VERSION XSTRING_(TUSB_VERSION_YEAR) "." XSTRING_(TUSB_VERSION_MONTH)
|
||||
#define TUSB_VERSION_MAJOR 0
|
||||
#define TUSB_VERSION_MINOR 5
|
||||
#define TUSB_VERSION_REVISION 0
|
||||
#define TUSB_VERSION_STRING TU_STRING(TUSB_VERSION_MAJOR) "." TU_STRING(TUSB_VERSION_MINOR) "." TU_STRING(TUSB_VERSION_REVISION)
|
||||
|
||||
/** \defgroup group_mcu Supported MCU
|
||||
* \ref CFG_TUSB_MCU must be defined to one of these
|
||||
@@ -162,8 +161,8 @@
|
||||
#define CFG_TUD_MIDI 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_CUSTOM_CLASS
|
||||
#define CFG_TUD_CUSTOM_CLASS 0
|
||||
#ifndef CFG_TUD_VENDOR
|
||||
#define CFG_TUD_VENDOR 0
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
#define CFG_TUD_MSC 1
|
||||
#define CFG_TUD_HID 1
|
||||
#define CFG_TUD_MIDI 1
|
||||
#define CFG_TUD_CUSTOM_CLASS 0
|
||||
#define CFG_TUD_VENDOR 1
|
||||
|
||||
// CDC FIFO size of TX and RX
|
||||
#define CFG_TUD_CDC_RX_BUFSIZE 256
|
||||
@@ -71,6 +71,11 @@
|
||||
#define CFG_TUD_MIDI_RX_BUFSIZE 64
|
||||
#define CFG_TUD_MIDI_TX_BUFSIZE 64
|
||||
|
||||
// Vendor FIFO size of TX and RX
|
||||
// If not configured vendor endpoints will not be buffered
|
||||
#define CFG_TUD_VENDOR_RX_BUFSIZE 64
|
||||
#define CFG_TUD_VENDOR_TX_BUFSIZE 64
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user