Added search functionality using binary search

This commit is contained in:
dario
2024-05-07 20:12:17 +02:00
parent ad76f8e12f
commit d88de338e9
2 changed files with 40 additions and 2 deletions

View File

@@ -4,6 +4,8 @@
#include <sta/bus/spi/device.hpp>
#include <sta/drivers/w25qxx_defs.hpp>
#include <functional>
namespace sta
{
@@ -53,8 +55,21 @@ namespace sta
*/
W25Qxx(SPIDevice * device, DelayUsFunc delay, AddressMode addrMode = AddressMode::_24BIT);
/**
* @brief Initialize the flash chip.
*
* @return uint8_t Returns 1 if successful, 0 otherwise.
*/
uint8_t init();
/**
* @brief Find the last page satisfying the given criterion. Uses a binary search to find this page.
*
* @param criterion A function evaluating the criterion on a page.
* @return uint32_t The last address such that the criterion is satisfied.
*/
uint32_t findLastPage(std::function<bool(uint8_t*)> criterion);
/**
* @brief Set the Address Mode object
*
@@ -173,8 +188,6 @@ namespace sta
* @return uint8_t
*/
uint8_t pageProgram(uint32_t address, uint8_t * buffer, size_t length);
public:
/*
* Erase operations