Skip to content

Commit 21a9712

Browse files
committed
QSPI: Add pointer to HAL init function
1 parent 82aefe7 commit 21a9712

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

drivers/QSPI.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ class QSPI : private NonCopyable<QSPI> {
235235
bool _initialized;
236236
PinName _qspi_io0, _qspi_io1, _qspi_io2, _qspi_io3, _qspi_clk, _qspi_cs; //IO lines, clock and chip select
237237
const qspi_pinmap_t *_explicit_pinmap;
238+
bool (QSPI::* _init_func)(void);
238239

239240
private:
240241
/* Private acquire function without locking/unlocking

drivers/source/QSPI.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ QSPI::QSPI(PinName io0, PinName io1, PinName io2, PinName io3, PinName sclk, Pin
6060
_mode = mode;
6161
_hz = ONE_MHZ;
6262
_initialized = false;
63+
_init_func = &QSPI::_initialize;
6364

6465
//Go ahead init the device here with the default config
65-
bool success = _initialize();
66+
bool success = (this->*_init_func)();
6667
MBED_ASSERT(success);
6768
}
6869

@@ -85,9 +86,10 @@ QSPI::QSPI(const qspi_pinmap_t &pinmap, int mode) : _qspi()
8586
_mode = mode;
8687
_hz = ONE_MHZ;
8788
_initialized = false;
89+
_init_func = &QSPI::_initialize_direct;
8890

8991
//Go ahead init the device here with the default config
90-
bool success = _initialize_direct();
92+
bool success = (this->*_init_func)();
9193
MBED_ASSERT(success);
9294
}
9395

@@ -304,7 +306,7 @@ bool QSPI::_acquire()
304306
{
305307
if (_owner != this) {
306308
//This will set freq as well
307-
_initialize();
309+
(this->*_init_func)();
308310
_owner = this;
309311
}
310312

0 commit comments

Comments
 (0)