#ifndef __APP_FLASH_H__ #define __APP_FLASH_H__ /************************************* *INCLUDES */ #include "exception.h" #include "app_power.h" #include "nrf_gpio.h" #include "nrf_delay.h" #include "nrf_sdm.h" //ERROR CODE #define ZONE_OP_SUCCESS 0x00 //ZONE操作成功 #define ZONE_ERROR_READ_FAIL (ZONE_OP_SUCCESS+0x01) //读取该区域失败 #define ZONE_ERROR_WRITE_FAIL (ZONE_OP_SUCCESS+0x02) //写入该区域失败 #define ZONE_ERROR_ERASE_FAIL (ZONE_OP_SUCCESS+0x03) //擦除该区域失败 #define ZONE_ERROR_ADDRESS_FAIL (ZONE_OP_SUCCESS+0x04) //输入地址越界 /******************************************** *API FUCTIONS */ //size:36 typedef struct _FlashStep{ uint8_t startTime[8]; //当前时间 uint32_t stepCur[2]; //当前永久步数 uint32_t step[2]; //每小时记录的左右鞋永久步数0左1右 uint32_t step_num; //已经记录的每小时步数数量 }FlashStep_t; //size:12 typedef struct _FlashClient{ uint8_t isConfig; uint32_t hardVersion; uint16_t sotfVersion; uint8_t macAddr[6]; }FlashClient_t; //size: typedef struct _FlashLog{ uint8_t Errorflag; uint8_t logData[50]; }FlashLog; //size:64 typedef struct _Flash_Param{ uint32_t head; uint8_t isHost; uint8_t macHost[6]; FlashStep_t mStep; FlashClient_t mClient; FlashLog mFlashLog; uint8_t Safe_cnt; battercb_t mbattercb_t; uint8_t RestartCnt; }Flash_t; extern Flash_t mFlash; /*1.当新API读到旧的数据的时候,新API多的参数用默认值填充,写回的时候按照新API的格式写回。(向后兼容) 2.当旧API读到新数据,自己不认识的那段buff,要保存起来,写回的时候,将这段buff原样memcpy。(向前兼容,没实现) */ /******************************************** *API FUCTIONS */ void Flash_Initialize(void); //存储步数 uint32_t Flash_SaveStep(void); //获取步数区域首地址 uint32_t Flash_GetStepZoneStartAddr(void); //删除所有步数 uint32_t Flash_DeleteAllStep(void); //删除information的数据 uint32_t Flash_DeleteAllInfor(void); //存储基本信息 uint32_t Flash_SaveInfomation(void); //获取脚步的起始地址 uint32_t flash_GetStep_StartAddress(void); //读取指定flash的内容 uint32_t flash_Data_Read(uint32_t addr, uint32_t *pData, uint32_t dataLen); //保存日志信息 uint32_t Flash_SaveLog(uint32_t id, uint32_t pc, uint32_t info); //测试接口 void TestHalFlashInterface(void); void flash_SetClearStepFlag(void); #endif