由于有一些需要由客户自己指定的数据,如WIFI的网络名、密码等,不能固定在下载程序中,所以可使用NV,由用户自己肯定。
NV操作主要实际下面三个函数:osal_nv_item_init、osal_nv_write、osal_nv_read文章源自微观生活(93wg.com)微观生活-https://93wg.com/15024.html
关于cc2530NV读取的简单代码例子:文章源自微观生活(93wg.com)微观生活-https://93wg.com/15024.html
需要注意的是,尽管NV可写入地址规模从 0x0401 – 0x0FFF,然而一定要注意,地址应当是 %4=1,如:0x401为十进制1025,1025%4=1;不能是%4=0,至于为何是%4,可以参照cc2530手册。文章源自微观生活(93wg.com)微观生活-https://93wg.com/15024.html
此外在某地址第一次读写时,结果可使用!=SUCCESS来判断,但若这个地址已经被初始化过并写入过数据,再一次被初始化过,如果还是用!=SUCCESS是不行的,由于此时即便没数据,但读取也是SUCCESS!文章源自微观生活(93wg.com)微观生活-https://93wg.com/15024.html
void writeNV(){文章源自微观生活(93wg.com)微观生活-https://93wg.com/15024.html
osal_nv_item_init(PATHS_ID ,1,NULL);//每一次写入前必需先初始化文章源自微观生活(93wg.com)微观生活-https://93wg.com/15024.html
uint8 sfcsh=0;文章源自微观生活(93wg.com)微观生活-https://93wg.com/15024.html
uint8 su_b=osal_nv_write(PATHS_ID ,0,1,&sfcsh);//写入标志文章源自微观生活(93wg.com)微观生活-https://93wg.com/15024.html
uint8 su_n= osal_nv_item_init(WIFI_NAME,40,NULL);文章源自微观生活(93wg.com)微观生活-https://93wg.com/15024.html
uint8 su_p= osal_nv_item_init(WIFI_PWD,40,NULL);文章源自微观生活(93wg.com)微观生活-https://93wg.com/15024.html
if((su_b==SUCCESS)&&(su_n==SUCCESS)&&(su_p==SUCCESS)){
HalLcdWriteString(&
}
}
uint8 readNV(){
uint8 * pshuju;
uint8 yuu =osal_nv_read(PATHS_ID,0,sizeof(pshuju),pshuju);
if(yuu==SUCCESS){
if(* pshuju==0)
{
return 0;
}else
{
return 1;
}
}
以上就是微观生活(93wg.com)关于“关于cc2530NV操作”的详细内容,希望对大家有所帮助!
评论