USBMSD SD card Hello World for Mbed platforms
Dependencies: mbed USBMSD_SD USBDevice
USB_SDcard.h@3:0ffb2eee9e06, 2011-11-11 (annotated)
- Committer:
- samux
- Date:
- Fri Nov 11 16:12:21 2011 +0000
- Revision:
- 3:0ffb2eee9e06
good: we can use the sd card as mass storage device
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
samux |
3:0ffb2eee9e06 | 1 | /* mbed Microcontroller Library - SDFileSystem |
samux |
3:0ffb2eee9e06 | 2 | * Copyright (c) 2008-2009, sford |
samux |
3:0ffb2eee9e06 | 3 | */ |
samux |
3:0ffb2eee9e06 | 4 | |
samux |
3:0ffb2eee9e06 | 5 | #ifndef USB_SDCARD_H |
samux |
3:0ffb2eee9e06 | 6 | #define USB_SDCARD_H |
samux |
3:0ffb2eee9e06 | 7 | |
samux |
3:0ffb2eee9e06 | 8 | #include "mbed.h" |
samux |
3:0ffb2eee9e06 | 9 | #include "USBMSD.h" |
samux |
3:0ffb2eee9e06 | 10 | |
samux |
3:0ffb2eee9e06 | 11 | class USB_SDcard: public USBMSD |
samux |
3:0ffb2eee9e06 | 12 | { |
samux |
3:0ffb2eee9e06 | 13 | public: |
samux |
3:0ffb2eee9e06 | 14 | USB_SDcard(PinName mosi = p5, PinName miso = p6, PinName sclk = p7, PinName cs = p8); |
samux |
3:0ffb2eee9e06 | 15 | |
samux |
3:0ffb2eee9e06 | 16 | /* |
samux |
3:0ffb2eee9e06 | 17 | * read a block on a storage chip |
samux |
3:0ffb2eee9e06 | 18 | * |
samux |
3:0ffb2eee9e06 | 19 | * @param data pointer where will be stored read data |
samux |
3:0ffb2eee9e06 | 20 | * @param block block number |
samux |
3:0ffb2eee9e06 | 21 | * @returns 0 if successful |
samux |
3:0ffb2eee9e06 | 22 | */ |
samux |
3:0ffb2eee9e06 | 23 | virtual int blockRead(uint8_t * data, uint16_t block); |
samux |
3:0ffb2eee9e06 | 24 | |
samux |
3:0ffb2eee9e06 | 25 | /* |
samux |
3:0ffb2eee9e06 | 26 | * write a block on a storage chip |
samux |
3:0ffb2eee9e06 | 27 | * |
samux |
3:0ffb2eee9e06 | 28 | * @param data data to write |
samux |
3:0ffb2eee9e06 | 29 | * @param block block number |
samux |
3:0ffb2eee9e06 | 30 | * @returns 0 if successful |
samux |
3:0ffb2eee9e06 | 31 | */ |
samux |
3:0ffb2eee9e06 | 32 | virtual int blockWrite(uint8_t * data, uint16_t block); |
samux |
3:0ffb2eee9e06 | 33 | |
samux |
3:0ffb2eee9e06 | 34 | protected: |
samux |
3:0ffb2eee9e06 | 35 | int _cmd(int cmd, int arg); |
samux |
3:0ffb2eee9e06 | 36 | int _read(uint8_t * buffer, uint16_t length); |
samux |
3:0ffb2eee9e06 | 37 | int _write(uint8_t * buffer, uint16_t length); |
samux |
3:0ffb2eee9e06 | 38 | |
samux |
3:0ffb2eee9e06 | 39 | SPI _spi; |
samux |
3:0ffb2eee9e06 | 40 | DigitalOut _cs; |
samux |
3:0ffb2eee9e06 | 41 | }; |
samux |
3:0ffb2eee9e06 | 42 | |
samux |
3:0ffb2eee9e06 | 43 | #endif |