#include "global_param.h"
|
#include "Flash.h"
|
|
//#include "dw_app.h"
|
#include "SPIFlash.h"
|
#include "AppConfig.h"
|
#include <string.h>
|
#include <delay.h>
|
uint16_t g_com_map[COM_MAP_SIZE];
|
char swname[]="CZURT_ZJBQ"; //³µÔØURT¡ª¡ªÖ®½±êÇ©
|
|
uint32_t save_com_map_to_flash(void)
|
{
|
uint32_t result = 0;
|
|
__disable_irq();
|
result = FLASH_Prepare(FLASH_IAP_CTRL_MAP, (COM_MAP_SIZE<<1));
|
while(!result)
|
{
|
result = FLASH_Prepare(FLASH_IAP_CTRL_MAP, (COM_MAP_SIZE<<1));
|
Delay_Ms(200);
|
}
|
if(result)
|
result = FLASH_Write(FLASH_IAP_CTRL_MAP, (const uint8_t*)g_com_map, (COM_MAP_SIZE<<1));
|
__enable_irq();
|
// memcpy(g_com_map2,g_com_map,COM_MAP_SIZE);
|
return result;
|
}
|
|
void parameter_init(void)
|
{
|
FLASH_Read(FLASH_IAP_CTRL_MAP, (uint8_t*)&g_com_map, (COM_MAP_SIZE<<1));
|
// memcpy(&g_com_map[SWNAME_INDEX],swname,16);
|
if(g_com_map[0] != 0x55AA)
|
{
|
g_com_map[0] = 0x55AA;
|
g_com_map[DEV_ID] =0x1872;//DEFAULT_DEV_ID; //ĬÈÏÉ豸ID
|
|
g_com_map[COM_INTERVAL]=1000;
|
g_com_map[MAX_REPORT_ANC_NUM]=10;
|
g_com_map[GROUP_ID]=0;
|
g_com_map[DIST_OFFSET]=-31;
|
|
g_com_map[DEV_ROLE] =0x1; //±êÇ©
|
|
|
g_com_map[HEARTBEAT]=0;
|
|
g_com_map[GPSUPLOADTIME_INDEX]=1;
|
//g_com_map[POWERx]=DEFAULT_RFPOWER;
|
g_com_map[IMU_THRES]=2;
|
g_com_map[NOMOVESLEEP_TIME]=120;
|
g_com_map[MOTOR_ENABLE]=1;
|
g_com_map[IMU_ENABLE]=1;
|
|
g_com_map[RTCMMODE_INDEX] = 0;
|
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[IP_0]=39;
|
g_com_map[IP_1]=106;
|
g_com_map[IP_2]=210;
|
g_com_map[IP_3]=13;
|
g_com_map[PORT]=7000;
|
|
g_com_map[TCP_IP_0]=121;
|
g_com_map[TCP_IP_1]=33;
|
g_com_map[TCP_IP_2]=226;
|
g_com_map[TCP_IP_3]=42;
|
g_com_map[TCP_PORT]=9039;
|
|
g_com_map[GPS_HZ]=600;
|
g_com_map[CHAICHUGPS_HZ]=600;
|
g_com_map[STATIONARY_TIME] = 5;
|
// SPIFlash_BulkErase(SPI_FLASH_ID_0);
|
save_com_map_to_flash();
|
}
|
g_com_map[CNT_REBOOT]=0;
|
g_com_map[CNT_UPDATE] = 0;
|
g_com_map[CNT_RESTART] = 0;
|
if( g_com_map[TCP_IP_0]==0xffff)
|
{
|
g_com_map[TCP_IP_0]=121;
|
g_com_map[TCP_IP_1]=33;
|
g_com_map[TCP_IP_2]=226;
|
g_com_map[TCP_IP_3]=42;
|
g_com_map[TCP_PORT]=9039;
|
}
|
|
|
}
|