1
WXK
9 天以前 aa14c757b47b2ef43ec8a6ced81fefe1e6594d2d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "global_param.h"
#include "MCUFlash.h"
#include "AppConfig.h"
#include <string.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;
    MCUFlash_Erase(APP_CONFIG_CTRL_MAP, sizeof(g_com_map));
    MCUFlash_Write(APP_CONFIG_CTRL_MAP, (uint8_t *)&g_com_map, sizeof(g_com_map));
 
    return result;
}
 
void parameter_init(void)
{
     MCUFlash_Read(APP_CONFIG_CTRL_MAP, (uint8_t *)&g_com_map, sizeof(g_com_map));
  //  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] = (uint16_t)-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[UDP_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] = 1;
        g_com_map[STATIONARY_TIME] = 5;
 
        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[IP_0] =39;
        g_com_map[IP_1] =106;
        g_com_map[IP_2] =210;
        g_com_map[IP_3] =13;
        g_com_map[UDP_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;
    }
}