9
9
bool USBStorage::usb_available = false ;
10
10
11
11
USBStorage::USBStorage (){
12
- #if defined(ARDUINO_PORTENTA_C33)
13
- register_hotplug_callback (DEV_USB, [](){
14
- usb_available = !usb_available;
15
-
16
- });
12
+ #if defined(ARDUINO_PORTENTA_C33)
13
+ register_hotplug_callback (DEV_USB, [](){
14
+ usb_available = !usb_available;
15
+ });
17
16
#endif
18
17
}
19
18
20
-
21
19
int USBStorage::begin (FileSystems fs){
22
20
this -> fs = fs;
23
21
this -> begin ();
24
22
}
25
23
26
24
int USBStorage::begin (){
27
-
28
-
29
-
30
25
int attempts = 0 ;
31
26
int err = mount (DEV_USB, this ->fs , MNT_DEFAULT);
32
27
@@ -45,14 +40,12 @@ int USBStorage::begin(){
45
40
return err == 0 ;
46
41
}
47
42
48
-
49
43
int USBStorage::unmount (){
50
44
auto unmountResult = umount (DEV_USB);
51
45
52
46
53
47
if (unmountResult == 0 ){
54
48
this -> connected = false ;
55
- } else {
56
49
}
57
50
58
51
return unmountResult == 0 ;
@@ -62,7 +55,6 @@ Folder USBStorage::getRootFolder(){
62
55
return Folder (" /usb" );
63
56
}
64
57
65
-
66
58
bool USBStorage::isAvailable (){
67
59
return usb_available;
68
60
}
@@ -72,34 +64,26 @@ bool USBStorage::isConnected(){
72
64
}
73
65
74
66
void USBStorage::checkConnection (){
75
- #if defined(ARDUINO_PORTENTA_H7_M7)
76
67
USBHost * host;
77
68
USBDeviceConnected * dev;
69
+ #if defined(ARDUINO_PORTENTA_H7_M7)
78
70
unsigned long currentMillis = millis ();
79
71
boolean found = false ;
80
72
81
73
if (currentMillis - previousMillis >= interval) {
82
- this -> previousMillis = currentMillis;
83
-
84
- host = USBHost::getHostInst ();
85
-
86
-
87
- if ((dev = host->getDevice (0 )) != NULL ) {
88
- usb_available = true ;
89
- found = true ;
90
- } else {
91
- usb_available = false ;
92
- }
74
+ this ->previousMillis = currentMillis;
75
+ host = USBHost::getHostInst ();
76
+
77
+ if ((dev = host->getDevice (0 )) != NULL ){
78
+ usb_available = true ;
79
+ found = true ;
80
+ } else {
81
+ usb_available = false ;
82
+ }
93
83
}
94
-
95
-
96
-
97
-
98
- #endif
84
+ #endif
99
85
}
100
86
101
-
102
-
103
87
int USBStorage::formatFAT (){
104
88
this -> begin ();
105
89
this -> unmount ();
0 commit comments