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
#ifndef _RADAR_F2R3_H_
#define _RADAR_F2R3_H_
#include "API.h"
#include "SCI0_UART.h"
#include "Line_In.h"
#include "Radar_Common.h"
/******************************************************************************
雷达配置
******************************************************************************/
#define RADAR_F2R3_MSG_LOST_THRESHOLD 1.5 //unit:s
#define RADAR_F2R3_MSG_INVALID_THRESHOLD 1.5 //unit:s
#define RADAR_CONFIGURATION RADAR_F2R3_CFG_F2R4
/******************************************************************************
雷达配置
******************************************************************************/
#define RADAR_F2R3_CFG_R3 0x1
#define RADAR_F2R3_CFG_R4 0x2
#define RADAR_F2R3_CFG_F2R3 0x3
#define RADAR_F2R3_CFG_F2R4 0x4
#define RADAR_F2R3_CFG_F4R4 0x5
#define RADAR_F2R3_NO_CFG 0x7
/******************************************************************************
系统状态
******************************************************************************/
#define RADAR_SYS_ST_DISABLE 0x0
#define RADAR_SYS_ST_ENABLE 0x1
#define RADAR_SYS_ST_FAIL 0x2
/******************************************************************************
接收Buffer结构
******************************************************************************/
typedef union
{
uint8_t Byte[5];
struct
{
uint8_t : 3;
uint8_t R_SYS_ST : 2;
uint8_t Config : 3;
uint8_t F_SYS_ST : 2;
uint8_t : 6;
uint8_t : 8;
uint8_t : 1;
uint8_t Snd : 3;
uint8_t SndDir : 1;
uint8_t : 3;
uint8_t CheckSum : 8;
}Frame;
struct
{
uint8_t RRM : 1;
uint8_t RLM : 1;
uint8_t RL : 1;
uint8_t R_SYS_ST : 2;
uint8_t Config : 3;
uint8_t F_SYS_ST : 2;
uint8_t : 2;
uint8_t LED0 : 1;
uint8_t SWITCH0 : 1;
uint8_t HOST0 : 1;
uint8_t RR : 1;
uint8_t : 1;
uint8_t LED1 : 1;
uint8_t SWITCH1 : 1;
uint8_t HOST1 : 1;
uint8_t FR : 1;
uint8_t FRM : 1;
uint8_t FLM : 1;
uint8_t FL : 1;
uint8_t : 1;
uint8_t Snd : 3;
uint8_t SndDir : 1;
uint8_t : 3;
uint8_t CheckSum : 8;
}Failure;
struct
{
uint8_t RL : 3;
uint8_t R_SYS_ST : 2;
uint8_t Config : 3;
uint8_t F_SYS_ST : 2;
uint8_t RR : 3;
uint8_t RM : 3;
uint8_t : 2;
uint8_t FM : 3;
uint8_t FL : 3;
uint8_t : 1;
uint8_t Snd : 3;
uint8_t SndDir : 1;
uint8_t FR : 3;
uint8_t CheckSum : 8;
}Msg;
}RadarF2R3DataBufferUnion;
/******************************************************************************
接收数值转换表
******************************************************************************/
static const uint8_t RadarF2R3DataConvTable[] = {0x0, 0x3, 0x2, 0x1, 0x0, 0x0, 0x0, 0x0};
/******************************************************************************
接收控制结构
******************************************************************************/
typedef struct
{
uint8_t Enable;
uint8_t Complete;
uint8_t Ptr;
uint16_t Timer;
uint16_t InvalidTimer;
uint16_t LostTimer;
uint16_t Counter;
}RadarF2R3ReceivingCtrlStruct;
/******************************************************************************
函数声明
******************************************************************************/
void Radar_F2R3_Init(void);
void Radar_F2R3_Receiving_Service(void);
void Radar_F2R3_Receive_Enable(uint8_t En);
void Radar_F2R3_Receive_Data(uint8_t Data, uint8_t Parity);
#endif