1. EasyFlash

Easyflash可以让 Flash 成为小型 KV 数据库(Key-Value) GitHub: https://github.com/armink/SFUD Gitee: https://gitee.com/Armink/EasyFlash

2. EasyFlash的移植

① 使用keil添加工程并添加对应的头文件

② 编写ef_port.c

/*
* This file is part of the EasyLogger Library.
*
* Copyright (c) 2015, 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: Portable interface for each platform.
* Created on: 2015-04-28
*/ #include <elog.h>
#include <elog_flash.h>
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h" #include <sfud.h>
#include "BSP_DebugUART.h" static SemaphoreHandle_t xMutexElog= NULL;
/**
* EasyLogger port initialize
*
* @return result
*/
ElogErrCode elog_port_init(void) {
ElogErrCode result = ELOG_NO_ERR; /* add your code here */
xMutexElog = xSemaphoreCreateMutex(); /* 创建互斥信号量 */
if(xMutexElog == NULL)
{
/* 没有创建成功,用户可以在这里加入创建失败的处理机制 */
while(1);
} return result;
} /**
* EasyLogger port deinitialize
*
*/
void elog_port_deinit(void) { /* add your code here */ } /**
* output log port interface
*
* @param log output of log
* @param size log size
*/
void elog_port_output(const char *log, size_t size) { /* add your code here */
// printf("%.*s", size, log);
BSP_Printf("%.*s", size, log);
/* output to flash */
if( isFlashReady )
elog_flash_write(log, size);
} /**
* output lock
*/
void elog_port_output_lock(void) { /* add your code here */
/* 裸机中使用开关中断方法 */
// __disable_irq();
/* add your code here */
/* OS 中使用临界区或互斥量,推荐互斥量方式 */
// taskENTER_CRITICAL(); /* 进入临界区 */
xSemaphoreTake(xMutexElog, portMAX_DELAY); /* 互斥信号量 */
} /**
* output unlock
*/
void elog_port_output_unlock(void) { /* add your code here */
/* 裸机中使用开关中断方法 */
// __enable_irq();
/* add your code here */
/* OS 中使用临界区或互斥量,推荐互斥量方式 */
// taskEXIT_CRITICAL(); /* 退出临界区 */
xSemaphoreGive(xMutexElog); /* 互斥信号量 */ } /**
* get current time interface
*
* @return current time
*/
const char *elog_port_get_time(void) { /* add your code here */
//ydm 这里需要配置RTC相关,暂时写一个固定值
return "10:08:12"; } /**
* get current process name interface
*
* @return current process name
*/
const char *elog_port_get_p_info(void) { /* add your code here */
return "";
} /**
* get current thread name interface
*
* @return current thread name
*/
const char *elog_port_get_t_info(void) { /* add your code here */
return pcTaskGetName(NULL); }

③ 编写ef_cfg.h

/*
* This file is part of the EasyLogger Library.
*
* Copyright (c) 2015-2016, 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 configure head file for this library.
* Created on: 2015-07-30
*/ #ifndef _ELOG_CFG_H_
#define _ELOG_CFG_H_
/*---------------------------------------------------------------------------*/
/* enable log output. */
#define ELOG_OUTPUT_ENABLE
/* setting static output log level. range: from ELOG_LVL_ASSERT to ELOG_LVL_VERBOSE */
#define ELOG_OUTPUT_LVL ELOG_LVL_VERBOSE
/* enable assert check */
#define ELOG_ASSERT_ENABLE
/* buffer size for every line's log */
#define ELOG_LINE_BUF_SIZE 1024
/* output line number max length */
#define ELOG_LINE_NUM_MAX_LEN 5
/* output filter's tag max length */
#define ELOG_FILTER_TAG_MAX_LEN 30
/* output filter's keyword max length */
#define ELOG_FILTER_KW_MAX_LEN 16
/* output filter's tag level max num */
#define ELOG_FILTER_TAG_LVL_MAX_NUM 5
/* output newline sign */
#define ELOG_NEWLINE_SIGN "\r\n"
/*---------------------------------------------------------------------------*/
/* enable log color */
//#define ELOG_COLOR_ENABLE
/* change the some level logs to not default color if you want */
//#define ELOG_COLOR_ASSERT (F_MAGENTA B_NULL S_NORMAL)
//#define ELOG_COLOR_ERROR (F_RED B_NULL S_NORMAL)
//#define ELOG_COLOR_WARN (F_YELLOW B_NULL S_NORMAL)
//#define ELOG_COLOR_INFO (F_CYAN B_NULL S_NORMAL)
//#define ELOG_COLOR_DEBUG (F_GREEN B_NULL S_NORMAL)
//#define ELOG_COLOR_VERBOSE (F_BLUE B_NULL S_NORMAL)
/*---------------------------------------------------------------------------*/
/* enable asynchronous output mode */
//#define ELOG_ASYNC_OUTPUT_ENABLE
/* the highest output level for async mode, other level will sync output */
//#define ELOG_ASYNC_OUTPUT_LVL ELOG_LVL_ASSERT
/* buffer size for asynchronous output mode */
//#define ELOG_ASYNC_OUTPUT_BUF_SIZE (ELOG_LINE_BUF_SIZE * 10)
/* each asynchronous output's log which must end with newline sign */
//#define ELOG_ASYNC_LINE_OUTPUT
/* asynchronous output mode using POSIX pthread implementation */
//#define ELOG_ASYNC_OUTPUT_USING_PTHREAD
/*---------------------------------------------------------------------------*/
/* enable buffered output mode */
#define ELOG_BUF_OUTPUT_ENABLE
/* buffer size for buffered output mode */
#define ELOG_BUF_OUTPUT_BUF_SIZE (ELOG_LINE_BUF_SIZE * 1) #endif /* _ELOG_CFG_H_ */

3. EasyFlash的使用

查看对应的API文档

最新文章

  1. hadoop程序问题:java.lang.IllegalArgumentException: Wrong FS: hdfs:/ expected file:///
  2. mysql 信息查询
  3. 使用jquery.qrcode生成二维码支持logo,和中文
  4. Delphi基本数据类型---枚举、子界、集合、数组
  5. git服务器简易搭建法
  6. [php]php时间戳当中关于时区的问题
  7. 20、手把手教你Extjs5(二十)模块Grid的多列表方案
  8. 洛谷 [P1426] 通往奥格瑞玛的道路
  9. 微信号的openid的深入理解
  10. Java8与传统的日期和时间类详解
  11. ebe
  12. 多渠道打包如何运行/debug指定的渠道
  13. .NET并行计算和并发3.2-多线程调用Invoke
  14. Vue 系列之 组件
  15. linux下磁盘相关工具(待整理)
  16. 【Android实验】线程的使用-计时器
  17. SuperMap/PlottingSymbol
  18. XMind2TestCase:一个高效测试用例设计的解决方案!
  19. Client tried to access password protected page without proper authorization (status code 401) 无法发布SceneService的解决方法
  20. Frequent values UVA - 11235(巧妙地RMQ)

热门文章

  1. 最近做app项目中遇到的问题 以及一些常见注意事项
  2. 初步了解web
  3. 【Spring浅析】一、 BeanFactory 有啥可说的?
  4. mxgraph中mxStencil使用教程
  5. MySQL之数据定义语言(DDL)
  6. 对于uos目前只能安装商店的感慨,强制安装除外
  7. (代替人类)很多操作都在Settings里面。 5.安装第三方库
  8. ft2000安装tigervnc
  9. VUE如何关闭代码规范extra semiclon/VUE新手必看-(转载)
  10. JavaScript正则表达式(深度)(Day_14)