Rev 737 | Rev 739 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 737 | Rev 738 | ||
---|---|---|---|
1 | #ifndef _UART1_H |
1 | #ifndef _UART1_H |
2 | #define _UART1_H |
2 | #define _UART1_H |
3 | 3 | ||
4 | #define UART_FLIGHTCTRL 0 |
4 | #define UART_FLIGHTCTRL 0 |
5 | #define UART_MK3MAG 1 |
5 | #define UART_MK3MAG 1 |
6 | #define UART_MKGPS 2 |
6 | #define UART_MKGPS 2 |
7 | 7 | ||
8 | #include "ubx.h" |
8 | #include "ubx.h" |
9 | #include "waypoints.h" |
9 | #include "waypoints.h" |
10 | 10 | ||
11 | #define NC_ERROR0_SPI_RX 0x01 |
11 | #define NC_ERROR0_SPI_RX 0x01 |
12 | #define NC_ERROR0_COMPASS_RX 0x02 |
12 | #define NC_ERROR0_COMPASS_RX 0x02 |
13 | #define NC_ERROR0_FC_INCOMPATIBLE 0x04 |
13 | #define NC_ERROR0_FC_INCOMPATIBLE 0x04 |
14 | #define NC_ERROR0_COMPASS_INCOMPATIBLE 0x08 |
14 | #define NC_ERROR0_COMPASS_INCOMPATIBLE 0x08 |
15 | #define NC_ERROR0_GPS_RX 0x10 |
15 | #define NC_ERROR0_GPS_RX 0x10 |
16 | #define NC_ERROR0_COMPASS_VALUE 0x20 |
16 | #define NC_ERROR0_COMPASS_VALUE 0x20 |
17 | 17 | ||
18 | #define DISABLE_FC_UART GPIO_WriteBit(GPIO3, GPIO_Pin_7, Bit_SET); |
18 | #define DISABLE_FC_UART GPIO_WriteBit(GPIO3, GPIO_Pin_7, Bit_SET); |
19 | #define ENABLE_FC_UART GPIO_WriteBit(GPIO3, GPIO_Pin_7, Bit_RESET); |
19 | #define ENABLE_FC_UART GPIO_WriteBit(GPIO3, GPIO_Pin_7, Bit_RESET); |
20 | 20 | ||
21 | typedef struct |
21 | typedef struct |
22 | { |
22 | { |
23 | u8 SWMajor; |
23 | u8 SWMajor; |
24 | u8 SWMinor; |
24 | u8 SWMinor; |
25 | u8 ProtoMajor; |
25 | u8 ProtoMajor; |
26 | u8 LabelTextCRC; |
26 | u8 LabelTextCRC; |
27 | u8 SWPatch; |
27 | u8 SWPatch; |
28 | u8 HardwareError[2]; |
28 | u8 HardwareError[2]; |
29 | u8 HWMajor; |
29 | u8 HWMajor; |
30 | u8 BL_Firmware; |
30 | u8 BL_Firmware; |
31 | u8 Flags; |
31 | u8 Flags; |
32 | } __attribute__((packed)) UART_VersionInfo_t; |
32 | } __attribute__((packed)) UART_VersionInfo_t; |
33 | 33 | ||
34 | extern UART_VersionInfo_t UART_VersionInfo; |
34 | extern UART_VersionInfo_t UART_VersionInfo; |
35 | 35 | ||
36 | //VersionInfo.Flags |
36 | //VersionInfo.Flags |
37 | #define NC_VERSION_FLAG_MK3MAG_PRESENT 0x01 |
37 | #define NC_VERSION_FLAG_MK3MAG_PRESENT 0x01 |
38 | #define NC_VERSION_FLAG_GPS_PRESENT 0x02 |
38 | #define NC_VERSION_FLAG_GPS_PRESENT 0x02 |
39 | 39 | ||
40 | typedef struct |
40 | typedef struct |
41 | { |
41 | { |
42 | s16 AngleNick; // in 0.1 deg |
42 | s16 AngleNick; // in 0.1 deg |
43 | s16 AngleRoll; // in 0.1 deg |
43 | s16 AngleRoll; // in 0.1 deg |
44 | s16 Heading; // in 0.1 deg |
44 | s16 Heading; // in 0.1 deg |
45 | u8 StickNick; |
45 | u8 StickNick; |
46 | u8 StickRoll; |
46 | u8 StickRoll; |
47 | u8 StickYaw; |
47 | u8 StickYaw; |
48 | u8 StickGas; |
48 | u8 StickGas; |
49 | s16 Altimeter; // in 5cm |
49 | s16 Altimeter; // in 5cm |
50 | u8 reserve[2]; |
50 | u8 reserve[2]; |
51 | } __attribute__((packed)) Data3D_t; |
51 | } __attribute__((packed)) Data3D_t; |
52 | 52 | ||
53 | extern Data3D_t Data3D; |
53 | extern Data3D_t Data3D; |
54 | 54 | ||
55 | 55 | ||
56 | extern const u8 ANALOG_LABEL[32][16]; |
56 | extern const u8 ANALOG_LABEL[32][16]; |
57 | 57 | ||
58 | #define AMPEL_FC 0x01 |
58 | #define AMPEL_FC 0x01 |
59 | #define AMPEL_BL 0x02 |
59 | #define AMPEL_BL 0x02 |
60 | #define AMPEL_NC 0x04 |
60 | #define AMPEL_NC 0x04 |
61 | #define AMPEL_COMPASS 0x08 |
61 | #define AMPEL_COMPASS 0x08 |
62 | 62 | ||
63 | typedef struct |
63 | typedef struct |
64 | { |
64 | { |
65 | u8 StatusGreen; |
65 | u8 StatusGreen; |
66 | u8 StatusRed; |
66 | u8 StatusRed; |
67 | u16 Analog[32]; // Debugwerte |
67 | u16 Analog[32]; // Debugwerte |
68 | } __attribute__((packed)) DebugOut_t; |
68 | } __attribute__((packed)) DebugOut_t; |
69 | 69 | ||
70 | extern DebugOut_t DebugOut; |
70 | extern DebugOut_t DebugOut; |
71 | 71 | ||
72 | /* |
72 | /* |
73 | typedef struct |
73 | typedef struct |
74 | { |
74 | { |
75 | u8 Digital[2]; |
75 | u8 Digital[2]; |
76 | u8 RemoteButtons; |
76 | u8 RemoteButtons; |
77 | s8 Nick; |
77 | s8 Nick; |
78 | s8 Roll; |
78 | s8 Roll; |
79 | s8 Yaw; |
79 | s8 Yaw; |
80 | u8 Gas; |
80 | u8 Gas; |
81 | s8 Height; |
81 | s8 Height; |
82 | u8 free; |
82 | u8 free; |
83 | u8 Frame; |
83 | u8 Frame; |
84 | u8 Config; |
84 | u8 Config; |
85 | } __attribute__((packed)) ExternControl_t; |
85 | } __attribute__((packed)) ExternControl_t; |
86 | */ |
86 | */ |
87 | 87 | ||
88 | #define EC_VALID 0x01 // only valid if this is 1 |
88 | #define EC_VALID 0x01 // only valid if this is 1 |
89 | #define EC_GAS_ADD 0x02 // if 1 -> use the GAS Value not as MAX |
89 | #define EC_GAS_ADD 0x02 // if 1 -> use the GAS Value not as MAX |
90 | #define EC_USE_SWITCH 0x20 // if 1 -> use the Switches for further control |
90 | #define EC_USE_SWITCH 0x20 // if 1 -> use the Switches for further control |
91 | #define EC_IGNORE_RC_STICK 0x40 // direct control (do nor add to RC-Stick) |
91 | #define EC_IGNORE_RC_STICK 0x40 // direct control (do nor add to RC-Stick) |
92 | #define EC_IGNORE_RC_LOST 0x80 // if 1 -> for Flying without RC-Control |
92 | #define EC_IGNORE_RC_LOST 0x80 // if 1 -> for Flying without RC-Control |
93 | 93 | ||
94 | // defines for ExternalControl.Switches -> control GPS Modes etc. if(Config & EC_USE_SWITCH) |
94 | // defines for ExternalControl.Switches -> control GPS Modes etc. if(Config & EC_USE_SWITCH) |
95 | #define EC2_PH 0x01 // GPS-Mode: PH |
95 | #define EC2_PH 0x01 // GPS-Mode: PH |
96 | #define EC2_CH 0x02 // GPS-Mode: CH |
96 | #define EC2_CH 0x02 // GPS-Mode: CH |
97 | #define EC2_CAREFREE 0x10 // |
97 | #define EC2_CAREFREE 0x10 // |
98 | #define EC2_ALTITUDE 0x20 // |
98 | #define EC2_ALTITUDE 0x20 // |
99 | #define EC2_AUTOSTART 0x40 // |
99 | #define EC2_AUTOSTART 0x40 // |
100 | #define EC2_AUTOLAND 0x80 // |
100 | #define EC2_AUTOLAND 0x80 // |
101 | 101 | ||
102 | typedef struct |
102 | typedef struct |
103 | { |
103 | { |
104 | signed char Nick; |
104 | signed char Nick; |
105 | signed char Roll; |
105 | signed char Roll; |
106 | signed char Gier; |
106 | signed char Gier; |
107 | signed char Gas; |
107 | signed char Gas; |
108 | unsigned char Frame; // will return a confirm frame with this value |
108 | unsigned char Frame; // will return a confirm frame with this value |
109 | unsigned char Config; |
109 | unsigned char Config; |
110 | unsigned char Switches; |
110 | unsigned char Switches; |
111 | unsigned char Free1; // these two don't need capacity in the ASCII data string |
111 | unsigned char Free1; // these two don't need capacity in the ASCII data string |
112 | unsigned char Free2; |
112 | unsigned char Free2; |
113 | } __attribute__((packed)) ExternControl_t; |
113 | } __attribute__((packed)) ExternControl_t; |
114 | extern ExternControl_t ExternControl; |
114 | extern ExternControl_t ExternControl; |
115 | extern u8 NewExternalControlFrame; // flag that sends the Frame to FC |
115 | extern u8 NewExternalControlFrame; // flag that sends the Frame to FC |
116 | 116 | ||
117 | #define SERIAL_POTI_START 17 |
117 | #define SERIAL_POTI_START 17 |
118 | #define WP_EVENT_PPM_IN 29 |
118 | #define WP_EVENT_PPM_IN 29 |
119 | #define PPM_IN_OFF 30 |
119 | #define PPM_IN_OFF 30 |
120 | #define PPM_IN_MAX 31 |
120 | #define PPM_IN_MAX 31 |
121 | #define PPM_IN_MID 32 |
121 | #define PPM_IN_MID 32 |
122 | typedef struct |
122 | typedef struct |
123 | { |
123 | { |
124 | signed char Ch[12]; |
124 | signed char Ch[12]; |
125 | } __attribute__((packed)) SerialChannel_t; |
125 | } __attribute__((packed)) SerialChannel_t; |
126 | extern SerialChannel_t SerialChannel; |
126 | extern SerialChannel_t SerialChannel; |
127 | extern u8 NewSerialChannelFrame; // flag that sends the Frame to FC |
127 | extern u8 NewSerialChannelFrame; // flag that sends the Frame to FC |
128 | 128 | ||
129 | typedef struct |
129 | typedef struct |
130 | { |
130 | { |
131 | s16 Nick; |
131 | s16 Nick; |
132 | s16 Roll; |
132 | s16 Roll; |
133 | s16 Compass; // angle between north and head of the MK |
133 | s16 Compass; // angle between north and head of the MK |
134 | } __attribute__((packed)) Attitude_t; |
134 | } __attribute__((packed)) Attitude_t; |
135 | 135 | ||
136 | 136 | ||
137 | typedef struct |
137 | typedef struct |
138 | { |
138 | { |
139 | u16 Distance_dm; // distance to target in dm |
139 | u16 Distance_dm; // distance to target in dm |
140 | s16 Bearing; // course to target in deg |
140 | s16 Bearing; // course to target in deg |
141 | } __attribute__((packed)) GPS_PosDev_t; |
141 | } __attribute__((packed)) GPS_PosDev_t; |
142 | 142 | ||
143 | #define NAVIDATA_VERSION 5 |
143 | #define NAVIDATA_VERSION 5 |
144 | 144 | ||
145 | typedef struct // 85 Bytes |
145 | typedef struct // 85 Bytes |
146 | { |
146 | { |
147 | u8 Version; // version of the data structure |
147 | u8 Version; // version of the data structure |
148 | GPS_Pos_t CurrentPosition; // see gpspos.h for details |
148 | GPS_Pos_t CurrentPosition; // see gpspos.h for details |
149 | GPS_Pos_t TargetPosition; |
149 | GPS_Pos_t TargetPosition; |
150 | GPS_PosDev_t TargetPositionDeviation; |
150 | GPS_PosDev_t TargetPositionDeviation; |
151 | GPS_Pos_t HomePosition; |
151 | GPS_Pos_t HomePosition; |
152 | GPS_PosDev_t HomePositionDeviation; |
152 | GPS_PosDev_t HomePositionDeviation; |
153 | u8 WaypointIndex; // index of current waypoints running from 0 to WaypointNumber-1 |
153 | u8 WaypointIndex; // index of current waypoints running from 0 to WaypointNumber-1 |
154 | u8 WaypointNumber; // number of stored waypoints |
154 | u8 WaypointNumber; // number of stored waypoints |
155 | u8 SatsInUse; // number of satellites used for position solution |
155 | u8 SatsInUse; // number of satellites used for position solution |
156 | s16 Altimeter; // hight according to air pressure |
156 | s16 Altimeter_20cm; // hight according to air pressure |
157 | s16 Variometer; // climb(+) and sink(-) rate |
157 | s16 Variometer; // climb(+) and sink(-) rate |
158 | u16 FlyingTime; // in seconds |
158 | u16 FlyingTime; // in seconds |
159 | u8 UBat; // Battery Voltage in 0.1 Volts |
159 | u8 UBat; // Battery Voltage in 0.1 Volts |
160 | u16 GroundSpeed; // speed over ground in cm/s (2D) |
160 | u16 GroundSpeed; // speed over ground in cm/s (2D) |
161 | s16 Heading; // current flight direction in ° as angle to north |
161 | s16 Heading; // current flight direction in ° as angle to north |
162 | s16 CompassHeading; // current compass value in ° |
162 | s16 CompassHeading; // current compass value in ° |
163 | s8 AngleNick; // current Nick angle in 1° |
163 | s8 AngleNick; // current Nick angle in 1° |
164 | s8 AngleRoll; // current Rick angle in 1° |
164 | s8 AngleRoll; // current Rick angle in 1° |
165 | u8 RC_Quality; // RC_Quality |
165 | u8 RC_Quality; // RC_Quality |
166 | u8 FCStatusFlags; // Flags from FC |
166 | u8 FCStatusFlags; // Flags from FC |
167 | u8 NCFlags; // Flags from NC |
167 | u8 NCFlags; // Flags from NC |
168 | u8 Errorcode; // 0 --> okay |
168 | u8 Errorcode; // 0 --> okay |
169 | u8 WP_OperatingRadius; // current WP operation radius around the Home Position in m |
169 | u8 WP_OperatingRadius; // current WP operation radius around the Home Position in m |
170 | s16 TopSpeed; // velocity in vertical direction in cm/s |
170 | s16 TopSpeed; // velocity in vertical direction in cm/s |
171 | u8 TargetHoldTime; // time in s to stay at the given target, counts down to 0 if target has been reached |
171 | u8 TargetHoldTime; // time in s to stay at the given target, counts down to 0 if target has been reached |
172 | u8 FCStatusFlags2; // StatusFlags2 (since version 5 added) |
172 | u8 FCStatusFlags2; // StatusFlags2 (since version 5 added) |
173 | s16 SetpointAltitude; // setpoint for altitude |
173 | s16 SetpointAltitude; // setpoint for altitude |
174 | u8 Gas; // for future use |
174 | u8 Gas; // for future use |
175 | u16 Current; // actual current in 0.1A steps |
175 | u16 Current; // actual current in 0.1A steps |
176 | u16 UsedCapacity; // used capacity in mAh |
176 | u16 UsedCapacity; // used capacity in mAh |
177 | } __attribute__((packed)) NaviData_t; |
177 | } __attribute__((packed)) NaviData_t; |
178 | extern NaviData_t NaviData; |
178 | extern NaviData_t NaviData; |
179 | 179 | ||
180 | typedef struct // 10 (15 Bytes belegen 27 ASCII-Zeichen) |
180 | typedef struct // 10 (15 Bytes belegen 27 ASCII-Zeichen) |
181 | { |
181 | { |
182 | u8 Index; // version of the data structure |
182 | u8 Index; // version of the data structure |
183 | s32 ActualLongitude; // |
183 | s32 ActualLongitude; // |
184 | s32 ActualLatitude; // |
184 | s32 ActualLatitude; // |
185 | s16 Altimeter; // hight according to air pressure |
185 | s16 Altimeter_20cm; // hight according to air pressure |
186 | u8 GroundSpeed; // speed over ground in 10cm/s (2D) (255 = 91km/h) |
186 | u8 GroundSpeed; // speed over ground in 10cm/s (2D) (255 = 91km/h) |
187 | u8 OSDStatusFlags; |
187 | u8 OSDStatusFlags; |
188 | u8 CamCtrlChar; // Status from a connected CamCtrl unit: 'R' = REC 'c' = Ready '!' = Error ...etc |
188 | u8 CamCtrlChar; // Status from a connected CamCtrl unit: 'R' = REC 'c' = Ready '!' = Error ...etc |
189 | u8 reserve1; |
189 | u8 reserve1; |
190 | } __attribute__((packed)) NaviData_Tiny_t; |
190 | } __attribute__((packed)) NaviData_Tiny_t; |
191 | extern NaviData_Tiny_t NaviData_Tiny; |
191 | extern NaviData_Tiny_t NaviData_Tiny; |
192 | 192 | ||
193 | #define START_PAYLOAD_DATA 13 // |
193 | #define START_PAYLOAD_DATA 13 // |
194 | 194 | ||
195 | typedef struct // 11 (24 Bytes belegen 39 ASCII-Zeichen) |
195 | typedef struct // 11 (24 Bytes belegen 39 ASCII-Zeichen) |
196 | { |
196 | { |
197 | u8 Index; // version of the data structure |
197 | u8 Index; // version of the data structure |
198 | s32 ActualLongitude; // |
198 | s32 ActualLongitude; // |
199 | s32 ActualLatitude; // |
199 | s32 ActualLatitude; // |
200 | s16 Altimeter; // hight according to air pressure |
200 | s16 Altimeter_20cm; // hight according to air pressure |
201 | u8 GroundSpeed; // speed over ground in 10cm/s (2D) (255 = 91km/h) |
201 | u8 GroundSpeed; // speed over ground in 10cm/s (2D) (255 = 91km/h) |
202 | u8 OSDStatusFlags; |
202 | u8 OSDStatusFlags; |
203 | u8 OSDStatusFlags2; |
203 | u8 OSDStatusFlags2; |
204 | u8 NCFlags; // Flags from NC |
204 | u8 NCFlags; // Flags from NC |
205 | u8 ReserveFlags; |
205 | u8 ReserveFlags; |
206 | u8 Errorcode; // 0 --> okay |
206 | u8 Errorcode; // 0 --> okay |
207 | u8 SpeakHoTT; |
207 | u8 SpeakHoTT; |
208 | u8 VarioCharacter; |
208 | u8 VarioCharacter; |
209 | u8 GPS_ModeCharacter; |
209 | u8 GPS_ModeCharacter; |
210 | u8 BL_MinOfMaxPWM; |
210 | u8 BL_MinOfMaxPWM; |
211 | } __attribute__((packed)) NaviData_Flags_t; |
211 | } __attribute__((packed)) NaviData_Flags_t; |
212 | extern NaviData_Flags_t NaviData_Flags; |
212 | extern NaviData_Flags_t NaviData_Flags; |
213 | 213 | ||
214 | typedef struct // 12 (27 Bytes belegen 43 ASCII-Zeichen) |
214 | typedef struct // 12 (27 Bytes belegen 43 ASCII-Zeichen) |
215 | { |
215 | { |
216 | u8 Index; // version of the data structure |
216 | u8 Index; // version of the data structure |
217 | s32 ActualLongitude; // |
217 | s32 ActualLongitude; // |
218 | s32 ActualLatitude; // |
218 | s32 ActualLatitude; // |
219 | s16 Altimeter; // hight according to air pressure |
219 | s16 Altimeter_20cm; // hight according to air pressure |
220 | u8 GroundSpeed; // speed over ground in 10cm/s (2D) (255 = 91km/h) |
220 | u8 GroundSpeed; // speed over ground in 10cm/s (2D) (255 = 91km/h) |
221 | u8 OSDStatusFlags; |
221 | u8 OSDStatusFlags; |
222 | s32 TargetLongitude; // |
222 | s32 TargetLongitude; // |
223 | s32 TargetLatitude; // |
223 | s32 TargetLatitude; // |
224 | s16 TargetAltitude; // hight according to air pressure |
224 | s16 TargetAltitude; // hight according to air pressure |
225 | u8 RC_Quality; // RC_Quality |
225 | u8 RC_Quality; // RC_Quality |
226 | u8 reserve; |
226 | u8 reserve; |
227 | } __attribute__((packed)) NaviData_Target_t; |
227 | } __attribute__((packed)) NaviData_Target_t; |
228 | extern NaviData_Target_t NaviData_Target; |
228 | extern NaviData_Target_t NaviData_Target; |
229 | 229 | ||
230 | typedef struct // 13 (30 Bytes belegen 47 ASCII-Zeichen) |
230 | typedef struct // 13 (30 Bytes belegen 47 ASCII-Zeichen) |
231 | { |
231 | { |
232 | u8 Index; // version of the data structure |
232 | u8 Index; // version of the data structure |
233 | s32 ActualLongitude; // |
233 | s32 ActualLongitude; // |
234 | s32 ActualLatitude; // |
234 | s32 ActualLatitude; // |
235 | s16 Altimeter; // hight according to air pressure |
235 | s16 Altimeter_20cm; // hight according to air pressure |
236 | u8 GroundSpeed; // speed over ground in 10cm/s (2D) (255 = 91km/h) |
236 | u8 GroundSpeed; // speed over ground in 10cm/s (2D) (255 = 91km/h) |
237 | u8 OSDStatusFlags; |
237 | u8 OSDStatusFlags; |
238 | s32 HomeLongitude; // |
238 | s32 HomeLongitude; // |
239 | s32 HomeLatitude; // |
239 | s32 HomeLatitude; // |
240 | s16 HomeAltitude; // hight according to air pressure |
240 | s16 HomeAltitude; // hight according to air pressure |
241 | u16 WP_OperatingRadius; // current WP operation radius around the Home Position in m |
241 | u16 WP_OperatingRadius; // current WP operation radius around the Home Position in m |
242 | u8 LipoCellCount; |
242 | u8 LipoCellCount; |
243 | u8 DescendRange; // in [10m] |
243 | u8 DescendRange; // in [10m] |
244 | u8 ManualFlyingRange; // in [10m] |
244 | u8 ManualFlyingRange; // in [10m] |
245 | u8 reserve1; |
245 | u8 reserve1; |
246 | u8 reserve2; |
246 | u8 reserve2; |
247 | } __attribute__((packed)) NaviData_Home_t; |
247 | } __attribute__((packed)) NaviData_Home_t; |
248 | extern NaviData_Home_t NaviData_Home; |
248 | extern NaviData_Home_t NaviData_Home; |
249 | 249 | ||
250 | typedef struct // 18 (21 Bytes belegen 35 ASCII-Zeichen) |
250 | typedef struct // 18 (21 Bytes belegen 35 ASCII-Zeichen) |
251 | { |
251 | { |
252 | u8 Index; // version of the data structure |
252 | u8 Index; // version of the data structure |
253 | s32 ActualLongitude; // |
253 | s32 ActualLongitude; // |
254 | s32 ActualLatitude; // |
254 | s32 ActualLatitude; // |
255 | s16 Altimeter; // hight according to air pressure |
255 | s16 Altimeter_20cm; // hight according to air pressure |
256 | u8 GroundSpeed; // speed over ground in 10cm/s (2D) (255 = 91km/h) |
256 | u8 GroundSpeed; // speed over ground in 10cm/s (2D) (255 = 91km/h) |
257 | u8 OSDStatusFlags; |
257 | u8 OSDStatusFlags; |
258 | s32 Longitude; // |
258 | s32 Longitude; // |
259 | s32 Latitude; // |
259 | s32 Latitude; // |
260 | } __attribute__((packed)) NaviData_Pos_t; |
260 | } __attribute__((packed)) NaviData_Pos_t; |
261 | 261 | ||
262 | extern NaviData_Pos_t NaviData_Failsafe; |
262 | extern NaviData_Pos_t NaviData_Failsafe; |
263 | 263 | ||
264 | typedef struct // 18 (9 Bytes belegen 19 ASCII-Zeichen) |
264 | typedef struct // 18 (9 Bytes belegen 19 ASCII-Zeichen) |
265 | { |
265 | { |
266 | u8 Index; // version of the data structure |
266 | u8 Index; // version of the data structure |
267 | s32 Longitude; // |
267 | s32 Longitude; // |
268 | s32 Latitude; // |
268 | s32 Latitude; // |
269 | } __attribute__((packed)) NaviData_Out_t; |
269 | } __attribute__((packed)) NaviData_Out_t; |
270 | extern NaviData_Out_t NaviData_Out1Trigger; |
270 | extern NaviData_Out_t NaviData_Out1Trigger; |
271 | 271 | ||
272 | typedef struct // 15 (18 Bytes belegen 31 ASCII-Zeichen) |
272 | typedef struct // 15 (18 Bytes belegen 31 ASCII-Zeichen) |
273 | { |
273 | { |
274 | u8 Index; // version of the data structure |
274 | u8 Index; // version of the data structure |
275 | s32 ActualLongitude; // |
275 | s32 ActualLongitude; // |
276 | s32 ActualLatitude; // |
276 | s32 ActualLatitude; // |
277 | s16 Altimeter; // hight according to air pressure |
277 | s16 Altimeter_20cm; // hight according to air pressure |
278 | u8 GroundSpeed; // speed over ground in 10cm/s (2D) (255 = 91km/h) |
278 | u8 GroundSpeed; // speed over ground in 10cm/s (2D) (255 = 91km/h) |
279 | u8 OSDStatusFlags; |
279 | u8 OSDStatusFlags; |
280 | u8 WaypointIndex; // index of current waypoints running from 0 to WaypointNumber-1 |
280 | u8 WaypointIndex; // index of current waypoints running from 0 to WaypointNumber-1 |
281 | u8 WaypointNumber; // number of stored waypoints |
281 | u8 WaypointNumber; // number of stored waypoints |
282 | u8 TargetHoldTime; // time in s to stay at the given target, counts down to 0 if target has been reached |
282 | u8 TargetHoldTime; // time in s to stay at the given target, counts down to 0 if target has been reached |
283 | u8 WP_Eventchannel; |
283 | u8 WP_Eventchannel; |
284 | u8 reserve; |
284 | u8 reserve; |
285 | } __attribute__((packed)) NaviData_WP_t; |
285 | } __attribute__((packed)) NaviData_WP_t; |
286 | extern NaviData_WP_t NaviData_WP; |
286 | extern NaviData_WP_t NaviData_WP; |
287 | 287 | ||
288 | typedef struct // 14 (24 Bytes belegen 39 ASCII-Zeichen) |
288 | typedef struct // 14 (24 Bytes belegen 39 ASCII-Zeichen) |
289 | { |
289 | { |
290 | u8 Index; // version of the data structure |
290 | u8 Index; // version of the data structure |
291 | s32 ActualLongitude; // |
291 | s32 ActualLongitude; // |
292 | s32 ActualLatitude; // |
292 | s32 ActualLatitude; // |
293 | s16 Altimeter; // hight according to air pressure |
293 | s16 Altimeter_20cm; // hight according to air pressure |
294 | u8 GroundSpeed; // speed over ground in 10cm/s (2D) (255 = 91km/h) |
294 | u8 GroundSpeed; // speed over ground in 10cm/s (2D) (255 = 91km/h) |
295 | u8 OSDStatusFlags; |
295 | u8 OSDStatusFlags; |
296 | u16 FlyingTime; // in seconds |
296 | u16 FlyingTime; // in seconds |
297 | u16 DistanceToHome; |
297 | u16 DistanceToHome; |
298 | u8 HeadingToHome; // in 2° (100 = 200°) |
298 | u8 HeadingToHome; // in 2° (100 = 200°) |
299 | u16 DistanceToTarget; |
299 | u16 DistanceToTarget; |
300 | u8 HeadingToTarget; // in 2° (100 = 200°) |
300 | u8 HeadingToTarget; // in 2° (100 = 200°) |
301 | s8 AngleNick; // current Nick angle in 1° |
301 | s8 AngleNick; // current Nick angle in 1° |
302 | s8 AngleRoll; // current Rick angle in 1° |
302 | s8 AngleRoll; // current Rick angle in 1° |
303 | u8 SatsInUse; // number of satellites used for position solution |
303 | u8 SatsInUse; // number of satellites used for position solution |
304 | } __attribute__((packed)) NaviData_Deviation_t; |
304 | } __attribute__((packed)) NaviData_Deviation_t; |
305 | extern NaviData_Deviation_t NaviData_Deviation; |
305 | extern NaviData_Deviation_t NaviData_Deviation; |
306 | 306 | ||
307 | typedef struct // 16 (27 Bytes belegen 43 ASCII-Zeichen) |
307 | typedef struct // 16 (27 Bytes belegen 43 ASCII-Zeichen) |
308 | { |
308 | { |
309 | u8 Index; // version of the data structure |
309 | u8 Index; // version of the data structure |
310 | s32 ActualLongitude; // |
310 | s32 ActualLongitude; // |
311 | s32 ActualLatitude; // |
311 | s32 ActualLatitude; // |
312 | s16 Altimeter; // hight according to air pressure |
312 | s16 Altimeter_20cm; // hight according to air pressure |
313 | u8 GroundSpeed; // speed over ground in 10cm/s (2D) (255 = 91km/h) |
313 | u8 GroundSpeed; // speed over ground in 10cm/s (2D) (255 = 91km/h) |
314 | u8 OSDStatusFlags; |
314 | u8 OSDStatusFlags; |
315 | u16 UBat; // Battery Voltage in 0.1 Volts |
315 | u16 UBat; // Battery Voltage in 0.1 Volts |
316 | u16 Current; // actual current in 0.1A steps |
316 | u16 Current; // actual current in 0.1A steps |
317 | u16 UsedCapacity; // used capacity in mAh |
317 | u16 UsedCapacity; // used capacity in mAh |
318 | s8 Variometer; // climb(+) and sink(-) rate |
318 | s8 Variometer; // climb(+) and sink(-) rate |
319 | u8 Heading; // Current moving direction in 2° (100 = 200°) |
319 | u8 Heading; // Current moving direction in 2° (100 = 200°) |
320 | u8 CompassHeading; // current compass value in 2° |
320 | u8 CompassHeading; // current compass value in 2° |
321 | u8 Gas; // for future use |
321 | u8 Gas; // for future use |
322 | u16 ShutterCounter; // counts every time a Out1 was activated |
322 | u16 ShutterCounter; // counts every time a Out1 was activated |
323 | s16 SetpointAltitude; // setpoint for altitude |
323 | s16 SetpointAltitude; // setpoint for altitude |
324 | } __attribute__((packed)) NaviData_Volatile_t; |
324 | } __attribute__((packed)) NaviData_Volatile_t; |
325 | extern NaviData_Volatile_t NaviData_Volatile; |
325 | extern NaviData_Volatile_t NaviData_Volatile; |
326 | 326 | ||
327 | #define OSD_FLAG_MASK1 (0x04 + 0x20 + 0x40 + 0x80) |
327 | #define OSD_FLAG_MASK1 (0x04 + 0x20 + 0x40 + 0x80) |
328 | #define OSD_FLAG_MASK2 (0x01 + 0x02 + 0x08 + 0x10) |
328 | #define OSD_FLAG_MASK2 (0x01 + 0x02 + 0x08 + 0x10) |
329 | 329 | ||
330 | // NC calculates |
330 | // NC calculates |
331 | //OSDStatusFlags = (FC.StatusFlags & OSD_FLAG_MASK1) | (FC.StatusFlags2 & OSD_FLAG_MASK2); |
331 | //OSDStatusFlags = (FC.StatusFlags & OSD_FLAG_MASK1) | (FC.StatusFlags2 & OSD_FLAG_MASK2); |
332 | //OSDStatusFlags2 = (FC.StatusFlags & ~OSD_FLAG_MASK1) | (FC.StatusFlags2 & ~OSD_FLAG_MASK2); |
332 | //OSDStatusFlags2 = (FC.StatusFlags & ~OSD_FLAG_MASK1) | (FC.StatusFlags2 & ~OSD_FLAG_MASK2); |
333 | 333 | ||
334 | //calculate Back: |
334 | //calculate Back: |
335 | //FC.StatusFlags = (OSDStatusFlags & OSD_FLAG_MASK1) | (OSDStatusFlags2 & ~OSD_FLAG_MASK1); |
335 | //FC.StatusFlags = (OSDStatusFlags & OSD_FLAG_MASK1) | (OSDStatusFlags2 & ~OSD_FLAG_MASK1); |
336 | //FC.StatusFlags2 = (OSDStatusFlags & OSD_FLAG_MASK2) | (OSDStatusFlags2 & ~OSD_FLAG_MASK2); |
336 | //FC.StatusFlags2 = (OSDStatusFlags & OSD_FLAG_MASK2) | (OSDStatusFlags2 & ~OSD_FLAG_MASK2); |
337 | 337 | ||
338 | 338 | ||
339 | /* |
339 | /* |
340 | OSDStatusFlags = (FC.StatusFlags & OSD_FLAG_MASK1) | (FC.StatusFlags2 & OSD_FLAG_MASK2); |
340 | OSDStatusFlags = (FC.StatusFlags & OSD_FLAG_MASK1) | (FC.StatusFlags2 & OSD_FLAG_MASK2); |
341 | NaviData_Flags.SpeakHoTT = FC.FromFC_SpeakHoTT; |
341 | NaviData_Flags.SpeakHoTT = FC.FromFC_SpeakHoTT; |
342 | NaviData_Flags.VarioCharacter = FromFC_VarioCharacter; |
342 | NaviData_Flags.VarioCharacter = FromFC_VarioCharacter; |
343 | NaviData_Flags.GPS_ModeCharacter = NC_GPS_ModeCharacter; |
343 | NaviData_Flags.GPS_ModeCharacter = NC_GPS_ModeCharacter; |
344 | NaviData_Flags.BL_MinOfMaxPWM = BL_MinOfMaxPWM; |
344 | NaviData_Flags.BL_MinOfMaxPWM = BL_MinOfMaxPWM; |
345 | NaviData_WP.WP_Wventchannel = LogFC_WP_EventChannel; |
345 | NaviData_WP.WP_Wventchannel = LogFC_WP_EventChannel; |
346 | */ |
346 | */ |
347 | 347 | ||
348 | extern UART_TypeDef *DebugUART; |
348 | extern UART_TypeDef *DebugUART; |
349 | extern volatile u8 SerialLinkOkay; |
349 | extern volatile u8 SerialLinkOkay; |
350 | extern Buffer_t UART1_tx_buffer; |
350 | extern Buffer_t UART1_tx_buffer; |
351 | extern Buffer_t UART1_rx_buffer; |
351 | extern Buffer_t UART1_rx_buffer; |
352 | 352 | ||
353 | void UART1_Init(void); |
353 | void UART1_Init(void); |
354 | void UART1_Transmit(void); |
354 | void UART1_Transmit(void); |
355 | void UART1_TransmitTxData(void); |
355 | void UART1_TransmitTxData(void); |
356 | void UART1_ProcessRxData(void); |
356 | void UART1_ProcessRxData(void); |
357 | 357 | ||
358 | s16 UART1_Putchar(char c); |
358 | s16 UART1_Putchar(char c); |
359 | void UART1_PutString(u8 *s); |
359 | void UART1_PutString(u8 *s); |
360 | extern u8 text[]; // globally used text buffer |
360 | extern u8 text[]; // globally used text buffer |
361 | extern u8 UART1_Request_SendFollowMe; |
361 | extern u8 UART1_Request_SendFollowMe; |
362 | extern u8 LastTransmittedFCStatusFlags2; |
362 | extern u8 LastTransmittedFCStatusFlags2; |
363 | extern u8 UART1_Request_ReadPoint; |
363 | extern u8 UART1_Request_ReadPoint; |
364 | extern WPL_Store_t WPL_Store; |
364 | extern WPL_Store_t WPL_Store; |
365 | extern u8 CalculateDebugLableCrc(void); |
365 | extern u8 CalculateDebugLableCrc(void); |
366 | extern u8 NaviData_Flags_SpeakHoTT_Processed; |
366 | extern u8 NaviData_Flags_SpeakHoTT_Processed; |
367 | 367 | ||
368 | typedef struct |
368 | typedef struct |
369 | { |
369 | { |
370 | u8 User[128]; |
370 | u8 User[128]; |
371 | u8 eMail[128]; |
371 | u8 eMail[128]; |
372 | u8 Feature[128]; |
372 | u8 Feature[128]; |
373 | u8 Expire[11]; |
373 | u8 Expire[11]; |
374 | u8 License[16]; |
374 | u8 License[16]; |
375 | } __attribute__((packed)) LicenseS_t; // from FC |
375 | } __attribute__((packed)) LicenseS_t; // from FC |
376 | extern u8 *LicensePtr; |
376 | extern u8 *LicensePtr; |
377 | 377 | ||
378 | extern u32 NMEA_Interval;// in ms |
378 | extern u32 NMEA_Interval;// in ms |
379 | #define LICENSE_SIZE 480 |
379 | #define LICENSE_SIZE 480 |
380 | #define LICENSE_SIZE_TEXT 411 |
380 | #define LICENSE_SIZE_TEXT 411 |
381 | 381 | ||
382 | #endif //_UART1_H |
382 | #endif //_UART1_H |
383 | 383 |