99bool USBStorage::usb_available = false ;
1010
1111USBStorage::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+ });
1716#endif
1817}
1918
20-
2119int USBStorage::begin (FileSystems fs){
2220 this -> fs = fs;
2321 this -> begin ();
2422}
2523
2624int USBStorage::begin (){
27-
28-
29-
3025 int attempts = 0 ;
3126 int err = mount (DEV_USB, this ->fs , MNT_DEFAULT);
3227
@@ -45,14 +40,12 @@ int USBStorage::begin(){
4540 return err == 0 ;
4641}
4742
48-
4943int USBStorage::unmount (){
5044 auto unmountResult = umount (DEV_USB);
5145
5246
5347 if (unmountResult == 0 ){
5448 this -> connected = false ;
55- } else {
5649 }
5750
5851 return unmountResult == 0 ;
@@ -62,7 +55,6 @@ Folder USBStorage::getRootFolder(){
6255 return Folder (" /usb" );
6356}
6457
65-
6658bool USBStorage::isAvailable (){
6759 return usb_available;
6860}
@@ -72,34 +64,26 @@ bool USBStorage::isConnected(){
7264}
7365
7466void USBStorage::checkConnection (){
75- #if defined(ARDUINO_PORTENTA_H7_M7)
7667 USBHost * host;
7768 USBDeviceConnected * dev;
69+ #if defined(ARDUINO_PORTENTA_H7_M7)
7870 unsigned long currentMillis = millis ();
7971 boolean found = false ;
8072
8173 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+ }
9383 }
94-
95-
96-
97-
98- #endif
84+ #endif
9985}
10086
101-
102-
10387int USBStorage::formatFAT (){
10488 this -> begin ();
10589 this -> unmount ();
0 commit comments