USBMSD SD card Hello World for Mbed platforms
Dependencies: mbed USBMSD_SD USBDevice
Diff: USB_SDcard.h
- Revision:
- 3:0ffb2eee9e06
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USB_SDcard.h Fri Nov 11 16:12:21 2011 +0000 @@ -0,0 +1,43 @@ +/* mbed Microcontroller Library - SDFileSystem + * Copyright (c) 2008-2009, sford + */ + +#ifndef USB_SDCARD_H +#define USB_SDCARD_H + +#include "mbed.h" +#include "USBMSD.h" + +class USB_SDcard: public USBMSD +{ +public: + USB_SDcard(PinName mosi = p5, PinName miso = p6, PinName sclk = p7, PinName cs = p8); + + /* + * 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); + + /* + * 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); + +protected: + int _cmd(int cmd, int arg); + int _read(uint8_t * buffer, uint16_t length); + int _write(uint8_t * buffer, uint16_t length); + + SPI _spi; + DigitalOut _cs; +}; + +#endif