mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/driver-w25qxxx.git
synced 2025-09-29 00:37:33 +00:00
Updated binary search and addressing
This commit is contained in:
@@ -39,6 +39,18 @@ namespace sta
|
||||
_32BIT
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
enum class ChunkSize
|
||||
{
|
||||
PAGE,
|
||||
SECTOR,
|
||||
BLOCK_32KB,
|
||||
BLOCK_64KB
|
||||
};
|
||||
|
||||
class W25Qxx
|
||||
{
|
||||
public:
|
||||
@@ -62,13 +74,18 @@ namespace sta
|
||||
*/
|
||||
uint8_t init();
|
||||
|
||||
uint32_t getChunkBytes(ChunkSize size);
|
||||
|
||||
/**
|
||||
* @brief Find the last page satisfying the given criterion. Uses a binary search to find this page.
|
||||
* @brief Find the first memory section not satisfying a given criterion using a binary search.
|
||||
*
|
||||
* @note This function assume that there is a page n such that every page before n satisfies the criterion, while every page after that doesn't
|
||||
*
|
||||
* @param criterion A function evaluating the criterion on a page.
|
||||
* @param size The size of the memory section. Has to be one of the predefined sizes.
|
||||
* @return uint32_t The last address such that the criterion is satisfied.
|
||||
*/
|
||||
uint32_t findLastPage(std::function<bool(uint8_t*)> criterion);
|
||||
uint32_t findLast(std::function<bool(uint8_t*)> criterion, ChunkSize size);
|
||||
|
||||
/**
|
||||
* @brief Set the Address Mode object
|
||||
@@ -188,6 +205,8 @@ namespace sta
|
||||
* @return uint8_t
|
||||
*/
|
||||
uint8_t pageProgram(uint32_t address, uint8_t * buffer, size_t length);
|
||||
|
||||
uint8_t sectorProgram(uint32_t address, uint8_t * buffer, size_t length);
|
||||
public:
|
||||
/*
|
||||
* Erase operations
|
||||
|
@@ -57,8 +57,15 @@
|
||||
#define W25QXX_INDIV_BLOCK_UNLOCK 0x39
|
||||
#define W25QXX_READ_BLOCK_LOCK 0x3D
|
||||
|
||||
|
||||
#define W25QXX_DEVICE_ID_RESULT 0xEF
|
||||
|
||||
#define W25QXX_PAGE_SIZE 0x100
|
||||
#define W25QXX_SECTOR_SIZE 0x1000
|
||||
#define W25QXX_BLOCK_32_KB_SIZE 0x8000
|
||||
#define W25QXX_BLOCK_64_KB_SIZE 0xF000
|
||||
|
||||
#define W25QXX_24B_MEM_SIZE 0xFFFFFF
|
||||
#define W25QXX_32B_MEM_SIZE 0xFFFFFFFF
|
||||
|
||||
|
||||
#endif // STA_SENSORS_W25QXX_DEFS_HPP
|
||||
|
Reference in New Issue
Block a user