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