Added mutex and more doxygen

This commit is contained in:
dario
2024-06-03 22:49:04 +02:00
parent 9dd2a8da9c
commit 007ed46363
3 changed files with 20 additions and 13 deletions

View File

@@ -33,6 +33,12 @@ namespace sta
// If the written data exceeds the remaining bytes in the page.
if (ptr_ + length >= W25QXX_PAGE_SIZE)
{
// If the segment is full, stop writing data to it.
if (address_ / W25QXX_SECTOR_SIZE == end_)
{
return;
}
std::memcpy(buffer_ + ptr_, bytes, remaining);
flash_->pageProgram(address_, buffer_, W25QXX_PAGE_SIZE);
@@ -43,15 +49,9 @@ namespace sta
address_ += W25QXX_PAGE_SIZE;
// If a new sector was started, erase the new sector.
// If a new sector has to be started, erase the new sector.
if (address_ % W25QXX_SECTOR_SIZE == 0)
{
// If the size of the logger segment was exceeded, restart at the first sector.
if (address_ / W25QXX_SECTOR_SIZE == end_)
{
address_ = start_ * W25QXX_SECTOR_SIZE;
}
flash_->sectorErase(address_);
}
}
@@ -81,7 +81,7 @@ namespace sta
template <typename T>
size_t Logger<T>::remaining()
{
return (end_ * W25QXX_SECTOR_SIZE - address_) / sizeof(T);
return (end_ * W25QXX_SECTOR_SIZE - address_) / sizeof(T);
}
template <typename T>