Skip to content

[WIP] Reuse QSPIF Block Device from Wiced driver #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/Arduino_Portenta_OTA_QSPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

using namespace arduino;

extern QSPIFBlockDevice *qspi_bd;

/******************************************************************************
CTOR/DTOR
******************************************************************************/
Expand All @@ -33,7 +35,7 @@ Arduino_Portenta_OTA_QSPI::Arduino_Portenta_OTA_QSPI(StorageTypePortenta const s
: Arduino_Portenta_OTA(storage_type, data_offset)
, _bd_qspi{NULL}
, _fs_qspi{NULL}
, _block_device_qspi(PD_11, PD_12, PF_7, PD_13, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000)
, _block_device_qspi{qspi_bd}
{
assert(_storage_type == QSPI_FLASH_FATFS || _storage_type == QSPI_FLASH_FATFS_MBR);
}
Expand All @@ -44,13 +46,17 @@ Arduino_Portenta_OTA_QSPI::Arduino_Portenta_OTA_QSPI(StorageTypePortenta const s

bool Arduino_Portenta_OTA_QSPI::init()
{
if (_block_device_qspi.init() != QSPIF_BD_ERROR_OK)
auto const err_init = _block_device_qspi->init();
if (err_init != QSPIF_BD_ERROR_OK) {
Serial1.print("Error while initialising the QSPI device. Err = ");
Serial1.println(err_init);
return false;
}

if(_storage_type == QSPI_FLASH_FATFS)
{
_fs_qspi = new mbed::FATFileSystem("fs");
int const err_mount = _fs_qspi->mount(&_block_device_qspi);
int const err_mount = _fs_qspi->mount(_block_device_qspi);
if (err_mount)
{
Serial1.print("Error while mounting the filesystem. Err = ");
Expand All @@ -62,7 +68,7 @@ bool Arduino_Portenta_OTA_QSPI::init()

if (_storage_type == QSPI_FLASH_FATFS_MBR)
{
_bd_qspi = new mbed::MBRBlockDevice(reinterpret_cast<mbed::BlockDevice *>(&_block_device_qspi), _data_offset);
_bd_qspi = new mbed::MBRBlockDevice(reinterpret_cast<mbed::BlockDevice *>(_block_device_qspi), _data_offset);
_fs_qspi = new mbed::FATFileSystem("fs");
int const err_mount = _fs_qspi->mount(_bd_qspi);
if (err_mount) {
Expand Down
2 changes: 1 addition & 1 deletion src/Arduino_Portenta_OTA_QSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Arduino_Portenta_OTA_QSPI : public Arduino_Portenta_OTA

mbed::BlockDevice * _bd_qspi;
mbed::FATFileSystem * _fs_qspi;
QSPIFBlockDevice _block_device_qspi;
QSPIFBlockDevice* _block_device_qspi;

};

Expand Down