USBMSD SD card Hello World for Mbed platforms

Dependencies:   mbed USBMSD_SD USBDevice

Revision:
20:50bf1cd2e2fe
Parent:
19:148a0b8d23bc
Child:
21:bbe291251dde
--- a/USBDevice/USBMSD/USBMSD.cpp	Sun Dec 11 15:42:23 2011 +0000
+++ b/USBDevice/USBMSD/USBMSD.cpp	Sun Dec 11 15:56:08 2011 +0000
@@ -18,15 +18,14 @@
 
 #include "stdint.h"
 #include "USBMSD.h"
-#include "USBBusInterface.h"
 
 #define DISK_OK         0x00
 #define NO_INIT         0x01
 #define NO_DISK         0x02
 #define WRITE_PROTECT   0x04
 
-#define CBW_Signature               0x43425355
-#define CSW_Signature               0x53425355
+#define CBW_Signature   0x43425355
+#define CSW_Signature   0x53425355
 
 // SCSI Commands
 #define TEST_UNIT_READY            0x00
@@ -48,12 +47,12 @@
 #define MODE_SENSE10               0x5A
 
 // MSC class specific requests
-#define MSC_REQUEST_RESET               0xFF
-#define MSC_REQUEST_GET_MAX_LUN         0xFE
+#define MSC_REQUEST_RESET          0xFF
+#define MSC_REQUEST_GET_MAX_LUN    0xFE
 
 #define DEFAULT_CONFIGURATION (1)
 
-// Max In/Out Packet Size on the bulk endpoint */
+// max packet size
 #define MAX_PACKET  MAX_PACKET_SIZE_EPBULK
 
 // CSW Status
@@ -74,6 +73,7 @@
 
     bool success = false;
     CONTROL_TRANSFER * transfer = getTransferPtr();
+    uint8_t maxLUN[1] = {0};
 
     if (transfer->setup.bmRequestType.Type == CLASS_TYPE) {
         switch (transfer->setup.bRequest) {
@@ -83,7 +83,7 @@
                 break;
             case MSC_REQUEST_GET_MAX_LUN:
                 transfer->remaining = 1;
-                transfer->ptr = getMaxLUN();
+                transfer->ptr = maxLUN;
                 transfer->direction = DEVICE_TO_HOST;
                 success = true;
                 break;
@@ -95,7 +95,7 @@
     return success;
 }
 
-DigitalOut l1(LED1); 
+
 bool USBMSD::connect() {
 
     //disk initialization
@@ -132,10 +132,6 @@
     stage = READ_CBW;
 }
 
-uint8_t * USBMSD::getMaxLUN() {
-    static uint8_t LUN[] = {0};
-    return LUN;
-}
 
 // Called in ISR context called when a data is received
 bool USBMSD::EP2_OUT_callback() {
@@ -353,20 +349,20 @@
 
 bool USBMSD::requestSense (void) {
     uint8_t request_sense[] = {
-        0x70,   // Response Code
+        0x70,
         0x00,
         0x05,   // Sense Key: illegal request
         0x00,
         0x00,
         0x00,
         0x00,
-        0x0A,   // Additional Length
+        0x0A,
         0x00,
         0x00,
         0x00,
         0x00,
-        0x30,   // ASC
-        0x01,   // ASCQ
+        0x30,
+        0x01,
         0x00,
         0x00,
         0x00,