mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/driver-w25qxxx.git
synced 2025-06-10 02:26:00 +00:00
Added feedback
This commit is contained in:
parent
231f2ea06d
commit
1d3ba48d7c
@ -2,9 +2,7 @@
|
|||||||
#define STA_SENSORS_W25Q128_HPP
|
#define STA_SENSORS_W25Q128_HPP
|
||||||
|
|
||||||
#include <sta/bus/spi/device.hpp>
|
#include <sta/bus/spi/device.hpp>
|
||||||
//#include <sta/devices/stm32/bus/spi.hpp>
|
|
||||||
#include <sta/mutex.hpp>
|
#include <sta/mutex.hpp>
|
||||||
|
|
||||||
#include <sta/drivers/w25qxx_defs.hpp>
|
#include <sta/drivers/w25qxx_defs.hpp>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
@ -20,14 +20,17 @@ namespace sta
|
|||||||
* @param endSector The index of the end sector (1 LSB = 4096 bytes).
|
* @param endSector The index of the end sector (1 LSB = 4096 bytes).
|
||||||
*/
|
*/
|
||||||
Logger(W25Qxx * flash, uint32_t startSector, uint32_t endSector);
|
Logger(W25Qxx * flash, uint32_t startSector, uint32_t endSector);
|
||||||
|
|
||||||
void findLast();
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Write a new data point to the flash chip as long as the segment's limit wasn't reached.
|
||||||
|
*
|
||||||
|
* @param data A pointer to the data to write to the flash chip.
|
||||||
|
* @return true if successful, false if the segment end was reached.
|
||||||
|
*/
|
||||||
bool write(T* data);
|
bool write(T* data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Write a new data point to the flash chip.
|
* @brief Write a new data point to the flash chip as long as the segment's limit wasn't reached.
|
||||||
* @note If the total capacity of this logger was exceeded, it restarts at the first sector, overwriting its data.
|
|
||||||
*
|
*
|
||||||
* @param data The data to write to the flash chip.
|
* @param data The data to write to the flash chip.
|
||||||
* @return true if successful, false if the segment end was reached.
|
* @return true if successful, false if the segment end was reached.
|
||||||
@ -68,17 +71,22 @@ namespace sta
|
|||||||
* @return T The ith element stored in the flash storage.
|
* @return T The ith element stored in the flash storage.
|
||||||
*/
|
*/
|
||||||
T get(std::size_t i);
|
T get(std::size_t i);
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief Find the first sector in the segment that was not written yet.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void findLast();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the ith element stored in the flash storage.
|
* @brief A method that checks if a page is empty
|
||||||
*
|
*
|
||||||
* @param i The index of the element to read.
|
* @param buffer A buffer of size 256 containing data from a page.
|
||||||
* @return T The ith element stored in the flash storage.
|
* @return true if the page is empty, false otherwise.
|
||||||
*/
|
*/
|
||||||
T operator[](std::size_t i);
|
|
||||||
private:
|
|
||||||
bool searchCriterion(uint8_t * buffer);
|
bool searchCriterion(uint8_t * buffer);
|
||||||
|
|
||||||
|
private:
|
||||||
W25Qxx * flash_;
|
W25Qxx * flash_;
|
||||||
uint32_t start_;
|
uint32_t start_;
|
||||||
uint32_t end_;
|
uint32_t end_;
|
||||||
|
@ -200,12 +200,6 @@ namespace sta
|
|||||||
return *reinterpret_cast<T*>(buffer);
|
return *reinterpret_cast<T*>(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
T Logger<T>::operator[](std::size_t i)
|
|
||||||
{
|
|
||||||
return this->get(i);
|
|
||||||
}
|
|
||||||
} // namespace sta
|
} // namespace sta
|
||||||
|
|
||||||
#endif // STA_UTILS_LOGGER_TPP
|
#endif // STA_UTILS_LOGGER_TPP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user