Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: USBMSD_AT45_HelloWorld
USBMSD_AT45 Class Reference
USBMSD device (USB flashdisk) with Atmel AT45DBxx serial flash. More...
#include <USBMSD_AT45.h>
Public Member Functions | |
USBMSD_AT45 (PinName mosi, PinName miso, PinName sclk, PinName ncs, int transport_block_size) | |
Constructor. | |
virtual int | disk_read (char *data, int block) |
disk_read() | |
virtual int | disk_write (const char *data, int block) |
disk_write() | |
virtual int | disk_size () |
disk_size() | |
virtual int | disk_sectors () |
disk_sectors() | |
virtual int | disk_status () |
disk_status() | |
virtual int | disk_initialize () |
disk_initialize() |
Detailed Description
USBMSD device (USB flashdisk) with Atmel AT45DBxx serial flash.
Example:
#include "mbed.h" #include "USBMSD_AT45.h" USBMSD_AT45 Flash(p5, p6, p7, p8, 512); // Mosi, Miso, Sclk, CS, Size of block being transported over USB // each time. Can be 512, 1024, 2048, 4096. Best is to select same // size as AT45DBxx SRAM buffer size. If page size of flash is not // binary 2^N (256, 512, 1024 bytes) but is 264, 528 or 1056 bytes // before each write we read block being written to SRAM then rewrite // part of them with data from host and write whole SRAM buffer back // to flash. This avoids to data being rewritten in other blocks // we actually do not write to. int main() { while(1) { // Do something else here } }
Definition at line 56 of file USBMSD_AT45.h.
Constructor & Destructor Documentation
USBMSD_AT45 | ( | PinName | mosi, |
PinName | miso, | ||
PinName | sclk, | ||
PinName | ncs, | ||
int | transport_block_size | ||
) |
Constructor.
Create an instance of the USBMSD_AT45 connected to specfied SPI pins, with the specified CHIP SELECT pin
- Parameters:
-
mosi The SPI mosi Pin (p5 or p11) miso The SPI miso Pin (p6 or p12) sclk The SPI sclk Pin (p7 or p13) ncs The SPI chip select Pin (any digital out pin) transport_block_size The size of block being transported over USB
Definition at line 47 of file USBMSD_AT45.cpp.
Member Function Documentation
int disk_initialize | ( | ) | [virtual] |
This method is called when disk_status returns 0x01 (not initialized)
Definition at line 68 of file USBMSD_AT45.cpp.
int disk_read | ( | char * | data, |
int | block | ||
) | [virtual] |
Reads block of data from storage chip. Size of block is set in constructor
- Parameters:
-
data Pointer to buffer where data will be read to block Number of requested block
Definition at line 104 of file USBMSD_AT45.cpp.
int disk_sectors | ( | ) | [virtual] |
- Parameters:
-
returns Count of sectors of storage chip
Definition at line 89 of file USBMSD_AT45.cpp.
int disk_size | ( | ) | [virtual] |
- Parameters:
-
returns Size of storage chip in bytes
Definition at line 82 of file USBMSD_AT45.cpp.
int disk_status | ( | ) | [virtual] |
- Parameters:
-
returns Status of storage chip - 0x00 ready, 0x01 not initialized (disk_initialize is then called)
Definition at line 96 of file USBMSD_AT45.cpp.
int disk_write | ( | const char * | data, |
int | block | ||
) | [virtual] |
Writes block of data to storage chip. Size of block is set in constructor
- Parameters:
-
data Pointer to buffer from which contains data to be written to storage chip block Number of block to be written to
Definition at line 216 of file USBMSD_AT45.cpp.
Generated on Fri Jul 15 2022 12:07:27 by
