USBMSD SD card Hello World for Mbed platforms
Dependencies: mbed USBMSD_SD USBDevice
Diff: USBDevice/USBMSD/USBMSD.h
- Revision:
- 3:0ffb2eee9e06
- Parent:
- 2:27a7e7f8d399
- Child:
- 4:980e6470dcce
--- a/USBDevice/USBMSD/USBMSD.h Fri Nov 11 15:22:53 2011 +0000 +++ b/USBDevice/USBMSD/USBMSD.h Fri Nov 11 16:12:21 2011 +0000 @@ -5,13 +5,14 @@ /* * Guide to adapt this class to your storage chip: * -* - adapt the BlockSize symbol in USBMSD.h -* - adapt the MemorySize symbol in USBMSD.cpp -* - declare your own object to store data: here AT45 mem -* - Be sure to provide : -* - mem.blockread(page, block_number); -* - mem.blockwrite(page, block_number); +* - 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 @@ -23,7 +24,6 @@ #include "USBDevice_Types.h" #include "USBDevice.h" -#include "SDcard.h" #define DEFAULT_CONFIGURATION (1) @@ -58,21 +58,7 @@ uint8_t Status; } CSW; -/** -* USBMSD example -* -* @code -* #include "mbed.h" -* #include "USBMSD.h" -* -* USBMSD msd; -* -* int main() { -* while(1); -* } -* -* @endcode -*/ + class USBMSD: public USBDevice { public: @@ -85,9 +71,26 @@ */ USBMSD(uint16_t vendor_id = 0x0703, uint16_t product_id = 0x0104, uint16_t product_release = 0x0001); - + /* + * read a block on a storage chip + * + * @param data pointer where will be stored read data + * @param block block number + * @returns 0 if successful + */ + virtual int blockRead(uint8_t * data, uint16_t block){return 1;}; + + /* + * write a block on a storage chip + * + * @param data data to write + * @param block block number + * @returns 0 if successful + */ + virtual int blockWrite(uint8_t * data, uint16_t block){return 1;}; + +protected: -protected: /* * Get number of logical unit - 1 (here 0) @@ -159,14 +162,6 @@ // cache in RAM before writing in memory. Useful also to read a block. uint8_t page[BlockSize]; - - // memory (Atmel AT45 family) - // - // You can change this memory to use another one (SDcard, ...) - // You need to provide : - // - mem.blockread(page, block_number); - // - mem.blockwrite(page, block_number); - SDcard mem; void CBWDecode(uint8_t * buf, uint16_t size); void sendCSW (void); @@ -186,4 +181,3 @@ }; #endif -