Skip to content

Commit 7f37a53

Browse files
committed
Move to default_instance QSPIF
1 parent 9aa4334 commit 7f37a53

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/Arduino_Portenta_OTA_QSPI.cpp

+8-10
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@
2525

2626
using namespace arduino;
2727

28-
#if defined (COMPONENT_4343W_FS)
29-
extern QSPIFBlockDevice *qspi_bd;
30-
#endif
31-
3228
/******************************************************************************
3329
CTOR/DTOR
3430
******************************************************************************/
@@ -47,18 +43,20 @@ Arduino_Portenta_OTA_QSPI::Arduino_Portenta_OTA_QSPI(StorageTypePortenta const s
4743

4844
bool Arduino_Portenta_OTA_QSPI::init()
4945
{
50-
#if !defined (COMPONENT_4343W_FS)
51-
qspi_bd = new QSPIFBlockDevice(PD_11, PD_12, PF_7, PD_13, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000);
52-
if (qspi_bd->init() != QSPIF_BD_ERROR_OK) {
46+
#if defined (COMPONENT_4343W_FS)
47+
_bd_raw_qspi = mbed::BlockDevice::get_default_instance();
48+
#else
49+
_bd_raw_qspi = new QSPIFBlockDevice(PD_11, PD_12, PF_7, PD_13, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000);
50+
#endif
51+
if (_bd_raw_qspi->init() != QSPIF_BD_ERROR_OK) {
5352
Serial1.println("Error: QSPI init failure.");
5453
return false;
5554
}
56-
#endif
5755

5856
if(_storage_type == QSPI_FLASH_FATFS)
5957
{
6058
_fs_qspi = new mbed::FATFileSystem("fs");
61-
int const err_mount = _fs_qspi->mount(qspi_bd);
59+
int const err_mount = _fs_qspi->mount(_bd_raw_qspi);
6260
if (err_mount)
6361
{
6462
Serial1.print("Error while mounting the filesystem. Err = ");
@@ -70,7 +68,7 @@ bool Arduino_Portenta_OTA_QSPI::init()
7068

7169
if (_storage_type == QSPI_FLASH_FATFS_MBR)
7270
{
73-
_bd_qspi = new mbed::MBRBlockDevice(reinterpret_cast<mbed::BlockDevice *>(qspi_bd), _data_offset);
71+
_bd_qspi = new mbed::MBRBlockDevice(_bd_raw_qspi, _data_offset);
7472
_fs_qspi = new mbed::FATFileSystem("fs");
7573
int const err_mount = _fs_qspi->mount(_bd_qspi);
7674
if (err_mount) {

src/Arduino_Portenta_OTA_QSPI.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,9 @@ class Arduino_Portenta_OTA_QSPI : public Arduino_Portenta_OTA
4545

4646
private:
4747

48+
mbed::BlockDevice * _bd_raw_qspi;
4849
mbed::BlockDevice * _bd_qspi;
4950
mbed::FATFileSystem * _fs_qspi;
50-
#if !defined (COMPONENT_4343W_FS)
51-
QSPIFBlockDevice *qspi_bd;
52-
#endif
53-
5451
};
5552

5653
#endif /* ARDUINO_PORTENTA_OTA_QSPI_H_ */

0 commit comments

Comments
 (0)