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