Skip to content

Commit a74c369

Browse files
author
Alrik Vidstrom
committed
Make minor improvements to the code
Some minor imporovements after reviewing the code before the final tests.
1 parent ba43834 commit a74c369

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

extras/tests/Arduino_POSIXStorage_Test/Arduino_POSIXStorage_Test.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ enum TestTypes : uint8_t
2424

2525
// !!! TEST CONFIGURATION !!! -->
2626

27-
constexpr enum TestTypes selectedTest = TEST_PORTENTA_H7_USB;
27+
constexpr enum TestTypes selectedTest = TEST_PORTENTA_C33_SDCARD;
2828

2929
// Notice that formtting tests can take a while to complete
3030

@@ -477,7 +477,7 @@ void setup() {
477477
if (DEV_USB == deviceName)
478478
{
479479
// Register multiple callbacks test (unplug) -->
480-
retVal = register_unplug_callback(DEV_USB, usbCallback);
480+
retVal = register_unplug_callback(DEV_USB, usbCallback2);
481481
if ((-1 != retVal) || (EBUSY != errno))
482482
{
483483
allTestsOk = false;

src/Arduino_POSIXStorage.cpp

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -243,24 +243,23 @@ enum BoardTypes detectBoardType()
243243
void portentaMachineControlPowerHandling()
244244
{
245245
// Determine if we're running on Machine Control or not on the first call to mount(), mkfs(),
246-
// register_hotplug_callback(), or register_unplug_callback() -->
246+
// register_hotplug_callback(), or register_unplug_callback()
247247
if (false == hasMountedBefore)
248248
{
249249
hasMountedBefore = true;
250250
if (BOARD_MACHINE_CONTROL == detectBoardType())
251251
{
252252
runningOnMachineControl = true;
253253
}
254-
}
255-
// <--
256254
#if defined(ARDUINO_PORTENTA_H7_M7)
257-
if (true == runningOnMachineControl)
258-
{
259-
// We need to apply power manually to the female USB A connector on the Machine Control
260-
mbed::DigitalOut enablePower(PB_14, 0);
261-
}
255+
if (true == runningOnMachineControl)
256+
{
257+
// We need to apply power manually to the female USB A connector on the Machine Control
258+
mbed::DigitalOut enablePower(PB_14, 0);
259+
}
262260
#endif
263-
} // End of portentaMachineControl()
261+
}
262+
} // End of portentaMachineControlPowerHandling()
264263

265264
void deleteDevice(const enum StorageDevices deviceName, struct DeviceFileSystemCombination * const deviceFileSystemCombination)
266265
{
@@ -556,7 +555,7 @@ int register_callback(const enum StorageDevices deviceName, void (* const callba
556555
// base-class object, and dynamic_cast wouldn't work anyway because compilation is done with -fno-rtti
557556
usbHostDevice = static_cast<USBHostMSD*>(usb.device);
558557
}
559-
bool attachCallbackReturn = false;
558+
bool attachCallbackReturn;
560559
if (CALLBACK_HOTPLUG == callbackType)
561560
{
562561
attachCallbackReturn = usbHostDevice->attach_detected_callback(callbackFunction);
@@ -657,7 +656,7 @@ int umount(const enum StorageDevices deviceName)
657656
return -1;
658657
}
659658
// See note (1) at the bottom of the file
660-
int unmountRet = deviceFileSystemCombination->fileSystem->unmount();
659+
const int unmountRet = deviceFileSystemCombination->fileSystem->unmount();
661660
if (0 == unmountRet)
662661
{
663662
// Ok to delete with base class pointer because the destructor of the base class is virtual
@@ -682,13 +681,10 @@ int register_hotplug_callback(const enum StorageDevices deviceName, void (* cons
682681
errno = callbackReturn;
683682
return -1;
684683
}
685-
else
686-
{
687-
return 0;
688-
}
684+
return 0;
689685
} // End of register_hotplug_callback()
690686

691-
// Not supported by the layer below on these platforms, but might be on other platforms
687+
// Currently not supported on any platform, but might be in the future
692688
int deregister_hotplug_callback(const enum StorageDevices deviceName)
693689
{
694690
(void) deviceName; // Remove when implemented, only here to silence -Wunused-parameter
@@ -704,13 +700,10 @@ int register_unplug_callback(const enum StorageDevices deviceName, void (* const
704700
errno = callbackReturn;
705701
return -1;
706702
}
707-
else
708-
{
709-
return 0;
710-
}
711-
} // End of register__unplug_callback()
703+
return 0;
704+
} // End of register_unplug_callback()
712705

713-
// Not supported by the layer below on these platforms, but might be on other platforms
706+
// Currently not supported on any platform, but might be in the future
714707
int deregister_unplug_callback(const enum StorageDevices deviceName)
715708
{
716709
(void) deviceName; // Remove when implemented, only here to silence -Wunused-parameter

0 commit comments

Comments
 (0)