-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathkved_flash.h
65 lines (55 loc) · 1.56 KB
/
kved_flash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
kved (key/value embedded database), a simple key/value database
implementation for microcontrollers.
Copyright (c) 2022 Marcelo Barros de Almeida <[email protected]>
*/
#pragma once
/**
@file
@defgroup KVED_FLASH KVED_FLASH
@brief kved flash API
@{
*/
/**
@brief Flash sectors that can be used for data persistence.
Positions and mappings will depend on the driver implementation.
*/
typedef enum kved_flash_sector_e
{
KVED_FLASH_SECTOR_A = 0, /**< Setor A */
KVED_FLASH_SECTOR_B, /**< Setor B */
KVED_FLASH_NUM_SECTORS, /**< Number of sectors */
} kved_flash_sector_t;
/**
@brief Delete a flash sector
@param[in] sec - sector to be deleted (see @ref kved_flash_sector_e)
@return true: sector erased
@return false: sector erasuring failed
*/
bool kved_flash_sector_erase(kved_flash_sector_t sec);
/**
@brief Write a word value into the flash sector
@param[in] sec - sector (see @ref kved_flash_sector_e)
@param[in] index - index position
@param[in] data - value to written (word)
*/
void kved_flash_data_write(kved_flash_sector_t sec, uint16_t index, kved_word_t data);
/**
@brief Reads a word value from the flash sector
@param[in] sec - sector (see @ref kved_flash_sector_e)
@param[in] index - index position
@return read value (word)
*/
kved_word_t kved_flash_data_read(kved_flash_sector_t sec, uint16_t index);
/**
@brief Returns the sector size
@return Sector size, in bytes
*/
uint32_t kved_flash_sector_size(void);
/**
@brief Flash initialization. It will depend on the driver implementation.
*/
void kved_flash_init(void);
/**
@}
*/