-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
41 lines (31 loc) · 887 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* Copyright (c) 2006-2020 Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*/
#include "mbed.h"
#include "USBMSD.h"
#include "FATFileSystem.h"
#define DEFAULT_BLOCK_SIZE 512
#define HEAP_BLOCK_DEVICE_SIZE (128 * DEFAULT_BLOCK_SIZE)
FATFileSystem heap_fs("heap_fs");
HeapBlockDevice bd(HEAP_BLOCK_DEVICE_SIZE, DEFAULT_BLOCK_SIZE);
int main()
{
bd.init();
FATFileSystem::format(&bd);
int err = heap_fs.mount(&bd);
if (err) {
printf("%s filesystem mount failed\ntry to reformat device... \r\n", heap_fs.getName());
err = heap_fs.reformat(&bd);
}
// If still error, then report failure
if (err) {
printf("Error: Unable to format/mount the device.\r\n");
while (1);
}
USBMSD usb(&bd);
while (true) {
usb.process();
}
return 0;
}