Merge remote-tracking branch 'upstream/master' into CCRX_Port

This commit is contained in:
Wini-Buh
2021-06-03 22:17:30 +02:00
103 changed files with 1429 additions and 1543 deletions

View File

@@ -55,9 +55,10 @@
//--------------------------------------------------------------------+
// INCLUDE
//--------------------------------------------------------------------+
#include "device/usbd.h"
#include "device/usbd_pvt.h"
#include "audio_device.h"
//#include "common/tusb_fifo.h"
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
@@ -548,7 +549,7 @@ static bool audiod_rx_done_cb(uint8_t rhport, audiod_function_t* audio, uint16_t
TU_VERIFY(usbd_edpt_xfer(rhport, audio->ep_out, audio->lin_buf_out, audio->ep_out_sz), false);
#else
// Data is already placed in EP FIFO, schedule for next receive
TU_VERIFY(usbd_edpt_iso_xfer(rhport, audio->ep_out, &audio->ep_out_ff, audio->ep_out_sz), false);
TU_VERIFY(usbd_edpt_xfer_fifo(rhport, audio->ep_out, &audio->ep_out_ff, audio->ep_out_sz), false);
#endif
#endif
@@ -852,7 +853,7 @@ static bool audiod_tx_done_cb(uint8_t rhport, audiod_function_t * audio)
TU_VERIFY(usbd_edpt_xfer(rhport, audio->ep_in, audio->lin_buf_in, n_bytes_tx));
#else
// Send everything in ISO EP FIFO
TU_VERIFY(usbd_edpt_iso_xfer(rhport, audio->ep_in, &audio->ep_in_ff, n_bytes_tx));
TU_VERIFY(usbd_edpt_xfer_fifo(rhport, audio->ep_in, &audio->ep_in_ff, n_bytes_tx));
#endif
#endif
@@ -1611,7 +1612,7 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
#if USE_LINEAR_BUFFER_RX
TU_VERIFY(usbd_edpt_xfer(rhport, audio->ep_out, audio->lin_buf_out, audio->ep_out_sz), false);
#else
TU_VERIFY(usbd_edpt_iso_xfer(rhport, audio->ep_out, &audio->ep_out_ff, audio->ep_out_sz), false);
TU_VERIFY(usbd_edpt_xfer_fifo(rhport, audio->ep_out, &audio->ep_out_ff, audio->ep_out_sz), false);
#endif
}

View File

@@ -28,10 +28,6 @@
#ifndef _TUSB_AUDIO_DEVICE_H_
#define _TUSB_AUDIO_DEVICE_H_
#include "assert.h"
#include "common/tusb_common.h"
#include "device/usbd.h"
#include "audio.h"
//--------------------------------------------------------------------+

View File

@@ -32,7 +32,6 @@
// INCLUDE
//--------------------------------------------------------------------+
#include "bth_device.h"
#include <common/tusb_types.h>
#include <device/usbd_pvt.h>
//--------------------------------------------------------------------+

View File

@@ -28,9 +28,11 @@
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_CDC)
#include "cdc_device.h"
#include "device/usbd.h"
#include "device/usbd_pvt.h"
#include "cdc_device.h"
#if defined(TU_HAS_NO_ATTR_WEAK)
static void (*const MAKE_WEAK_FUNC(tud_cdc_rx_cb))(uint8_t) = TUD_CDC_RX_CB;
static void (*const MAKE_WEAK_FUNC(tud_cdc_rx_wanted_cb))(uint8_t, char) = TUD_CDC_RX_WANTED_CB;

View File

@@ -28,7 +28,6 @@
#define _TUSB_CDC_DEVICE_H_
#include "common/tusb_common.h"
#include "device/usbd.h"
#include "cdc.h"
//--------------------------------------------------------------------+

View File

@@ -28,7 +28,7 @@
#if (TUSB_OPT_HOST_ENABLED && CFG_TUH_CDC)
#include "common/tusb_common.h"
#include "host/usbh.h"
#include "cdc_host.h"
//--------------------------------------------------------------------+
@@ -96,24 +96,26 @@ bool tuh_cdc_serial_is_mounted(uint8_t dev_addr)
bool tuh_cdc_send(uint8_t dev_addr, void const * p_data, uint32_t length, bool is_notify)
{
(void) is_notify;
TU_VERIFY( tuh_cdc_mounted(dev_addr) );
TU_VERIFY( p_data != NULL && length, TUSB_ERROR_INVALID_PARA);
uint8_t const ep_out = cdch_data[dev_addr-1].ep_out;
if ( hcd_edpt_busy(dev_addr, ep_out) ) return false;
return hcd_pipe_xfer(dev_addr, ep_out, (void *) p_data, length, is_notify);
return usbh_edpt_xfer(dev_addr, ep_out, (void *) p_data, length);
}
bool tuh_cdc_receive(uint8_t dev_addr, void * p_buffer, uint32_t length, bool is_notify)
{
(void) is_notify;
TU_VERIFY( tuh_cdc_mounted(dev_addr) );
TU_VERIFY( p_buffer != NULL && length, TUSB_ERROR_INVALID_PARA);
uint8_t const ep_in = cdch_data[dev_addr-1].ep_in;
if ( hcd_edpt_busy(dev_addr, ep_in) ) return false;
return hcd_pipe_xfer(dev_addr, ep_in, p_buffer, length, is_notify);
return usbh_edpt_xfer(dev_addr, ep_in, p_buffer, length);
}
bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_control_complete_cb_t complete_cb)

View File

@@ -27,8 +27,6 @@
#ifndef _TUSB_CDC_HOST_H_
#define _TUSB_CDC_HOST_H_
#include "common/tusb_common.h"
#include "host/usbh.h"
#include "cdc.h"
#ifdef __cplusplus

View File

@@ -239,7 +239,7 @@ static tusb_error_t send_message_get_response_subtask( uint8_t dev_addr, cdch_da
if ( TUSB_ERROR_NONE != error ) STASK_RETURN(error);
//------------- waiting for Response Available notification -------------//
(void) hcd_pipe_xfer(p_cdc->pipe_notification, msg_notification[dev_addr-1], 8, true);
(void) usbh_edpt_xfer(p_cdc->pipe_notification, msg_notification[dev_addr-1], 8);
osal_semaphore_wait(rndish_data[dev_addr-1].sem_notification_hdl, OSAL_TIMEOUT_NORMAL, &error);
if ( TUSB_ERROR_NONE != error ) STASK_RETURN(error);
STASK_ASSERT(msg_notification[dev_addr-1][0] == 1);

View File

@@ -28,9 +28,11 @@
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_DFU_MODE)
#include "dfu_device.h"
#include "device/usbd.h"
#include "device/usbd_pvt.h"
#include "dfu_device.h"
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+

View File

@@ -27,8 +27,6 @@
#ifndef _TUSB_DFU_DEVICE_H_
#define _TUSB_DFU_DEVICE_H_
#include "common/tusb_common.h"
#include "device/usbd.h"
#include "dfu.h"
#ifdef __cplusplus

View File

@@ -28,9 +28,11 @@
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_DFU_RUNTIME)
#include "dfu_rt_device.h"
#include "device/usbd.h"
#include "device/usbd_pvt.h"
#include "dfu_rt_device.h"
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+

View File

@@ -27,8 +27,6 @@
#ifndef _TUSB_DFU_RT_DEVICE_H_
#define _TUSB_DFU_RT_DEVICE_H_
#include "common/tusb_common.h"
#include "device/usbd.h"
#include "dfu.h"
#ifdef __cplusplus

View File

@@ -31,10 +31,11 @@
//--------------------------------------------------------------------+
// INCLUDE
//--------------------------------------------------------------------+
#include "common/tusb_common.h"
#include "hid_device.h"
#include "device/usbd.h"
#include "device/usbd_pvt.h"
#include "hid_device.h"
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
@@ -224,7 +225,7 @@ uint16_t hidd_open(uint8_t rhport, tusb_desc_interface_t const * desc_itf, uint1
{
if ( !usbd_edpt_xfer(rhport, p_hid->ep_out, p_hid->epout_buf, sizeof(p_hid->epout_buf)) )
{
TU_LOG1_FAILED();
TU_LOG_FAILED();
TU_BREAKPOINT();
}
}

View File

@@ -27,8 +27,6 @@
#ifndef _TUSB_HID_DEVICE_H_
#define _TUSB_HID_DEVICE_H_
#include "common/tusb_common.h"
#include "device/usbd.h"
#include "hid.h"
#ifdef __cplusplus

View File

@@ -28,7 +28,7 @@
#if (TUSB_OPT_HOST_ENABLED && CFG_TUH_HID)
#include "common/tusb_common.h"
#include "host/usbh.h"
#include "hid_host.h"
//--------------------------------------------------------------------+

View File

@@ -24,14 +24,9 @@
* This file is part of the TinyUSB stack.
*/
/** \addtogroup ClassDriver_HID
* @{ */
#ifndef _TUSB_HID_HOST_H_
#define _TUSB_HID_HOST_H_
#include "common/tusb_common.h"
#include "host/usbh.h"
#include "hid.h"
#ifdef __cplusplus
@@ -134,5 +129,3 @@ void hidh_close(uint8_t dev_addr);
#endif
#endif /* _TUSB_HID_HOST_H_ */
/** @} */ // ClassDriver_HID

View File

@@ -31,10 +31,11 @@
//--------------------------------------------------------------------+
// INCLUDE
//--------------------------------------------------------------------+
#include "midi_device.h"
#include "class/audio/audio.h"
#include "device/usbd.h"
#include "device/usbd_pvt.h"
#include "midi_device.h"
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+

View File

@@ -27,9 +27,6 @@
#ifndef _TUSB_MIDI_DEVICE_H_
#define _TUSB_MIDI_DEVICE_H_
#include "common/tusb_common.h"
#include "device/usbd.h"
#include "class/audio/audio.h"
#include "midi.h"

View File

@@ -24,13 +24,6 @@
* This file is part of the TinyUSB stack.
*/
/** \ingroup group_class
* \defgroup ClassDriver_MSC MassStorage (MSC)
* @{ */
/** \defgroup ClassDriver_MSC_Common Common Definitions
* @{ */
#ifndef _TUSB_MSC_H_
#define _TUSB_MSC_H_
@@ -387,6 +380,3 @@ TU_VERIFY_STATIC(sizeof(scsi_write10_t) == 10, "size is not correct");
#endif
#endif /* _TUSB_MSC_H_ */
/// @}
/// @}

View File

@@ -28,11 +28,12 @@
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_MSC)
#include "common/tusb_common.h"
#include "msc_device.h"
#include "device/usbd.h"
#include "device/usbd_pvt.h"
#include "device/dcd.h" // for faking dcd_event_xfer_complete
#include "msc_device.h"
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
@@ -171,7 +172,7 @@ uint16_t mscd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint1
// Prepare for Command Block Wrapper
if ( !usbd_edpt_xfer(rhport, p_msc->ep_out, (uint8_t*) &p_msc->cbw, sizeof(msc_cbw_t)) )
{
TU_LOG1_FAILED();
TU_LOG_FAILED();
TU_BREAKPOINT();
}

View File

@@ -28,7 +28,6 @@
#define _TUSB_MSC_DEVICE_H_
#include "common/tusb_common.h"
#include "device/usbd.h"
#include "msc.h"
#ifdef __cplusplus
@@ -51,53 +50,45 @@
TU_VERIFY_STATIC(CFG_TUD_MSC_EP_BUFSIZE < UINT16_MAX, "Size is not correct");
/** \addtogroup ClassDriver_MSC
* @{
* \defgroup MSC_Device Device
* @{ */
//--------------------------------------------------------------------+
// Application API
//--------------------------------------------------------------------+
// Set SCSI sense response
bool tud_msc_set_sense(uint8_t lun, uint8_t sense_key, uint8_t add_sense_code, uint8_t add_sense_qualifier);
//--------------------------------------------------------------------+
// Application Callbacks (WEAK is optional)
//--------------------------------------------------------------------+
/**
* Invoked when received \ref SCSI_CMD_READ_10 command
* \param[in] lun Logical unit number
* \param[in] lba Logical Block Address to be read
* \param[in] offset Byte offset from LBA
* \param[out] buffer Buffer which application need to update with the response data.
* \param[in] bufsize Requested bytes
*
* \return Number of byte read, if it is less than requested bytes by \a \b bufsize. Tinyusb will transfer
* this amount first and invoked this again for remaining data.
*
* \retval zero Indicate application is not ready yet to response e.g disk I/O is not complete.
* tinyusb will invoke this callback with the same parameters again some time later.
*
* \retval negative Indicate error e.g reading disk I/O. tinyusb will \b STALL the corresponding
* endpoint and return failed status in command status wrapper phase.
*/
// Invoked when received SCSI READ10 command
// - Address = lba * BLOCK_SIZE + offset
// - offset is only needed if CFG_TUD_MSC_EP_BUFSIZE is smaller than BLOCK_SIZE.
//
// - Application fill the buffer (up to bufsize) with address contents and return number of read byte. If
// - read < bufsize : These bytes are transferred first and callback invoked again for remaining data.
//
// - read == 0 : Indicate application is not ready yet e.g disk I/O busy.
// Callback invoked again with the same parameters later on.
//
// - read < 0 : Indicate application error e.g invalid address. This request will be STALLed
// and return failed status in command status wrapper phase.
int32_t tud_msc_read10_cb (uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize);
/**
* Invoked when received \ref SCSI_CMD_WRITE_10 command
* \param[in] lun Logical unit number
* \param[in] lba Logical Block Address to be write
* \param[in] offset Byte offset from LBA
* \param[out] buffer Buffer which holds written data.
* \param[in] bufsize Requested bytes
*
* \return Number of byte written, if it is less than requested bytes by \a \b bufsize. Tinyusb will proceed with
* other work and invoked this again with adjusted parameters.
*
* \retval zero Indicate application is not ready yet e.g disk I/O is not complete.
* Tinyusb will invoke this callback with the same parameters again some time later.
*
* \retval negative Indicate error writing disk I/O. Tinyusb will \b STALL the corresponding
* endpoint and return failed status in command status wrapper phase.
*/
// Invoked when received SCSI WRITE10 command
// - Address = lba * BLOCK_SIZE + offset
// - offset is only needed if CFG_TUD_MSC_EP_BUFSIZE is smaller than BLOCK_SIZE.
//
// - Application write data from buffer to address contents (up to bufsize) and return number of written byte. If
// - write < bufsize : callback invoked again with remaining data later on.
//
// - write == 0 : Indicate application is not ready yet e.g disk I/O busy.
// Callback invoked again with the same parameters later on.
//
// - write < 0 : Indicate application error e.g invalid address. This request will be STALLed
// and return failed status in command status wrapper phase.
//
// TODO change buffer to const uint8_t*
int32_t tud_msc_write10_cb (uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize);
// Invoked when received SCSI_CMD_INQUIRY
@@ -152,9 +143,6 @@ TU_ATTR_WEAK void tud_msc_scsi_complete_cb(uint8_t lun, uint8_t const scsi_cmd[1
// Hook to make a mass storage device read-only. TODO remove
TU_ATTR_WEAK bool tud_msc_is_writable_cb(uint8_t lun);
/** @} */
/** @} */
//--------------------------------------------------------------------+
// Internal Class Driver API
//--------------------------------------------------------------------+

View File

@@ -28,10 +28,7 @@
#if TUSB_OPT_HOST_ENABLED & CFG_TUH_MSC
//--------------------------------------------------------------------+
// INCLUDE
//--------------------------------------------------------------------+
#include "common/tusb_common.h"
#include "host/usbh.h"
#include "msc_host.h"
//--------------------------------------------------------------------+
@@ -74,7 +71,8 @@ CFG_TUSB_MEM_SECTION static msch_interface_t _msch_itf[CFG_TUSB_HOST_DEVICE_MAX]
// buffer used to read scsi information when mounted
// largest response data currently is inquiry TODO Inquiry is not part of enum anymore
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4) static uint8_t _msch_buffer[sizeof(scsi_inquiry_resp_t)];
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4)
static uint8_t _msch_buffer[sizeof(scsi_inquiry_resp_t)];
static inline msch_interface_t* get_itf(uint8_t dev_addr)
{
@@ -441,7 +439,7 @@ static bool config_test_unit_ready_complete(uint8_t dev_addr, msc_cbw_t const* c
{
// Unit is ready, read its capacity
TU_LOG2("SCSI Read Capacity\r\n");
tuh_msc_read_capacity(dev_addr, cbw->lun, (scsi_read_capacity10_resp_t*) _msch_buffer, config_read_capacity_complete);
tuh_msc_read_capacity(dev_addr, cbw->lun, (scsi_read_capacity10_resp_t*) ((void*) _msch_buffer), config_read_capacity_complete);
}else
{
// Note: During enumeration, some device fails Test Unit Ready and require a few retries
@@ -468,7 +466,7 @@ static bool config_read_capacity_complete(uint8_t dev_addr, msc_cbw_t const* cbw
msch_interface_t* p_msc = get_itf(dev_addr);
// Capacity response field: Block size and Last LBA are both Big-Endian
scsi_read_capacity10_resp_t* resp = (scsi_read_capacity10_resp_t*) _msch_buffer;
scsi_read_capacity10_resp_t* resp = (scsi_read_capacity10_resp_t*) ((void*) _msch_buffer);
p_msc->capacity[cbw->lun].block_count = tu_ntohl(resp->last_lba) + 1;
p_msc->capacity[cbw->lun].block_size = tu_ntohl(resp->block_size);

View File

@@ -27,8 +27,6 @@
#ifndef _TUSB_MSC_HOST_H_
#define _TUSB_MSC_HOST_H_
#include "common/tusb_common.h"
#include "host/usbh.h"
#include "msc.h"
#ifdef __cplusplus

View File

@@ -29,8 +29,10 @@
#if ( TUSB_OPT_DEVICE_ENABLED && CFG_TUD_NET )
#include "net_device.h"
#include "device/usbd.h"
#include "device/usbd_pvt.h"
#include "net_device.h"
#include "rndis_protocol.h"
void rndis_class_set_handler(uint8_t *data, int size); /* found in ./misc/networking/rndis_reports.c */

View File

@@ -28,8 +28,6 @@
#ifndef _TUSB_NET_DEVICE_H_
#define _TUSB_NET_DEVICE_H_
#include "common/tusb_common.h"
#include "device/usbd.h"
#include "class/cdc/cdc.h"
/* declared here, NOT in usb_descriptors.c, so that the driver can intelligently ZLP as needed */

View File

@@ -77,15 +77,11 @@
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_USBTMC)
#include <string.h>
#include "usbtmc.h"
#include "usbtmc_device.h"
#include "device/usbd.h"
#include "osal/osal.h"
// FIXME: I shouldn't need to include _pvt headers, but it is necessary for usbd_edpt_xfer, _stall, and _busy
#include "device/usbd_pvt.h"
#include "usbtmc_device.h"
#ifdef xDEBUG
#include "uart_util.h"
static char logMsg[150];

View File

@@ -28,9 +28,11 @@
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_VENDOR)
#include "vendor_device.h"
#include "device/usbd.h"
#include "device/usbd_pvt.h"
#include "vendor_device.h"
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
@@ -193,7 +195,7 @@ uint16_t vendord_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, ui
// Prepare for incoming data
if ( !usbd_edpt_xfer(rhport, p_vendor->ep_out, p_vendor->epout_buf, sizeof(p_vendor->epout_buf)) )
{
TU_LOG1_FAILED();
TU_LOG_FAILED();
TU_BREAKPOINT();
}

View File

@@ -28,7 +28,6 @@
#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

View File

@@ -31,7 +31,7 @@
//--------------------------------------------------------------------+
// INCLUDE
//--------------------------------------------------------------------+
#include "common/tusb_common.h"
#include "host/usbh.h"
#include "vendor_host.h"
//--------------------------------------------------------------------+
@@ -66,7 +66,7 @@ tusb_error_t tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, uint16_t pr
return TUSB_ERROR_INTERFACE_IS_BUSY;
}
(void) hcd_pipe_xfer( custom_interface[dev_addr-1].pipe_in, p_buffer, length, true);
(void) usbh_edpt_xfer( custom_interface[dev_addr-1].pipe_in, p_buffer, length);
return TUSB_ERROR_NONE;
}
@@ -80,7 +80,7 @@ tusb_error_t tusbh_custom_write(uint8_t dev_addr, uint16_t vendor_id, uint16_t p
return TUSB_ERROR_INTERFACE_IS_BUSY;
}
(void) hcd_pipe_xfer( custom_interface[dev_addr-1].pipe_out, p_data, length, true);
(void) usbh_edpt_xfer( custom_interface[dev_addr-1].pipe_out, p_data, length);
return TUSB_ERROR_NONE;
}

View File

@@ -24,15 +24,10 @@
* This file is part of the TinyUSB stack.
*/
/** \ingroup group_class
* \defgroup Group_Custom Custom Class (not supported yet)
* @{ */
#ifndef _TUSB_VENDOR_HOST_H_
#define _TUSB_VENDOR_HOST_H_
#include "common/tusb_common.h"
#include "host/usbh.h"
#ifdef __cplusplus
extern "C" {
@@ -70,5 +65,3 @@ void cush_close(uint8_t dev_addr);
#endif
#endif /* _TUSB_VENDOR_HOST_H_ */
/** @} */