Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Adding class example documentation #7

Merged
merged 1 commit into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions QSPIFBlockDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,44 @@ enum qspif_polarity_mode {
#define MAX_NUM_OF_ERASE_TYPES 4
#define QSPIF_MAX_ACTIVE_FLASH_DEVICES 10

/** BlockDevice for SFDP based flash devices over QSPI bus
*
* @code
* // Here's an example using QSPI flash device on DISCO_L476VG target
* #include "mbed.h"
* #include "QSPIFBlockDevice.h"
*
* QSPIFBlockDevice block_device(QSPI_FLASH1_IO0, QSPI_FLASH1_IO1, QSPI_FLASH1_IO2, QSPI_FLASH1_IO3,
* QSPI_FLASH1_SCK, QSPI_FLASH1_CSN, QSPIF_POLARITY_MODE_0, MBED_CONF_QSPIF_QSPI_FREQ);
*
* int main()
* {
* printf("QSPI SFDP Flash Block Device example\n");
*
* // Initialize the SPI flash device and print the memory layout
* block_device.init();
* bd_size_t sector_size_at_address_0 = block_device.get_erase_size(0);
*
* printf("QSPIF BD size: %llu\n", block_device.size());
* printf("QSPIF BD read size: %llu\n", block_device.get_read_size());
* printf("QSPIF BD program size: %llu\n", block_device.get_program_size());
* printf("QSPIF BD erase size (at address 0): %llu\n", sector_size_at_address_0);
*
* // Write "Hello World!" to the first block
* char *buffer = (char *) malloc(sector_size_at_address_0);
* sprintf(buffer, "Hello World!\n");
* block_device.erase(0, sector_size_at_address_0);
* block_device.program(buffer, 0, sector_size_at_address_0);
*
* // Read back what was stored
* block_device.read(buffer, 0, sector_size_at_address_0);
* printf("%s", buffer);
*
* // Deinitialize the device
* block_device.deinit();
* }
* @endcode
*/
class QSPIFBlockDevice : public BlockDevice {
public:
/** Create QSPIFBlockDevice - An SFDP based Flash Block Device over QSPI bus
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ int main() {
printf("QSPIF BD size: %llu\n", block_device.size());
printf("QSPIF BD read size: %llu\n", block_device.get_read_size());
printf("QSPIF BD program size: %llu\n", block_device.get_program_size());

printf("QSPIF BD erase size (at address 0): %llu\n", sector_size_at_address_0);

// Write "Hello World!" to the first block
Expand Down