Subversion Repositories NaviCtrl

Rev

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

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