Example program for USBMSD device (USB Flashdisk) library using AT45DBxx serial flash storage chip. Works with 2, 4, 8, 16, 32 and 64 Mbit chips within AT45DBxx

Dependencies:   USBDevice USBMSD_AT45 mbed

Committer:
llumpu
Date:
Sat Oct 27 14:37:34 2012 +0000
Revision:
0:42f27224d4d7
Initial release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
llumpu 0:42f27224d4d7 1 #include "mbed.h"
llumpu 0:42f27224d4d7 2 #include "USBMSD_AT45.h"
llumpu 0:42f27224d4d7 3
llumpu 0:42f27224d4d7 4 USBMSD_AT45 Flash(p5, p6, p7, p8, 512); // Mosi, Miso, Sclk, CS, Size of block being transported over USB
llumpu 0:42f27224d4d7 5 // each time. Can be 512, 1024, 2048, 4096. Best is to select same
llumpu 0:42f27224d4d7 6 // size as AT45DBxx SRAM buffer size. If page size of flash is not
llumpu 0:42f27224d4d7 7 // binary 2^N (256, 512, 1024 bytes) but is 264, 528 or 1056 bytes
llumpu 0:42f27224d4d7 8 // before each write we read block being written to SRAM then rewrite
llumpu 0:42f27224d4d7 9 // part of them with data from host and write whole SRAM buffer back
llumpu 0:42f27224d4d7 10 // to flash. This avoids to data being rewritten in other blocks
llumpu 0:42f27224d4d7 11 // we actually do not write to.
llumpu 0:42f27224d4d7 12 int main() {
llumpu 0:42f27224d4d7 13
llumpu 0:42f27224d4d7 14 while(1) {
llumpu 0:42f27224d4d7 15
llumpu 0:42f27224d4d7 16 // Do something else here
llumpu 0:42f27224d4d7 17
llumpu 0:42f27224d4d7 18 }
llumpu 0:42f27224d4d7 19 }