Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1198 - 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                             // 420 * 0.5ms interval (16bit-Timer 2)
34
#define RX_TIME_OLD     3 * RX_TIMEOUT  // Grenze, Datensatz viel zu alt
35
#define RX_TIME_END     20* RX_TIMEOUT  // Zählerbegrenzung und lipo speichern
36
 
37
//volatile unsigned char buffercounter;
38
 
39
//char data_decode[RXD_BUFFER_SIZE];
40
volatile uint16_t rx_timeout;
41
 
42
void USART_Init(unsigned int baud);
43
void USART_send_Str(char *str );
44
uint8_t rx_line_decode(char rx_ID);
45
//void tx_Mk(unsigned char addr, char cmd, char *data, uint8_t len);
46
 
47
// Orginal H&I MK-Software 
48
typedef struct
49
{
50
        int32_t Longitude;  // in 1E-7 deg
51
        int32_t Latitude;       // in 1E-7 deg
52
        int32_t Altitude;       // in mm
53
        uint8_t Status;         // validity of data
54
} __attribute__((packed)) GPS_Pos_t;
55
 
56
typedef struct
57
{
58
        uint16_t Distance;                                      // distance to target in dm
59
        int16_t  Bearing;                                       // course to target in deg
60
} __attribute__((packed)) GPS_PosDev_t;
61
 
62
typedef struct
63
{
64
        uint8_t          Version;                                       // version of the data structure
65
        GPS_Pos_t        CurrentPosition;                       // see ubx.h for details
66
        GPS_Pos_t        TargetPosition;
67
        GPS_PosDev_t TargetPositionDeviation;
68
        GPS_Pos_t        HomePosition;
69
        GPS_PosDev_t HomePositionDeviation;
70
        uint8_t          WaypointIndex;                         // index of current waypoints running from 0 to WaypointNumber-1
71
        uint8_t          WaypointNumber;                        // number of stored waypoints
72
        uint8_t          SatsInUse;                                     // number of satellites used for position solution
73
        int16_t          Altimeter;                             // hight according to air pressure
74
        int16_t          Variometer;                            // climb(+) and sink(-) rate
75
        uint16_t         FlyingTime;                            // in seconds
76
        uint8_t          UBat;                                          // Battery Voltage in 0.1 Volts
77
        uint16_t         GroundSpeed;                           // speed over ground in cm/s (2D)
78
        int16_t          Heading;                                       // current flight direction in ° as angle to north
79
        int16_t          CompassHeading;                        // current compass value in °
80
        int8_t           AngleNick;                                     // current Nick angle in 1°
81
        int8_t           AngleRoll;                                     // current Roll angle in 1°
82
        uint8_t          RC_Quality;                            // RC_Quality
83
        uint8_t          FCStatusFlags;                         // Flags from FC
84
        uint8_t          NCFlags;                                       // Flags from NC
85
        uint8_t          Errorcode;                                     // 0 --> okay
86
        uint8_t          OperatingRadius;                       // current operation radius around the Home Position in m
87
        int16_t          TopSpeed;                                      // velocity in vertical direction in cm/s
88
        uint8_t          TargetHoldTime;                        // time in s to stay at the given target, counts down to 0 if target has been reached
89
        uint8_t          RC_RSSI;                                       // Receiver signal strength (since version 2 added)
90
        int16_t          SetpointAltitude;                      // setpoint for altitude
91
        uint8_t          Gas;                                           // for future use
92
        uint16_t         Current;                                       // actual current in 0.1A steps
93
        uint16_t         UsedCapacity;                          // used capacity in mAh
94
} __attribute__((packed)) NaviData_t;
95
 
96
typedef union
97
{
98
  char data_decode[RXD_BUFFER_SIZE];
99
  NaviData_t navi_data;
100
} MK_t;
101
 
102
MK_t MK;
103
 
104
typedef struct
105
{
106
  double        Home_Lon;
107
  double        Home_Lat;
108
  int32_t       Home_Lon_7;             // in 1E-7 deg
109
  int32_t       Home_Lat_7;             // in 1E-7 deg
110
  int32_t       Home_Alt;               // in mm
111
  int16_t       direction;              // ermittelte Konstante aus Mittelposition Antenne geo.bearing - navi_data.CompassHeading
112
} HomePos_t;
113
 
114
HomePos_t MK_pos;// steht hier nur wegen Vermeidung Compiler-Warnung
115
uint8_t wi232RX; // Statusflag für Empfangszeichen auf lcd
116
 
117
void USART_RX_Mode(uint8_t tracking);
118
uint8_t Get_Pololu_cmd(char *ptrOut, uint8_t ptrIn);
119
 
120
#endif /* USART_H_ */
121