![]() |
Speeduino
|
Namespaces | |
| namespace | EEPROMApi |
Functions | |
| static byte | EEPROMApi::read (uint16_t address) |
| static void | EEPROMApi::write (uint16_t address, byte val) |
| static uint16_t | EEPROMApi::length (void) |
| storage_api_t | getEEPROMStorageApi (void) |
| Create a storage_api_t instance that wraps getEEPROM() | |
| bool | update (const storage_api_t &api, uint16_t address, byte value) |
| Conditionally write a byte to storage if it differs from the one already saved. | |
| void | updateBlock (const storage_api_t &api, uint16_t address, const byte *pFirst, const byte *pLast) |
| Conditionally write bytes from block of memory to storage. Values are written only if they differ from the one already saved at the same address. | |
| uint16_t | updateBlockLimitWriteOps (const storage_api_t &api, uint16_t address, const byte *pFirst, const byte *pLast, uint16_t maxWrites) |
| Conditionally write bytes from block of memory to storage, with a limited number of write operations. | |
| uint16_t | loadBlock (const storage_api_t &api, int16_t address, byte *pFirst, const byte *pLast) |
| Copy a block of data from storage to memory. | |
| void | fillBlock (const storage_api_t &api, uint16_t address, uint16_t length, byte value) |
| Fills the given block with a constant. | |
| void | moveBlock (const storage_api_t &api, uint16_t dest, uint16_t source, uint16_t size) |
| Move a block of bytes. | |
Fills the given block with a constant.
| api | Raw storage API |
| address | the location to begin writing to (zero based) |
| length | number of bytes to write |
| value | fill value |


| storage_api_t getEEPROMStorageApi | ( | void | ) |
Create a storage_api_t instance that wraps getEEPROM()
Applies the adapter pattern to provide storage_api_t from EEPROM_t


| uint16_t loadBlock | ( | const storage_api_t & | api, |
| int16_t | address, | ||
| byte * | pFirst, | ||
| const byte * | pLast | ||
| ) |
Copy a block of data from storage to memory.
This is essentially the opposite of updateBlock()
| api | Raw storage API |
| address | the location to begin reading from (zero based) |
| pFirst | Points to the start of the memory block |
| pLast | Points to one byte past the end of the block |


Move a block of bytes.
This will handle overlapping blocks. I.e. if [dest, size) overlaps [source, size)
| api | Raw storage API |
| dest | Address to copy to |
| source | Address to copy from |
| size | number of bytes to copy |

| bool update | ( | const storage_api_t & | api, |
| uint16_t | address, | ||
| byte | value | ||
| ) |
Conditionally write a byte to storage if it differs from the one already saved.
Background: some storage hardware has a limited number of write cycles per cell. E.g. flash memory can only withstand a certain number of write/erase cycles before it begins to wear out and can no longer reliably store data. This is typically in the range of 3000-5000 cycles for multi-level cell (MLC) NAND flash, or 10,000-100,000 cycles for single-level cell (SLC) NAND flash. So we want to limit writes as much as possible. Hence this function.
| api | Raw storage API |
| address | the location to write to (zero based) |
| value | the value to write |


| void updateBlock | ( | const storage_api_t & | api, |
| uint16_t | address, | ||
| const byte * | pFirst, | ||
| const byte * | pLast | ||
| ) |
Conditionally write bytes from block of memory to storage. Values are written only if they differ from the one already saved at the same address.
address+(pLast-pFirst) < api.length(). I.e. that the block fits into the address space. | api | Raw storage API |
| address | the location to begin writing to (zero based) |
| pFirst | Points to the start of the memory block |
| pLast | Points to one byte past the end of the block |


| uint16_t updateBlockLimitWriteOps | ( | const storage_api_t & | api, |
| uint16_t | address, | ||
| const byte * | pFirst, | ||
| const byte * | pLast, | ||
| uint16_t | maxWrites | ||
| ) |
Conditionally write bytes from block of memory to storage, with a limited number of write operations.
Write operations are typically pretty slow (E.g. 3.3ms on AVR EEPROM). If a block contains many bytes that need to be written, we can cause the system to stutter as the main loop stalls waiting for writes to complete. So instead we limit the number of write operations per call to this function.
| api | Raw storage API |
| address | the location to begin writing to (zero based) |
| pFirst | Points to the start of the memory block |
| pLast | Points to one byte past the end of the block |
| maxWrites | Maximum number of write operations. |

