Skip to content

Commit 21effa1

Browse files
committed
UsbMsd: MSD_QSPI example, mount both QSPI partitions
1 parent 8911a05 commit 21effa1

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

libraries/UsbMsd/examples/MSD_QSPI/MSD_QSPI.ino

+24-25
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,16 @@
1414
This example code is in the public domain.
1515
*/
1616

17-
/*
18-
* CONFIGURATION DEFINES
19-
*/
20-
21-
/* the name of the filesystem */
22-
#define TEST_FS_NAME "qspi"
23-
24-
#include "QSPIFlashBlockDevice.h"
17+
#include "BlockDevice.h"
18+
#include "MBRBlockDevice.h"
2519
#include "UsbMsd.h"
2620
#include "FATFileSystem.h"
2721

2822
BlockDevice* root = BlockDevice::get_default_instance();
29-
USBMSD msd(root);
30-
FATFileSystem fs(TEST_FS_NAME);
31-
32-
std::string root_folder = std::string("/") + std::string(TEST_FS_NAME);
23+
MBRBlockDevice sys_bd(root, 1);
24+
MBRBlockDevice user_bd(root, 2);
25+
FATFileSystem sys_fs("sys");
26+
FATFileSystem user_fs("user");
3327

3428
/* -------------------------------------------------------------------------- */
3529
void printDirectoryContent(const char* name) {
@@ -64,33 +58,38 @@ void printDirectoryContent(const char* name) {
6458
/* SETUP */
6559
/* -------------------------------------------------------------------------- */
6660
void setup() {
67-
61+
6862
/* SERIAL INITIALIZATION */
6963
Serial.begin(9600);
70-
while(!Serial) {
71-
64+
while(!Serial) {
7265
}
7366

7467
Serial.println("*** USB Mass Storage DEVICE on QSPI Flash ***");
75-
76-
68+
7769
/* Mount the partition */
78-
int err = fs.mount(root);
70+
int err = sys_fs.mount(&sys_bd);
7971
if (err) {
80-
Serial.println("Unable to mount filesystem");
72+
Serial.println("Unable to mount system filesystem");
8173
while(1) {
82-
8374
}
84-
}
75+
}
76+
77+
/* Mount the partition */
78+
err = user_fs.mount(&user_bd);
79+
if (err) {
80+
Serial.println("Unable to mount user filesystem");
81+
while(1) {
82+
}
83+
}
8584
}
8685

8786
/* -------------------------------------------------------------------------- */
8887
/* LOOP */
8988
/* -------------------------------------------------------------------------- */
9089
void loop() {
91-
Serial.print("Content of the folder ");
92-
Serial.print(root_folder.c_str());
93-
Serial.println(":");
94-
printDirectoryContent(root_folder.c_str());
90+
Serial.println("Content of the system partition:");
91+
printDirectoryContent("/sys");
92+
Serial.println("Content of the user partition:");
93+
printDirectoryContent("/user");
9594
delay(2000);
9695
}

0 commit comments

Comments
 (0)