#include "global_param.h"
|
#include "Flash.h"
|
#include "dw_app.h"
|
#include <string.h>
|
|
uint16_t g_com_map[COM_MAP_SIZE];
|
|
u8 parameter_check(void)
|
{
|
if(g_com_map[0] != 0x55AA)
|
{
|
return 1;
|
}
|
if(g_com_map[COM_INTERVAL]<50||COM_INTERVAL>1000)
|
{
|
return 1;
|
}
|
if(g_com_map[POWER]>67)
|
{
|
return 1;
|
}
|
if(g_com_map[MOTOR_ENABLE]>1)
|
{
|
return 1;
|
}
|
if(g_com_map[IMU_ENABLE]>1)
|
{
|
return 1;
|
}
|
if(g_com_map[ACTIVE_INDEX]>1)
|
{
|
return 1;
|
}
|
return 0;
|
}
|
uint32_t save_com_map_to_flash(void)
|
{
|
uint32_t result = 0;
|
if(parameter_check()) //²ÎÊý´íÎ󣬲»±£´æ
|
{
|
return 1;
|
}
|
__disable_irq();
|
result = FLASH_Prepare(FLASH_IAP_CTRL_MAP, (COM_MAP_SIZE<<1));
|
if(result)
|
result = FLASH_Write(FLASH_IAP_CTRL_MAP, (const uint8_t*)g_com_map, (COM_MAP_SIZE<<1));
|
__enable_irq();
|
return result;
|
}
|
|
void parameter_init(void)
|
{
|
memset((uint8_t*)&g_com_map,0,(COM_MAP_SIZE<<1));
|
FLASH_Read(FLASH_IAP_CTRL_MAP, (uint8_t*)&g_com_map, (COM_MAP_SIZE<<1));
|
|
if(g_com_map[0] != 0x55AA)
|
{
|
g_com_map[0] = 0x55AA;
|
g_com_map[DEV_ID] =0x1234;//DEFAULT_DEV_ID; //ĬÈÏÉ豸ID
|
|
g_com_map[COM_INTERVAL]=500; //ƵÂÊ2HZ
|
g_com_map[MAX_REPORT_ANC_NUM]=10;
|
g_com_map[GROUP_ID]=0;
|
g_com_map[DIST_OFFSET]=0;
|
|
g_com_map[DEV_ROLE] =0x1; //±êÇ©
|
|
|
g_com_map[HEARTBEAT]=0;
|
|
g_com_map[POWER]=67; //·¢É书ÂÊ
|
g_com_map[IMU_THRES]=2;
|
g_com_map[NOMOVESLEEP_TIME]=3600; //¾²Ö¹ÐÝÃß2·ÖÖÓ
|
g_com_map[MOTOR_ENABLE]=1; //Õ𶯵ç»úʹÄÜ
|
g_com_map[IMU_ENABLE]=1; //¾²Ö¹ÐÝÃßʹÄÜ
|
|
g_com_map[CNT_RESTART]=0;
|
g_com_map[CNT_REBOOT]=0;
|
g_com_map[CNT_UPDATE]=0;
|
g_com_map[MODBUS_MODE]=0;
|
g_com_map[ACTIVE_INDEX]=0;
|
g_com_map[STATIONARY_TIME]=20; //¾²Ö¹Åж¨Ê±¼ä20Ãë
|
g_com_map[HEIGHTOFFEST_INDEX]=0;
|
g_com_map[GPS_ONTIME]=3600;
|
save_com_map_to_flash();
|
}
|
}
|