Skip to content

Commit e580a80

Browse files
committed
BlockDevice: add get_default_instance()
1 parent 8e63f4d commit e580a80

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
BlockDevice.cpp
3+
Copyright (c) 2023 Arduino SA. All right reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#include <QSPIFlashBlockDevice.h>
21+
22+
BlockDevice *BlockDevice::get_default_instance()
23+
{
24+
static QSPIFlashBlockDevice default_bd(PIN_QSPI_CLK, PIN_QSPI_SS, PIN_QSPI_D0, PIN_QSPI_D1, PIN_QSPI_D2, PIN_QSPI_D3);
25+
return &default_bd;
26+
}

libraries/BlockDevices/BlockDevice.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class BlockDevice {
5353
BlockDevice(BlockDevice const&) = delete;
5454
void operator=(BlockDevice const&) = delete;
5555

56+
static BlockDevice *get_default_instance();
57+
5658
virtual ~BlockDevice() = default;
5759
/* initialize a block device */
5860
virtual int init() = 0;

0 commit comments

Comments
 (0)