#define HX3918_DEBUG 1
#if HX3918_DEBUG == 1
#define HX3918_LOG(msg, ...) cplog_printf( msg, ##__VA_ARGS__)//printf( msg, ##__VA_ARGS__)//
+//#define HX3918_LOG(msg, ...) printf( msg, ##__VA_ARGS__)//printf( msg, ##__VA_ARGS__)//
#else
#define HX3918_LOG(msg, ...)
#endif
6. 注意CSx和CHx, CSx是指外部PAD接到芯片的对应CS管脚. CH是指内部采集数据的3个通道, CSx可配置在不同的CH上;
-------------------------------- -------------------------------- -----------------------------------*/
+extern int item32_CARDID_write(char * data);
+
+extern int tem32_CARDID_read(char * data,int data_MAX_len);
+
+
+
+void hx3918_read_nv(void);
+//#include "../../../../product/craneg_modem/ril/libasr-ril/at-item32_CARDID.h"
#ifdef SAR_ALG_LIB
//#define TEMP_COMPENSATION
}
}
-/**
- * hx3918 从flash读取对空校准后的OFFSET和NV_BASE
-* @param NULL
-*/
-void hx3918_read_nv(void)
-{
-
- //
- //从flash读取4个值, 分别是以前保存的值; 这个函数用户需要自己完成, flash存储的位置不能被用户操作删掉
- //flash_fds_data_get(4);
- // Helios_SecureData_t r_data={0};
- // r_data.index = 1;
- // r_data.pBuffer = (uint8_t *)fds_read;
- // r_data.len = sizeof(fds_read);
- // Helios_Securedata_Read(&r_data);
- nv_watch_sensor_hx3918_data_t nv_data = {0};
-
- UI_NV_Read_Req(NV_SECTION_UI_SENSOR_HX3918_DATA, 0, sizeof(nv_watch_sensor_hx3918_data_t), (uint8_t *)&nv_data);
- memcpy(fds_read,&nv_data.data,sizeof(fds_read));
- nv_wear_offset[0] = fds_read[0];
- nv_wear_offset[1] = fds_read[1];
- nv_base_data[0] = fds_read[2];
- nv_base_data[1] = fds_read[3];
-
- //如果flash记录的值大于上限, 则让靠近感应进入相对值模式
- if ( (nv_wear_offset[0] == 0&& nv_base_data[0] == 0) || nv_wear_offset[0] == 0xFFFF)
- {
- nv_wear_offset[0] = 0;
- nv_base_data[0] = 0;
- nv_wear_offset[1] = 0;
- nv_base_data[1] = 0;
- cap_enable = false;
- is_offset_manual = 0;
- }
- else
- {
- is_offset_manual = 1;
-
- }
-
- TYHX_LOG("hx3918_read_nv ,OFF[0]: %d, OFF[1]:%d\r\n",nv_wear_offset[0],nv_wear_offset[1]);
- TYHX_LOG("BASE[0]: %d, BASE[1]:%d,mode: %d \r\n",nv_base_data[0],nv_base_data[1],is_offset_manual);
-
-
-
-}
/**
* hx3918 靠近感应初始化, 通过对hx3918_chip_id 判断,来判断靠近感应是独立工作还是跟PPG一起工作
if((prox_factory_offset0 == 510) &&(prox_factory_offset1 == 510)&&(prox_factory_lp[0]==0)&&(prox_factory_lp[1]==0))
{
- TYHX_LOG("ERR, read offset err, please redo it !!!\r\n");
+ HX3918_LOG("ERR, read offset err, please redo it !!!\r\n");
}
else
{
fds_read[1] = fds_write[1];
fds_read[2] = fds_write[2];
fds_read[3] = fds_write[3];
- // Helios_SecureData_t w_data={0};
- // w_data.index = 1;
- // w_data.pBuffer = (uint8_t *)fds_write;
- // w_data.len = sizeof(fds_write);
- // Helios_Securedata_Store(&w_data);
- nv_watch_sensor_hx3918_data_t nv_data = {0};
- memcpy(&nv_data.data,fds_write,sizeof(nv_watch_sensor_hx3918_data_t));
- UI_NV_Write_Req(NV_SECTION_UI_SENSOR_HX3918_DATA, 0, sizeof(nv_watch_sensor_hx3918_data_t), (uint8_t *)&nv_data);
+
+ HX3918_LOG("hx3918_factory_cali_save_nv:%d,%d,%d,%d\n",fds_read[0],fds_read[1],fds_read[2],fds_read[3]);
+ nv_watch_not_clean_data_t nv_data = {0};
+ UI_NV_Read_Req(NV_SECTION_UI_Not_Clear_DATA, 0, sizeof(nv_watch_not_clean_data_t), (uint8_t *)&nv_data);
+ memcpy(&nv_data.hx3918_data,fds_write,sizeof(nv_data.hx3918_data));
+ UI_NV_Write_Req(NV_SECTION_UI_Not_Clear_DATA, 0, sizeof(nv_watch_not_clean_data_t), (uint8_t *)&nv_data);
TYHX_LOG("[hx3918_factory_cali_save_nv]");
for(int i=0; i<4; i++)
{
//用户需要flash保存
//flash_fds_data_write(4);
}
+/**
+ * hx3918 从flash读取对空校准后的OFFSET和NV_BASE
+* @param NULL
+*/
+void hx3918_read_nv(void)
+{
+
+ //
+ //从flash读取4个值, 分别是以前保存的值; 这个函数用户需要自己完成, flash存储的位置不能被用户操作删掉
+
+ nv_watch_not_clean_data_t nv_data = {0};
+
+ UI_NV_Read_Req(NV_SECTION_UI_Not_Clear_DATA, 0, sizeof(nv_watch_not_clean_data_t), (uint8_t *)&nv_data);
+ memcpy(fds_read,&nv_data.hx3918_data,sizeof(fds_read));
+
+ HX3918_LOG("hx3918_read_nv!!!!!!!!!!!!!\n\n\n");
+
+ HX3918_LOG("hx3918_read_nv:%d,%d,%d,%d\n",fds_read[0],fds_read[1],fds_read[2],fds_read[3]);
+ nv_wear_offset[0] = fds_read[0];
+ nv_wear_offset[1] = fds_read[1];
+ nv_base_data[0] = fds_read[2];
+ nv_base_data[1] = fds_read[3];
+
+ //如果flash记录的值大于上限, 则让靠近感应进入相对值模式
+ if ( (nv_wear_offset[0] == 0&& nv_base_data[0] == 0) || nv_wear_offset[0] == 0xFFFF)
+ {
+ nv_wear_offset[0] = 0;
+ nv_base_data[0] = 0;
+ nv_wear_offset[1] = 0;
+ nv_base_data[1] = 0;
+ cap_enable = false;
+ is_offset_manual = 0;
+ }
+ else
+ {
+ is_offset_manual = 1;
+
+ }
+
+ TYHX_LOG("hx3918_read_nv ,OFF[0]: %d, OFF[1]:%d\r\n",nv_wear_offset[0],nv_wear_offset[1]);
+ TYHX_LOG("BASE[0]: %d, BASE[1]:%d,mode: %d \r\n",nv_base_data[0],nv_base_data[1],is_offset_manual);
+
+
+}
#endif // SAR_ALG_LIB
#define NV_SECTION_UI_SIM_UNBIND_SWITCH_LEN (sizeof(nv_watch_switch_t))
#define NV_SECTION_UI_SIM_ICCID_DATA_LEN (sizeof(nv_watch_sim_iccid_t))
#endif
-#define NV_SECTION_UI_SENSOR_HX3918_DATA_LEN (sizeof(nv_watch_sensor_hx3918_data_t))
+#define NV_SECTION_UI_Not_Clear_DATA_LEN (sizeof(nv_watch_not_clean_data_t))
#ifdef __MMI_REMIND_WAKE_UP_SUPPORT__
#define NV_SECTION_UI_REMIND_WAKE_UP_DATA_LEN (sizeof(nv_watch_remind_wake_up_t))
#endif
#define NV_SECTION_UI_SIM_UNBIND_SWITCH_FILE "ui_sim_unbind_switch.nv"
#define NV_SECTION_UI_SIM_ICCID_DATA_FILE "ui_sim_iccid_data.nv"
#endif
-#define NV_SECTION_UI_SENSOR_HX3918_DATA_FILE "ui_sensor_hx3918_data.nv"
+#define NV_SECTION_UI_Not_Clear_DATA_FILE "Not_Clear.nvm"
#ifdef __MMI_REMIND_WAKE_UP_SUPPORT__
#define NV_SECTION_UI_REMIND_WAKE_UP_DATA_FILE "ui_remind_wake_up_data.nv"
#endif
case NV_SECTION_UI_SIM_ICCID_DATA:
return (NV_SECTION_LEN(NV_SECTION_UI_SIM_ICCID_DATA));
#endif
- case NV_SECTION_UI_SENSOR_HX3918_DATA:
- return (NV_SECTION_LEN(NV_SECTION_UI_SENSOR_HX3918_DATA));
+ case NV_SECTION_UI_Not_Clear_DATA:
+ return (NV_SECTION_LEN(NV_SECTION_UI_Not_Clear_DATA));
#ifdef __MMI_REMIND_WAKE_UP_SUPPORT__
case NV_SECTION_UI_REMIND_WAKE_UP_DATA:
return (NV_SECTION_LEN(NV_SECTION_UI_REMIND_WAKE_UP_DATA));
case NV_SECTION_UI_SIM_ICCID_DATA:
return (NV_SECTION_FILE_PATH(NV_SECTION_UI_SIM_ICCID_DATA));
#endif
- case NV_SECTION_UI_SENSOR_HX3918_DATA:
- return (NV_SECTION_FILE_PATH(NV_SECTION_UI_SENSOR_HX3918_DATA));
+ case NV_SECTION_UI_Not_Clear_DATA:
+ return (NV_SECTION_FILE_PATH(NV_SECTION_UI_Not_Clear_DATA));
#ifdef __MMI_REMIND_WAKE_UP_SUPPORT__
case NV_SECTION_UI_REMIND_WAKE_UP_DATA:
return (NV_SECTION_FILE_PATH(NV_SECTION_UI_REMIND_WAKE_UP_DATA));
{
char * TempData;
uint32_t SectionLen = UI_NV_Get_Section_Len(SectionId);
+ char not_clean_flag = 0;
char FilePath[NV_MAX_SECTION_PATH_NAME];
ui_file_t * pfile;
nv_watch_settings_t * setting;
#ifdef __MMI_ZHSX_SUPPORT_CHECK_SIM_UNBIND__
nv_watch_sim_iccid_t * sim_iccid_data;
#endif
- nv_watch_sensor_hx3918_data_t * sensor_hx3918_data;
+ nv_watch_not_clean_data_t * not_clean_data;
#ifdef __MMI_REMIND_WAKE_UP_SUPPORT__
nv_watch_remind_wake_up_t * remind_wake_up_data;
#endif
break;
#endif
- case NV_SECTION_UI_SENSOR_HX3918_DATA:
- sensor_hx3918_data = lv_mem_alloc(SectionLen);
- memset(sensor_hx3918_data, 0x0, SectionLen);
- TempData = (char *)sensor_hx3918_data;
- break;
+ case NV_SECTION_UI_Not_Clear_DATA:
+ not_clean_data = lv_mem_alloc(SectionLen);
+ memset(not_clean_data, 0x0, SectionLen);
+ TempData = (char *)not_clean_data;
+
+ break;
#ifdef __MMI_REMIND_WAKE_UP_SUPPORT__
case NV_SECTION_UI_REMIND_WAKE_UP_DATA:
TempData = NULL;
break;
}
-
- snprintf(FilePath, NV_MAX_SECTION_PATH_NAME, "%s%s", NV_SECTION_ROOT_DIR, UI_NV_Get_Section_path(SectionId));
- UI_FILE_REMOVE(FilePath);
- pfile = UI_FILE_OPEN((const char *)FilePath, UI_FILE_WRITE_ONLY);
- UI_FILE_WRITE(pfile, TempData, SectionLen); // write to operate file
- UI_FILE_CLOSE(pfile);
- lv_mem_free(TempData);
+ if(TempData != NULL)
+ {
+ snprintf(FilePath, NV_MAX_SECTION_PATH_NAME, "%s%s", NV_SECTION_ROOT_DIR, UI_NV_Get_Section_path(SectionId));
+ UI_FILE_REMOVE(FilePath);
+ pfile = UI_FILE_OPEN((const char *)FilePath, UI_FILE_WRITE_ONLY);
+ UI_FILE_WRITE(pfile, TempData, SectionLen); // write to operate file
+ UI_FILE_CLOSE(pfile);
+ lv_mem_free(TempData);
+ }
+
return (1);
}
SectionLen = UI_NV_Get_Section_Len(SectionId);
if(SectionLen < (Offset + Len)) {
- printf("Len of Section is %d, offset + len = %d is too big\n",
+ cplog_printf("Len of Section is %d, offset + len = %d is too big\n",
SectionLen,
Offset + Len);
return(0);
pfile = UI_FILE_OPEN((const char *)FilePath, UI_FILE_RD_APPEND);
if(NULL == pfile->file_d) {
- printf("please check file path\n");
+ cplog_printf("please check file path\n");
UI_NV_Reset_Default(SectionId);
return(0);
}
UI_FILE_SEEK(pfile, Offset); // write nv data
WriteLen = UI_FILE_WRITE(pfile, Data, Len);
if(0 == WriteLen) {
- printf("write in fs is wrong, return default valure\n");
+ cplog_printf("write in fs is wrong, return default valure\n");
return(0);
}
UI_FILE_CLOSE(pfile);
char FilePath[NV_MAX_SECTION_PATH_NAME] = {0};
if(SectionLen < (Offset + Len)) {
- printf("len of section is %d, offset + len = %d is too big\n",
+ cplog_printf("len of section is %d, offset + len = %d is too big\n",
SectionLen,
Offset + Len);
return(ReadLen);
snprintf(FilePath, NV_MAX_SECTION_PATH_NAME, "%s%s", NV_SECTION_ROOT_DIR, UI_NV_Get_Section_path(SectionId));
pfile = UI_FILE_OPEN((const char *)FilePath, UI_FILE_RD_APPEND);
if(NULL == pfile->file_d) {
- printf("please check file path\n");
+ cplog_printf("please check file path\n");
} else {
UI_FILE_SEEK(pfile, Offset); // read data
ReadLen = UI_FILE_READ(pfile, Data, Len);
}
if(0 == ReadLen) {
- printf("read in fs is wrong return default value\n");
+ cplog_printf("read in fs is wrong return default value\n");
if(1 == UI_NV_Reset_Default(SectionId)) {
pfile = UI_FILE_OPEN((const char *)FilePath, UI_FILE_RD_APPEND);
if(NULL == pfile->file_d) {
- printf("please check file path\n");
+ cplog_printf("please check file path\n");
return(0);
}
// section before this has default value,open default nv file
snprintf(FilePath, NV_MAX_SECTION_PATH_NAME, "%s%s", NV_SECTION_ROOT_DIR, UI_NV_Get_Section_path(i));
pfile = UI_FILE_OPEN((const char *)FilePath, UI_FILE_READ_ONLY);
- if(NULL == pfile->file_d) {
- UI_NV_Reset_Default(i);
+ if(NULL == pfile->file_d) {
+ UI_NV_Reset_Default(i);
+
+
+
}
UI_FILE_CLOSE(pfile);
}
typedef struct
{
- uint32_t data[4]; // ::string
-} __packed nv_watch_sensor_hx3918_data_t;
+ uint32_t hx3918_data[4]; // ::string
+} __packed nv_watch_not_clean_data_t;
NV_SECTION_UI_SIM_UNBIND_SWITCH, // nv_watch_switch_t
NV_SECTION_UI_SIM_ICCID_DATA, // nv_watch_sim_iccid_t
#endif
- NV_SECTION_UI_SENSOR_HX3918_DATA, // nv_watch_sensor_hx3918_data_t
+ NV_SECTION_UI_Not_Clear_DATA, // nv_watch_not_clean_data_t
#ifdef __MMI_REMIND_WAKE_UP_SUPPORT__
NV_SECTION_UI_REMIND_WAKE_UP_DATA, // nv_watch_remind_wake_up_t
#endif
long rec;
UINT32 file_size=0;
-// qspi_printf("nvm_tfs_findfirst %s\r\n",filename_ptr);
+ cplog_printf("nvm_tfs_findfirst %s\r\n",filename_ptr);
DIAG_FILTER(TFSOP, FFINDFIRST, LAB001, DIAG_INFORMATION)
diagPrintf("nvm_tfs_findfirst %s", filename_ptr);
if ((filename_ptr == NULL) ||(strlen(filename_ptr) >= NVM_TFS_FILE_NAME_LEN_MAX))
{
nvm_tfs_unlock();
- qspi_printf("file name error\r\n");
+ cplog_printf("file name error\r\n");
return 1;
}
if(p_tfs_file_info->free==0)
{
-// qspi_printf("Match:%s,%s\r\n", p_tfs_file_info->file_name, filename_ptr);
+ //cplog_printf("Match:%s,%s\r\n", p_tfs_file_info->file_name, filename_ptr);
if (NVMFileNameMatch(p_tfs_file_info->file_name, filename_ptr))
{
-// qspi_printf("Matched %s, %s\r\n", p_tfs_file_info->file_name, filename_ptr);
+ //cplog_printf("Matched %s, %s\r\n", p_tfs_file_info->file_name, filename_ptr);
file_size=p_tfs_file_info->size;
diagPrintf("filter file count: %d",count);
for(i=0;i<count;i++)
{
- uart_printf("%s ",filename_filter[i]);
+ uart_printf("count: %d %s ",count,filename_filter[i]);
}
uart_printf("\r\n");
ret=FDI_findfirst("*", &info);
if (ret!=0)
return;
- if(get_fs_mode()==FAT_FS_MODE)
- {
- for(i=0;i<FILE_NUM_LFS;i++)
+ if(get_fs_mode()==FAT_FS_MODE)
{
- // uart_printf("i=%d, name: %s, 0x%x\r\n",i, FILE_LIST_LFS[i].file_name, FILE_LIST_LFS[i].permissions);
- // skip '.' and root '..'
- if ((memcmp(FILE_LIST_LFS[i].file_name, ".", 1) == 0) || ( memcmp(FILE_LIST_LFS[i].file_name, "..", 2) == 0))
- continue;
-
- for (j=0;j<count;j++)
+ for(i=0;i<FILE_NUM_LFS;i++)
{
- if(strcmp(FILE_LIST_LFS[i].file_name,filename_filter[j])==0)
+ //uart_printf("FILE_NUM_LFS:i=%d, name: %s, 0x%x\r\n",i, FILE_LIST_LFS[i].file_name, FILE_LIST_LFS[i].permissions);
+ // skip '.' and root '..'
+ if ((memcmp(FILE_LIST_LFS[i].file_name, ".", 1) == 0) || ( memcmp(FILE_LIST_LFS[i].file_name, "..", 2) == 0))
+ continue;
+
+ for (j=0;j<count;j++)
{
- break;
+ if(strcmp(FILE_LIST_LFS[i].file_name,filename_filter[j])==0)
+ {
+ break;
+ }
+ }
+ if(j==count)
+ {
+ if(FILE_LIST_LFS[i].permissions==FDI5_FILE_DEFAULT_PERMISSIONS)//file
+ ret=FDI_remove(FILE_LIST_LFS[i].file_name);
+ else //dir
+ ret=FDI_removeDir(FILE_LIST_LFS[i].file_name);
+ if(ret!=0)
+ uart_printf("remove fail: %d, %s, 0x%x\r\n", ret, FILE_LIST_LFS[i].file_name,FILE_LIST_LFS[i].permissions);
}
- }
- if(j==count)
- {
- if(FILE_LIST_LFS[i].permissions==FDI5_FILE_DEFAULT_PERMISSIONS)//file
- ret=FDI_remove(FILE_LIST_LFS[i].file_name);
- else //dir
- ret=FDI_removeDir(FILE_LIST_LFS[i].file_name);
- if(ret!=0)
- uart_printf("remove fail: %d, %s, 0x%x\r\n", ret, FILE_LIST_LFS[i].file_name,FILE_LIST_LFS[i].permissions);
}
}
- }
- else if(get_fs_mode()==TFS_FS_MODE)
- {
- do
+ else if(get_fs_mode()==TFS_FS_MODE)
{
- for (j=0;j<count;j++)
+ do
{
- if(strcmp(info.file_name,filename_filter[j])==0)
- break;
- }
- if(j==count)
- FDI_remove(info.file_name);
+ for (j=0;j<count;j++)
+ {
+ if(strcmp(info.file_name,filename_filter[j])==0)
+ break;
+ }
+ if(j==count)
+ {
+ //uart_printf("TFS_FS_MODE:FDI_remove:%s \r\n",info.file_name);
+ //不删除Not_Clear.nvm
+ if(strcmp(info.file_name,"Not_Clear.nvm")!=0)
+ {
+ FDI_remove(info.file_name);
+ uart_printf("TFS_FS_MODE:FDI_remove:%s \r\n",info.file_name);
+ }else
+ uart_printf("TFS_FS_MODE:Not remove:%s \r\n",info.file_name);
+
+ }
+
- ret=FDI_findnext(&info);
- }while(ret==0);
+ ret=FDI_findnext(&info);
+ //uart_printf("TFS_FS_MODE:%s \r\n",info.file_name);
+ }while(ret==0);
- }
+ }
nvm_cache_flush_all();
}
else
#ifdef PLAT_USE_ALIOS
#include "alios_mbedtls_config.h"
#else
-#include "asros_mbedtls_config.h"
+#include "../../asros/asros_mbedtls_config.h"
+//#include "asros_mbedtls_config.h"
#endif
#if defined(MBEDTLS_USER_CONFIG_FILE)