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