Merge pull request #854 from hathach/more-housekeeping

More housekeeping
This commit is contained in:
Ha Thach 2021-05-27 19:44:10 +07:00 committed by GitHub
commit 81d238bd46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 155 additions and 176 deletions

View File

@ -25,6 +25,10 @@
- Improve Audio driver and add uac2_headset example - Improve Audio driver and add uac2_headset example
- Improve STM32 Synopsys DCD with various PRs - Improve STM32 Synopsys DCD with various PRs
- **[J McCarthy](https://github.com/xmos-jmccarthy)**
- Add new DFU 1.1 class driver
- Add new example for dfu
- **[Kamil Tomaszewski](https://github.com/kamtom480)** - **[Kamil Tomaszewski](https://github.com/kamtom480)**
- Add new DCD port for **Sony CXD56** (spresnese board) - Add new DCD port for **Sony CXD56** (spresnese board)
@ -53,10 +57,14 @@
- **[Raspberry Pi Team](https://github.com/raspberrypi)** - **[Raspberry Pi Team](https://github.com/raspberrypi)**
- Add new DCD port for **Raspberry Pi RP2040** - Add new DCD port for **Raspberry Pi RP2040**
- Add new HCD port for **Raspberry Pi RP2040**
- **[Reinhard Panhuber](https://github.com/PanRe)** - **[Reinhard Panhuber](https://github.com/PanRe)**
- Add new class driver for **USB Audio Class 2.0 (UAC2)** - Add new class driver for **USB Audio Class 2.0 (UAC2)**
- Enhance tu_fifo with unmasked pointer, which better support DMA - Rework tu_fifo with unmasked pointer, add DMA support, and constant address support
- Add new DCD/USBD edpt_xfer_fifo() API for optimizing endpoint transfer
- Add and greatly improve Isochronous transfer
- Add new audio examples: audio_test and audio_4_channel_mic
- **[Scott Shawcroft](https://github.com/tannewt)** - **[Scott Shawcroft](https://github.com/tannewt)**
- Add new DCD port for **SAMD21 and SAMD51** - Add new DCD port for **SAMD21 and SAMD51**

View File

@ -77,7 +77,7 @@ Supports multiple device configurations by dynamically changing usb descriptors.
TinyUSB is completely thread-safe by pushing all ISR events into a central queue, then process it later in the non-ISR context task function. It also uses semaphore/mutex to access shared resources such as CDC FIFO. Therefore the stack needs to use some of OS's basic APIs. Following OSes are already supported out of the box. TinyUSB is completely thread-safe by pushing all ISR events into a central queue, then process it later in the non-ISR context task function. It also uses semaphore/mutex to access shared resources such as CDC FIFO. Therefore the stack needs to use some of OS's basic APIs. Following OSes are already supported out of the box.
- **No OS** : Disabling USB IRQ is used as way to provide mutex - **No OS**
- **FreeRTOS** - **FreeRTOS**
- **Mynewt** Due to the newt package build system, Mynewt examples are better to be on its [own repo](https://github.com/hathach/mynewt-tinyusb-example) - **Mynewt** Due to the newt package build system, Mynewt examples are better to be on its [own repo](https://github.com/hathach/mynewt-tinyusb-example)

View File

@ -2,18 +2,65 @@
## WIP ## WIP
- Add new port Silabs EFM32GG12, board EFM32GG12 Thunderboard Kit (SLTB009A) - Rework tu_fifo_t with separated mutex for read and write, better support DMA with read/write buffer info. And constant address mode
- Add new port Renesas RX63N, board GR-CITRUS - Improve audio_test example and add audio_4_channel_mic example
- MIDI - Add new dfu example
- Fix MIDI buffer overflow issue - Remove pico-sdk from submodule
### Device Controller Driver (DCD)
- Add new DCD port for Silabs EFM32GG12 with board Thunderboard Kit (SLTB009A)
- Add new DCD port Renesas RX63N, board GR-CITRUS
- Add new (optional) endpoint API dcd_edpt_xfer_fifo
- Fix build with nRF5340
- Fix build with lpc15 and lpc54
- Fix build with lpc177x_8x
- STM32 Synopsys: greatly improve Isochronous transfer with edpt_xfer_fifo API
- Support LPC55 port1 highspeed
- Add support for Espressif esp32s3
- nRF: fix race condition that could cause drop packet of Bulk OUT transfer
### USB Device Driver (USBD)
- Add new (optional) endpoint ADPI usbd_edpt_xfer_fifo
### Device Class Driver
CDC
- [Breaking] tud_cdc_peek(), tud_vendor_peek() dropped position parameter. If needed, tu_fifo_get_read_info() can be used to peek at random offset.
DFU
- Add new DFU 1.1 class driver (WIP)
HID
- Fix keyboard report descriptor template
- Add more hid keys constant from 0x6B to 0xA4
- [Breaking] rename API
- HID_PROTOCOL_NONE/KEYBOARD/MOUST to HID_ITF_PROTOCOL_NONE/KEYBOARD/MOUSE
- tud_hid_boot_mode() to tud_hid_get_protocol()
- tud_hid_boot_mode_cb() to tud_hid_set_protocol_cb()
MIDI
- Fix MIDI buffer overflow issue
- [Breaking] rename API
- Rename tud_midi_read() to tud_midi_stream_read() - Rename tud_midi_read() to tud_midi_stream_read()
- Rename tud_midi_write() to tud_midi_stream_write() - Rename tud_midi_write() to tud_midi_stream_write()
- Rename tud_midi_receive() to tud_midi_packet_read() - Rename tud_midi_receive() to tud_midi_packet_read()
- Rename tud_midi_send() to tud_midi_packet_write() - Rename tud_midi_send() to tud_midi_packet_write()
- New board stm32f072-eval
- Breaking changes ### Host Controller Driver (HCD)
- tud_cdc_peek(), tud_vendor_peek() dropped position parameter. If needed, tu_fifo_get_read_info() can be used to peek
at random offset. ### USB Host Driver (USBH)
### Host Class Driver
HID
- Rework host hid driver, basically everything changes
## 0.9.0 - 2021.03.12 ## 0.9.0 - 2021.03.12

View File

@ -55,9 +55,10 @@
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// INCLUDE // INCLUDE
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#include "device/usbd.h"
#include "device/usbd_pvt.h" #include "device/usbd_pvt.h"
#include "audio_device.h" #include "audio_device.h"
//#include "common/tusb_fifo.h"
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF // 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); TU_VERIFY(usbd_edpt_xfer(rhport, audio->ep_out, audio->lin_buf_out, audio->ep_out_sz), false);
#else #else
// Data is already placed in EP FIFO, schedule for next receive // 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
#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)); TU_VERIFY(usbd_edpt_xfer(rhport, audio->ep_in, audio->lin_buf_in, n_bytes_tx));
#else #else
// Send everything in ISO EP FIFO // 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
#endif #endif
@ -1611,7 +1612,7 @@ static bool audiod_set_interface(uint8_t rhport, tusb_control_request_t const *
#if USE_LINEAR_BUFFER_RX #if USE_LINEAR_BUFFER_RX
TU_VERIFY(usbd_edpt_xfer(rhport, audio->ep_out, audio->lin_buf_out, audio->ep_out_sz), false); TU_VERIFY(usbd_edpt_xfer(rhport, audio->ep_out, audio->lin_buf_out, audio->ep_out_sz), false);
#else #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 #endif
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,10 +31,11 @@
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// INCLUDE // INCLUDE
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#include "common/tusb_common.h" #include "device/usbd.h"
#include "hid_device.h"
#include "device/usbd_pvt.h" #include "device/usbd_pvt.h"
#include "hid_device.h"
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF // MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -24,13 +24,6 @@
* This file is part of the TinyUSB stack. * 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_ #ifndef _TUSB_MSC_H_
#define _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
#endif /* _TUSB_MSC_H_ */ #endif /* _TUSB_MSC_H_ */
/// @}
/// @}

View File

@ -28,11 +28,12 @@
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_MSC) #if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_MSC)
#include "common/tusb_common.h" #include "device/usbd.h"
#include "msc_device.h"
#include "device/usbd_pvt.h" #include "device/usbd_pvt.h"
#include "device/dcd.h" // for faking dcd_event_xfer_complete #include "device/dcd.h" // for faking dcd_event_xfer_complete
#include "msc_device.h"
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF // MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+

View File

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

View File

@ -28,10 +28,7 @@
#if TUSB_OPT_HOST_ENABLED & CFG_TUH_MSC #if TUSB_OPT_HOST_ENABLED & CFG_TUH_MSC
//--------------------------------------------------------------------+ #include "host/usbh.h"
// INCLUDE
//--------------------------------------------------------------------+
#include "common/tusb_common.h"
#include "msc_host.h" #include "msc_host.h"
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+

View File

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

View File

@ -29,8 +29,10 @@
#if ( TUSB_OPT_DEVICE_ENABLED && CFG_TUD_NET ) #if ( TUSB_OPT_DEVICE_ENABLED && CFG_TUD_NET )
#include "net_device.h" #include "device/usbd.h"
#include "device/usbd_pvt.h" #include "device/usbd_pvt.h"
#include "net_device.h"
#include "rndis_protocol.h" #include "rndis_protocol.h"
void rndis_class_set_handler(uint8_t *data, int size); /* found in ./misc/networking/rndis_reports.c */ 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_ #ifndef _TUSB_NET_DEVICE_H_
#define _TUSB_NET_DEVICE_H_ #define _TUSB_NET_DEVICE_H_
#include "common/tusb_common.h"
#include "device/usbd.h"
#include "class/cdc/cdc.h" #include "class/cdc/cdc.h"
/* declared here, NOT in usb_descriptors.c, so that the driver can intelligently ZLP as needed */ /* 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) #if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_USBTMC)
#include <string.h>
#include "usbtmc.h"
#include "usbtmc_device.h"
#include "device/usbd.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 "device/usbd_pvt.h"
#include "usbtmc_device.h"
#ifdef xDEBUG #ifdef xDEBUG
#include "uart_util.h" #include "uart_util.h"
static char logMsg[150]; static char logMsg[150];

View File

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

View File

@ -28,7 +28,6 @@
#define _TUSB_VENDOR_DEVICE_H_ #define _TUSB_VENDOR_DEVICE_H_
#include "common/tusb_common.h" #include "common/tusb_common.h"
#include "device/usbd.h"
#ifndef CFG_TUD_VENDOR_EPSIZE #ifndef CFG_TUD_VENDOR_EPSIZE
#define CFG_TUD_VENDOR_EPSIZE 64 #define CFG_TUD_VENDOR_EPSIZE 64

View File

@ -31,7 +31,7 @@
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// INCLUDE // INCLUDE
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#include "common/tusb_common.h" #include "host/usbh.h"
#include "vendor_host.h" #include "vendor_host.h"
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+

View File

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

View File

@ -72,10 +72,11 @@
#include "tusb_option.h" #include "tusb_option.h"
#include "tusb_compiler.h" #include "tusb_compiler.h"
#include "tusb_verify.h" #include "tusb_verify.h"
#include "tusb_error.h" // TODO remove
#include "tusb_timeout.h"
#include "tusb_types.h" #include "tusb_types.h"
#include "tusb_error.h" // TODO remove
#include "tusb_timeout.h" // TODO remove
//------------- Mem -------------// //------------- Mem -------------//
#define tu_memclr(buffer, size) memset((buffer), 0, (size)) #define tu_memclr(buffer, size) memset((buffer), 0, (size))
#define tu_varclr(_var) tu_memclr(_var, sizeof(*(_var))) #define tu_varclr(_var) tu_memclr(_var, sizeof(*(_var)))

View File

@ -25,8 +25,6 @@
* This file is part of the TinyUSB stack. * This file is part of the TinyUSB stack.
*/ */
#include <string.h>
#include "osal/osal.h" #include "osal/osal.h"
#include "tusb_fifo.h" #include "tusb_fifo.h"

View File

@ -28,6 +28,10 @@
#ifndef _TUSB_FIFO_H_ #ifndef _TUSB_FIFO_H_
#define _TUSB_FIFO_H_ #define _TUSB_FIFO_H_
#ifdef __cplusplus
extern "C" {
#endif
// Due to the use of unmasked pointers, this FIFO does not suffer from loosing // Due to the use of unmasked pointers, this FIFO does not suffer from loosing
// one item slice. Furthermore, write and read operations are completely // one item slice. Furthermore, write and read operations are completely
// decoupled as write and read functions do not modify a common state. Henceforth, // decoupled as write and read functions do not modify a common state. Henceforth,
@ -37,25 +41,17 @@
// read pointers can be updated from within a DMA ISR. Overflows are detectable // read pointers can be updated from within a DMA ISR. Overflows are detectable
// within a certain number (see tu_fifo_overflow()). // within a certain number (see tu_fifo_overflow()).
#include "common/tusb_common.h"
// mutex is only needed for RTOS // mutex is only needed for RTOS
// for OS None, we don't get preempted // for OS None, we don't get preempted
#define CFG_FIFO_MUTEX (CFG_TUSB_OS != OPT_OS_NONE) #define CFG_FIFO_MUTEX (CFG_TUSB_OS != OPT_OS_NONE)
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
#if CFG_FIFO_MUTEX #if CFG_FIFO_MUTEX
#include "osal/osal.h" #include "osal/osal.h"
#define tu_fifo_mutex_t osal_mutex_t #define tu_fifo_mutex_t osal_mutex_t
#endif #endif
/** \struct tu_fifo_t
* \brief Simple Circular FIFO
*/
typedef struct typedef struct
{ {
uint8_t* buffer ; ///< buffer pointer uint8_t* buffer ; ///< buffer pointer
@ -104,7 +100,8 @@ bool tu_fifo_clear(tu_fifo_t *f);
bool tu_fifo_config(tu_fifo_t *f, void* buffer, uint16_t depth, uint16_t item_size, bool overwritable); bool tu_fifo_config(tu_fifo_t *f, void* buffer, uint16_t depth, uint16_t item_size, bool overwritable);
#if CFG_FIFO_MUTEX #if CFG_FIFO_MUTEX
static inline void tu_fifo_config_mutex(tu_fifo_t *f, tu_fifo_mutex_t write_mutex_hdl, tu_fifo_mutex_t read_mutex_hdl) TU_ATTR_ALWAYS_INLINE static inline
void tu_fifo_config_mutex(tu_fifo_t *f, tu_fifo_mutex_t write_mutex_hdl, tu_fifo_mutex_t read_mutex_hdl)
{ {
f->mutex_wr = write_mutex_hdl; f->mutex_wr = write_mutex_hdl;
f->mutex_rd = read_mutex_hdl; f->mutex_rd = read_mutex_hdl;
@ -129,15 +126,16 @@ uint16_t tu_fifo_remaining (tu_fifo_t* f);
bool tu_fifo_overflowed (tu_fifo_t* f); bool tu_fifo_overflowed (tu_fifo_t* f);
void tu_fifo_correct_read_pointer (tu_fifo_t* f); void tu_fifo_correct_read_pointer (tu_fifo_t* f);
static inline uint16_t tu_fifo_depth(tu_fifo_t* f) TU_ATTR_ALWAYS_INLINE static inline
uint16_t tu_fifo_depth(tu_fifo_t* f)
{ {
return f->depth; return f->depth;
} }
// Pointer modifications intended to be used in combinations with DMAs. // Pointer modifications intended to be used in combinations with DMAs.
// USE WITH CARE - NO SAFTY CHECKS CONDUCTED HERE! NOT MUTEX PROTECTED! // USE WITH CARE - NO SAFTY CHECKS CONDUCTED HERE! NOT MUTEX PROTECTED!
void tu_fifo_advance_write_pointer (tu_fifo_t *f, uint16_t n); void tu_fifo_advance_write_pointer(tu_fifo_t *f, uint16_t n);
void tu_fifo_advance_read_pointer (tu_fifo_t *f, uint16_t n); void tu_fifo_advance_read_pointer (tu_fifo_t *f, uint16_t n);
// If you want to read/write from/to the FIFO by use of a DMA, you may need to conduct two copies // If you want to read/write from/to the FIFO by use of a DMA, you may need to conduct two copies
// to handle a possible wrapping part. These functions deliver a pointer to start // to handle a possible wrapping part. These functions deliver a pointer to start

View File

@ -28,6 +28,7 @@
#define _TUSB_DCD_H_ #define _TUSB_DCD_H_
#include "common/tusb_common.h" #include "common/tusb_common.h"
#include "osal/osal.h"
#include "common/tusb_fifo.h" #include "common/tusb_fifo.h"
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1271,7 +1271,7 @@ bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
// bytes should be written and second to keep the return value free to give back a boolean // bytes should be written and second to keep the return value free to give back a boolean
// success message. If total_bytes is too big, the FIFO will copy only what is available // success message. If total_bytes is too big, the FIFO will copy only what is available
// into the USB buffer! // into the USB buffer!
bool usbd_edpt_iso_xfer(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes) bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes)
{ {
uint8_t const epnum = tu_edpt_number(ep_addr); uint8_t const epnum = tu_edpt_number(ep_addr);
uint8_t const dir = tu_edpt_dir(ep_addr); uint8_t const dir = tu_edpt_dir(ep_addr);

View File

@ -70,8 +70,8 @@ bool tud_mounted(void);
bool tud_suspended(void); bool tud_suspended(void);
// Check if device is ready to transfer // Check if device is ready to transfer
TU_ATTR_ALWAYS_INLINE TU_ATTR_ALWAYS_INLINE static inline
static inline bool tud_ready(void) bool tud_ready(void)
{ {
return tud_mounted() && !tud_suspended(); return tud_mounted() && !tud_suspended();
} }

View File

@ -73,7 +73,7 @@ void usbd_edpt_close(uint8_t rhport, uint8_t ep_addr);
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);
// Submit a usb ISO transfer by use of a FIFO (ring buffer) - all bytes in FIFO get transmitted // Submit a usb ISO transfer by use of a FIFO (ring buffer) - all bytes in FIFO get transmitted
bool usbd_edpt_iso_xfer(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes); bool usbd_edpt_xfer_fifo(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes);
// Claim an endpoint before submitting a transfer. // Claim an endpoint before submitting a transfer.
// If caller does not make any transfer, it must release endpoint for others. // If caller does not make any transfer, it must release endpoint for others.
@ -94,7 +94,7 @@ void usbd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr);
// Check if endpoint is stalled // Check if endpoint is stalled
bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr); bool usbd_edpt_stalled(uint8_t rhport, uint8_t ep_addr);
static inline TU_ATTR_ALWAYS_INLINE static inline
bool usbd_edpt_ready(uint8_t rhport, uint8_t ep_addr) bool usbd_edpt_ready(uint8_t rhport, uint8_t ep_addr)
{ {
return !usbd_edpt_busy(rhport, ep_addr) && !usbd_edpt_stalled(rhport, ep_addr); return !usbd_edpt_busy(rhport, ep_addr) && !usbd_edpt_stalled(rhport, ep_addr);

View File

@ -28,9 +28,7 @@
#if (TUSB_OPT_HOST_ENABLED && CFG_TUH_HUB) #if (TUSB_OPT_HOST_ENABLED && CFG_TUH_HUB)
//--------------------------------------------------------------------+ #include "usbh.h"
// INCLUDE
//--------------------------------------------------------------------+
#include "hub.h" #include "hub.h"
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+

View File

@ -37,7 +37,6 @@
#define _TUSB_HUB_H_ #define _TUSB_HUB_H_
#include "common/tusb_common.h" #include "common/tusb_common.h"
#include "usbh.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -34,10 +34,7 @@
extern "C" { extern "C" {
#endif #endif
//--------------------------------------------------------------------+ #include "common/tusb_common.h"
// INCLUDE
//--------------------------------------------------------------------+
#include "osal/osal.h" // TODO refractor move to common.h ?
#include "hcd.h" #include "hcd.h"
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
@ -67,10 +64,6 @@ typedef struct {
typedef bool (*tuh_control_complete_cb_t)(uint8_t dev_addr, tusb_control_request_t const * request, xfer_result_t result); typedef bool (*tuh_control_complete_cb_t)(uint8_t dev_addr, tusb_control_request_t const * request, xfer_result_t result);
//--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
//--------------------------------------------------------------------+
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// APPLICATION API // APPLICATION API
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+

View File

@ -40,7 +40,6 @@
#include "soc/gpio_sig_map.h" #include "soc/gpio_sig_map.h"
#include "soc/usb_periph.h" #include "soc/usb_periph.h"
#include "common/tusb_fifo.h"
#include "device/dcd.h" #include "device/dcd.h"
// Since TinyUSB doesn't use SOF for now, and this interrupt too often (1ms interval) // Since TinyUSB doesn't use SOF for now, and this interrupt too often (1ms interval)

View File

@ -29,7 +29,6 @@
#if CFG_TUSB_MCU == OPT_MCU_SAMG #if CFG_TUSB_MCU == OPT_MCU_SAMG
#include "sam.h" #include "sam.h"
#include "common/tusb_fifo.h"
#include "device/dcd.h" #include "device/dcd.h"
// TODO should support (SAM3S || SAM4S || SAM4E || SAMG55) // TODO should support (SAM3S || SAM4S || SAM4E || SAMG55)

View File

@ -37,7 +37,6 @@
#if TUSB_OPT_DEVICE_ENABLED && (CFG_TUSB_MCU == OPT_MCU_NUC120) #if TUSB_OPT_DEVICE_ENABLED && (CFG_TUSB_MCU == OPT_MCU_NUC120)
#include "common/tusb_fifo.h"
#include "device/dcd.h" #include "device/dcd.h"
#include "NUC100Series.h" #include "NUC100Series.h"

View File

@ -37,7 +37,6 @@
#if TUSB_OPT_DEVICE_ENABLED && ( (CFG_TUSB_MCU == OPT_MCU_NUC121) || (CFG_TUSB_MCU == OPT_MCU_NUC126) ) #if TUSB_OPT_DEVICE_ENABLED && ( (CFG_TUSB_MCU == OPT_MCU_NUC121) || (CFG_TUSB_MCU == OPT_MCU_NUC126) )
#include "common/tusb_fifo.h"
#include "device/dcd.h" #include "device/dcd.h"
#include "NuMicro.h" #include "NuMicro.h"

View File

@ -37,7 +37,6 @@
#if TUSB_OPT_DEVICE_ENABLED && (CFG_TUSB_MCU == OPT_MCU_NUC505) #if TUSB_OPT_DEVICE_ENABLED && (CFG_TUSB_MCU == OPT_MCU_NUC505)
#include "common/tusb_fifo.h"
#include "device/dcd.h" #include "device/dcd.h"
#include "NUC505Series.h" #include "NUC505Series.h"

View File

@ -35,8 +35,6 @@
#include "pico/fix/rp2040_usb_device_enumeration.h" #include "pico/fix/rp2040_usb_device_enumeration.h"
#endif #endif
#include "osal/osal.h"
#include "common/tusb_fifo.h"
#include "device/dcd.h" #include "device/dcd.h"
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/

View File

@ -33,7 +33,6 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "device/dcd.h" #include "device/dcd.h"
#include "osal/osal.h"
#define CXD56_EPNUM (7) #define CXD56_EPNUM (7)
#define CXD56_SETUP_QUEUE_DEPTH (4) #define CXD56_SETUP_QUEUE_DEPTH (4)

View File

@ -120,7 +120,6 @@
// Some definitions are copied to our private include file. // Some definitions are copied to our private include file.
#undef USE_HAL_DRIVER #undef USE_HAL_DRIVER
#include "common/tusb_fifo.h"
#include "device/dcd.h" #include "device/dcd.h"
#include "portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h" #include "portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h"

View File

@ -94,10 +94,8 @@
#else #else
#error "Unsupported MCUs" #error "Unsupported MCUs"
#endif #endif
#include "common/tusb_fifo.h"
#include "device/dcd.h" #include "device/dcd.h"
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+

View File

@ -28,7 +28,6 @@
#if CFG_TUSB_MCU == OPT_MCU_NONE #if CFG_TUSB_MCU == OPT_MCU_NONE
#include "common/tusb_fifo.h"
#include "device/dcd.h" #include "device/dcd.h"
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+

View File

@ -30,7 +30,6 @@
#if TUSB_OPT_DEVICE_ENABLED && ( CFG_TUSB_MCU == OPT_MCU_MSP430x5xx ) #if TUSB_OPT_DEVICE_ENABLED && ( CFG_TUSB_MCU == OPT_MCU_MSP430x5xx )
#include "msp430.h" #include "msp430.h"
#include "common/tusb_fifo.h"
#include "device/dcd.h" #include "device/dcd.h"
/*------------------------------------------------------------------*/ /*------------------------------------------------------------------*/

View File

@ -55,11 +55,11 @@
#define OPT_MCU_NRF5X 100 ///< Nordic nRF5x series #define OPT_MCU_NRF5X 100 ///< Nordic nRF5x series
// SAM // SAM
#define OPT_MCU_SAMD11 204 ///< MicroChip SAMD11
#define OPT_MCU_SAMD21 200 ///< MicroChip SAMD21 #define OPT_MCU_SAMD21 200 ///< MicroChip SAMD21
#define OPT_MCU_SAMD51 201 ///< MicroChip SAMD51 #define OPT_MCU_SAMD51 201 ///< MicroChip SAMD51
#define OPT_MCU_SAME5X 203 ///< MicroChip SAM E5x
#define OPT_MCU_SAMG 202 ///< MicroChip SAMDG series #define OPT_MCU_SAMG 202 ///< MicroChip SAMDG series
#define OPT_MCU_SAME5X 203 ///< MicroChip SAM E5x
#define OPT_MCU_SAMD11 204 ///< MicroChip SAMD11
#define OPT_MCU_SAML22 205 ///< MicroChip SAML22 #define OPT_MCU_SAML22 205 ///< MicroChip SAML22
// STM32 // STM32