Subversion Repositories NaviCtrl

Rev

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

Rev 101 Rev 110
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
 
-
 
8
#define TXD_BUFFER_LEN  150
-
 
9
#define RXD_BUFFER_LEN  150
-
 
10
#define BAUD_RATE 57600         //Baud Rate for the serial interfaces
-
 
11
 
7
 
12
#include "ubx.h"
8
#include "ubx.h"
13
 
9
 
14
typedef struct
10
typedef struct
15
{
11
{
16
   s16 AngleNick;       // in 0.1 deg
12
   s16 AngleNick;       // in 0.1 deg
17
   s16 AngleRoll;   // in 0.1 deg
13
   s16 AngleRoll;   // in 0.1 deg
18
   s16 Heading;         // in 0.1 deg
14
   s16 Heading;         // in 0.1 deg
19
   u8 reserve[8];
15
   u8 reserve[8];
20
} __attribute__((packed)) Data3D_t;
16
} __attribute__((packed)) Data3D_t;
21
 
17
 
22
extern Data3D_t Data3D;
18
extern Data3D_t Data3D;
23
 
19
 
24
typedef struct
20
typedef struct
25
{
21
{
26
        u8 Digital[2];
22
        u8 Digital[2];
27
        u16 Analog[32];    // Debugwerte
23
        u16 Analog[32];    // Debugwerte
28
} __attribute__((packed)) DebugOut_t;
24
} __attribute__((packed)) DebugOut_t;
29
 
25
 
30
extern DebugOut_t DebugOut;
26
extern DebugOut_t DebugOut;
31
 
27
 
32
typedef struct
28
typedef struct
33
{
29
{
34
        u8      Digital[2];
30
        u8      Digital[2];
35
        u8      RemoteButtons;
31
        u8      RemoteButtons;
36
        s8      Nick;
32
        s8      Nick;
37
        s8      Roll;
33
        s8      Roll;
38
        s8      Yaw;
34
        s8      Yaw;
39
        u8      Gas;
35
        u8      Gas;
40
        s8      Height;
36
        s8      Height;
41
        u8      free;
37
        u8      free;
42
        u8      Frame;
38
        u8      Frame;
43
        u8      Config;
39
        u8      Config;
44
} __attribute__((packed)) ExternControl_t;
40
} __attribute__((packed)) ExternControl_t;
45
 
41
 
46
extern ExternControl_t ExternControl;
42
extern ExternControl_t ExternControl;
47
 
43
 
48
typedef struct
44
typedef struct
49
{
45
{
50
        s16 Nick;
46
        s16 Nick;
51
        s16 Roll;
47
        s16 Roll;
52
        s16 Compass;                                    // angle between north and head of the MK
48
        s16 Compass;                                    // angle between north and head of the MK
53
}  __attribute__((packed)) Attitude_t;
49
}  __attribute__((packed)) Attitude_t;
54
 
50
 
55
typedef struct
51
typedef struct
56
{
52
{
57
        u16 Distance;                                   // distance to target in dm
53
        u16 Distance;                                   // distance to target in dm
58
        s16 Bearing;                                    // course to target in deg
54
        s16 Bearing;                                    // course to target in deg
59
}  __attribute__((packed)) GPS_PosDev_t;
55
}  __attribute__((packed)) GPS_PosDev_t;
60
 
56
 
61
#define NAVIDATA_VERSION 1
57
#define NAVIDATA_VERSION 1
62
 
58
 
63
typedef struct
59
typedef struct
64
{
60
{
65
        u8 Version;                                             // version of the data structure
61
        u8 Version;                                             // version of the data structure
66
        GPS_Pos_t CurrentPosition;              // see ubx.h for details
62
        GPS_Pos_t CurrentPosition;              // see ubx.h for details
67
        GPS_Pos_t TargetPosition;
63
        GPS_Pos_t TargetPosition;
68
        GPS_PosDev_t TargetPositionDeviation;
64
        GPS_PosDev_t TargetPositionDeviation;
69
        GPS_Pos_t HomePosition;
65
        GPS_Pos_t HomePosition;
70
        GPS_PosDev_t HomePositionDeviation;
66
        GPS_PosDev_t HomePositionDeviation;
71
        u8  WaypointIndex;                              // index of current waypoints running from 0 to WaypointNumber-1
67
        u8  WaypointIndex;                              // index of current waypoints running from 0 to WaypointNumber-1
72
        u8  WaypointNumber;                             // number of stored waypoints
68
        u8  WaypointNumber;                             // number of stored waypoints
73
        u8  SatsInUse;                                  // number of satellites used for position solution
69
        u8  SatsInUse;                                  // number of satellites used for position solution
74
        s16 Altimeter;                                  // hight according to air pressure
70
        s16 Altimeter;                                  // hight according to air pressure
75
        s16 Variometer;                                 // climb(+) and sink(-) rate
71
        s16 Variometer;                                 // climb(+) and sink(-) rate
76
        u16 FlyingTime;                                 // in seconds
72
        u16 FlyingTime;                                 // in seconds
77
        u8  UBat;                                               // Battery Voltage in 0.1 Volts
73
        u8  UBat;                                               // Battery Voltage in 0.1 Volts
78
        u16 GroundSpeed;                                // speed over ground in cm/s (2D)
74
        u16 GroundSpeed;                                // speed over ground in cm/s (2D)
79
        s16 Heading;                                    // current flight direction in ° as angle to north
75
        s16 Heading;                                    // current flight direction in ° as angle to north
80
        s16     CompassHeading;                         // current compass value in °
76
        s16     CompassHeading;                         // current compass value in °
81
        s8  AngleNick;                                  // current Nick angle in 1°
77
        s8  AngleNick;                                  // current Nick angle in 1°
82
        s8  AngleRoll;                                  // current Rick angle in 1°
78
        s8  AngleRoll;                                  // current Rick angle in 1°
83
        u8  RC_Quality;                                 // RC_Quality
79
        u8  RC_Quality;                                 // RC_Quality
84
        u8  MKFlags;                                    // Flags from FC
80
        u8  MKFlags;                                    // Flags from FC
85
        u8  NCFlags;                                    // Flags from NC
81
        u8  NCFlags;                                    // Flags from NC
86
        u8  Errorcode;                                  // 0 --> okay
82
        u8  Errorcode;                                  // 0 --> okay
87
    u8  OperatingRadius;                        // current operation radius around the Home Position in m
83
    u8  OperatingRadius;                        // current operation radius around the Home Position in m
88
        s16 TopSpeed;                                   // velocity in vertical direction in cm/s
84
        s16 TopSpeed;                                   // velocity in vertical direction in cm/s
89
        u8 TargetHoldTime;                              // time in s to stay at the given target, counts down to 0 if target has been reached
85
        u8 TargetHoldTime;                              // time in s to stay at the given target, counts down to 0 if target has been reached
90
        u8  Reserve[4];                                 // for future use
86
        u8  Reserve[4];                                 // for future use
91
} __attribute__((packed)) NaviData_t;
87
} __attribute__((packed)) NaviData_t;
92
 
88
 
93
extern NaviData_t NaviData;
89
extern NaviData_t NaviData;
94
extern u8 Request_NaviData;
90
extern u8 Request_NaviData;
95
 
91
 
96
#define NC_FLAG_FREE                    0x01
92
#define NC_FLAG_FREE                    0x01
97
#define NC_FLAG_PH                              0x02
93
#define NC_FLAG_PH                              0x02
98
#define NC_FLAG_CH                              0x04
94
#define NC_FLAG_CH                              0x04
99
#define NC_FLAG_RANGE_LIMIT             0x08
95
#define NC_FLAG_RANGE_LIMIT             0x08
100
#define NC_FLAG_NOSERIALLINK    0x10
96
#define NC_FLAG_NOSERIALLINK    0x10
101
#define NC_FLAG_TARGET_REACHED  0x20
97
#define NC_FLAG_TARGET_REACHED  0x20
102
#define NC_FLAG_MANUAL_CONTROL  0x40
98
#define NC_FLAG_MANUAL_CONTROL  0x40
103
#define NC_FLAG_8                               0x80
99
#define NC_FLAG_8                               0x80
104
 
100
 
105
extern UART_TypeDef *DebugUART;
101
extern UART_TypeDef *DebugUART;
106
extern volatile u8 SerialLinkOkay;
102
extern volatile u8 SerialLinkOkay;
107
 
103
 
108
 
104
 
109
void UART1_Init(void);
105
void UART1_Init(void);
110
void UART1_Transmit(void);
106
void UART1_Transmit(void);
111
void UART1_TransmitTxData(void);
107
void UART1_TransmitTxData(void);
112
void UART1_ProcessRxData(void);
108
void UART1_ProcessRxData(void);
113
 
109
 
114
s16 uart_putchar (char c);
110
s16  UART1_Putchar(char c);
115
void SerialPutString(u8 *s);
111
void UART1_PutString(u8 *s);
116
extern u8 text[100]; // globally used text buffer
112
extern u8 text[100]; // globally used text buffer
117
extern u8 Request_SendFollowMe;
113
extern u8 UART1_Request_SendFollowMe;
118
#endif //_UART1_H
114
#endif //_UART1_H
119
 
115