NRF52832的加入了协议栈以后的flash读写问题

在调试nrf52832的时候,想着以前用过nrf52832的flash,然后直接用用过的flash读写程序来直接使用,结果发现增加了协议栈以后,一调用flash擦写程序,整个程序就崩溃了。
经过排查,发现自己调用的flash读写程序,是裸机使用的,不能用于协议栈上,需要调用专门协议栈的flash 读写函数。(具体因暂时没找到,可能是协议栈里有保护?)
使用的协议栈库是 fstorage文件夹的库,主要是用了nrf_fstorage.c和nrf_fstorage_sd.c的函数

1.flash地址初始化

NRF_FSTORAGE_DEF(nrf_fstorage_t fstorage) =
{
    /* Set a handler for fstorage events. */
    .evt_handler = fstorage_evt_handler,

    /* These below are the boundaries of the flash space assigned to this instance of fstorage.
     * You must set these manually, even at runtime, before nrf_fstorage_init() is called.
     * The function nrf5_flash_end_addr_get() can be used to retrieve the last address on the
     * last page of flash available to write data. */
    .start_addr = 0x60000, //开始地址
    .end_addr   = 0x7ffff, //结束地址
};


//初始化调用
 p_fs_api = &nrf_fstorage_sd;//处理操作类型设置
 rc = nrf_fstorage_init(&fstorage, p_fs_api, NULL);//flash处理的开始地址和结束地址初始化
 APP_ERROR_CHECK(rc);

2.擦除函数

主要用于擦除flash,在写之前都要擦除才能写入

et_code_t   nrf_fstorage_erase(nrf_fstorage_t const * p_fs,  
                                uint32_t    page_addr,    
                                uint32_t   len,   
                                void * p_param);

3.写入flash

写入的时候,需要四字节对齐

ret_code_t nrf_fstorage_write(nrf_fstorage_t const * p_fs,
                              uint32_t               dest,
                              void           const * p_src,
                              uint32_t               len,
                              void                 * p_param);

4,读flash

我觉得可以调用它的库,也可以不调用,就是一个指针的事。。

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值