@@ -49,6 +49,44 @@ enum qspif_polarity_mode {
49
49
#define MAX_NUM_OF_ERASE_TYPES 4
50
50
#define QSPIF_MAX_ACTIVE_FLASH_DEVICES 10
51
51
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
+ */
52
90
class QSPIFBlockDevice : public BlockDevice {
53
91
public:
54
92
/* * Create QSPIFBlockDevice - An SFDP based Flash Block Device over QSPI bus
0 commit comments