diff --git a/drivers/CoreFlashMemory/CMakeLists.txt b/drivers/CoreFlashMemory/CMakeLists.txt index 8221553e9e..81ded08e13 100644 --- a/drivers/CoreFlashMemory/CMakeLists.txt +++ b/drivers/CoreFlashMemory/CMakeLists.txt @@ -11,7 +11,7 @@ target_include_directories(CoreFlashMemory target_sources(CoreFlashMemory PRIVATE - source/CoreFlashMemoryIS25LP016D.cpp + source/CoreFlashIS25LP016D.cpp source/CoreFlashManagerIS25LP016D.cpp ) @@ -22,7 +22,7 @@ target_link_libraries(CoreFlashMemory if (${CMAKE_PROJECT_NAME} STREQUAL "LekaOSUnitTests") leka_unit_tests_sources( - tests/CoreFlashMemoryIS25LP016D_test.cpp + tests/CoreFlashIS25LP016D_test.cpp tests/CoreFlashManagerIS25LP016D_test.cpp ) diff --git a/drivers/CoreFlashMemory/include/CoreFlashMemoryIS25LP016D.h b/drivers/CoreFlashMemory/include/CoreFlashIS25LP016D.h similarity index 90% rename from drivers/CoreFlashMemory/include/CoreFlashMemoryIS25LP016D.h rename to drivers/CoreFlashMemory/include/CoreFlashIS25LP016D.h index 5cc48ecead..648566368c 100644 --- a/drivers/CoreFlashMemory/include/CoreFlashMemoryIS25LP016D.h +++ b/drivers/CoreFlashMemory/include/CoreFlashIS25LP016D.h @@ -28,10 +28,10 @@ enum class ReadMode }; using read_mode_t = ReadMode; -class CoreFlashMemoryIS25LP016D : public interface::FlashMemory +class CoreFlashIS25LP016D : public interface::FlashMemory { public: - explicit CoreFlashMemoryIS25LP016D(interface::QSPI &qspi, interface::FlashManager &flash_manager) + explicit CoreFlashIS25LP016D(interface::QSPI &qspi, interface::FlashManager &flash_manager) : _qspi(qspi), _flash_manager(flash_manager) {}; void setSPIMode(spi_mode_t mode); diff --git a/drivers/CoreFlashMemory/source/CoreFlashMemoryIS25LP016D.cpp b/drivers/CoreFlashMemory/source/CoreFlashIS25LP016D.cpp similarity index 78% rename from drivers/CoreFlashMemory/source/CoreFlashMemoryIS25LP016D.cpp rename to drivers/CoreFlashMemory/source/CoreFlashIS25LP016D.cpp index 8d509b4be1..86b77c22ec 100644 --- a/drivers/CoreFlashMemory/source/CoreFlashMemoryIS25LP016D.cpp +++ b/drivers/CoreFlashMemory/source/CoreFlashIS25LP016D.cpp @@ -2,7 +2,7 @@ // Copyright 2021 APF France handicap // SPDX-License-Identifier: Apache-2.0 -#include "CoreFlashMemoryIS25LP016D.h" +#include "CoreFlashIS25LP016D.h" #include "rtos/ThisThread.h" @@ -11,7 +11,7 @@ using namespace flash::is25lp016d; namespace leka { -void CoreFlashMemoryIS25LP016D::setSPIMode(spi_mode_t mode) +void CoreFlashIS25LP016D::setSPIMode(spi_mode_t mode) { _spi_mode = mode; @@ -35,22 +35,22 @@ void CoreFlashMemoryIS25LP016D::setSPIMode(spi_mode_t mode) _qspi.setFrequency(flash::is25lp016d::max_clock_frequency_in_hz); } -void CoreFlashMemoryIS25LP016D::setReadMode(read_mode_t mode) +void CoreFlashIS25LP016D::setReadMode(read_mode_t mode) { _read_mode = mode; } -auto CoreFlashMemoryIS25LP016D::getSize() -> size_t +auto CoreFlashIS25LP016D::getSize() -> size_t { return flash::is25lp016d::size; } -void CoreFlashMemoryIS25LP016D::reset() +void CoreFlashIS25LP016D::reset() { _flash_manager.reset(); } -auto CoreFlashMemoryIS25LP016D::read(uint32_t address, lstd::span rx_buffer, size_t rx_buffer_size) -> size_t +auto CoreFlashIS25LP016D::read(uint32_t address, lstd::span rx_buffer, size_t rx_buffer_size) -> size_t { if (address + rx_buffer.size() > flash::is25lp016d::size) { return 0; @@ -76,8 +76,7 @@ auto CoreFlashMemoryIS25LP016D::read(uint32_t address, lstd::span rx_bu return bytes_read; } -auto CoreFlashMemoryIS25LP016D::write(uint32_t address, const lstd::span tx_buffer, size_t tx_buffer_size) - -> size_t +auto CoreFlashIS25LP016D::write(uint32_t address, const lstd::span tx_buffer, size_t tx_buffer_size) -> size_t { if (address + tx_buffer.size() > getSize()) { return 0; @@ -97,7 +96,7 @@ auto CoreFlashMemoryIS25LP016D::write(uint32_t address, const lstd::span #include "gtest/gtest.h" @@ -30,17 +30,17 @@ MATCHER_P(compareArray, expected_array, "") return same_content; } -class CoreFlashMemoryIS25LP016DTest : public ::testing::Test +class CoreFlashIS25LP016DTest : public ::testing::Test { protected: - CoreFlashMemoryIS25LP016DTest() : flash_memory_is25lp(qspimock, flash_manager_is25lp) {} + CoreFlashIS25LP016DTest() : flash_memory_is25lp(qspimock, flash_manager_is25lp) {} // void SetUp() override {} // void TearDown() override {} mock::QSPI qspimock; mock::FlashManager flash_manager_is25lp; - CoreFlashMemoryIS25LP016D flash_memory_is25lp; + CoreFlashIS25LP016D flash_memory_is25lp; }; ACTION_TEMPLATE(getDataTransmissionFormat, HAS_1_TEMPLATE_PARAMS(int, k), AND_1_VALUE_PARAMS(returned_format)) @@ -56,12 +56,12 @@ ACTION_TEMPLATE(getDataTransmissionFormat, HAS_1_TEMPLATE_PARAMS(int, k), AND_1_ returned_format->dummy_cycles = actual_format.dummy_cycles; } -TEST_F(CoreFlashMemoryIS25LP016DTest, instantiation) +TEST_F(CoreFlashIS25LP016DTest, instantiation) { ASSERT_NE(&flash_memory_is25lp, nullptr); } -TEST_F(CoreFlashMemoryIS25LP016DTest, spiModeStandard) +TEST_F(CoreFlashIS25LP016DTest, spiModeStandard) { auto spi_mode = SPIMode::Standard; @@ -94,7 +94,7 @@ TEST_F(CoreFlashMemoryIS25LP016DTest, spiModeStandard) ASSERT_EQ(expected_data_transmission_format.dummy_cycles, actual_data_transmission_format.dummy_cycles); } -TEST_F(CoreFlashMemoryIS25LP016DTest, spiModeDual) +TEST_F(CoreFlashIS25LP016DTest, spiModeDual) { auto spi_mode = SPIMode::Dual; @@ -104,7 +104,7 @@ TEST_F(CoreFlashMemoryIS25LP016DTest, spiModeDual) flash_memory_is25lp.setSPIMode(spi_mode); } -TEST_F(CoreFlashMemoryIS25LP016DTest, spiModeQuad) +TEST_F(CoreFlashIS25LP016DTest, spiModeQuad) { auto spi_mode = SPIMode::Quad; @@ -114,7 +114,7 @@ TEST_F(CoreFlashMemoryIS25LP016DTest, spiModeQuad) flash_memory_is25lp.setSPIMode(spi_mode); } -TEST_F(CoreFlashMemoryIS25LP016DTest, spiModeDefault) +TEST_F(CoreFlashIS25LP016DTest, spiModeDefault) { auto spi_mode = static_cast(99); @@ -147,7 +147,7 @@ TEST_F(CoreFlashMemoryIS25LP016DTest, spiModeDefault) ASSERT_EQ(expected_data_transmission_format.dummy_cycles, actual_data_transmission_format.dummy_cycles); } -TEST_F(CoreFlashMemoryIS25LP016DTest, readModeNormal) +TEST_F(CoreFlashIS25LP016DTest, readModeNormal) { auto read_mode = ReadMode::Normal; std::array buffer {}; @@ -165,7 +165,7 @@ TEST_F(CoreFlashMemoryIS25LP016DTest, readModeNormal) flash_memory_is25lp.read(0x00, buffer, 0x10); } -TEST_F(CoreFlashMemoryIS25LP016DTest, readModeFast) +TEST_F(CoreFlashIS25LP016DTest, readModeFast) { auto read_mode = ReadMode::Fast; std::array buffer {}; @@ -182,7 +182,7 @@ TEST_F(CoreFlashMemoryIS25LP016DTest, readModeFast) flash_memory_is25lp.read(0x00, buffer, 0x10); } -TEST_F(CoreFlashMemoryIS25LP016DTest, readModeDefault) +TEST_F(CoreFlashIS25LP016DTest, readModeDefault) { auto read_mode = static_cast(99); std::array buffer {}; @@ -200,7 +200,7 @@ TEST_F(CoreFlashMemoryIS25LP016DTest, readModeDefault) flash_memory_is25lp.read(0x00, buffer, 0x10); } -TEST_F(CoreFlashMemoryIS25LP016DTest, getSize) +TEST_F(CoreFlashIS25LP016DTest, getSize) { auto expected_size = flash::is25lp016d::size; auto actual_size = flash_memory_is25lp.getSize(); @@ -208,14 +208,14 @@ TEST_F(CoreFlashMemoryIS25LP016DTest, getSize) ASSERT_EQ(expected_size, actual_size); } -TEST_F(CoreFlashMemoryIS25LP016DTest, reset) +TEST_F(CoreFlashIS25LP016DTest, reset) { EXPECT_CALL(flash_manager_is25lp, reset).Times(1); flash_memory_is25lp.reset(); } -TEST_F(CoreFlashMemoryIS25LP016DTest, read) +TEST_F(CoreFlashIS25LP016DTest, read) { uint32_t address = 0x2A; const size_t bytes_to_read = 0x10; @@ -236,7 +236,7 @@ TEST_F(CoreFlashMemoryIS25LP016DTest, read) ASSERT_EQ(expected_bytes_read, actual_bytes_read); } -TEST_F(CoreFlashMemoryIS25LP016DTest, readOverSize) +TEST_F(CoreFlashIS25LP016DTest, readOverSize) { uint32_t address = flash::is25lp016d::size; const size_t bytes_to_read = 0x10; @@ -250,7 +250,7 @@ TEST_F(CoreFlashMemoryIS25LP016DTest, readOverSize) ASSERT_EQ(expected_bytes_read, actual_bytes_read); } -TEST_F(CoreFlashMemoryIS25LP016DTest, readFailChipIsNotAvailable) +TEST_F(CoreFlashIS25LP016DTest, readFailChipIsNotAvailable) { uint32_t address = 0x2A; const size_t bytes_to_read = 0x10; @@ -270,7 +270,7 @@ TEST_F(CoreFlashMemoryIS25LP016DTest, readFailChipIsNotAvailable) ASSERT_EQ(expected_bytes_read, actual_bytes_read); } -TEST_F(CoreFlashMemoryIS25LP016DTest, write) +TEST_F(CoreFlashIS25LP016DTest, write) { uint32_t address = 0x2A; auto buffer = lstd::to_array({0x61, 0x62, 0x63, 0x64, 0x65, 0x66}); // "abcdef" @@ -294,7 +294,7 @@ TEST_F(CoreFlashMemoryIS25LP016DTest, write) ASSERT_EQ(expected_bytes_written, actual_bytes_write); } -TEST_F(CoreFlashMemoryIS25LP016DTest, writeOverSize) +TEST_F(CoreFlashIS25LP016DTest, writeOverSize) { uint32_t address = flash::is25lp016d::size; auto buffer = lstd::to_array({0x61, 0x62, 0x63, 0x64, 0x65, 0x66}); // "abcdef" @@ -308,7 +308,7 @@ TEST_F(CoreFlashMemoryIS25LP016DTest, writeOverSize) ASSERT_EQ(expected_bytes_written, actual_bytes_write); } -TEST_F(CoreFlashMemoryIS25LP016DTest, writeFailNotEnableToWrite) +TEST_F(CoreFlashIS25LP016DTest, writeFailNotEnableToWrite) { uint32_t address = 0x2A; auto buffer = lstd::to_array({0x61, 0x62, 0x63, 0x64, 0x65, 0x66}); // "abcdef" @@ -328,7 +328,7 @@ TEST_F(CoreFlashMemoryIS25LP016DTest, writeFailNotEnableToWrite) ASSERT_EQ(expected_bytes_written, actual_bytes_write); } -TEST_F(CoreFlashMemoryIS25LP016DTest, writeFailChipIsNotAvailable) +TEST_F(CoreFlashIS25LP016DTest, writeFailChipIsNotAvailable) { uint32_t address = 0x2A; auto buffer = lstd::to_array({0x61, 0x62, 0x63, 0x64, 0x65, 0x66}); // "abcdef" @@ -350,7 +350,7 @@ TEST_F(CoreFlashMemoryIS25LP016DTest, writeFailChipIsNotAvailable) ASSERT_EQ(expected_bytes_written, actual_bytes_write); } -TEST_F(CoreFlashMemoryIS25LP016DTest, erase) +TEST_F(CoreFlashIS25LP016DTest, erase) { EXPECT_CALL(flash_manager_is25lp, erase).Times(1); diff --git a/spikes/lk_flash_memory/main.cpp b/spikes/lk_flash_memory/main.cpp index e652b5ba7b..4f92acb2f8 100644 --- a/spikes/lk_flash_memory/main.cpp +++ b/spikes/lk_flash_memory/main.cpp @@ -7,8 +7,8 @@ #include "drivers/BufferedSerial.h" #include "rtos/ThisThread.h" +#include "CoreFlashIS25LP016D.h" #include "CoreFlashManagerIS25LP016D.h" -#include "CoreFlashMemoryIS25LP016D.h" #include "CoreQSPI.h" #include "HelloWorld.h" #include "LogKit.h" @@ -28,7 +28,7 @@ auto main() -> int auto coreqspi = CoreQSPI(); auto coremanageris25lp = CoreFlashManagerIS25LP016D(coreqspi); - auto coreis25lp = CoreFlashMemoryIS25LP016D(coreqspi, coremanageris25lp); + auto coreis25lp = CoreFlashIS25LP016D(coreqspi, coremanageris25lp); coreis25lp.reset(); rtos::ThisThread::sleep_for(2s);