takashi kadono / Mbed OS Nucleo_446

Dependencies:   ssd1331

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SystemStorage.cpp Source File

SystemStorage.cpp

00001 /*
00002  * Copyright (c) 2018 ARM Limited. All rights reserved.
00003  * SPDX-License-Identifier: Apache-2.0
00004  * Licensed under the Apache License, Version 2.0 (the License); you may
00005  * not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
00012  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #include "BlockDevice.h"
00017 #include "FileSystem.h"
00018 #include "FATFileSystem.h"
00019 #include "LittleFileSystem.h"
00020 
00021 #if COMPONENT_SPIF
00022 #include "SPIFBlockDevice.h"
00023 #endif
00024 
00025 #if COMPONENT_DATAFLASH
00026 #include "DataFlashBlockDevice.h"
00027 #endif
00028 
00029 #if COMPONENT_SD
00030 #include "SDBlockDevice.h"
00031 #endif
00032 
00033 using namespace mbed;
00034 
00035 MBED_WEAK BlockDevice *BlockDevice::get_default_instance()
00036 {
00037 #if COMPONENT_SPIF
00038 
00039     static SPIFBlockDevice default_bd(
00040         MBED_CONF_SPIF_DRIVER_SPI_MOSI,
00041         MBED_CONF_SPIF_DRIVER_SPI_MISO,
00042         MBED_CONF_SPIF_DRIVER_SPI_CLK,
00043         MBED_CONF_SPIF_DRIVER_SPI_CS,
00044         MBED_CONF_SPIF_DRIVER_SPI_FREQ
00045     );
00046 
00047     return &default_bd;
00048 
00049 #elif COMPONENT_DATAFLASH
00050 
00051     static DataFlashBlockDevice default_bd(
00052         MBED_CONF_DATAFLASH_SPI_MOSI,
00053         MBED_CONF_DATAFLASH_SPI_MISO,
00054         MBED_CONF_DATAFLASH_SPI_CLK,
00055         MBED_CONF_DATAFLASH_SPI_CS
00056     );
00057 
00058     return &default_bd;
00059 
00060 #elif COMPONENT_SD
00061 
00062     static SDBlockDevice default_bd(
00063         MBED_CONF_SD_SPI_MOSI,
00064         MBED_CONF_SD_SPI_MISO,
00065         MBED_CONF_SD_SPI_CLK,
00066         MBED_CONF_SD_SPI_CS
00067     );
00068 
00069     return &default_bd;
00070 
00071 #else
00072 
00073     return NULL;
00074 
00075 #endif
00076 
00077 }
00078 
00079 MBED_WEAK FileSystem *FileSystem::get_default_instance()
00080 {
00081 #if COMPONENT_SPIF || COMPONENT_DATAFLASH
00082 
00083     static LittleFileSystem flash("flash", BlockDevice::get_default_instance());
00084     flash.set_as_default();
00085 
00086     return &flash;
00087 
00088 #elif COMPONENT_SD
00089 
00090     static FATFileSystem sdcard("sd", BlockDevice::get_default_instance());
00091     sdcard.set_as_default();
00092 
00093     return &sdcard;
00094 
00095 #else
00096 
00097     return NULL;
00098 
00099 #endif
00100 
00101 }