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

Commit 4d77de6

Browse files
author
Offir Kochalsky
committed
Adding class example documentation
1 parent b8d690e commit 4d77de6

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

QSPIFBlockDevice.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,44 @@ enum qspif_polarity_mode {
4949
#define MAX_NUM_OF_ERASE_TYPES 4
5050
#define QSPIF_MAX_ACTIVE_FLASH_DEVICES 10
5151

52+
/** BlockDevice for SFDP based flash devices over QSPI bus
53+
*
54+
* @code
55+
* // Here's an example using QSPI flash device on DISCO_L476VG target
56+
* #include "mbed.h"
57+
* #include "QSPIFBlockDevice.h"
58+
*
59+
* QSPIFBlockDevice block_device(QSPI_FLASH1_IO0, QSPI_FLASH1_IO1, QSPI_FLASH1_IO2, QSPI_FLASH1_IO3,
60+
* QSPI_FLASH1_SCK, QSPI_FLASH1_CSN, QSPIF_POLARITY_MODE_0, MBED_CONF_QSPIF_QSPI_FREQ);
61+
*
62+
* int main()
63+
* {
64+
* printf("QSPI SFDP Flash Block Device example\n");
65+
*
66+
* // Initialize the SPI flash device and print the memory layout
67+
* block_device.init();
68+
* bd_size_t sector_size_at_address_0 = block_device.get_erase_size(0);
69+
*
70+
* printf("QSPIF BD size: %llu\n", block_device.size());
71+
* printf("QSPIF BD read size: %llu\n", block_device.get_read_size());
72+
* printf("QSPIF BD program size: %llu\n", block_device.get_program_size());
73+
* printf("QSPIF BD erase size (at address 0): %llu\n", sector_size_at_address_0);
74+
*
75+
* // Write "Hello World!" to the first block
76+
* char *buffer = (char *) malloc(sector_size_at_address_0);
77+
* sprintf(buffer, "Hello World!\n");
78+
* block_device.erase(0, sector_size_at_address_0);
79+
* block_device.program(buffer, 0, sector_size_at_address_0);
80+
*
81+
* // Read back what was stored
82+
* block_device.read(buffer, 0, sector_size_at_address_0);
83+
* printf("%s", buffer);
84+
*
85+
* // Deinitialize the device
86+
* block_device.deinit();
87+
* }
88+
* @endcode
89+
*/
5290
class QSPIFBlockDevice : public BlockDevice {
5391
public:
5492
/** Create QSPIFBlockDevice - An SFDP based Flash Block Device over QSPI bus

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ int main() {
2727
printf("QSPIF BD size: %llu\n", block_device.size());
2828
printf("QSPIF BD read size: %llu\n", block_device.get_read_size());
2929
printf("QSPIF BD program size: %llu\n", block_device.get_program_size());
30-
3130
printf("QSPIF BD erase size (at address 0): %llu\n", sector_size_at_address_0);
3231

3332
// Write "Hello World!" to the first block

0 commit comments

Comments
 (0)