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
|
||||
|
||||
#include <sta/bus/spi/device.hpp>
|
||||
//#include <sta/devices/stm32/bus/spi.hpp>
|
||||
#include <sta/mutex.hpp>
|
||||
|
||||
#include <sta/drivers/w25qxx_defs.hpp>
|
||||
|
||||
#include <functional>
|
||||
|
@ -21,13 +21,16 @@ namespace sta
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* @brief Write a new data point to the flash chip.
|
||||
* @note If the total capacity of this logger was exceeded, it restarts at the first sector, overwriting its data.
|
||||
* @brief Write a new data point to the flash chip as long as the segment's limit wasn't reached.
|
||||
*
|
||||
* @param data The data to write to the flash chip.
|
||||
* @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.
|
||||
*/
|
||||
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.
|
||||
* @return T The ith element stored in the flash storage.
|
||||
* @param buffer A buffer of size 256 containing data from a page.
|
||||
* @return true if the page is empty, false otherwise.
|
||||
*/
|
||||
T operator[](std::size_t i);
|
||||
private:
|
||||
bool searchCriterion(uint8_t * buffer);
|
||||
|
||||
private:
|
||||
W25Qxx * flash_;
|
||||
uint32_t start_;
|
||||
uint32_t end_;
|
||||
|
@ -200,12 +200,6 @@ namespace sta
|
||||
return *reinterpret_cast<T*>(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Logger<T>::operator[](std::size_t i)
|
||||
{
|
||||
return this->get(i);
|
||||
}
|
||||
} // namespace sta
|
||||
|
||||
#endif // STA_UTILS_LOGGER_TPP
|
||||
|
Loading…
x
Reference in New Issue
Block a user