summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTORS.md10
-rw-r--r--README.md2
-rw-r--r--docs/changelog.md63
-rw-r--r--src/class/audio/audio_device.c9
-rw-r--r--src/class/audio/audio_device.h4
-rwxr-xr-xsrc/class/bth/bth_device.c1
-rw-r--r--src/class/cdc/cdc_device.c4
-rw-r--r--src/class/cdc/cdc_device.h1
-rw-r--r--src/class/cdc/cdc_host.c2
-rw-r--r--src/class/cdc/cdc_host.h2
-rw-r--r--src/class/dfu/dfu_device.c4
-rw-r--r--src/class/dfu/dfu_device.h2
-rw-r--r--src/class/dfu/dfu_rt_device.c4
-rw-r--r--src/class/dfu/dfu_rt_device.h2
-rw-r--r--src/class/hid/hid_device.c5
-rw-r--r--src/class/hid/hid_device.h2
-rw-r--r--src/class/hid/hid_host.c2
-rw-r--r--src/class/hid/hid_host.h7
-rw-r--r--src/class/midi/midi_device.c5
-rw-r--r--src/class/midi/midi_device.h3
-rw-r--r--src/class/msc/msc.h10
-rw-r--r--src/class/msc/msc_device.c5
-rw-r--r--src/class/msc/msc_device.h72
-rw-r--r--src/class/msc/msc_host.c5
-rw-r--r--src/class/msc/msc_host.h2
-rw-r--r--src/class/net/net_device.c4
-rw-r--r--src/class/net/net_device.h2
-rw-r--r--src/class/usbtmc/usbtmc_device.c8
-rw-r--r--src/class/vendor/vendor_device.c4
-rw-r--r--src/class/vendor/vendor_device.h1
-rw-r--r--src/class/vendor/vendor_host.c2
-rw-r--r--src/class/vendor/vendor_host.h7
-rw-r--r--src/common/tusb_common.h5
-rw-r--r--src/common/tusb_fifo.c2
-rw-r--r--src/common/tusb_fifo.h26
-rw-r--r--src/device/dcd.h1
-rw-r--r--src/device/usbd.c2
-rw-r--r--src/device/usbd.h4
-rw-r--r--src/device/usbd_pvt.h4
-rw-r--r--src/host/hub.c4
-rw-r--r--src/host/hub.h1
-rw-r--r--src/host/usbh.h9
-rw-r--r--src/portable/espressif/esp32sx/dcd_esp32sx.c1
-rw-r--r--src/portable/microchip/samg/dcd_samg.c1
-rw-r--r--src/portable/nuvoton/nuc120/dcd_nuc120.c1
-rw-r--r--src/portable/nuvoton/nuc121/dcd_nuc121.c1
-rw-r--r--src/portable/nuvoton/nuc505/dcd_nuc505.c1
-rw-r--r--src/portable/raspberrypi/rp2040/dcd_rp2040.c2
-rw-r--r--src/portable/sony/cxd56/dcd_cxd56.c1
-rw-r--r--src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c1
-rw-r--r--src/portable/st/synopsys/dcd_synopsys.c2
-rw-r--r--src/portable/template/dcd_template.c1
-rw-r--r--src/portable/ti/msp430x5xx/dcd_msp430x5xx.c1
-rw-r--r--src/tusb_option.h4
54 files changed, 155 insertions, 176 deletions
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index 5ce352f57..5fa3e5250 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -25,6 +25,10 @@
- Improve Audio driver and add uac2_headset example
- 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)**
- Add new DCD port for **Sony CXD56** (spresnese board)
@@ -53,10 +57,14 @@
- **[Raspberry Pi Team](https://github.com/raspberrypi)**
- Add new DCD port for **Raspberry Pi RP2040**
+ - Add new HCD port for **Raspberry Pi RP2040**
- **[Reinhard Panhuber](https://github.com/PanRe)**
- 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)**
- Add new DCD port for **SAMD21 and SAMD51**
diff --git a/README.md b/README.md
index bef49eea4..f7b2cd811 100644
--- a/README.md
+++ b/README.md
@@ -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.
-- **No OS** : Disabling USB IRQ is used as way to provide mutex
+- **No OS**
- **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)
diff --git a/docs/changelog.md b/docs/changelog.md
index 436259cee..fba362904 100644
--- a/docs/changelog.md
+++ b/docs/changelog.md
@@ -2,18 +2,65 @@
## WIP
-- Add new port Silabs EFM32GG12, board EFM32GG12 Thunderboard Kit (SLTB009A)
-- Add new port Renesas RX63N, board GR-CITRUS
-- MIDI
- - Fix MIDI buffer overflow issue
+- Rework tu_fifo_t with separated mutex for read and write, better support DMA with read/write buffer info. And constant address mode
+- Improve audio_test example and add audio_4_channel_mic example
+- Add new dfu example
+- 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_write() to tud_midi_stream_write()
- Rename tud_midi_receive() to tud_midi_packet_read()
- Rename tud_midi_send() to tud_midi_packet_write()
-- New board stm32f072-eval
-- Breaking changes
- - tud_cdc_peek(), tud_vendor_peek() dropped position parameter. If needed, tu_fifo_get_read_info() can be used to peek
- at random offset.
+
+### Host Controller Driver (HCD)
+
+### USB Host Driver (USBH)
+
+### Host Class Driver
+
+HID
+
+- Rework host hid driver, basically everything changes
## 0.9.0 - 2021.03.12
diff --git a/src/class/audio/audio_device.c b/src/class/audio/audio_device.c
index 72533013c..8e4420ed0 100644
--- a/src/class/audio/audio_device.c
+++ b/src/class/audio/audio_device.c
@@ -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
}
diff --git a/src/class/audio/audio_device.h b/src/class/audio/audio_device.h
index b8e6ef9c0..5a469523c 100644
--- a/src/class/audio/audio_device.h
+++ b/src/class/audio/audio_device.h
@@ -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"
//--------------------------------------------------------------------+
diff --git a/src/class/bth/bth_device.c b/src/class/bth/bth_device.c
index 481dc134e..1d27ae7c5 100755
--- a/src/class/bth/bth_device.c
+++ b/src/class/bth/bth_device.c
@@ -32,7 +32,6 @@
// INCLUDE
//--------------------------------------------------------------------+
#include "bth_device.h"
-#include <common/tusb_types.h>
#include <device/usbd_pvt.h>
//--------------------------------------------------------------------+
diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c
index f5853fddb..cac811c45 100644
--- a/src/class/cdc/cdc_device.c
+++ b/src/class/cdc/cdc_device.c
@@ -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"
+
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+
diff --git a/src/class/cdc/cdc_device.h b/src/class/cdc/cdc_device.h
index 986585c5b..7ff757add 100644
--- a/src/class/cdc/cdc_device.h
+++ b/src/class/cdc/cdc_device.h
@@ -28,7 +28,6 @@
#define _TUSB_CDC_DEVICE_H_
#include "common/tusb_common.h"
-#include "device/usbd.h"
#include "cdc.h"
//--------------------------------------------------------------------+
diff --git a/src/class/cdc/cdc_host.c b/src/class/cdc/cdc_host.c
index a897fb58a..c22107bbb 100644
--- a/src/class/cdc/cdc_host.c
+++ b/src/class/cdc/cdc_host.c
@@ -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"
//--------------------------------------------------------------------+
diff --git a/src/class/cdc/cdc_host.h b/src/class/cdc/cdc_host.h
index 66c2f0727..6ff392709 100644
--- a/src/class/cdc/cdc_host.h
+++ b/src/class/cdc/cdc_host.h
@@ -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
diff --git a/src/class/dfu/dfu_device.c b/src/class/dfu/dfu_device.c
index 8496cb02b..81045ff7b 100644
--- a/src/class/dfu/dfu_device.c
+++ b/src/class/dfu/dfu_device.c
@@ -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
//--------------------------------------------------------------------+
diff --git a/src/class/dfu/dfu_device.h b/src/class/dfu/dfu_device.h
index c45c436c5..9a09a46b1 100644
--- a/src/class/dfu/dfu_device.h
+++ b/src/class/dfu/dfu_device.h
@@ -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
diff --git a/src/class/dfu/dfu_rt_device.c b/src/class/dfu/dfu_rt_device.c
index faeae9b68..07e6f30f3 100644
--- a/src/class/dfu/dfu_rt_device.c
+++ b/src/class/dfu/dfu_rt_device.c
@@ -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
//--------------------------------------------------------------------+
diff --git a/src/class/dfu/dfu_rt_device.h b/src/class/dfu/dfu_rt_device.h
index 0e5fd005a..babaa8214 100644
--- a/src/class/dfu/dfu_rt_device.h
+++ b/src/class/dfu/dfu_rt_device.h
@@ -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
diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c
index 0d9cdb22b..c7f5d04ec 100644
--- a/src/class/hid/hid_device.c
+++ b/src/class/hid/hid_device.c
@@ -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
//--------------------------------------------------------------------+
diff --git a/src/class/hid/hid_device.h b/src/class/hid/hid_device.h
index 61274be4d..beb755888 100644
--- a/src/class/hid/hid_device.h
+++ b/src/class/hid/hid_device.h
@@ -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
diff --git a/src/class/hid/hid_host.c b/src/class/hid/hid_host.c
index 1bc86e4ad..83f3f3039 100644
--- a/src/class/hid/hid_host.c
+++ b/src/class/hid/hid_host.c
@@ -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"
//--------------------------------------------------------------------+
diff --git a/src/class/hid/hid_host.h b/src/class/hid/hid_host.h
index ea693df69..2e4cce600 100644
--- a/src/class/hid/hid_host.h
+++ b/src/class/hid/hid_host.h
@@ -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
diff --git a/src/class/midi/midi_device.c b/src/class/midi/midi_device.c
index 2c50bc4f3..953ca26e6 100644
--- a/src/class/midi/midi_device.c
+++ b/src/class/midi/midi_device.c
@@ -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
//--------------------------------------------------------------------+
diff --git a/src/class/midi/midi_device.h b/src/class/midi/midi_device.h
index 67f03930c..211edc8d1 100644
--- a/src/class/midi/midi_device.h
+++ b/src/class/midi/midi_device.h
@@ -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"
diff --git a/src/class/msc/msc.h b/src/class/msc/msc.h
index 0bdc00692..84b6e4d79 100644
--- a/src/class/msc/msc.h
+++ b/src/class/msc/msc.h
@@ -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_ */
-
-/// @}
-/// @}
diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c
index 539941935..9b06b7a33 100644
--- a/src/class/msc/msc_device.c
+++ b/src/class/msc/msc_device.c
@@ -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
//--------------------------------------------------------------------+
diff --git a/src/class/msc/msc_device.h b/src/class/msc/msc_device.h
index 469f2f2f7..8f90ef4ad 100644
--- a/src/class/msc/msc_device.h
+++ b/src/class/msc/msc_device.h
@@ -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
//--------------------------------------------------------------------+
diff --git a/src/class/msc/msc_host.c b/src/class/msc/msc_host.c
index ca360ca2a..5a4ffff48 100644
--- a/src/class/msc/msc_host.c
+++ b/src/class/msc/msc_host.c
@@ -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"
//--------------------------------------------------------------------+
diff --git a/src/class/msc/msc_host.h b/src/class/msc/msc_host.h
index b5ffcd401..ce4fe64dc 100644
--- a/src/class/msc/msc_host.h
+++ b/src/class/msc/msc_host.h
@@ -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
diff --git a/src/class/net/net_device.c b/src/class/net/net_device.c
index ce1131223..9d9719ce4 100644
--- a/src/class/net/net_device.c
+++ b/src/class/net/net_device.c
@@ -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 */
diff --git a/src/class/net/net_device.h b/src/class/net/net_device.h
index 38c47d647..f030f3077 100644
--- a/src/class/net/net_device.h
+++ b/src/class/net/net_device.h
@@ -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 */
diff --git a/src/class/usbtmc/usbtmc_device.c b/src/class/usbtmc/usbtmc_device.c
index d5f8fe41d..c1ee49f45 100644
--- a/src/class/usbtmc/usbtmc_device.c
+++ b/src/class/usbtmc/usbtmc_device.c
@@ -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];
diff --git a/src/class/vendor/vendor_device.c b/src/class/vendor/vendor_device.c
index 5fc7dd569..081aac9f6 100644
--- a/src/class/vendor/vendor_device.c
+++ b/src/class/vendor/vendor_device.c
@@ -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
//--------------------------------------------------------------------+
diff --git a/src/class/vendor/vendor_device.h b/src/class/vendor/vendor_device.h
index 2c3d79a3d..6d9c784c0 100644
--- a/src/class/vendor/vendor_device.h
+++ b/src/class/vendor/vendor_device.h
@@ -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
diff --git a/src/class/vendor/vendor_host.c b/src/class/vendor/vendor_host.c
index 0524cb981..1978ef61c 100644
--- a/src/class/vendor/vendor_host.c
+++ b/src/class/vendor/vendor_host.c
@@ -31,7 +31,7 @@
//--------------------------------------------------------------------+
// INCLUDE
//--------------------------------------------------------------------+
-#include "common/tusb_common.h"
+#include "host/usbh.h"
#include "vendor_host.h"
//--------------------------------------------------------------------+
diff --git a/src/class/vendor/vendor_host.h b/src/class/vendor/vendor_host.h
index fa1879376..07fa56c61 100644
--- a/src/class/vendor/vendor_host.h
+++ b/src/class/vendor/vendor_host.h
@@ -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_ */
-
-/** @} */
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h
index 88e85c9e0..1ebd8dd61 100644
--- a/src/common/tusb_common.h
+++ b/src/common/tusb_common.h
@@ -72,10 +72,11 @@
#include "tusb_option.h"
#include "tusb_compiler.h"
#include "tusb_verify.h"
-#include "tusb_error.h" // TODO remove
-#include "tusb_timeout.h"
#include "tusb_types.h"
+#include "tusb_error.h" // TODO remove
+#include "tusb_timeout.h" // TODO remove
+
//------------- Mem -------------//
#define tu_memclr(buffer, size) memset((buffer), 0, (size))
#define tu_varclr(_var) tu_memclr(_var, sizeof(*(_var)))
diff --git a/src/common/tusb_fifo.c b/src/common/tusb_fifo.c
index 5f7b6a26d..1eb886aa1 100644
--- a/src/common/tusb_fifo.c
+++ b/src/common/tusb_fifo.c
@@ -25,8 +25,6 @@
* This file is part of the TinyUSB stack.
*/
-#include <string.h>
-
#include "osal/osal.h"
#include "tusb_fifo.h"
diff --git a/src/common/tusb_fifo.h b/src/common/tusb_fifo.h
index 8d73911f0..cf299269d 100644
--- a/src/common/tusb_fifo.h
+++ b/src/common/tusb_fifo.h
@@ -28,6 +28,10 @@
#ifndef _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
// one item slice. Furthermore, write and read operations are completely
// 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
// within a certain number (see tu_fifo_overflow()).
+#include "common/tusb_common.h"
+
// mutex is only needed for RTOS
// for OS None, we don't get preempted
#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
#include "osal/osal.h"
#define tu_fifo_mutex_t osal_mutex_t
#endif
-/** \struct tu_fifo_t
- * \brief Simple Circular FIFO
- */
typedef struct
{
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);
#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_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);
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;
}
// Pointer modifications intended to be used in combinations with DMAs.
// 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_read_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);
// 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
diff --git a/src/device/dcd.h b/src/device/dcd.h
index 71e88054c..e17c62d4e 100644
--- a/src/device/dcd.h
+++ b/src/device/dcd.h
@@ -28,6 +28,7 @@
#define _TUSB_DCD_H_
#include "common/tusb_common.h"
+#include "osal/osal.h"
#include "common/tusb_fifo.h"
#ifdef __cplusplus
diff --git a/src/device/usbd.c b/src/device/usbd.c
index 8454a2951..71c5d4e6c 100644
--- a/src/device/usbd.c
+++ b/src/device/usbd.c
@@ -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
// success message. If total_bytes is too big, the FIFO will copy only what is available
// 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 dir = tu_edpt_dir(ep_addr);
diff --git a/src/device/usbd.h b/src/device/usbd.h
index 53519c4de..3857295d7 100644
--- a/src/device/usbd.h
+++ b/src/device/usbd.h
@@ -70,8 +70,8 @@ bool tud_mounted(void);
bool tud_suspended(void);
// Check if device is ready to transfer
-TU_ATTR_ALWAYS_INLINE
-static inline bool tud_ready(void)
+TU_ATTR_ALWAYS_INLINE static inline
+bool tud_ready(void)
{
return tud_mounted() && !tud_suspended();
}
diff --git a/src/device/usbd_pvt.h b/src/device/usbd_pvt.h
index 44310f022..65fdadf51 100644
--- a/src/device/usbd_pvt.h
+++ b/src/device/usbd_pvt.h
@@ -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);
// 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.
// 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
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)
{
return !usbd_edpt_busy(rhport, ep_addr) && !usbd_edpt_stalled(rhport, ep_addr);
diff --git a/src/host/hub.c b/src/host/hub.c
index 2191c4560..4db680f9e 100644
--- a/src/host/hub.c
+++ b/src/host/hub.c
@@ -28,9 +28,7 @@
#if (TUSB_OPT_HOST_ENABLED && CFG_TUH_HUB)
-//--------------------------------------------------------------------+
-// INCLUDE
-//--------------------------------------------------------------------+
+#include "usbh.h"
#include "hub.h"
//--------------------------------------------------------------------+
diff --git a/src/host/hub.h b/src/host/hub.h
index 851bb8e66..2b2f39ee1 100644
--- a/src/host/hub.h
+++ b/src/host/hub.h
@@ -37,7 +37,6 @@
#define _TUSB_HUB_H_
#include "common/tusb_common.h"
-#include "usbh.h"
#ifdef __cplusplus
extern "C" {
diff --git a/src/host/usbh.h b/src/host/usbh.h
index 590c8a359..a9790b484 100644
--- a/src/host/usbh.h
+++ b/src/host/usbh.h
@@ -34,10 +34,7 @@
extern "C" {
#endif
-//--------------------------------------------------------------------+
-// INCLUDE
-//--------------------------------------------------------------------+
-#include "osal/osal.h" // TODO refractor move to common.h ?
+#include "common/tusb_common.h"
#include "hcd.h"
//--------------------------------------------------------------------+
@@ -68,10 +65,6 @@ typedef struct {
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
//--------------------------------------------------------------------+
diff --git a/src/portable/espressif/esp32sx/dcd_esp32sx.c b/src/portable/espressif/esp32sx/dcd_esp32sx.c
index 502273a9b..d728487c2 100644
--- a/src/portable/espressif/esp32sx/dcd_esp32sx.c
+++ b/src/portable/espressif/esp32sx/dcd_esp32sx.c
@@ -40,7 +40,6 @@
#include "soc/gpio_sig_map.h"
#include "soc/usb_periph.h"
-#include "common/tusb_fifo.h"
#include "device/dcd.h"
// Since TinyUSB doesn't use SOF for now, and this interrupt too often (1ms interval)
diff --git a/src/portable/microchip/samg/dcd_samg.c b/src/portable/microchip/samg/dcd_samg.c
index 9b6a1f9a5..d50621ce4 100644
--- a/src/portable/microchip/samg/dcd_samg.c
+++ b/src/portable/microchip/samg/dcd_samg.c
@@ -29,7 +29,6 @@
#if CFG_TUSB_MCU == OPT_MCU_SAMG
#include "sam.h"
-#include "common/tusb_fifo.h"
#include "device/dcd.h"
// TODO should support (SAM3S || SAM4S || SAM4E || SAMG55)
diff --git a/src/portable/nuvoton/nuc120/dcd_nuc120.c b/src/portable/nuvoton/nuc120/dcd_nuc120.c
index 7aeb49f2a..047fa3fa6 100644
--- a/src/portable/nuvoton/nuc120/dcd_nuc120.c
+++ b/src/portable/nuvoton/nuc120/dcd_nuc120.c
@@ -37,7 +37,6 @@
#if TUSB_OPT_DEVICE_ENABLED && (CFG_TUSB_MCU == OPT_MCU_NUC120)
-#include "common/tusb_fifo.h"
#include "device/dcd.h"
#include "NUC100Series.h"
diff --git a/src/portable/nuvoton/nuc121/dcd_nuc121.c b/src/portable/nuvoton/nuc121/dcd_nuc121.c
index e76d7118c..37b7b0106 100644
--- a/src/portable/nuvoton/nuc121/dcd_nuc121.c
+++ b/src/portable/nuvoton/nuc121/dcd_nuc121.c
@@ -37,7 +37,6 @@
#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 "NuMicro.h"
diff --git a/src/portable/nuvoton/nuc505/dcd_nuc505.c b/src/portable/nuvoton/nuc505/dcd_nuc505.c
index 46081d4d0..4e633086d 100644
--- a/src/portable/nuvoton/nuc505/dcd_nuc505.c
+++ b/src/portable/nuvoton/nuc505/dcd_nuc505.c
@@ -37,7 +37,6 @@
#if TUSB_OPT_DEVICE_ENABLED && (CFG_TUSB_MCU == OPT_MCU_NUC505)
-#include "common/tusb_fifo.h"
#include "device/dcd.h"
#include "NUC505Series.h"
diff --git a/src/portable/raspberrypi/rp2040/dcd_rp2040.c b/src/portable/raspberrypi/rp2040/dcd_rp2040.c
index 7731078b5..0048270a6 100644
--- a/src/portable/raspberrypi/rp2040/dcd_rp2040.c
+++ b/src/portable/raspberrypi/rp2040/dcd_rp2040.c
@@ -35,8 +35,6 @@
#include "pico/fix/rp2040_usb_device_enumeration.h"
#endif
-#include "osal/osal.h"
-#include "common/tusb_fifo.h"
#include "device/dcd.h"
/*------------------------------------------------------------------*/
diff --git a/src/portable/sony/cxd56/dcd_cxd56.c b/src/portable/sony/cxd56/dcd_cxd56.c
index 54958182b..834976468 100644
--- a/src/portable/sony/cxd56/dcd_cxd56.c
+++ b/src/portable/sony/cxd56/dcd_cxd56.c
@@ -33,7 +33,6 @@
#include <nuttx/arch.h>
#include "device/dcd.h"
-#include "osal/osal.h"
#define CXD56_EPNUM (7)
#define CXD56_SETUP_QUEUE_DEPTH (4)
diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
index 0b7605a73..74c144107 100644
--- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
@@ -120,7 +120,6 @@
// Some definitions are copied to our private include file.
#undef USE_HAL_DRIVER
-#include "common/tusb_fifo.h"
#include "device/dcd.h"
#include "portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h"
diff --git a/src/portable/st/synopsys/dcd_synopsys.c b/src/portable/st/synopsys/dcd_synopsys.c
index 76f5c6050..8a196e061 100644
--- a/src/portable/st/synopsys/dcd_synopsys.c
+++ b/src/portable/st/synopsys/dcd_synopsys.c
@@ -94,10 +94,8 @@
#else
#error "Unsupported MCUs"
-
#endif
-#include "common/tusb_fifo.h"
#include "device/dcd.h"
//--------------------------------------------------------------------+
diff --git a/src/portable/template/dcd_template.c b/src/portable/template/dcd_template.c
index 92a9f3144..12b9144bf 100644
--- a/src/portable/template/dcd_template.c
+++ b/src/portable/template/dcd_template.c
@@ -28,7 +28,6 @@
#if CFG_TUSB_MCU == OPT_MCU_NONE
-#include "common/tusb_fifo.h"
#include "device/dcd.h"
//--------------------------------------------------------------------+
diff --git a/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c b/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
index e13ee697e..027ed26c9 100644
--- a/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
+++ b/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
@@ -30,7 +30,6 @@
#if TUSB_OPT_DEVICE_ENABLED && ( CFG_TUSB_MCU == OPT_MCU_MSP430x5xx )
#include "msp430.h"
-#include "common/tusb_fifo.h"
#include "device/dcd.h"
/*------------------------------------------------------------------*/
diff --git a/src/tusb_option.h b/src/tusb_option.h
index b317f7630..feff013c7 100644
--- a/src/tusb_option.h
+++ b/src/tusb_option.h
@@ -55,11 +55,11 @@
#define OPT_MCU_NRF5X 100 ///< Nordic nRF5x series
// SAM
-#define OPT_MCU_SAMD11 204 ///< MicroChip SAMD11
#define OPT_MCU_SAMD21 200 ///< MicroChip SAMD21
#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_SAME5X 203 ///< MicroChip SAM E5x
+#define OPT_MCU_SAMD11 204 ///< MicroChip SAMD11
#define OPT_MCU_SAML22 205 ///< MicroChip SAML22
// STM32