Skip to content

Commit 38f181d

Browse files
Merge pull request #1 from cristidragomir97/refactorings
Refactorings
2 parents 12b6e76 + a5f54ee commit 38f181d

16 files changed

+72
-1164
lines changed
-5.43 MB
Binary file not shown.

examples/AdvancedInternalStorage/AdvancedInternalStorage.ino

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#include <Arduino.h>
21
#include <Arduino_UnifiedStorage.h>
32
#include <vector>
43

src/Arduino_UnifiedStorage.h

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@
55

66
#include "Arduino.h"
77
#include "Arduino_POSIXStorage.h"
8+
#include "Boards.h"
9+
#include "Utils.h"
10+
#include "Types.h"
11+
#include "Partitioning.h"
12+
813
#include "Folder.h"
914
#include "UFile.h"
10-
#include "Utils.h"
15+
16+
17+
1118

1219

1320

@@ -52,15 +59,17 @@ class Arduino_UnifiedStorage {
5259
};
5360

5461

55-
#if defined(ARDUINO_PORTENTA_C33) || defined(ARDUINO_PORTENTA_H7_M7)
56-
#include "USBStorage.h"
57-
#include "SDStorage.h"
58-
#include "InternalStorage.h"
59-
#elif defined(ARDUINO_OPTA)
60-
#include "USBStorage.h"
61-
#include "InternalStorage.h"
62-
#endif
62+
#if defined(HAS_USB)
63+
#include "USBStorage.h"
64+
#endif
65+
66+
#if defined(HAS_SD)
67+
#include "SDStorage.h"
68+
#endif
6369

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

6574
#endif
6675

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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
#define InternalStorage_H
33

44
#include "Arduino_UnifiedStorage.h"
5-
#include "Partitioning.h"
65
#include "Types.h"
6+
7+
78
/**
89
* Represents internal storage using the Arduino Unified Storage library.
910
*/
@@ -83,6 +84,8 @@ class InternalStorage : public Arduino_UnifiedStorage {
8384
BlockDeviceType *getBlockDevice();
8485

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

8790

8891
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_POSIXStorage.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/SDStorage.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
#include "Arduino_UnifiedStorage.h"
77

8-
#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_C33) || !defined(ARDUINO_OPTA)
98

109
/**
1110
* Represents an SD card storage using the Arduino Unified Storage library.
@@ -59,5 +58,3 @@ class SDStorage: public Arduino_UnifiedStorage {
5958
};
6059

6160
#endif
62-
63-
#endif

0 commit comments

Comments
 (0)