diff options
| author | Ha Thach <[email protected]> | 2021-05-27 19:44:10 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-05-27 19:44:10 +0700 |
| commit | 81d238bd463c694af6ef31015107c0727805c7c7 (patch) | |
| tree | 3fe4e811be63d83f8c47cc49ca6f048bd5904f4a /src/class | |
| parent | 4e2684f23aacfd9a08046c2a60da50bd1af09a27 (diff) | |
| parent | 7c66c5121b862443aacf7eadbef45153a3fa3060 (diff) | |
Merge pull request #854 from hathach/more-housekeeping
More housekeeping
Diffstat (limited to 'src/class')
29 files changed, 65 insertions, 116 deletions
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_ */ - -/** @} */ |
