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