chen
2025-05-07 c8c1cf5223f0576d4c378ac627d6eeed6caf04d5
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#include "board.h"
#ifndef __COMMMAP_H
#define __COMMMAP_H
 
//#include "stm32f10x.h"
//#include <string.h>
//#include "Utility.h"
//#include "ConfigCan.h"
//#include "ConfigUsart.h"
//#include "port.h"
//#include "Flash.h"
 
#define COM_FRAME_MAX_SIZE            50
 
//----------------Ö¸ÁîλÖÃ----------------
#define COM_HEAD0                    0x00
#define COM_HEAD1                    0x01
#define COM_LENGTH                    0x02
#define COM_SRC_ID                    0x03
#define COM_DST_ID                    0x04
#define COM_CMD                        0x05
#define COM_INDEX                    0x06
#define COM_DATA                    0x07
 
//----------------Ö¸ÁîÀàÐÍ----------------
//¿ØÖƱí·ÃÎÊÖ¸Áî
#define CMD_CMAP_RD                    0x01
#define CMD_CMAP_WR                    0x02
#define CMD_CMAP_WR_NR                0x03
#define CMD_CMAP_ACK_RD                0x04
#define CMD_CMAP_ACK_WR                0x05
//Êý¾ÝÏÂÔØÏà¹ØÖ¸Áî
#define CMD_IAP_BEGIN                0x07
#define CMD_IAP_TRANS                0x08
#define CMD_IAP_VERIFY                0x09
#define CMD_MCU_RESET                0x0A
#define CMD_IAP_ACK                    0x0B
#define CMD_SAVE_UID                0x0C
 
 
////¿ØÖÆÖ¸Áî
//#define CMD_CTRL_RD                0x01        //¶ÁÖ¸Áî
//#define CMD_CTRL_WR                0x02        //дָÁî
//#define CMD_CTRL_WR_NR            0x03        //д¿ØÖƱíÖ¸ÁÎÞ·µ»Ø£©
//#define IS_CTRL_PACK(PACK_TYPE)        (((PACK_TYPE) == CMD_CTRL_RD) || \
//                                     ((PACK_TYPE) == CMD_CTRL_WR)    || \
//                                     ((PACK_TYPE) == CMD_CTRL_WR_NR) )
//                                     
////ͨѶָÁî
//#define CMD_IAP_BEGIN                0x07   //the macro declaration should be same between difference commu src
//#define CMD_IAP_WR                    0x08 
//#define CMD_IAP_CHECKSUM             0x09
//#define CMD_IAP_RESET               0x0A
//#define IS_IAP_PACK(PACK_TYPE)        (((PACK_TYPE) == CMD_IAP_BEGIN) || \
//                                     ((PACK_TYPE) == CMD_IAP_WR)    || \
//                                     ((PACK_TYPE) == CMD_IAP_CHECKSUM)    || \
//                                     ((PACK_TYPE) == CMD_IAP_RESET)    )        
////ÓïÒôÖ¸Áî
//#define  CMD_SPK_PLAY                0x11
//#define  CMD_SPK_ERASE               0x12
//#define  CMD_SPK_WR_DATA            0x13
//#define  CMD_SPK_READ               0x14 //ÕâÀïÒ»´ÎÐÔ¶ÁÈ¡ÓïÒô¶ÎÐÅÏ¢
//#define  IS_SPK_PACK(PACK_TYPE)        (((PACK_TYPE) == CMD_SPK_PLAY)    || \
//                                     ((PACK_TYPE) == CMD_SPK_ERASE)    || \
//                                     ((PACK_TYPE) == CMD_SPK_READ)    || \
//                                     ((PACK_TYPE) == CMD_SPK_WR_DATA) )
////Åä¶ÔÖ¸Áî
//#define CMD_RMC_PAIR                0x1A
 
//----------------------ID list--------------------------------------
#define _SW_VER                (uint16_t)((0x0000<<8)|(0x0001<<4)|(1))      //¹Ì¼þ°æ±¾
#define FW_VERSION            (uint16_t)((0x00<<12)|_SW_VER)
 
#define ID_THIS                        ID_UWB_ANCHOR
 
#define ID_APR_HEAD_R                0x00
#define ID_APR_TOP                    0x01
#define ID_APR_YAW                    0x02
#define ID_APR_HEAD_L                0x03
#define ID_VIO_MAIN_CTRLLER            0x04
#define ID_APR_X86                    0x05
#define ID_VIO_BLE                    0x06
#define ID_VIO_BMS                    0x07
#define ID_VIO_UP_CTRLLER            0x08
#define ID_UWB_ANCHOR                0x09
#define ID_UWB_TAG                    0x0A
#define ID_MOBILE                    0x0B
#define ID_DEBUGGER                    0x0C
 
//--------------------Communication Method---------------------------
#define SEND_FROM_CAN                0x01
#define SEND_FROM_UART                0x02
 
 
#define COMM_MAP_MAX_SIZE    70
//-------------------------Anchor°å Map------------------------------
#define COMM_MAP_UP_FW_VERSION        0x0A
#define COMM_MAP_ANCHOR_FW_VERSION    0x0B
#define COMM_MAP_TAG_FW_VERSION    0x0C
 
#define COMM_MAP_ELEC_ANG_OFFSET    0x10
#define COMM_MAP_PHY_ANG_OFFSET        0x11
#define COMM_MAP_PAIR_STATE            0x12
#define COMM_MAP_PDOFSET            0x13
#define COMM_MAP_PAIRFLAG            0x14
#define COMM_MAP_ANGLE_OFFSET            0x15
#define COMM_MAP_CALIB_OK            0x16
 
#define COMM_MAP_PAIR_REQUESTED        0x1A
#define COMM_MAP_TEST_FLAG        0x1B
 
//-------------------------Tag°å Map------------------------------
#define COM_MAP_UWB_DATA_SIZE        (COMM_MAP_IMU_MAGZ_SPD - COMM_MAP_IS_UWB_UPDATED + 1)
#define COMM_MAP_IS_UWB_UPDATED        0x20
#define COMM_MAP_ANGLE                0x21        //UWB²âµÃµÄ½Ç¶ÈÐÅÏ¢
#define COMM_MAP_DIST                0x22        //UWB²âµÃµÄ¾àÀëÐÅÏ¢
#define COMM_MAP_SIG_QUALITY        0x23        //UWBÐźÅÖÊÁ¿
#define COMM_MAP_TAG_ADDR            0x24
#define COMM_MAP_KEYS                0x25        //Ò£¿ØÆ÷°´¼üÐÅÏ¢
#define COMM_MAP_ROCKER_X            0x26        //Ò£¿ØÆ÷ºáÏòÒ¡¸ËµÄÖµ
#define COMM_MAP_ROCKER_Y            0x27        //Ò£¿ØÆ÷×ÝÏòÒ¡¸ËµÄÖµ
#define COMM_MAP_BAT_VOL            0x28        //Ò£¿ØÆ÷µçÁ¿
//Ò£¿ØÆ÷IMUÏà¹Ø×´Ì¬
#define COMM_MAP_IMU_ROLL_SPD        0x29
#define COMM_MAP_IMU_PITCH_SPD        0x2A
#define COMM_MAP_IMU_YAW_SPD        0x2B
#define COMM_MAP_IMU_ACCX_SPD        0x2C
#define COMM_MAP_IMU_ACCY_SPD        0x2D
#define COMM_MAP_IMU_ACCZ_SPD        0x2E
#define COMM_MAP_IMU_MAGX_SPD        0x2F
#define COMM_MAP_IMU_MAGY_SPD        0x30
#define COMM_MAP_IMU_MAGZ_SPD        0x31
//Ò£¿ØÆ÷µÆµÄ״̬
#define COMM_MAP_RC_LED_FOLLOW        0x32
#define COMM_MAP_RC_LED_SHOT        0x33    
#define COMM_MAP_WARN                0x34        //Ò£¿ØÆ÷±¨¾¯Ìáʾ״̬
 
//-------------------------Э¿Ø°å Map--------------------------------
#define COMM_MAP_LED                0x40
#define COMM_MAP_IS_GIMBAL_PLUGED    0x41
#define COMM_MAP_SBV_MODE            0x42
#define COMM_MAP_GIMBAL_MODE        0x43
#define COMM_MAP_VOICE_FLAG            0x44
#define COMM_MAP_VOICE_INDEX        0x45
 
 
 
 
 
/*---------------------------------------------------------------------
                            VOICE PACK INDEX
---------------------------------------------------------------------*/
//ÓïÒôÖ¸Áî
#define VOICE_WARNING                0
#define VOICE_ERROR                    1
#define VOICE_SHOT                    2
#define VOICE_RECORD                3
#define    VOICE_DI                    4
#define VOICE_DIDI                    5
#define VOICE_CALL_ARRIVE            6
#define VOICE_STANDBY                7
#define VOICE_OVERSPEED2            8
 
#define VOICE_START                    16
#define VOICE_CLOSE                    17
#define VOICE_OVERSPEED1            18
#define VOICE_LOCK                    19
#define VOICE_SIGNAL_WEAK            20
#define VOICE_BACKWARD                21
#define VOICE_LOWBATERAY            22
#define    VOICE_FOLLOW_MODE            23
#define VOICE_FOLLOW_MODE_EXIT        24
#define VOICE_GIMBAL_PLUGEDIN        25
#define VOICE_NO_CAMERA                26
#define VOICE_GIMBAL_TAKEOFF        27
#define VOICE_REMOTE_CTRL_MODE        28
#define VOICE_BLE_CONNECT            29
#define VOICE_BLE_DISCONECT            30
#define VOICE_NOT_ACTIVATED            31
#define VOICE_CLOSE_ALERT            32
#define VOICE_CAM_MODE_STABLE        33
#define VOICE_CAM_MODE_FOLLOW        34
#define VOICE_CAM_MODE_LOCK            35
 
#define VOICE_MALFUNCTION            56
#define VOICE_HIGHBATERAY            57
 
typedef struct ComData_
{
    uint8_t length;
    uint8_t src_id;
    uint8_t dst_id;
    uint8_t cmd;
    uint8_t index;
    uint8_t data[COM_FRAME_MAX_SIZE];
} ComDataClass;
 
typedef enum{    UsartReceiveWaitHead0, 
                UsartReceiveWaitHead1, 
                UsartReceiveWaitLength, 
                UsartReceiveWaitData
}UsartRecvPackState;
 
extern uint16_t gCommMap[COMM_MAP_MAX_SIZE];
extern uint16_t gSbvComMap[COMM_MAP_MAX_SIZE];
extern uint8_t gErrorCode;
 
 
//--------------Ó¦ÓÃ²ã»Øµ÷º¯Êý---------------
//extern void (*IapHandlerCallback)(CanReceiveFrame *);
//extern void (*CtrlHandlerCallback)(CanReceiveFrame *);
//extern void (*SpkHandlerCallback)(CanReceiveFrame *);
//extern void (*UwbHandlerCallback)(void);
 
void CommMapInit(void);
//void CanParseDataHandler(CanRxMsg* pRxMessage);
void SendFrame(uint8_t data_length, uint8_t src_id, uint8_t dst_id, uint8_t cmd, uint8_t index, uint8_t* data);
#endif