Skip to content

Move to default_instance QSPIF #21

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

Merged
merged 1 commit into from
Mar 8, 2022
Merged
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
18 changes: 8 additions & 10 deletions src/Arduino_Portenta_OTA_QSPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@

using namespace arduino;

#if defined (COMPONENT_4343W_FS)
extern QSPIFBlockDevice *qspi_bd;
#endif

/******************************************************************************
CTOR/DTOR
******************************************************************************/
Expand All @@ -47,18 +43,20 @@ Arduino_Portenta_OTA_QSPI::Arduino_Portenta_OTA_QSPI(StorageTypePortenta const s

bool Arduino_Portenta_OTA_QSPI::init()
{
#if !defined (COMPONENT_4343W_FS)
qspi_bd = new QSPIFBlockDevice(PD_11, PD_12, PF_7, PD_13, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000);
if (qspi_bd->init() != QSPIF_BD_ERROR_OK) {
#if defined (COMPONENT_4343W_FS)
_bd_raw_qspi = mbed::BlockDevice::get_default_instance();
#else
_bd_raw_qspi = new QSPIFBlockDevice(PD_11, PD_12, PF_7, PD_13, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000);
#endif
if (_bd_raw_qspi->init() != QSPIF_BD_ERROR_OK) {
Serial1.println("Error: QSPI init failure.");
return false;
}
#endif

if(_storage_type == QSPI_FLASH_FATFS)
{
_fs_qspi = new mbed::FATFileSystem("fs");
int const err_mount = _fs_qspi->mount(qspi_bd);
int const err_mount = _fs_qspi->mount(_bd_raw_qspi);
if (err_mount)
{
Serial1.print("Error while mounting the filesystem. Err = ");
Expand All @@ -70,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 *>(qspi_bd), _data_offset);
_bd_qspi = new mbed::MBRBlockDevice(_bd_raw_qspi, _data_offset);
_fs_qspi = new mbed::FATFileSystem("fs");
int const err_mount = _fs_qspi->mount(_bd_qspi);
if (err_mount) {
Expand Down
5 changes: 1 addition & 4 deletions src/Arduino_Portenta_OTA_QSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,9 @@ class Arduino_Portenta_OTA_QSPI : public Arduino_Portenta_OTA

private:

mbed::BlockDevice * _bd_raw_qspi;
mbed::BlockDevice * _bd_qspi;
mbed::FATFileSystem * _fs_qspi;
#if !defined (COMPONENT_4343W_FS)
QSPIFBlockDevice *qspi_bd;
#endif

};

#endif /* ARDUINO_PORTENTA_OTA_QSPI_H_ */