0,0 → 1,120 |
|
/****************************************************************/ |
/* */ |
/* NG-Video 5,8GHz */ |
/* */ |
/* Copyright (C) 2011 - gebad */ |
/* */ |
/* This code is distributed under the GNU Public License */ |
/* which can be found at http://www.gnu.org/licenses/gpl.txt */ |
/* */ |
/****************************************************************/ |
|
#ifndef USART_H_ |
#define USART_H_ |
|
#define TRACKING_RSSI 1 |
#define TRACKING_GPS 2 |
#define TRACKING_MKCOCKPIT 3 |
|
#define RXD_BUFFER_SIZE 150 //Puffergröße in Byte |
#define TXD_BUFFER_SIZE 20 |
#define ANY_ADDRESS 0 |
#define FC_ADDRESS 1 |
#define NC_ADDRESS 2 |
|
#define FC_FLAG_MOTOR_RUN 0x01 |
#define FC_FLAG_FLY 0x02 |
#define FC_FLAG_CALIBRATE 0x04 |
#define FC_FLAG_MOTOR_START 0x08 |
|
#define NC_FLAG_GPS_OK 0x80 |
|
#define RX_TIMEOUT 420 // 210ms |
#define RX_TIME_OLD 3 * RX_TIMEOUT // Grenze, Datensatz viel zu alt |
|
//volatile unsigned char buffercounter; |
|
//char data_decode[RXD_BUFFER_SIZE]; |
volatile uint16_t rx_timeout; |
|
void USART_Init(unsigned int baud); |
void USART_send_Str(char *str ); |
uint8_t rx_line_decode(char rx_ID); |
//void tx_Mk(unsigned char addr, char cmd, char *data, uint8_t len); |
|
// Orginal H&I MK-Software |
typedef struct |
{ |
int32_t Longitude; // in 1E-7 deg |
int32_t Latitude; // in 1E-7 deg |
int32_t Altitude; // in mm |
uint8_t Status; // validity of data |
} __attribute__((packed)) GPS_Pos_t; |
|
typedef struct |
{ |
uint16_t Distance; // distance to target in dm |
int16_t Bearing; // course to target in deg |
} __attribute__((packed)) GPS_PosDev_t; |
|
typedef struct |
{ |
uint8_t Version; // version of the data structure |
GPS_Pos_t CurrentPosition; // see ubx.h for details |
GPS_Pos_t TargetPosition; |
GPS_PosDev_t TargetPositionDeviation; |
GPS_Pos_t HomePosition; |
GPS_PosDev_t HomePositionDeviation; |
uint8_t WaypointIndex; // index of current waypoints running from 0 to WaypointNumber-1 |
uint8_t WaypointNumber; // number of stored waypoints |
uint8_t SatsInUse; // number of satellites used for position solution |
int16_t Altimeter; // hight according to air pressure |
int16_t Variometer; // climb(+) and sink(-) rate |
uint16_t FlyingTime; // in seconds |
uint8_t UBat; // Battery Voltage in 0.1 Volts |
uint16_t GroundSpeed; // speed over ground in cm/s (2D) |
int16_t Heading; // current flight direction in ° as angle to north |
int16_t CompassHeading; // current compass value in ° |
int8_t AngleNick; // current Nick angle in 1° |
int8_t AngleRoll; // current Roll angle in 1° |
uint8_t RC_Quality; // RC_Quality |
uint8_t FCStatusFlags; // Flags from FC |
uint8_t NCFlags; // Flags from NC |
uint8_t Errorcode; // 0 --> okay |
uint8_t OperatingRadius; // current operation radius around the Home Position in m |
int16_t TopSpeed; // velocity in vertical direction in cm/s |
uint8_t TargetHoldTime; // time in s to stay at the given target, counts down to 0 if target has been reached |
uint8_t RC_RSSI; // Receiver signal strength (since version 2 added) |
int16_t SetpointAltitude; // setpoint for altitude |
uint8_t Gas; // for future use |
uint16_t Current; // actual current in 0.1A steps |
uint16_t UsedCapacity; // used capacity in mAh |
} __attribute__((packed)) NaviData_t; |
|
typedef union |
{ |
char data_decode[RXD_BUFFER_SIZE]; |
NaviData_t navi_data; |
} MK_t; |
|
MK_t MK; |
|
typedef struct |
{ |
double Home_Lon; |
double Home_Lat; |
int32_t Home_Lon_7; // in 1E-7 deg |
int32_t Home_Lat_7; // in 1E-7 deg |
int32_t Home_Alt; // in mm |
int16_t direction; // ermittelte Konstante aus Mittelposition Antenne geo.bearing - navi_data.CompassHeading |
} __attribute__((packed)) HomePos_t; |
|
HomePos_t MK_pos;// steht hier nur wegen Vermeidung Compiler-Warnung |
uint8_t wi232RX; // Statusflag für Empfangszeichen auf lcd |
|
void USART_RX_Mode(uint8_t tracking); |
uint8_t Get_Pololu_cmd(char *ptrOut, uint8_t ptrIn); |
|
#endif /* USART_H_ */ |
|