picofuse

block.h
Go to the documentation of this file.
1 
29 #pragma once
30 #include <stdbool.h>
31 #include <stddef.h>
32 #include <stdint.h>
33 
35 // CONSTANTS
36 
43 #ifndef BLOCK_MAX_CAPACITY
44 #define BLOCK_MAX_CAPACITY 4u
45 #endif
46 
53 #ifndef BLOCK_CONTEXT_SIZE
54 #define BLOCK_CONTEXT_SIZE 32u
55 #endif
56 
58 // TYPES
59 
60 typedef struct hw_block_t hw_block_t;
61 
63 // PROPERTIES
64 
74 size_t hw_block_count(const hw_block_t *block);
75 
82 size_t hw_block_size(const hw_block_t *block);
83 
86 // METHODS
88 
101 bool hw_block_read(const hw_block_t *block, size_t index, void *dst);
102 
111 bool hw_block_erase(hw_block_t *block, size_t index);
112 
122 bool hw_block_write(hw_block_t *block, size_t index, const void *src);
123 
129 void hw_block_deinit(hw_block_t *block);
130 
bool hw_block_erase(hw_block_t *block, size_t index)
Erase one block.
size_t hw_block_count(const hw_block_t *block)
Return the number of addressable blocks.
size_t hw_block_size(const hw_block_t *block)
Return the block size in bytes.
void hw_block_deinit(hw_block_t *block)
Deinitialize a block handle.
bool hw_block_read(const hw_block_t *block, size_t index, void *dst)
Read one block into dst.
bool hw_block_write(hw_block_t *block, size_t index, const void *src)
Write one block from src.