Rev 560 | Rev 598 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 560 | Rev 588 | ||
---|---|---|---|
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 | typedef struct |
18 | typedef struct |
19 | { |
19 | { |
20 | u8 SWMajor; |
20 | u8 SWMajor; |
21 | u8 SWMinor; |
21 | u8 SWMinor; |
22 | u8 ProtoMajor; |
22 | u8 ProtoMajor; |
23 | u8 Reserved1; |
23 | u8 Reserved1; |
24 | u8 SWPatch; |
24 | u8 SWPatch; |
25 | u8 HardwareError[2]; |
25 | u8 HardwareError[2]; |
26 | u8 HWMajor; |
26 | u8 HWMajor; |
27 | u8 BL_Firmware; |
27 | u8 BL_Firmware; |
28 | u8 Flags; |
28 | u8 Flags; |
29 | } __attribute__((packed)) UART_VersionInfo_t; |
29 | } __attribute__((packed)) UART_VersionInfo_t; |
30 | 30 | ||
31 | extern UART_VersionInfo_t UART_VersionInfo; |
31 | extern UART_VersionInfo_t UART_VersionInfo; |
32 | 32 | ||
33 | //VersionInfo.Flags |
33 | //VersionInfo.Flags |
34 | #define NC_VERSION_FLAG_MK3MAG_PRESENT 0x01 |
34 | #define NC_VERSION_FLAG_MK3MAG_PRESENT 0x01 |
35 | #define NC_VERSION_FLAG_GPS_PRESENT 0x02 |
35 | #define NC_VERSION_FLAG_GPS_PRESENT 0x02 |
36 | 36 | ||
37 | typedef struct |
37 | typedef struct |
38 | { |
38 | { |
39 | s16 AngleNick; // in 0.1 deg |
39 | s16 AngleNick; // in 0.1 deg |
40 | s16 AngleRoll; // in 0.1 deg |
40 | s16 AngleRoll; // in 0.1 deg |
41 | s16 Heading; // in 0.1 deg |
41 | s16 Heading; // in 0.1 deg |
42 | u8 StickNick; |
42 | u8 StickNick; |
43 | u8 StickRoll; |
43 | u8 StickRoll; |
44 | u8 StickYaw; |
44 | u8 StickYaw; |
45 | u8 StickGas; |
45 | u8 StickGas; |
- | 46 | s16 Altimeter; // in 5cm |
|
46 | u8 reserve[4]; |
47 | u8 reserve[2]; |
47 | } __attribute__((packed)) Data3D_t; |
48 | } __attribute__((packed)) Data3D_t; |
48 | 49 | ||
49 | extern Data3D_t Data3D; |
50 | extern Data3D_t Data3D; |
50 | 51 | ||
51 | 52 | ||
52 | extern const u8 ANALOG_LABEL[32][16]; |
53 | extern const u8 ANALOG_LABEL[32][16]; |
53 | 54 | ||
54 | #define AMPEL_FC 0x01 |
55 | #define AMPEL_FC 0x01 |
55 | #define AMPEL_BL 0x02 |
56 | #define AMPEL_BL 0x02 |
56 | #define AMPEL_NC 0x04 |
57 | #define AMPEL_NC 0x04 |
57 | #define AMPEL_COMPASS 0x08 |
58 | #define AMPEL_COMPASS 0x08 |
58 | 59 | ||
59 | typedef struct |
60 | typedef struct |
60 | { |
61 | { |
61 | u8 StatusGreen; |
62 | u8 StatusGreen; |
62 | u8 StatusRed; |
63 | u8 StatusRed; |
63 | u16 Analog[32]; // Debugwerte |
64 | u16 Analog[32]; // Debugwerte |
64 | } __attribute__((packed)) DebugOut_t; |
65 | } __attribute__((packed)) DebugOut_t; |
65 | 66 | ||
66 | extern DebugOut_t DebugOut; |
67 | extern DebugOut_t DebugOut; |
67 | 68 | ||
68 | typedef struct |
69 | typedef struct |
69 | { |
70 | { |
70 | u8 Digital[2]; |
71 | u8 Digital[2]; |
71 | u8 RemoteButtons; |
72 | u8 RemoteButtons; |
72 | s8 Nick; |
73 | s8 Nick; |
73 | s8 Roll; |
74 | s8 Roll; |
74 | s8 Yaw; |
75 | s8 Yaw; |
75 | u8 Gas; |
76 | u8 Gas; |
76 | s8 Height; |
77 | s8 Height; |
77 | u8 free; |
78 | u8 free; |
78 | u8 Frame; |
79 | u8 Frame; |
79 | u8 Config; |
80 | u8 Config; |
80 | } __attribute__((packed)) ExternControl_t; |
81 | } __attribute__((packed)) ExternControl_t; |
81 | 82 | ||
82 | extern ExternControl_t ExternControl; |
83 | extern ExternControl_t ExternControl; |
83 | 84 | ||
84 | typedef struct |
85 | typedef struct |
85 | { |
86 | { |
86 | s16 Nick; |
87 | s16 Nick; |
87 | s16 Roll; |
88 | s16 Roll; |
88 | s16 Compass; // angle between north and head of the MK |
89 | s16 Compass; // angle between north and head of the MK |
89 | } __attribute__((packed)) Attitude_t; |
90 | } __attribute__((packed)) Attitude_t; |
90 | 91 | ||
91 | 92 | ||
92 | typedef struct |
93 | typedef struct |
93 | { |
94 | { |
94 | u16 Distance; // distance to target in dm |
95 | u16 Distance; // distance to target in dm |
95 | s16 Bearing; // course to target in deg |
96 | s16 Bearing; // course to target in deg |
96 | } __attribute__((packed)) GPS_PosDev_t; |
97 | } __attribute__((packed)) GPS_PosDev_t; |
97 | 98 | ||
98 | #define NAVIDATA_VERSION 5 |
99 | #define NAVIDATA_VERSION 5 |
99 | 100 | ||
100 | typedef struct |
101 | typedef struct |
101 | { |
102 | { |
102 | u8 Version; // version of the data structure |
103 | u8 Version; // version of the data structure |
103 | GPS_Pos_t CurrentPosition; // see gpspos.h for details |
104 | GPS_Pos_t CurrentPosition; // see gpspos.h for details |
104 | GPS_Pos_t TargetPosition; |
105 | GPS_Pos_t TargetPosition; |
105 | GPS_PosDev_t TargetPositionDeviation; |
106 | GPS_PosDev_t TargetPositionDeviation; |
106 | GPS_Pos_t HomePosition; |
107 | GPS_Pos_t HomePosition; |
107 | GPS_PosDev_t HomePositionDeviation; |
108 | GPS_PosDev_t HomePositionDeviation; |
108 | u8 WaypointIndex; // index of current waypoints running from 0 to WaypointNumber-1 |
109 | u8 WaypointIndex; // index of current waypoints running from 0 to WaypointNumber-1 |
109 | u8 WaypointNumber; // number of stored waypoints |
110 | u8 WaypointNumber; // number of stored waypoints |
110 | u8 SatsInUse; // number of satellites used for position solution |
111 | u8 SatsInUse; // number of satellites used for position solution |
111 | s16 Altimeter; // hight according to air pressure |
112 | s16 Altimeter; // hight according to air pressure |
112 | s16 Variometer; // climb(+) and sink(-) rate |
113 | s16 Variometer; // climb(+) and sink(-) rate |
113 | u16 FlyingTime; // in seconds |
114 | u16 FlyingTime; // in seconds |
114 | u8 UBat; // Battery Voltage in 0.1 Volts |
115 | u8 UBat; // Battery Voltage in 0.1 Volts |
115 | u16 GroundSpeed; // speed over ground in cm/s (2D) |
116 | u16 GroundSpeed; // speed over ground in cm/s (2D) |
116 | s16 Heading; // current flight direction in ° as angle to north |
117 | s16 Heading; // current flight direction in ° as angle to north |
117 | s16 CompassHeading; // current compass value in ° |
118 | s16 CompassHeading; // current compass value in ° |
118 | s8 AngleNick; // current Nick angle in 1° |
119 | s8 AngleNick; // current Nick angle in 1° |
119 | s8 AngleRoll; // current Rick angle in 1° |
120 | s8 AngleRoll; // current Rick angle in 1° |
120 | u8 RC_Quality; // RC_Quality |
121 | u8 RC_Quality; // RC_Quality |
121 | u8 FCStatusFlags; // Flags from FC |
122 | u8 FCStatusFlags; // Flags from FC |
122 | u8 NCFlags; // Flags from NC |
123 | u8 NCFlags; // Flags from NC |
123 | u8 Errorcode; // 0 --> okay |
124 | u8 Errorcode; // 0 --> okay |
124 | u8 WP_OperatingRadius; // current WP operation radius around the Home Position in m |
125 | u8 WP_OperatingRadius; // current WP operation radius around the Home Position in m |
125 | s16 TopSpeed; // velocity in vertical direction in cm/s |
126 | s16 TopSpeed; // velocity in vertical direction in cm/s |
126 | u8 TargetHoldTime; // time in s to stay at the given target, counts down to 0 if target has been reached |
127 | u8 TargetHoldTime; // time in s to stay at the given target, counts down to 0 if target has been reached |
127 | u8 FCStatusFlags2; // StatusFlags2 (since version 5 added) |
128 | u8 FCStatusFlags2; // StatusFlags2 (since version 5 added) |
128 | s16 SetpointAltitude; // setpoint for altitude |
129 | s16 SetpointAltitude; // setpoint for altitude |
129 | u8 Gas; // for future use |
130 | u8 Gas; // for future use |
130 | u16 Current; // actual current in 0.1A steps |
131 | u16 Current; // actual current in 0.1A steps |
131 | u16 UsedCapacity; // used capacity in mAh |
132 | u16 UsedCapacity; // used capacity in mAh |
132 | } __attribute__((packed)) NaviData_t; |
133 | } __attribute__((packed)) NaviData_t; |
133 | 134 | ||
134 | extern NaviData_t NaviData; |
135 | extern NaviData_t NaviData; |
135 | // .NCFlags |
136 | // .NCFlags |
136 | #define NC_FLAG_FREE 0x01 |
137 | #define NC_FLAG_FREE 0x01 |
137 | #define NC_FLAG_PH 0x02 |
138 | #define NC_FLAG_PH 0x02 |
138 | #define NC_FLAG_CH 0x04 |
139 | #define NC_FLAG_CH 0x04 |
139 | #define NC_FLAG_RANGE_LIMIT 0x08 |
140 | #define NC_FLAG_RANGE_LIMIT 0x08 |
140 | #define NC_FLAG_NOSERIALLINK 0x10 |
141 | #define NC_FLAG_NOSERIALLINK 0x10 |
141 | #define NC_FLAG_TARGET_REACHED 0x20 |
142 | #define NC_FLAG_TARGET_REACHED 0x20 |
142 | #define NC_FLAG_MANUAL_CONTROL 0x40 |
143 | #define NC_FLAG_MANUAL_CONTROL 0x40 |
143 | #define NC_FLAG_GPS_OK 0x80 |
144 | #define NC_FLAG_GPS_OK 0x80 |
144 | 145 | ||
145 | extern UART_TypeDef *DebugUART; |
146 | extern UART_TypeDef *DebugUART; |
146 | extern volatile u8 SerialLinkOkay; |
147 | extern volatile u8 SerialLinkOkay; |
147 | extern Buffer_t UART1_tx_buffer; |
148 | extern Buffer_t UART1_tx_buffer; |
148 | extern Buffer_t UART1_rx_buffer; |
149 | extern Buffer_t UART1_rx_buffer; |
149 | 150 | ||
150 | void UART1_Init(void); |
151 | void UART1_Init(void); |
151 | void UART1_Transmit(void); |
152 | void UART1_Transmit(void); |
152 | void UART1_TransmitTxData(void); |
153 | void UART1_TransmitTxData(void); |
153 | void UART1_ProcessRxData(void); |
154 | void UART1_ProcessRxData(void); |
154 | 155 | ||
155 | s16 UART1_Putchar(char c); |
156 | s16 UART1_Putchar(char c); |
156 | void UART1_PutString(u8 *s); |
157 | void UART1_PutString(u8 *s); |
157 | extern u8 text[]; // globally used text buffer |
158 | extern u8 text[]; // globally used text buffer |
158 | extern u8 UART1_Request_SendFollowMe; |
159 | extern u8 UART1_Request_SendFollowMe; |
159 | extern u8 LastTransmittedFCStatusFlags2; |
160 | extern u8 LastTransmittedFCStatusFlags2; |
160 | extern u8 UART1_Request_ReadPoint; |
161 | extern u8 UART1_Request_ReadPoint; |
161 | extern WPL_Store_t WPL_Store; |
162 | extern WPL_Store_t WPL_Store; |
162 | 163 | ||
163 | typedef struct |
164 | typedef struct |
164 | { |
165 | { |
165 | u8 User[128]; |
166 | u8 User[128]; |
166 | u8 eMail[128]; |
167 | u8 eMail[128]; |
167 | u8 Feature[128]; |
168 | u8 Feature[128]; |
168 | u8 Expire[11]; |
169 | u8 Expire[11]; |
169 | u8 License[16]; |
170 | u8 License[16]; |
170 | } __attribute__((packed)) LicenseS_t; // from FC |
171 | } __attribute__((packed)) LicenseS_t; // from FC |
171 | extern u8 *LicensePtr; |
172 | extern u8 *LicensePtr; |
172 | 173 | ||
173 | extern u32 NMEA_Interval;// in ms |
174 | extern u32 NMEA_Interval;// in ms |
174 | #define LICENSE_SIZE 480 |
175 | #define LICENSE_SIZE 480 |
175 | #define LICENSE_SIZE_TEXT 411 |
176 | #define LICENSE_SIZE_TEXT 411 |
176 | 177 | ||
177 | #endif //_UART1_H |
178 | #endif //_UART1_H |
178 | 179 |