Skip to content

Commit

Permalink
🚚 (is25lp): Rename CoreFlashMemoryIS25LP into CoreFlashIS25LP
Browse files Browse the repository at this point in the history
  • Loading branch information
YannLocatelli committed Oct 1, 2021
1 parent b6ec97a commit e5fb735
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 37 deletions.
4 changes: 2 additions & 2 deletions drivers/CoreFlashMemory/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ target_include_directories(CoreFlashMemory

target_sources(CoreFlashMemory
PRIVATE
source/CoreFlashMemoryIS25LP016D.cpp
source/CoreFlashIS25LP016D.cpp
source/CoreFlashManagerIS25LP016D.cpp
)

Expand All @@ -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
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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;

Expand All @@ -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<uint8_t> rx_buffer, size_t rx_buffer_size) -> size_t
auto CoreFlashIS25LP016D::read(uint32_t address, lstd::span<uint8_t> rx_buffer, size_t rx_buffer_size) -> size_t
{
if (address + rx_buffer.size() > flash::is25lp016d::size) {
return 0;
Expand All @@ -76,8 +76,7 @@ auto CoreFlashMemoryIS25LP016D::read(uint32_t address, lstd::span<uint8_t> rx_bu
return bytes_read;
}

auto CoreFlashMemoryIS25LP016D::write(uint32_t address, const lstd::span<uint8_t> tx_buffer, size_t tx_buffer_size)
-> size_t
auto CoreFlashIS25LP016D::write(uint32_t address, const lstd::span<uint8_t> tx_buffer, size_t tx_buffer_size) -> size_t
{
if (address + tx_buffer.size() > getSize()) {
return 0;
Expand All @@ -97,7 +96,7 @@ auto CoreFlashMemoryIS25LP016D::write(uint32_t address, const lstd::span<uint8_t
return bytes_write;
}

void CoreFlashMemoryIS25LP016D::erase()
void CoreFlashIS25LP016D::erase()
{
_flash_manager.erase();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright 2021 APF France handicap
// SPDX-License-Identifier: Apache-2.0

#include "CoreFlashMemoryIS25LP016D.h"
#include "CoreFlashIS25LP016D.h"
#include <lstd_array>

#include "gtest/gtest.h"
Expand Down Expand Up @@ -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))
Expand All @@ -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;

Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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<spi_mode_t>(99);

Expand Down Expand Up @@ -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<uint8_t, 0x10> buffer {};
Expand All @@ -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<uint8_t, 0x10> buffer {};
Expand All @@ -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<read_mode_t>(99);
std::array<uint8_t, 0x10> buffer {};
Expand All @@ -200,22 +200,22 @@ 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();

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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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<uint8_t>({0x61, 0x62, 0x63, 0x64, 0x65, 0x66}); // "abcdef"
Expand All @@ -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<uint8_t>({0x61, 0x62, 0x63, 0x64, 0x65, 0x66}); // "abcdef"
Expand All @@ -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<uint8_t>({0x61, 0x62, 0x63, 0x64, 0x65, 0x66}); // "abcdef"
Expand All @@ -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<uint8_t>({0x61, 0x62, 0x63, 0x64, 0x65, 0x66}); // "abcdef"
Expand All @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions spikes/lk_flash_memory/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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);
Expand Down

0 comments on commit e5fb735

Please sign in to comment.