|
| 1 | +#include "QSPIFBlockDevice.h" |
| 2 | +#include "FATFileSystem.h" |
| 3 | +#include "doomgeneric.h" |
| 4 | + |
| 5 | +QSPIFBlockDevice block_device(PD_11, PD_12, PF_7, PD_13, |
| 6 | + PF_10, PG_6, QSPIF_POLARITY_MODE_1, MBED_CONF_QSPIF_QSPI_FREQ); |
| 7 | + |
| 8 | +mbed::FATFileSystem fs("fs"); |
| 9 | + |
| 10 | +extern "C" int main_wrapper(int argc, char **argv); |
| 11 | +char*argv[] = {"/fs/doom", "-iwad", "/fs/DOOM1.WAD"}; |
| 12 | + |
| 13 | +void setup() { |
| 14 | + // put your setup code here, to run once: |
| 15 | + delay(2000); |
| 16 | + int err = fs.mount(&block_device); |
| 17 | + if (err) { |
| 18 | + // Reformat if we can't mount the filesystem |
| 19 | + // this should only happen on the first boot |
| 20 | + printf("No filesystem found, formatting... "); |
| 21 | + fflush(stdout); |
| 22 | + err = fs.reformat(&block_device); |
| 23 | + } |
| 24 | + DIR *dir; |
| 25 | + struct dirent *ent; |
| 26 | + printf("try to open dir\n"); |
| 27 | + if ((dir = opendir("/fs")) != NULL) { |
| 28 | + /* print all the files and directories within directory */ |
| 29 | + while ((ent = readdir (dir)) != NULL) { |
| 30 | + printf ("%s\n", ent->d_name); |
| 31 | + } |
| 32 | + closedir (dir); |
| 33 | + } else { |
| 34 | + /* could not open directory */ |
| 35 | + printf ("error\n"); |
| 36 | + } |
| 37 | + main_wrapper(3, argv); |
| 38 | +} |
| 39 | + |
| 40 | +void loop() { |
| 41 | + // put your main code here, to run repeatedly: |
| 42 | + |
| 43 | +} |
0 commit comments