summaryrefslogtreecommitdiff
path: root/src/class/msc
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-04-19 00:49:32 +0700
committerGitHub <[email protected]>2019-04-19 00:49:32 +0700
commitee3504fdb06ad83a0d4896b56a4181c114fda703 (patch)
treeb88a4144ee3fc2799268e6f51869756eea18ba23 /src/class/msc
parent074898099da6bfd8784019d97c64712f73b779b0 (diff)
parent6796026476e14fc82402cdbd2dc4418f51240ae5 (diff)
Merge pull request #56 from hathach/develop
refactor hid device, remove auto descriptor, update example
Diffstat (limited to 'src/class/msc')
-rw-r--r--src/class/msc/msc_device.c1
-rw-r--r--src/class/msc/msc_device.h28
2 files changed, 22 insertions, 7 deletions
diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c
index ace91b40a..a6b65557c 100644
--- a/src/class/msc/msc_device.c
+++ b/src/class/msc/msc_device.c
@@ -113,7 +113,6 @@ bool tud_msc_set_sense(uint8_t lun, uint8_t sense_key, uint8_t add_sense_code, u
return true;
}
-
//--------------------------------------------------------------------+
// USBD-CLASS API
//--------------------------------------------------------------------+
diff --git a/src/class/msc/msc_device.h b/src/class/msc/msc_device.h
index 74be7e06d..b6cef78b6 100644
--- a/src/class/msc/msc_device.h
+++ b/src/class/msc/msc_device.h
@@ -31,6 +31,9 @@
#include "device/usbd.h"
#include "msc.h"
+#ifdef __cplusplus
+ extern "C" {
+#endif
//--------------------------------------------------------------------+
// Class Driver Configuration
@@ -44,7 +47,7 @@ TU_VERIFY_STATIC(CFG_TUD_MSC_BUFSIZE < UINT16_MAX, "Size is not correct");
#endif
#ifndef CFG_TUD_MSC_BUFSIZE
- #error CFG_TUD_MSC_BUFSIZE must be defined, value of CFG_TUD_MSC_BLOCK_SZ should work well, the more the better
+ #error CFG_TUD_MSC_BUFSIZE must be defined, value of a block size should work well, the more the better
#endif
#ifndef CFG_TUD_MSC_VENDOR
@@ -59,10 +62,6 @@ TU_VERIFY_STATIC(CFG_TUD_MSC_BUFSIZE < UINT16_MAX, "Size is not correct");
#error CFG_TUD_MSC_PRODUCT_REV 4-byte string must be defined
#endif
-#ifdef __cplusplus
- extern "C" {
-#endif
-
/** \addtogroup ClassDriver_MSC
* @{
* \defgroup MSC_Device Device
@@ -133,7 +132,7 @@ void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_siz
*/
int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize);
-/*------------- Optional callbacks : Could be used by application to free up resources -------------*/
+/*------------- Optional callbacks -------------*/
// Invoked when Read10 command is complete
ATTR_WEAK void tud_msc_read10_complete_cb(uint8_t lun);
@@ -147,6 +146,23 @@ ATTR_WEAK void tud_msc_scsi_complete_cb(uint8_t lun, uint8_t const scsi_cmd[16])
// Hook to make a mass storage device read-only. TODO remove
ATTR_WEAK bool tud_msc_is_writable_cb(uint8_t lun);
+//--------------------------------------------------------------------+
+// Interface Descriptor Template
+//--------------------------------------------------------------------+
+
+// Length of template descriptor: 23 bytes
+#define TUD_MSC_DESC_LEN (9 + 7 + 7)
+
+// Interface Number, EP Out & EP In address
+#define TUD_MSC_DESCRIPTOR(_itfnum, _stridx, _epout, _epin, _epsize) \
+ /* Interface */\
+ 9, TUSB_DESC_INTERFACE, _itfnum, 0, 2, TUSB_CLASS_MSC, MSC_SUBCLASS_SCSI, MSC_PROTOCOL_BOT, _stridx,\
+ /* Endpoint Out */\
+ 7, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0,\
+ /* Endpoint In */\
+ 7, TUSB_DESC_ENDPOINT, _epin, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0
+
+
/** @} */
/** @} */