forked from smartmx/TFDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtfdb_port.c
73 lines (65 loc) · 1.87 KB
/
tfdb_port.c
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
66
67
68
69
70
71
/*
* Copyright (c) 2022-2023, smartmx - smartmx@qq.com
*
* SPDX-License-Identifier: MIT
*
* Change Logs:
* Date Author Notes
* 2022-02-03 smartmx the first version
* 2022-02-08 smartmx fix bugs
* 2022-02-12 smartmx fix bugs, add support for 2 byte write flash
* 2022-03-15 smartmx fix bugs, add support for stm32l4 flash
* 2022-08-02 smartmx add TFDB_VALUE_AFTER_ERASE_SIZE option
* 2023-02-22 smartmx add dual flash index function
*
*/
#include "tfdb_port.h"
/**
* Read data from flash.
* @note This operation's units is refer to TFDB_WRITE_UNIT_BYTES.
*
* @param addr flash address.
* @param buf buffer to store read data.
* @param size read bytes size.
*
* @return TFDB_Err_Code
*/
TFDB_Err_Code tfdb_port_read(tfdb_addr_t addr, uint8_t *buf, size_t size)
{
TFDB_Err_Code result = TFDB_NO_ERR;
/* You can add your code under here. */
return result;
}
/**
* Erase flash.
* @param addr flash address.
* @param size erase bytes size.
*
* @return TFDB_Err_Code
*/
TFDB_Err_Code tfdb_port_erase(tfdb_addr_t addr, size_t size)
{
TFDB_Err_Code result = TFDB_NO_ERR;
/* You can add your code under here. */
return result;
}
/**
* Write data to flash.
* @note This operation's units is refer to TFDB_WRITE_UNIT_BYTES.
* if you're using some flash like stm32L4xx, please add flash check
* operations before write flash to ensure the write area is erased.
* if the write area is not erased, please just return TFDB_NO_ERR.
* TFDB will check data and retry at next address.
*
* @param addr flash address.
* @param buf the write data buffer.
* @param size write bytes size.
*
* @return result
*/
TFDB_Err_Code tfdb_port_write(tfdb_addr_t addr, const uint8_t *buf, size_t size)
{
TFDB_Err_Code result = TFDB_NO_ERR;
/* You can add your code under here. */
return result;
}