ram version see usbmsd_sd.cpp ram ok fs CANNOT be installed - too small use for illustrative purpose only

Dependencies:   USBDevice USBMSD_SD mbed

Fork of USBMSD_SD_HelloWorld_Mbed by Samuel Mokrani

Revision:
11:a26e7b7a1221
Parent:
10:cf8fd2b6ca23
Child:
12:a12eb1fc05f3
--- a/USBMSD/USBMSD.cpp	Wed Nov 16 11:06:27 2011 +0000
+++ b/USBMSD/USBMSD.cpp	Wed Nov 16 17:17:42 2011 +0000
@@ -62,7 +62,6 @@
                     case REPORT_DESCRIPTOR:
                         if ((reportDesc() != NULL) \
                                 && (reportDescLength() != 0)) {
-                            printf("report desc\r\n");
                             transfer->remaining = reportDescLength();
                             transfer->ptr = reportDesc();
                             transfer->direction = DEVICE_TO_HOST;
@@ -70,7 +69,6 @@
                         }
                         break;
                     case HID_DESCRIPTOR:
-                        printf("hid desc\r\n");
                         // Find the HID descriptor, after the configuration descriptor
                         hidDescriptor = findDescriptor(HID_DESCRIPTOR);
                         if (hidDescriptor != NULL) {
@@ -106,15 +104,12 @@
                 transfer->notify = true;
                 success = true;
             case MSC_REQUEST_GET_MAX_LUN:
-                printf("get max lun\r\n");
                 transfer->remaining = 1;
                 transfer->ptr = dum;
                 transfer->direction = DEVICE_TO_HOST;
                 success = true;
                 break;
             case SET_IDLE:
-                printf("set idle\r\n");
-                // First byte will be used for report ID
                 success = true;
             default:
                 break;
@@ -179,9 +174,9 @@
         return false;
     }
 
-    printf("blockSize: %d\r\n", BlockSize);
+    /*printf("blockSize: %d\r\n", BlockSize);
     printf("memSize: %d\r\n", MemorySize);
-    printf("number of blocks: %d\r\n", BlockCount);
+    printf("number of blocks: %d\r\n", BlockCount);*/
 
     //connect the device
     USBDevice::connect();
@@ -330,8 +325,8 @@
 bool USBMSD::inquiryRequest (void) {
     uint8_t inquiry[] = { 0x00, 0x80, 0x00, 0x01,
                           36 - 4, 0x80, 0x00, 0x00,
-                          'M', 'B', 'E', 'D', '.', 'O', 'R', 'G',
-                          'M', 'B', 'E', 'D', ' ', 'U', 'S', 'B', ' ', 'D', 'I', 'S', 'K', ' ', ' ', ' ',
+                          'M', 'b', 'e', 'd', '.', 'o', 'r', 'g',
+                          'M', 'b', 'e', 'd', ' ', 'U', 'S', 'B', ' ', 'D', 'i', 's', 'k', ' ', ' ', ' ',
                           '1', '.', '0', ' ',
                         };
     if (!write(inquiry, sizeof(inquiry))) {
@@ -385,9 +380,7 @@
     }
     stage = SEND_CSW;
 
-    if (!writeNB(EPBULK_IN, buf, size, MAX_PACKET_SIZE_EPBULK)) {
-        return false;
-    }
+    writeNB(EPBULK_IN, buf, size, MAX_PACKET_SIZE_EPBULK);
 
     csw.DataResidue -= size;
     csw.Status = CSW_PASSED;
@@ -443,7 +436,7 @@
     sendCSW();
 }
 
-DigitalOut l1(LED1);
+
 void USBMSD::CBWDecode(uint8_t * buf, uint16_t size) {
     if (size == sizeof(cbw)) {
         memcpy((uint8_t *)&cbw, buf, size);
@@ -648,9 +641,9 @@
 
 uint8_t * USBMSD::stringIproductDesc() {
     static uint8_t stringIproductDescriptor[] = {
-        0x12,                                           //bLength
+        0x1e,                                           //bLength
         STRING_DESCRIPTOR,                              //bDescriptorType 0x03
-        'M',0,'b',0,'e',0,'d',0,' ',0,'M',0,'S',0,'D',0 //bString iProduct - Mbed Audio
+        'M',0,'b',0,'e',0,'d',0,' ',0,'M',0,'S',0,'D', 0, ' ', 0, '&', 0, ' ', 0, 'H', 0, 'I', 0, 'D', 0 //bString iProduct - Mbed Audio
     };
     return stringIproductDescriptor;
 }
@@ -693,39 +686,11 @@
         C_RESERVED | C_SELF_POWERED,    // bmAttributes
         C_POWER(0),                     // bMaxPower
 
-        // Interface 1, Alternate Setting 0, MSC Class
-        9,      // bLength
-        4,      // bDescriptorType
-        0x00,   // bInterfaceNumber
-        0x00,   // bAlternateSetting
-        0x02,   // bNumEndpoints
-        0x08,   // bInterfaceClass
-        0x06,   // bInterfaceSubClass
-        0x50,   // bInterfaceProtocol
-        0x00,   // iInterface
-
-        // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
-        7,                          // bLength
-        5,                          // bDescriptorType
-        PHY_TO_DESC(EPBULK_IN),     // bEndpointAddress
-        0x02,                       // bmAttributes (0x02=bulk)
-        LSB(MAX_PACKET_SIZE_EPBULK),// wMaxPacketSize (LSB)
-        MSB(MAX_PACKET_SIZE_EPBULK),// wMaxPacketSize (MSB)
-        0,                          // bInterval
-
-        // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
-        7,                          // bLength
-        5,                          // bDescriptorType
-        PHY_TO_DESC(EPBULK_OUT),    // bEndpointAddress
-        0x02,                       // bmAttributes (0x02=bulk)
-        LSB(MAX_PACKET_SIZE_EPBULK),// wMaxPacketSize (LSB)
-        MSB(MAX_PACKET_SIZE_EPBULK),// wMaxPacketSize (MSB)
-        0,                           // bInterval
 
         // interface 1: HID
         INTERFACE_DESCRIPTOR_LENGTH,    // bLength
         INTERFACE_DESCRIPTOR,           // bDescriptorType
-        0x01,                           // bInterfaceNumber
+        0x00,                           // bInterfaceNumber
         0x00,                           // bAlternateSetting
         0x02,                           // bNumEndpoints
         HID_CLASS,                      // bInterfaceClass
@@ -759,6 +724,36 @@
         MSB(MAX_PACKET_SIZE_EPINT),     // wMaxPacketSize (MSB)
         10,                             // bInterval (milliseconds)
 
+        // Interface 1, Alternate Setting 0, MSC Class
+        9,      // bLength
+        4,      // bDescriptorType
+        0x01,   // bInterfaceNumber
+        0x00,   // bAlternateSetting
+        0x02,   // bNumEndpoints
+        0x08,   // bInterfaceClass
+        0x06,   // bInterfaceSubClass
+        0x50,   // bInterfaceProtocol
+        0x00,   // iInterface
+
+        // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
+        7,                          // bLength
+        5,                          // bDescriptorType
+        PHY_TO_DESC(EPBULK_IN),     // bEndpointAddress
+        0x02,                       // bmAttributes (0x02=bulk)
+        LSB(MAX_PACKET_SIZE_EPBULK),// wMaxPacketSize (LSB)
+        MSB(MAX_PACKET_SIZE_EPBULK),// wMaxPacketSize (MSB)
+        0,                          // bInterval
+
+        // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13
+        7,                          // bLength
+        5,                          // bDescriptorType
+        PHY_TO_DESC(EPBULK_OUT),    // bEndpointAddress
+        0x02,                       // bmAttributes (0x02=bulk)
+        LSB(MAX_PACKET_SIZE_EPBULK),// wMaxPacketSize (LSB)
+        MSB(MAX_PACKET_SIZE_EPBULK),// wMaxPacketSize (MSB)
+        0,                           // bInterval
+
+
     };
     return configDescriptor;
 }