USBMSD SD card Hello World for Mbed platforms
Dependencies: mbed USBMSD_SD USBDevice
Diff: USBDevice/USBMSD/USBMSD.h
- Revision:
- 6:126c4d980196
- Parent:
- 5:8afbc15d6892
--- a/USBDevice/USBMSD/USBMSD.h Sun Nov 13 12:30:43 2011 +0000 +++ b/USBDevice/USBMSD/USBMSD.h Mon Nov 14 10:00:07 2011 +0000 @@ -5,14 +5,6 @@ /* * Guide to adapt this class to your storage chip: * -* - Adapt the BlockSize symbol in USBMSD.h -* - Adapt the MemorySize symbol in USBMSD.cpp -* - Declare a class which inherits from USBMSD -* - Define two virtual functions: -* - blockRead(uint8_t * page, uint16_t block_number); -* - blockWrite(uint8_t * page, uint16_t block_number); -* These functions are used by USBMSD class to read or write data -* - Instanciate your object */ #ifndef USBMSD_H @@ -27,15 +19,13 @@ #define DEFAULT_CONFIGURATION (1) -// Block Size -#define BlockSize 512 // MSC Bulk-only Stage enum Stage { READ_CBW, // wait a CBW + ERROR, // error PROCESS_CBW, // process a CBW request SEND_CSW, // send a CSW - ERROR, // error WAIT_CSW, // wait that a CSW has been effectively sent }; @@ -89,6 +79,32 @@ */ virtual int blockWrite(uint8_t * data, uint16_t block){return 1;}; + /* + * Disk initilization + */ + virtual int diskInit(){return -1;}; + + /* + * Return block size + * + * @returns size of a block + */ + virtual uint16_t blockSize(){return 0;}; + + /* + * Return memory size + * + * @returns memory size + */ + virtual uint32_t memorySize(){return 0;}; + + /* + * Connect the USB MSD device. Establish disk initialization before really connect the device. + * + * @returns + */ + bool connect(); + protected: @@ -162,7 +178,11 @@ bool memOK; // cache in RAM before writing in memory. Useful also to read a block. - uint8_t page[BlockSize]; + uint8_t * page; + + uint16_t BlockSize; + uint32_t MemorySize; + uint16_t BlockCount; void CBWDecode(uint8_t * buf, uint16_t size); void sendCSW (void);