Subversion Repositories NaviCtrl

Rev

Rev 225 | Rev 254 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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