Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1115 - 1
 
2
/****************************************************************/
3
/*                                                                                                                              */
4
/*                               NG-Video 5,8GHz                                                        */
5
/*                                                                                                                              */
6
/*                              Copyright (C) 2011 - gebad                                              */
7
/*                                                                                                                              */
8
/*  This code is distributed under the GNU Public License               */
9
/*      which can be found at http://www.gnu.org/licenses/gpl.txt       */
10
/*                                                                                                                              */
11
/****************************************************************/
12
 
13
#ifndef USART_H_
14
#define USART_H_
15
 
16
#define TRACKING_RSSI           1
17
#define TRACKING_GPS            2
18
#define TRACKING_MKCOCKPIT      3
19
 
20
#define RXD_BUFFER_SIZE 150   //Puffergröße in Byte
21
#define TXD_BUFFER_SIZE 20
22
#define ANY_ADDRESS             0
23
#define FC_ADDRESS              1
24
#define NC_ADDRESS              2
25
 
26
#define FC_FLAG_MOTOR_RUN               0x01
27
#define FC_FLAG_FLY                             0x02
28
#define FC_FLAG_CALIBRATE               0x04
29
#define FC_FLAG_MOTOR_START             0x08
30
 
31
#define NC_FLAG_GPS_OK                  0x80
32
 
33
#define RX_TIMEOUT      420                             // 210ms
34
#define RX_TIME_OLD     3 * RX_TIMEOUT  // Grenze, Datensatz viel zu alt
35
 
36
//volatile unsigned char buffercounter;
37
 
38
//char data_decode[RXD_BUFFER_SIZE];
39
volatile uint16_t rx_timeout;
40
 
41
void USART_Init(unsigned int baud);
42
void USART_send_Str(char *str );
43
uint8_t rx_line_decode(char rx_ID);
44
//void tx_Mk(unsigned char addr, char cmd, char *data, uint8_t len);
45
 
46
// Orginal H&I MK-Software 
47
typedef struct
48
{
49
        int32_t Longitude;  // in 1E-7 deg
50
        int32_t Latitude;       // in 1E-7 deg
51
        int32_t Altitude;       // in mm
52
        uint8_t Status;         // validity of data
53
} __attribute__((packed)) GPS_Pos_t;
54
 
55
typedef struct
56
{
57
        uint16_t Distance;                                      // distance to target in dm
58
        int16_t  Bearing;                                       // course to target in deg
59
} __attribute__((packed)) GPS_PosDev_t;
60
 
61
typedef struct
62
{
63
        uint8_t          Version;                                       // version of the data structure
64
        GPS_Pos_t        CurrentPosition;                       // see ubx.h for details
65
        GPS_Pos_t        TargetPosition;
66
        GPS_PosDev_t TargetPositionDeviation;
67
        GPS_Pos_t        HomePosition;
68
        GPS_PosDev_t HomePositionDeviation;
69
        uint8_t          WaypointIndex;                         // index of current waypoints running from 0 to WaypointNumber-1
70
        uint8_t          WaypointNumber;                        // number of stored waypoints
71
        uint8_t          SatsInUse;                                     // number of satellites used for position solution
72
        int16_t          Altimeter;                             // hight according to air pressure
73
        int16_t          Variometer;                            // climb(+) and sink(-) rate
74
        uint16_t         FlyingTime;                            // in seconds
75
        uint8_t          UBat;                                          // Battery Voltage in 0.1 Volts
76
        uint16_t         GroundSpeed;                           // speed over ground in cm/s (2D)
77
        int16_t          Heading;                                       // current flight direction in ° as angle to north
78
        int16_t          CompassHeading;                        // current compass value in °
79
        int8_t           AngleNick;                                     // current Nick angle in 1°
80
        int8_t           AngleRoll;                                     // current Roll angle in 1°
81
        uint8_t          RC_Quality;                            // RC_Quality
82
        uint8_t          FCStatusFlags;                         // Flags from FC
83
        uint8_t          NCFlags;                                       // Flags from NC
84
        uint8_t          Errorcode;                                     // 0 --> okay
85
        uint8_t          OperatingRadius;                       // current operation radius around the Home Position in m
86
        int16_t          TopSpeed;                                      // velocity in vertical direction in cm/s
87
        uint8_t          TargetHoldTime;                        // time in s to stay at the given target, counts down to 0 if target has been reached
88
        uint8_t          RC_RSSI;                                       // Receiver signal strength (since version 2 added)
89
        int16_t          SetpointAltitude;                      // setpoint for altitude
90
        uint8_t          Gas;                                           // for future use
91
        uint16_t         Current;                                       // actual current in 0.1A steps
92
        uint16_t         UsedCapacity;                          // used capacity in mAh
93
} __attribute__((packed)) NaviData_t;
94
 
95
typedef union
96
{
97
  char data_decode[RXD_BUFFER_SIZE];
98
  NaviData_t navi_data;
99
} MK_t;
100
 
101
MK_t MK;
102
 
103
typedef struct
104
{
105
  double        Home_Lon;
106
  double        Home_Lat;
107
  int32_t       Home_Lon_7;             // in 1E-7 deg
108
  int32_t       Home_Lat_7;             // in 1E-7 deg
109
  int32_t       Home_Alt;               // in mm
110
  int16_t       direction;              // ermittelte Konstante aus Mittelposition Antenne geo.bearing - navi_data.CompassHeading
111
} __attribute__((packed)) HomePos_t;
112
 
113
HomePos_t MK_pos;// steht hier nur wegen Vermeidung Compiler-Warnung
114
uint8_t wi232RX; // Statusflag für Empfangszeichen auf lcd
115
 
116
void USART_RX_Mode(uint8_t tracking);
117
uint8_t Get_Pololu_cmd(char *ptrOut, uint8_t ptrIn);
118
 
119
#endif /* USART_H_ */
120