-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#63 - Mocks for SPISDCard/MMCSDCard/SPIFlash added.
- Loading branch information
1 parent
ae82b06
commit 4de738b
Showing
20 changed files
with
278 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
lib/smooth/include/smooth/core/filesystem/mock/MMCSDCard.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Smooth - C++ framework for writing applications based on Espressif's ESP-IDF. | ||
// Copyright (C) 2017 Per Malmberg (https://github.com/PerMalmberg) | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
#pragma once | ||
|
||
#include "SDCard.h" | ||
#include <smooth/core/io/mock/gpio.h> | ||
|
||
namespace smooth::core::filesystem | ||
{ | ||
class MMCSDCard | ||
: public SDCard | ||
{ | ||
public: | ||
MMCSDCard(gpio_num_t /*command*/, | ||
gpio_num_t /*data0*/, | ||
gpio_num_t /*data1*/, | ||
gpio_num_t /*data2*/, | ||
gpio_num_t /*data3*/, | ||
bool use_1_line_mode = false, | ||
gpio_num_t card_detect = static_cast<gpio_num_t>(-1), | ||
gpio_num_t write_protect = static_cast<gpio_num_t>(-1)) | ||
:SDCard() | ||
{ | ||
(void)use_1_line_mode; | ||
(void)card_detect; | ||
(void)write_protect; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Smooth - C++ framework for writing applications based on Espressif's ESP-IDF. | ||
// Copyright (C) 2019 Per Malmberg (https://github.com/PerMalmberg) | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
#pragma once | ||
|
||
#include <smooth/core/filesystem/MountPoint.h> | ||
#include <smooth/core/filesystem/FSLock.h> | ||
#include <smooth/core/logging/log.h> | ||
#include <smooth/core/filesystem/filesystem.h> | ||
|
||
namespace smooth::core::filesystem | ||
{ | ||
class SDCard | ||
{ | ||
public: | ||
virtual ~SDCard() = default; | ||
|
||
virtual bool init(const SDCardMount& mount, bool /*format_on_mount_failure*/, int max_file_count) | ||
{ | ||
initialized = is_directory(mount.mount_point()); | ||
|
||
if (!initialized) | ||
{ | ||
logging::Log::error("Mock-SDCard", mount.mount_point().str() + | ||
" does not exist, please create it before running."); | ||
} | ||
FSLock::init(max_file_count); | ||
|
||
return initialized; | ||
}; | ||
|
||
[[nodiscard]] virtual bool is_initialized() const | ||
{ | ||
return initialized; | ||
} | ||
|
||
void deinit() {}; | ||
|
||
protected: | ||
bool initialized{}; | ||
private: | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Smooth - C++ framework for writing applications based on Espressif's ESP-IDF. | ||
// Copyright (C) 2017 Per Malmberg (https://github.com/PerMalmberg) | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
#pragma once | ||
|
||
#include <smooth/core/filesystem/MountPoint.h> | ||
#include <smooth/core/filesystem/FSLock.h> | ||
#include <smooth/core/filesystem/filesystem.h> | ||
|
||
namespace smooth::core::filesystem | ||
{ | ||
class SPIFlash | ||
{ | ||
public: | ||
SPIFlash(const FlashMount& mount_point, | ||
const char* /*partition_name*/, | ||
int max_file_count, | ||
bool /*format_on_mount_failure*/) | ||
{ | ||
initialized = is_directory(mount_point.mount_point()); | ||
|
||
if(!initialized) | ||
{ | ||
Log::error("Mock-SPIFlash", | ||
mount_point.mount_point().str() + " does not exist, please create it before running."); | ||
} | ||
FSLock::init(max_file_count); | ||
} | ||
|
||
bool mount() | ||
{ | ||
return initialized; | ||
} | ||
|
||
void unmount() {} | ||
|
||
private: | ||
bool initialized{}; | ||
}; | ||
} |
41 changes: 41 additions & 0 deletions
41
lib/smooth/include/smooth/core/filesystem/mock/SPISDCard.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Smooth - C++ framework for writing applications based on Espressif's ESP-IDF. | ||
// Copyright (C) 2017 Per Malmberg (https://github.com/PerMalmberg) | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
#pragma once | ||
|
||
#include "SDCard.h" | ||
#include <smooth/core/filesystem/MountPoint.h> | ||
#include <smooth/core/io/mock/gpio.h> | ||
|
||
namespace smooth::core::filesystem | ||
{ | ||
class SPISDCard | ||
: public SDCard | ||
{ | ||
public: | ||
SPISDCard(gpio_num_t /*miso*/, | ||
gpio_num_t /*mosi*/, | ||
gpio_num_t /*serial_clock*/, | ||
gpio_num_t /*chip_select*/, | ||
gpio_num_t card_detect = GPIO_NUM_NC, | ||
gpio_num_t write_protect = GPIO_NUM_NC) | ||
: SDCard() | ||
{ | ||
(void) card_detect; | ||
(void) write_protect; | ||
} | ||
}; | ||
} |
Oops, something went wrong.