Skip to content

Commit a5f54ee

Browse files
fixed issues caused by refactorings
1 parent f783e81 commit a5f54ee

12 files changed

+63
-1168
lines changed

src/Arduino_UnifiedStorage.h

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,20 @@
22
#ifndef UnifiedStorage_H
33
#define UnifiedStorage_H
44

5-
#define HAS_SD defined(ARDUINO_PORTENTA_C33) || defined(ARDUINO_PORTENTA_H7_M7)
6-
#define HAS_USB defined(ARDUINO_PORTENTA_C33) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_OPTA)
7-
#define HAS_QSPI defined(ARDUINO_PORTENTA_C33) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_OPTA) || defined(ARDUINO_NICLA_VISION)
8-
9-
#define USES_RENESAS_CORE defined(ARDUINO_PORTENTA_C33)
10-
#define USES_MBED_CORE defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_OPTA) || defined(ARDUINO_NICLA_VISION)
11-
125

136
#include "Arduino.h"
147
#include "Arduino_POSIXStorage.h"
15-
#include <vector>
16-
#include "Types.h"
8+
#include "Boards.h"
179
#include "Utils.h"
10+
#include "Types.h"
11+
#include "Partitioning.h"
12+
1813
#include "Folder.h"
1914
#include "UFile.h"
2015

2116

2217

2318

24-
#if defined(HAS_USB)
25-
#include "USBStorage.h"
26-
#endif
27-
28-
#if defined(HAS_SD)
29-
#include "SDStorage.h"
30-
#endif
31-
32-
#if defined(HAS_QSPI)
33-
#include "InternalStorage.h"
34-
#endif
3519

3620

3721

@@ -75,8 +59,17 @@ class Arduino_UnifiedStorage {
7559
};
7660

7761

62+
#if defined(HAS_USB)
63+
#include "USBStorage.h"
64+
#endif
7865

66+
#if defined(HAS_SD)
67+
#include "SDStorage.h"
68+
#endif
7969

70+
#if defined(HAS_QSPI)
71+
#include "InternalStorage.h"
72+
#endif
8073

8174
#endif
8275

src/Boards.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#if defined(ARDUINO_PORTENTA_C33)
2+
#define HAS_SD
3+
#define HAS_USB
4+
#define HAS_QSPI
5+
#define USES_RENESAS_CORE
6+
#endif
7+
8+
#if defined(ARDUINO_PORTENTA_H7_M7)
9+
#define HAS_SD
10+
#define HAS_USB
11+
#define HAS_QSPI
12+
#define USES_MBED_CORE
13+
#endif
14+
15+
#if defined(ARDUINO_OPTA)
16+
#define HAS_USB
17+
#define HAS_QSPI
18+
#define USES_MBED_CORE
19+
#endif
20+
21+
#if defined(ARDUINO_NICLA_VISION)
22+
#define HAS_QSPI
23+
#define USES_MBED_CORE
24+
#endif
25+
26+
27+
28+
29+

src/Folder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef Folder_H
22
#define Folder_H
33

4+
45
#include "Utils.h"
56
#include "UFile.h"
6-
7-
7+
#include <vector>
88

99
class UFile;
1010
/**

src/InternalStorage.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ bool InternalStorage::partition(std::vector<Partition> partitions){
2020
Partitioning::partitionDrive(QSPIFBlockDeviceType::get_default_instance(), partitions);
2121
}
2222

23+
24+
2325
bool InternalStorage::begin(){
2426
this -> blockDevice = BlockDeviceType::get_default_instance();
2527
this -> userData = new MBRBlockDeviceType(this->blockDevice, this->partitionNumber);

src/InternalStorage.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
#define InternalStorage_H
33

44
#include "Arduino_UnifiedStorage.h"
5-
#include "Partitioning.h"
65
#include "Types.h"
76

7+
88
/**
99
* Represents internal storage using the Arduino Unified Storage library.
1010
*/
@@ -84,6 +84,8 @@ class InternalStorage : public Arduino_UnifiedStorage {
8484
BlockDeviceType *getBlockDevice();
8585

8686
static bool partition(std::vector<Partition> partitions);
87+
// partition() -> one Partition
88+
// restoreDefaultPartitions();
8789

8890

8991
private:

src/Partitioning.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020

2121
bool Partitioning::isPartitionSchemeValid(BlockDeviceType * bd, std::vector<Partition> partitions){
22-
size_t driveSize = bd -> size() / 1024;
22+
size_t driveSize = bd -> size() / 1024; //
2323
int totalSize = 0;
2424

2525
for (size_t i = 1; i < partitions.size() + 1; ++i) {

src/Partitioning.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
#include "Arduino.h"
3-
#include "Arduino_UnifiedStorage.h"
43
#include "Types.h"
4+
#include "Arduino_POSIXStorage.h"
55
#include <vector>
66

77
struct Partition {
@@ -17,6 +17,5 @@ class Partitioning{
1717
static bool isPartitionSchemeValid(BlockDeviceType * bd, std::vector<Partition> partitions);
1818
static bool formatPartition(BlockDeviceType * bd, int partitionNumber, FileSystems fs);
1919
static bool createAndFormatPartitions(BlockDeviceType * bd, std::vector<Partition> partitions);
20-
21-
20+
2221
};

src/Types.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
#include "Boards.h"
3+
24
#if defined(USES_RENESAS_CORE)
35
#include "BlockDevice.h"
46
#include "MBRBlockDevice.h"
@@ -15,6 +17,7 @@
1517
#elif defined(USES_MBED_CORE)
1618
#include "QSPIFBlockDevice.h"
1719
#include "MBRBlockDevice.h"
20+
#include "LittleFileSystem.h"
1821
#include "FATFileSystem.h"
1922

2023
typedef QSPIFBlockDevice QSPIFBlockDeviceType;
@@ -23,5 +26,4 @@
2326
typedef mbed::FATFileSystem FATFileSystemType;
2427
typedef mbed::LittleFileSystem LittleFileSystemType;
2528
typedef mbed::FileSystem FileSystemType;
26-
2729
#endif

src/UFile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <Arduino.h>
55
#include <string.h>
6+
#include <vector>
67
#include "Utils.h"
78

89
class Folder;

src/USBStorage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ void USBStorage::onConnect(void (* const callbackFunction)()){
2020
register_hotplug_callback(DEV_USB, callbackFunction);
2121
}
2222

23-
void USBStorage::removeConnectCallback(){
23+
void USBStorage::removeOnConnectCallback(){
2424
deregister_hotplug_callback(DEV_USB);
2525
}
2626

2727
void USBStorage::onDisconnect(void (* const callbackFunction)()){
2828
register_unplug_callback(DEV_USB, callbackFunction);
2929
}
3030

31-
void USBStorage::removeDisconnectCallback(){
31+
void USBStorage::removeOnDisconnectCallback(){
3232
deregister_unplug_callback(DEV_USB);
3333
}
3434

src/USBStorage.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
#include "Arduino_UnifiedStorage.h"
1+
22

33
#ifndef USBStorage_H
44
#define USBStorage_H
55

6+
#include "Arduino_UnifiedStorage.h"
67
/**
78
* Represents a USB storage using the Arduino Unified Storage library.
89
*/
@@ -59,19 +60,18 @@ class USBStorage : public Arduino_UnifiedStorage {
5960

6061
void onConnect(void (* const callbackFunction)());
6162

62-
void removeConnectCallback();
63+
void removeOnConnectCallback();
6364

6465
void onDisconnect(void (* const callbackFunction)());
6566

66-
void removeDisconnectCallback();
67+
void removeOnDisconnectCallback();
6768

6869

6970
private:
7071
FileSystems fileSystem = FS_FAT;
7172
bool mounted = false;
7273
unsigned long previousMillis;
73-
unsigned int interval = 500;
74-
74+
unsigned int interval = 500; // document what this does too, make it constexp (mountRetryInterval)
7575
};
7676

7777
#endif

0 commit comments

Comments
 (0)