Skip to content

Commit 88e9cad

Browse files
committed
Reuse QSPIF Block Device from Wiced driver
1 parent 36bd62b commit 88e9cad

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/Arduino_Portenta_OTA_QSPI.cpp

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

2626
using namespace arduino;
2727

28+
extern QSPIFBlockDevice *qspi_bd;
29+
2830
/******************************************************************************
2931
CTOR/DTOR
3032
******************************************************************************/
@@ -33,7 +35,7 @@ Arduino_Portenta_OTA_QSPI::Arduino_Portenta_OTA_QSPI(StorageTypePortenta const s
3335
: Arduino_Portenta_OTA(storage_type, data_offset)
3436
, _bd_qspi{NULL}
3537
, _fs_qspi{NULL}
36-
, _block_device_qspi(PD_11, PD_12, PF_7, PD_13, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000)
38+
, _block_device_qspi{qspi_bd}
3739
{
3840
assert(_storage_type == QSPI_FLASH_FATFS || _storage_type == QSPI_FLASH_FATFS_MBR);
3941
}
@@ -44,13 +46,17 @@ Arduino_Portenta_OTA_QSPI::Arduino_Portenta_OTA_QSPI(StorageTypePortenta const s
4446

4547
bool Arduino_Portenta_OTA_QSPI::init()
4648
{
47-
if (_block_device_qspi.init() != QSPIF_BD_ERROR_OK)
49+
auto const err_init = _block_device_qspi->init();
50+
if (err_init != QSPIF_BD_ERROR_OK) {
51+
Serial1.print("Error while initialising the QSPI device. Err = ");
52+
Serial1.println(err_init);
4853
return false;
54+
}
4955

5056
if(_storage_type == QSPI_FLASH_FATFS)
5157
{
5258
_fs_qspi = new mbed::FATFileSystem("fs");
53-
int const err_mount = _fs_qspi->mount(&_block_device_qspi);
59+
int const err_mount = _fs_qspi->mount(_block_device_qspi);
5460
if (err_mount)
5561
{
5662
Serial1.print("Error while mounting the filesystem. Err = ");
@@ -62,7 +68,7 @@ bool Arduino_Portenta_OTA_QSPI::init()
6268

6369
if (_storage_type == QSPI_FLASH_FATFS_MBR)
6470
{
65-
_bd_qspi = new mbed::MBRBlockDevice(reinterpret_cast<mbed::BlockDevice *>(&_block_device_qspi), _data_offset);
71+
_bd_qspi = new mbed::MBRBlockDevice(reinterpret_cast<mbed::BlockDevice *>(_block_device_qspi), _data_offset);
6672
_fs_qspi = new mbed::FATFileSystem("fs");
6773
int const err_mount = _fs_qspi->mount(_bd_qspi);
6874
if (err_mount) {

src/Arduino_Portenta_OTA_QSPI.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Arduino_Portenta_OTA_QSPI : public Arduino_Portenta_OTA
4747

4848
mbed::BlockDevice * _bd_qspi;
4949
mbed::FATFileSystem * _fs_qspi;
50-
QSPIFBlockDevice _block_device_qspi;
50+
QSPIFBlockDevice* _block_device_qspi;
5151

5252
};
5353

0 commit comments

Comments
 (0)