Compare commits
47 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
a67fffcb4a | 2 years ago |
|
|
f9adf31468 | 2 years ago |
|
|
7b2073086a | 2 years ago |
|
|
9e525c7475 | 2 years ago |
|
|
bee1918ebd | 3 years ago |
|
|
cbb16391b1 | 3 years ago |
|
|
ac971cb63d | 3 years ago |
|
|
f732982f71 | 3 years ago |
|
|
90bc6d5c06 | 3 years ago |
|
|
06370af0a2 | 3 years ago |
|
|
aaa168123f | 3 years ago |
|
|
a5f09478f7 | 3 years ago |
|
|
af12a8e8a7 | 3 years ago |
|
|
91eb583605 | 3 years ago |
|
|
4e992a8917 | 3 years ago |
|
|
c5b48a4736 | 3 years ago |
|
|
c2879bbf75 | 4 years ago |
|
|
f886316b3f | 4 years ago |
|
|
d80224448a | 4 years ago |
|
|
ef3556f202 | 5 years ago |
|
|
173b09d718 | 6 years ago |
|
|
ad78365216 | 6 years ago |
|
|
e034e0879f | 6 years ago |
|
|
d4ef8b6caf | 6 years ago |
|
|
7cd2f0a979 | 6 years ago |
|
|
d8405708b6 | 6 years ago |
|
|
7483c7971f | 6 years ago |
|
|
2d31e24352 | 6 years ago |
|
|
12f8f0864c | 6 years ago |
|
|
bcae150bf9 | 6 years ago |
|
|
9a3daaa4c6 | 6 years ago |
|
|
3babfbc970 | 6 years ago |
|
|
b91bd2c7f9 | 6 years ago |
|
|
10ff7de6ac | 6 years ago |
|
|
aa491ca744 | 6 years ago |
|
|
edc13635cb | 6 years ago |
|
|
7076d58541 | 6 years ago |
|
|
d19cd3c7e7 | 6 years ago |
|
|
779210861b | 6 years ago |
|
|
058f773c1b | 6 years ago |
|
|
bda011569d | 6 years ago |
|
|
3bec40409a | 6 years ago |
|
|
546418c418 | 6 years ago |
|
|
3532410375 | 6 years ago |
|
|
d3182370d7 | 6 years ago |
|
|
16056b8a01 | 6 years ago |
|
|
46eca3f7b6 | 7 years ago |
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 8.1 KiB |
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* This file is part of the EasyFlash Library.
|
||||
*
|
||||
* Copyright (c) 2019-2020, Armink, <armink.ztl@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* 'Software'), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Function: It is the definitions head file for this library.
|
||||
* Created on: 2019-11-20
|
||||
*/
|
||||
|
||||
#ifndef EF_DEF_H_
|
||||
#define EF_DEF_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* EasyFlash software version number */
|
||||
#define EF_SW_VERSION "4.1.99"
|
||||
#define EF_SW_VERSION_NUM 0x40199
|
||||
|
||||
/*
|
||||
* ENV version number defined by user.
|
||||
* Please change it when your firmware add a new ENV to default_env_set.
|
||||
*/
|
||||
#ifndef EF_ENV_VER_NUM
|
||||
#define EF_ENV_VER_NUM 0
|
||||
#endif
|
||||
|
||||
/* the ENV max name length must less then it */
|
||||
#ifndef EF_ENV_NAME_MAX
|
||||
#define EF_ENV_NAME_MAX 32
|
||||
#endif
|
||||
|
||||
/* EasyFlash debug print function. Must be implement by user. */
|
||||
#ifdef PRINT_DEBUG
|
||||
#define EF_DEBUG(...) ef_log_debug(__FILE__, __LINE__, __VA_ARGS__)
|
||||
#else
|
||||
#define EF_DEBUG(...)
|
||||
#endif
|
||||
/* EasyFlash routine print function. Must be implement by user. */
|
||||
#define EF_INFO(...) ef_log_info(__VA_ARGS__)
|
||||
/* EasyFlash assert for developer. */
|
||||
#define EF_ASSERT(EXPR) \
|
||||
if (!(EXPR)) \
|
||||
{ \
|
||||
EF_DEBUG("(%s) has assert failed at %s.\n", #EXPR, __FUNCTION__); \
|
||||
while (1); \
|
||||
}
|
||||
|
||||
typedef struct _ef_env {
|
||||
char *key;
|
||||
void *value;
|
||||
size_t value_len;
|
||||
} ef_env, *ef_env_t;
|
||||
|
||||
/* EasyFlash error code */
|
||||
typedef enum {
|
||||
EF_NO_ERR,
|
||||
EF_ERASE_ERR,
|
||||
EF_READ_ERR,
|
||||
EF_WRITE_ERR,
|
||||
EF_ENV_NAME_ERR,
|
||||
EF_ENV_NAME_EXIST,
|
||||
EF_ENV_FULL,
|
||||
EF_ENV_INIT_FAILED,
|
||||
} EfErrCode;
|
||||
|
||||
/* the flash sector current status */
|
||||
typedef enum {
|
||||
EF_SECTOR_EMPTY,
|
||||
EF_SECTOR_USING,
|
||||
EF_SECTOR_FULL,
|
||||
} EfSecrorStatus;
|
||||
|
||||
enum env_status {
|
||||
ENV_UNUSED,
|
||||
ENV_PRE_WRITE,
|
||||
ENV_WRITE,
|
||||
ENV_PRE_DELETE,
|
||||
ENV_DELETED,
|
||||
ENV_ERR_HDR,
|
||||
ENV_STATUS_NUM,
|
||||
};
|
||||
typedef enum env_status env_status_t;
|
||||
|
||||
struct env_node_obj {
|
||||
env_status_t status; /**< ENV node status, @see node_status_t */
|
||||
bool crc_is_ok; /**< ENV node CRC32 check is OK */
|
||||
uint8_t name_len; /**< name length */
|
||||
uint32_t magic; /**< magic word(`K`, `V`, `4`, `0`) */
|
||||
uint32_t len; /**< ENV node total length (header + name + value), must align by EF_WRITE_GRAN */
|
||||
uint32_t value_len; /**< value length */
|
||||
char name[EF_ENV_NAME_MAX]; /**< name */
|
||||
struct {
|
||||
uint32_t start; /**< ENV node start address */
|
||||
uint32_t value; /**< value start address */
|
||||
} addr;
|
||||
};
|
||||
typedef struct env_node_obj *env_node_obj_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* EF_DEF_H_ */
|
||||
Loading…
Reference in New Issue