Rev 161 | Rev 206 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 161 | Rev 199 | ||
---|---|---|---|
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 | 9 | ||
10 | 10 | ||
11 | typedef struct |
11 | typedef struct |
12 | { |
12 | { |
13 | u8 SWMajor; |
13 | u8 SWMajor; |
14 | u8 SWMinor; |
14 | u8 SWMinor; |
15 | u8 ProtoMajor; |
15 | u8 ProtoMajor; |
16 | u8 ProtoMinor; |
16 | u8 ProtoMinor; |
17 | u8 SWPatch; |
17 | u8 SWPatch; |
18 | u8 Reserved[5]; |
18 | u8 Reserved[5]; |
19 | } __attribute__((packed)) UART_VersionInfo_t; |
19 | } __attribute__((packed)) UART_VersionInfo_t; |
20 | 20 | ||
21 | extern UART_VersionInfo_t UART_VersionInfo; |
21 | extern UART_VersionInfo_t UART_VersionInfo; |
22 | 22 | ||
23 | 23 | ||
24 | typedef struct |
24 | typedef struct |
25 | { |
25 | { |
26 | s16 AngleNick; // in 0.1 deg |
26 | s16 AngleNick; // in 0.1 deg |
27 | s16 AngleRoll; // in 0.1 deg |
27 | s16 AngleRoll; // in 0.1 deg |
28 | s16 Heading; // in 0.1 deg |
28 | s16 Heading; // in 0.1 deg |
29 | u8 reserve[8]; |
29 | u8 reserve[8]; |
30 | } __attribute__((packed)) Data3D_t; |
30 | } __attribute__((packed)) Data3D_t; |
31 | 31 | ||
32 | extern Data3D_t Data3D; |
32 | extern Data3D_t Data3D; |
33 | 33 | ||
34 | 34 | ||
35 | extern const u8 ANALOG_LABEL[32][16]; |
35 | extern const u8 ANALOG_LABEL[32][16]; |
36 | 36 | ||
37 | typedef struct |
37 | typedef struct |
38 | { |
38 | { |
39 | u8 Digital[2]; |
39 | u8 Digital[2]; |
40 | u16 Analog[32]; // Debugwerte |
40 | u16 Analog[32]; // Debugwerte |
41 | } __attribute__((packed)) DebugOut_t; |
41 | } __attribute__((packed)) DebugOut_t; |
42 | 42 | ||
43 | extern DebugOut_t DebugOut; |
43 | extern DebugOut_t DebugOut; |
44 | 44 | ||
45 | typedef struct |
45 | typedef struct |
46 | { |
46 | { |
47 | u8 Digital[2]; |
47 | u8 Digital[2]; |
48 | u8 RemoteButtons; |
48 | u8 RemoteButtons; |
49 | s8 Nick; |
49 | s8 Nick; |
50 | s8 Roll; |
50 | s8 Roll; |
51 | s8 Yaw; |
51 | s8 Yaw; |
52 | u8 Gas; |
52 | u8 Gas; |
53 | s8 Height; |
53 | s8 Height; |
54 | u8 free; |
54 | u8 free; |
55 | u8 Frame; |
55 | u8 Frame; |
56 | u8 Config; |
56 | u8 Config; |
57 | } __attribute__((packed)) ExternControl_t; |
57 | } __attribute__((packed)) ExternControl_t; |
58 | 58 | ||
59 | extern ExternControl_t ExternControl; |
59 | extern ExternControl_t ExternControl; |
60 | 60 | ||
61 | typedef struct |
61 | typedef struct |
62 | { |
62 | { |
63 | s16 Nick; |
63 | s16 Nick; |
64 | s16 Roll; |
64 | s16 Roll; |
65 | s16 Compass; // angle between north and head of the MK |
65 | s16 Compass; // angle between north and head of the MK |
66 | } __attribute__((packed)) Attitude_t; |
66 | } __attribute__((packed)) Attitude_t; |
67 | 67 | ||
68 | typedef struct |
68 | typedef struct |
69 | { |
69 | { |
70 | u16 Distance; // distance to target in dm |
70 | u16 Distance; // distance to target in dm |
71 | s16 Bearing; // course to target in deg |
71 | s16 Bearing; // course to target in deg |
72 | } __attribute__((packed)) GPS_PosDev_t; |
72 | } __attribute__((packed)) GPS_PosDev_t; |
73 | 73 | ||
74 | #define NAVIDATA_VERSION 2 |
74 | #define NAVIDATA_VERSION 2 |
75 | 75 | ||
76 | typedef struct |
76 | typedef struct |
77 | { |
77 | { |
78 | u8 Version; // version of the data structure |
78 | u8 Version; // version of the data structure |
79 | GPS_Pos_t CurrentPosition; // see ubx.h for details |
79 | GPS_Pos_t CurrentPosition; // see ubx.h for details |
80 | GPS_Pos_t TargetPosition; |
80 | GPS_Pos_t TargetPosition; |
81 | GPS_PosDev_t TargetPositionDeviation; |
81 | GPS_PosDev_t TargetPositionDeviation; |
82 | GPS_Pos_t HomePosition; |
82 | GPS_Pos_t HomePosition; |
83 | GPS_PosDev_t HomePositionDeviation; |
83 | GPS_PosDev_t HomePositionDeviation; |
84 | u8 WaypointIndex; // index of current waypoints running from 0 to WaypointNumber-1 |
84 | u8 WaypointIndex; // index of current waypoints running from 0 to WaypointNumber-1 |
85 | u8 WaypointNumber; // number of stored waypoints |
85 | u8 WaypointNumber; // number of stored waypoints |
86 | u8 SatsInUse; // number of satellites used for position solution |
86 | u8 SatsInUse; // number of satellites used for position solution |
87 | s16 Altimeter; // hight according to air pressure |
87 | s16 Altimeter; // hight according to air pressure |
88 | s16 Variometer; // climb(+) and sink(-) rate |
88 | s16 Variometer; // climb(+) and sink(-) rate |
89 | u16 FlyingTime; // in seconds |
89 | u16 FlyingTime; // in seconds |
90 | u8 UBat; // Battery Voltage in 0.1 Volts |
90 | u8 UBat; // Battery Voltage in 0.1 Volts |
91 | u16 GroundSpeed; // speed over ground in cm/s (2D) |
91 | u16 GroundSpeed; // speed over ground in cm/s (2D) |
92 | s16 Heading; // current flight direction in ° as angle to north |
92 | s16 Heading; // current flight direction in ° as angle to north |
93 | s16 CompassHeading; // current compass value in ° |
93 | s16 CompassHeading; // current compass value in ° |
94 | s8 AngleNick; // current Nick angle in 1° |
94 | s8 AngleNick; // current Nick angle in 1° |
95 | s8 AngleRoll; // current Rick angle in 1° |
95 | s8 AngleRoll; // current Rick angle in 1° |
96 | u8 RC_Quality; // RC_Quality |
96 | u8 RC_Quality; // RC_Quality |
97 | u8 MKFlags; // Flags from FC |
97 | u8 FCFlags; // Flags from FC |
98 | u8 NCFlags; // Flags from NC |
98 | u8 NCFlags; // Flags from NC |
99 | u8 Errorcode; // 0 --> okay |
99 | u8 Errorcode; // 0 --> okay |
100 | u8 OperatingRadius; // current operation radius around the Home Position in m |
100 | u8 OperatingRadius; // current operation radius around the Home Position in m |
101 | s16 TopSpeed; // velocity in vertical direction in cm/s |
101 | s16 TopSpeed; // velocity in vertical direction in cm/s |
102 | u8 TargetHoldTime; // time in s to stay at the given target, counts down to 0 if target has been reached |
102 | u8 TargetHoldTime; // time in s to stay at the given target, counts down to 0 if target has been reached |
103 | u8 RC_RSSI; // Receiver signal strength (since version 2 added) |
103 | u8 RC_RSSI; // Receiver signal strength (since version 2 added) |
104 | s16 SetpointAltitude; // setpoint for altitude |
104 | s16 SetpointAltitude; // setpoint for altitude |
105 | u8 Gas; // for future use |
105 | u8 Gas; // for future use |
106 | } __attribute__((packed)) NaviData_t; |
106 | } __attribute__((packed)) NaviData_t; |
107 | 107 | ||
108 | extern NaviData_t NaviData; |
108 | extern NaviData_t NaviData; |
109 | 109 | ||
110 | #define NC_FLAG_FREE 0x01 |
110 | #define NC_FLAG_FREE 0x01 |
111 | #define NC_FLAG_PH 0x02 |
111 | #define NC_FLAG_PH 0x02 |
112 | #define NC_FLAG_CH 0x04 |
112 | #define NC_FLAG_CH 0x04 |
113 | #define NC_FLAG_RANGE_LIMIT 0x08 |
113 | #define NC_FLAG_RANGE_LIMIT 0x08 |
114 | #define NC_FLAG_NOSERIALLINK 0x10 |
114 | #define NC_FLAG_NOSERIALLINK 0x10 |
115 | #define NC_FLAG_TARGET_REACHED 0x20 |
115 | #define NC_FLAG_TARGET_REACHED 0x20 |
116 | #define NC_FLAG_MANUAL_CONTROL 0x40 |
116 | #define NC_FLAG_MANUAL_CONTROL 0x40 |
117 | #define NC_FLAG_8 0x80 |
117 | #define NC_FLAG_8 0x80 |
118 | 118 | ||
119 | extern UART_TypeDef *DebugUART; |
119 | extern UART_TypeDef *DebugUART; |
120 | extern volatile u8 SerialLinkOkay; |
120 | extern volatile u8 SerialLinkOkay; |
121 | 121 | ||
122 | 122 | ||
123 | void UART1_Init(void); |
123 | void UART1_Init(void); |
124 | void UART1_Transmit(void); |
124 | void UART1_Transmit(void); |
125 | void UART1_TransmitTxData(void); |
125 | void UART1_TransmitTxData(void); |
126 | void UART1_ProcessRxData(void); |
126 | void UART1_ProcessRxData(void); |
127 | 127 | ||
128 | s16 UART1_Putchar(char c); |
128 | s16 UART1_Putchar(char c); |
129 | void UART1_PutString(u8 *s); |
129 | void UART1_PutString(u8 *s); |
130 | extern u8 text[]; // globally used text buffer |
130 | extern u8 text[]; // globally used text buffer |
131 | extern u8 UART1_Request_SendFollowMe; |
131 | extern u8 UART1_Request_SendFollowMe; |
132 | #endif //_UART1_H |
132 | #endif //_UART1_H |
133 | 133 |