From d6b16dbff1236c7377e54c65a71f308be831e3a1 Mon Sep 17 00:00:00 2001 From: Lars Wilko Sentse Date: Sun, 9 Jun 2024 12:32:13 +0200 Subject: [PATCH] fixed assert for start and end sector --- include/sta/drivers/w25qxx.hpp | 3 ++- include/sta/utils/logger.tpp | 2 +- src/w25qxx.cpp | 22 +++++++++++----------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/sta/drivers/w25qxx.hpp b/include/sta/drivers/w25qxx.hpp index 4682f02..3e8e962 100644 --- a/include/sta/drivers/w25qxx.hpp +++ b/include/sta/drivers/w25qxx.hpp @@ -2,6 +2,7 @@ #define STA_SENSORS_W25Q128_HPP #include +//#include #include #include @@ -333,4 +334,4 @@ namespace sta } // namespace sta -#endif // STA_SENSORS_W25Q128_HPP \ No newline at end of file +#endif // STA_SENSORS_W25Q128_HPP diff --git a/include/sta/utils/logger.tpp b/include/sta/utils/logger.tpp index 5eebdd3..4c1501c 100644 --- a/include/sta/utils/logger.tpp +++ b/include/sta/utils/logger.tpp @@ -16,7 +16,7 @@ namespace sta ptr_ {0} { STA_ASSERT(flash != nullptr); - STA_ASSERT(endAddr > startAddr); + STA_ASSERT(endSec > startSec); // Jump to the last written page. findLast(); diff --git a/src/w25qxx.cpp b/src/w25qxx.cpp index 15031d4..3fd777c 100644 --- a/src/w25qxx.cpp +++ b/src/w25qxx.cpp @@ -22,7 +22,7 @@ namespace sta uint8_t W25Qxx::init() { - lock_guard(*mutex_); + lock_guardlock(*mutex_); powerDown(); delay_(5); @@ -76,7 +76,7 @@ namespace sta { STA_ASSERT(startAddr <= endAddr); - lock_guard(*mutex_); + lock_guardlock(*mutex_); uint32_t bytes = getChunkBytes(size); uint32_t left = startAddr / bytes; @@ -118,7 +118,7 @@ namespace sta uint8_t W25Qxx::setAddressMode(AddressMode addrMode) { - lock_guard(*mutex_); + lock_guardlock(*mutex_); busWrite(W25QXX_4_BYTE_ADDR_ENABLE); while (isBusy()) {} @@ -128,7 +128,7 @@ namespace sta AddressMode W25Qxx::getAddressMode() { - lock_guard(*mutex_); + lock_guardlock(*mutex_); uint8_t status; readStatusRegister(3, &status); @@ -138,7 +138,7 @@ namespace sta uint8_t W25Qxx::getChipID() { - lock_guard(*mutex_); + lock_guardlock(*mutex_); uint8_t buffer[4]; busRead(W25QXX_RELEASE_POWER_DOWN, buffer, 3); @@ -148,7 +148,7 @@ namespace sta uint8_t W25Qxx::getManufacturerID() { - lock_guard(*mutex_); + lock_guardlock(*mutex_); uint8_t dummy[3] = {0, 0, 0}; uint8_t id[2] = {0, 0}; @@ -160,7 +160,7 @@ namespace sta uint64_t W25Qxx::getUniqueID() { - lock_guard(*mutex_); + lock_guardlock(*mutex_); uint8_t dummy[4]; uint8_t id[8]; @@ -179,7 +179,7 @@ namespace sta bool W25Qxx::isBusy() { - lock_guard(*mutex_); + lock_guardlock(*mutex_); uint8_t status = 0; readStatusRegister(1, &status); @@ -189,7 +189,7 @@ namespace sta uint8_t W25Qxx::readData(uint32_t address, uint8_t * buffer, size_t length, bool fast /* = true */) { - lock_guard(*mutex_); + lock_guardlock(*mutex_); uint8_t instruction = fast ? W25QXX_FAST_READ : W25QXX_READ; @@ -241,7 +241,7 @@ namespace sta uint8_t W25Qxx::pageProgram(uint32_t address, uint8_t * buffer, size_t length) { - lock_guard(*mutex_); + lock_guardlock(*mutex_); STA_ASSERT(length <= W25QXX_PAGE_SIZE); while (isBusy()) {} @@ -278,7 +278,7 @@ namespace sta uint8_t W25Qxx::sectorProgram(uint32_t address, uint8_t * buffer, size_t length) { - lock_guard(*mutex_); + lock_guardlock(*mutex_); STA_ASSERT(length <= W25QXX_SECTOR_SIZE);