NRF52832的FDS程序,参考非蓝牙例程修改而来(需要增加DFU的基础上只要增加如下程序即可解决)
/* Dummy configuration data. */
static configuration_t m_dummy_cfg =
{
.config1_on = false,
.config2_on = true,
.boot_count = 0x0,
.device_name = "dummy",
}; /* A record containing dummy configuration data. */
static fds_record_t const m_dummy_record =
{
.file_id = CONFIG_FILE,
.key = CONFIG_REC_KEY,
.data.p_data = &ucheck_v,//&m_dummy_cfg,
/* The length of a record is always expressed in 4-byte units (words). */
.data.length_words = (sizeof(ucheck_v) + 3) / sizeof(uint32_t),
}; /* Keep track of the progress of a delete_all operation. */
//static struct
//{
// bool delete_next; //!< Delete next record.
// bool pending; //!< Waiting for an fds FDS_EVT_DEL_RECORD event, to delete the next record.
//} m_delete_all; void user_data_update(void)
{
ret_code_t rc; // NRF_LOG_INFO("Reading flash usage statistics..."); fds_stat_t stat = {0}; rc = fds_stat(&stat);
APP_ERROR_CHECK(rc); NRF_LOG_INFO("Found %d valid records.", stat.valid_records);
NRF_LOG_INFO("Found %d dirty records (ready to be garbage collected).", stat.dirty_records); fds_record_desc_t desc = {0};
fds_find_token_t tok = {0}; rc = fds_record_find(CONFIG_FILE, CONFIG_REC_KEY, &desc, &tok); if (rc == FDS_SUCCESS)
{
/* A config file is in flash. Let's update it. */
fds_flash_record_t config = {0}; /* Open the record and read its contents. */
rc = fds_record_open(&desc, &config);
APP_ERROR_CHECK(rc); /* Copy the configuration from flash into m_dummy_cfg. */
//memcpy(&ucheck_v, config.p_data, sizeof(check_V));//这里是更新数据,所以不能把旧数据复制过来了 NRF_LOG_INFO("Config file found, updating boot count to %d.", ucheck_v.boot_count); /* Update boot count. */
ucheck_v.boot_count++; /* Close the record when done reading. */
rc = fds_record_close(&desc);
APP_ERROR_CHECK(rc); /* Write the updated record to flash. */
rc = fds_record_update(&desc, &m_dummy_record);
APP_ERROR_CHECK(rc);
}
else
{
/* System config not found; write a new one. */
NRF_LOG_INFO("Writing config file..."); rc = fds_record_write(&desc, &m_dummy_record);
APP_ERROR_CHECK(rc);
} //cli_start();
}
void user_init_data_flash(void)
{
ret_code_t rc;
fds_record_desc_t desc = {0};
fds_find_token_t tok = {0}; rc = fds_record_find(CONFIG_FILE, CONFIG_REC_KEY, &desc, &tok); if (rc == FDS_SUCCESS)
{
/* A config file is in flash. Let's update it. */
fds_flash_record_t config = {0}; /* Open the record and read its contents. */
rc = fds_record_open(&desc, &config);
APP_ERROR_CHECK(rc); /* Copy the configuration from flash into m_dummy_cfg. */
memcpy(&ucheck_v, config.p_data, sizeof(check_V)); NRF_LOG_INFO("Config file found, updating boot count to %d.", ucheck_v.boot_count); /* Update boot count. */
ucheck_v.boot_count++; /* Close the record when done reading. */
rc = fds_record_close(&desc);
APP_ERROR_CHECK(rc); /* Write the updated record to flash. */
rc = fds_record_update(&desc, &m_dummy_record);
APP_ERROR_CHECK(rc);
} }
在增加了DFU之后的52832程序,只要增加如下程序就可以完成FDS的数据保存
NRF52832的FDS程序,参考非蓝牙例程修改而来(需要增加DFU的基础上只要增加如下程序即可解决)的更多相关文章
- (Map)利用Map,完成下面的功能: 从命令行读入一个字符串,表示一个年份,输出该年的世界杯冠军是哪支球队。如果该 年没有举办世界杯,则输出:没有举办世界杯。 附:世界杯冠军以及对应的夺冠年份,请参考本章附录。 附录 (Map)在原有世界杯Map 的基础上,增加如下功能: 读入一支球队的名字,输出该球队夺冠的年份列表。 例如,读入“巴西”,应当输出 1958 1962 1970 1
package homework001; import java.util.HashMap; import java.util.Scanner; public class Map { public s ...
- QT创建模态对话框阻塞整个应用程序和非模态对话框唯一性约束的简单示例
QT创建模态对话框阻塞整个应用程序和非模态对话框唯一性约束的简单示例 部分代码: // 创建模态对话框阻塞整个应用程序和非模态对话框唯一性约束 QMenu *pDialog = mBar->ad ...
- 操作系统的发展史(并发与并行)<异步与同步>《进程与程序》[非堵塞与堵塞]
目录 一:一:手工操作 -- 穿孔卡片 1.简介 二:手工操作方式两个特点: 三:批处理 -- 磁带存储 1.联机批处理系统 2.脱机批处理系统 3.多道程序系统 4.多道批处理系统 四:总结发展史 ...
- C#取得Web程序和非Web程序的根目录的N种取法
取得控制台应用程序的根目录方法方法1.Environment.CurrentDirectory 取得或设置当前工作目录的完整限定路径方法2.AppDomain.CurrentDomain.BaseDi ...
- 从此走上一条iOS程序猿不归路。。。
新的城市,新的生活!前不久刚刚结束了苦逼的面试找工作之旅,期间也小有收货,如今正处年底工作闲暇之余,将前一阵子陆陆续续的总结整理了一下,本人菜鸟程序猿一只,水平有限,本文总结的知识不算深入,比较浅显, ...
- Lua 学习之基础篇九<Lua 协同程序(Coroutine)>
引言 讲到协程,首先来介绍一下线程和协程的区别 lua协程和多线程 相同之处:拥有自己独立的桟.局部变量和PC计数器,同时又与其他协程共享全局变量和其他大部分东西 不同之处:一个多线程程序可以同时运行 ...
- 应用程序框架实战十四:DDD分层架构之领域实体(基础篇)
上一篇,我介绍了自己在DDD分层架构方面的一些感想,本文开始介绍领域层的实体,代码主要参考自<领域驱动设计C#2008实现>,另外参考了网上找到的一些示例代码. 什么是实体 由标识来区分的 ...
- 基于php基础语言编写的小程序之计算器
基于php基础语言编写的小程序之计算器 需求:在输入框中输入数字进行加.减.乘.除运算(html+php) 思路: 1首先要创建输入数字和运算符的输入框,数字用input的text属性,运算符用sel ...
- 【转】appStore上传苹果应用程序软件发布流程
转载地址:http://blog.sina.com.cn/s/blog_68661bd801019uzd.html 首先确定帐号是否能发布, https://developer.apple.com/a ...
- appStore上传苹果应用程序软件发布流程(之前都是同事发,复制一份备用)
首先确定帐号是否能发布, https://developer.apple.com/account,如果你打开Provisioning Portal,然后点击DisTribution看到的是下图中那样, ...
随机推荐
- 服务器5M带宽下载速计算
5M贷款的服务器实际下载速度不是5M每秒,而是640KB/S,是由于服务商口中的宽带指的是bit(比特),而下载速度使用的单位是Byte(字节),1Byte(字节)=8bit(比特),所以,宽带和下载 ...
- php redis使用 常用方法 | Windows环境下安装Redis | Windows下php安装redis扩展(详解版)
redis可视化工具:http://www.treesoft.cn/dms.html #php redis使用 常用方法 https://www.cnblogs.com/mg007/p/1043107 ...
- elasticSearch(五)--排序
1.字段值排序 2.多级排序 3.字符串参数排序 GET /_search?sort=date:desc&sort=_score&q=search
- WCF 安全
服务器端与客户端都安装证书,双方通过证书加密通讯. 配置wsHttpBinding,使用基于消息的用户名验证.首先配置为Windows账户库验证. 服务器端配置: <?xml version=& ...
- VUE+elementUI 分页请求回显问题解决方案
一直专注写后台的本人,之前新产品回显问题,一直没处理,这对实施配置系统,会产生很大影响 由于写页面的同事要离职,一直在游泳,只能自己上手去干了.本人对 vue 和elementUI 处于一知半解,所以 ...
- Java-对象 认识对象
1.对象同时具有属性和方法两个特性.对象的属性和方法通常被封装在一起,共同体现事物特性,两者相辅相成,不可分割
- 结构体struct
在 C# 中,结构体是值类型数据结构.它使得一个单一变量可以存储各种数据类型的相关数据.struct 关键字用于创建结构体. 结构体是用来代表一个记录.假设您想跟踪图书馆中书的动态.您可能想跟踪每本书 ...
- linux篇之WC(word count)的使用概述
Text. Linux系统中的wc(Word Count)命令的功能为统计指定文件中的字节数.字数.行数,并将统计结果显示输出. 1.命令格式: wc [选项] [文件1] [文件2] ... 2.命 ...
- Java基础——(综合练习)买飞机票和找素数
package com.zhao.test; import java.util.Scanner; public class Test14 { /* 需求:机票价格按照淡季旺季.头等舱和经济舱收费. 输 ...
- springboot-mybatis集成pagehelper分页插件
1.引入jar包(示例) implementation group: 'com.github.pagehelper', name: 'pagehelper-spring-boot-starter', ...