From 22786f8817fb9cc3f558a721029d99d20149a152 Mon Sep 17 00:00:00 2001 From: heyuanjie87 Date: Wed, 9 Jan 2013 12:04:01 +0800 Subject: allows the user to custom PID and VID; add a dcd operation to send status in control transfer --- components/drivers/include/drivers/usb_device.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'components/drivers/include') diff --git a/components/drivers/include/drivers/usb_device.h b/components/drivers/include/drivers/usb_device.h index b969eb6864..e4b623ab00 100644 --- a/components/drivers/include/drivers/usb_device.h +++ b/components/drivers/include/drivers/usb_device.h @@ -19,10 +19,19 @@ #include #include "usb_common.h" -#define CONTROL_SEND_STATUS 0x00 -#define CONTROL_RECEIVE_STATUS 0x01 +/* Vendor ID */ +#ifdef USB_VENDOR_ID +#define USB_VENDOR_ID _VENDOR_ID +#else +#define _VENDOR_ID 0x0EFF +#endif +/* Product ID */ +#ifdef USB_PRODUCT_ID +#define USB_PRODUCT_ID _PRODUCT_ID +#else +#define _PRODUCT_ID 0x0001 +#endif -#define USB_VENDOR_ID 0x0483 /* Vendor ID */ #define USB_BCD_DEVICE 0x0200 /* USB Specification Release Number in Binary-Coded Decimal */ #define USB_BCD_VERSION 0x0200 /* USB 2.0 */ @@ -42,6 +51,7 @@ struct udcd_ops rt_err_t (*ep_stop)(struct uendpoint* ep); rt_err_t (*ep_read)(struct uendpoint* ep, void *buffer, rt_size_t size); rt_size_t (*ep_write)(struct uendpoint* ep, void *buffer, rt_size_t size); + rt_err_t (*send_status)(void); }; struct udcd @@ -264,4 +274,11 @@ rt_inline rt_size_t dcd_ep_write(udcd_t dcd, uep_t ep, void *buffer, return dcd->ops->ep_write(ep, buffer, size); } +rt_inline rt_err_t dcd_send_status(udcd_t dcd) +{ + RT_ASSERT(dcd != RT_NULL); + + return dcd->ops->send_status(); +} + #endif -- cgit v1.3.1 From 6b0b2d51e30c4b0feadc624759a750a556ddce1d Mon Sep 17 00:00:00 2001 From: heyuanjie87 Date: Wed, 9 Jan 2013 12:12:25 +0800 Subject: move the define related to Mass to mstorage.h --- components/drivers/include/drivers/usb_common.h | 52 ++----------------------- 1 file changed, 3 insertions(+), 49 deletions(-) (limited to 'components/drivers/include') diff --git a/components/drivers/include/drivers/usb_common.h b/components/drivers/include/drivers/usb_common.h index 503d3edbae..16b332744a 100644 --- a/components/drivers/include/drivers/usb_common.h +++ b/components/drivers/include/drivers/usb_common.h @@ -9,11 +9,11 @@ * * Change Logs: * Date Author Notes - * 2012-10-01 Yi Qiu first version + * 2012-10-01 Yi Qiu first version */ -#ifndef __RT_USB_COMMON_H__ -#define __RT_USB_COMMON_H__ +#ifndef __USB_COMMON_H__ +#define __USB_COMMON_H__ #ifdef __cplusplus extern "C" { @@ -320,52 +320,6 @@ struct ureqest }; typedef struct ureqest* ureq_t; -struct ustorage_cbw -{ - rt_uint32_t signature; - rt_uint32_t tag; - rt_uint32_t xfer_len; - rt_uint8_t dflags; - rt_uint8_t lun; - rt_uint8_t cb_len; - rt_uint8_t cb[16]; -}; -typedef struct ustorage_cbw* ustorage_cbw_t; - -struct ustorage_csw -{ - rt_uint32_t signature; - rt_uint32_t tag; - rt_uint32_t data_reside; - rt_uint8_t status; -}; -typedef struct ustorage_csw* ustorage_csw_t; - -#define SIZEOF_CSW 0x0d -#define SIZEOF_CBW 0x1f - -#define CBWFLAGS_DIR_M 0x80 -#define CBWFLAGS_DIR_IN 0x80 -#define CBWFLAGS_DIR_OUT 0x00 - -#define SCSI_TEST_UNIT_READY 0x00 -#define SCSI_REQUEST_SENSE 0x03 -#define SCSI_INQUIRY_CMD 0x12 -#define SCSI_ALLOW_MEDIUM_REMOVAL 0x1e -#define SCSI_MODE_SENSE_6 0x1a -#define SCSI_READ_CAPACITIES 0x23 -#define SCSI_READ_CAPACITY 0x25 -#define SCSI_READ_10 0x28 -#define SCSI_WRITE_10 0x2a -#define SCSI_VERIFY_10 0x2f - -#define CBW_SIGNATURE 0x43425355 -#define CSW_SIGNATURE 0x53425355 -#define CBW_TAG_VALUE 0x12345678 - -#define USBREQ_GET_MAX_LUN 0xfe -#define USBREQ_MASS_STORAGE_RESET 0xff - #define MIN(a, b) (a < b ? a : b) #define MAX(a, b) (a > b ? a : b) -- cgit v1.3.1 From d84fde4e5493b1409adb2892fd4ac7cb4aadf303 Mon Sep 17 00:00:00 2001 From: heyuanjie87 Date: Wed, 9 Jan 2013 18:56:14 +0800 Subject: revert the define --- components/drivers/include/drivers/usb_common.h | 28 +++++++++++++++++++++++ components/drivers/usb/usbdevice/class/mstorage.h | 25 -------------------- 2 files changed, 28 insertions(+), 25 deletions(-) (limited to 'components/drivers/include') diff --git a/components/drivers/include/drivers/usb_common.h b/components/drivers/include/drivers/usb_common.h index 16b332744a..495cc17787 100644 --- a/components/drivers/include/drivers/usb_common.h +++ b/components/drivers/include/drivers/usb_common.h @@ -323,6 +323,34 @@ typedef struct ureqest* ureq_t; #define MIN(a, b) (a < b ? a : b) #define MAX(a, b) (a > b ? a : b) +/* + * the define related to mass storage + */ +#define USBREQ_GET_MAX_LUN 0xfe +#define USBREQ_MASS_STORAGE_RESET 0xff + +#define SIZEOF_CSW 0x0d +#define SIZEOF_CBW 0x1f + +#define CBWFLAGS_DIR_M 0x80 +#define CBWFLAGS_DIR_IN 0x80 +#define CBWFLAGS_DIR_OUT 0x00 + +#define SCSI_TEST_UNIT_READY 0x00 +#define SCSI_REQUEST_SENSE 0x03 +#define SCSI_INQUIRY_CMD 0x12 +#define SCSI_ALLOW_MEDIUM_REMOVAL 0x1e +#define SCSI_MODE_SENSE_6 0x1a +#define SCSI_READ_CAPACITIES 0x23 +#define SCSI_READ_CAPACITY 0x25 +#define SCSI_READ_10 0x28 +#define SCSI_WRITE_10 0x2a +#define SCSI_VERIFY_10 0x2f + +#define CBW_SIGNATURE 0x43425355 +#define CSW_SIGNATURE 0x53425355 +#define CBW_TAG_VALUE 0x12345678 + #pragma pack() #ifdef __cplusplus diff --git a/components/drivers/usb/usbdevice/class/mstorage.h b/components/drivers/usb/usbdevice/class/mstorage.h index 556e3aa77e..eb8e81a68f 100644 --- a/components/drivers/usb/usbdevice/class/mstorage.h +++ b/components/drivers/usb/usbdevice/class/mstorage.h @@ -18,31 +18,6 @@ #include -#define USBREQ_GET_MAX_LUN 0xfe -#define USBREQ_MASS_STORAGE_RESET 0xff - -#define SIZEOF_CSW 0x0d -#define SIZEOF_CBW 0x1f - -#define CBWFLAGS_DIR_M 0x80 -#define CBWFLAGS_DIR_IN 0x80 -#define CBWFLAGS_DIR_OUT 0x00 - -#define SCSI_TEST_UNIT_READY 0x00 -#define SCSI_REQUEST_SENSE 0x03 -#define SCSI_INQUIRY_CMD 0x12 -#define SCSI_ALLOW_MEDIUM_REMOVAL 0x1e -#define SCSI_MODE_SENSE_6 0x1a -#define SCSI_READ_CAPACITIES 0x23 -#define SCSI_READ_CAPACITY 0x25 -#define SCSI_READ_10 0x28 -#define SCSI_WRITE_10 0x2a -#define SCSI_VERIFY_10 0x2f - -#define CBW_SIGNATURE 0x43425355 -#define CSW_SIGNATURE 0x53425355 -#define CBW_TAG_VALUE 0x12345678 - #pragma pack(1) struct ustorage_cbw -- cgit v1.3.1