Subversion Repositories NaviCtrl

Rev

Rev 101 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#ifndef _UART1_H
#define _UART1_H

#define UART_FLIGHTCTRL 0
#define UART_MK3MAG     1
#define UART_MKGPS      2

#define TXD_BUFFER_LEN  150
#define RXD_BUFFER_LEN  150
#define BAUD_RATE 57600         //Baud Rate for the serial interfaces

#include "ubx.h"

typedef struct
{
   s16 AngleNick;       // in 0.1 deg
   s16 AngleRoll;   // in 0.1 deg
   s16 Heading;         // in 0.1 deg
   u8 reserve[8];
} __attribute__((packed)) Data3D_t;

extern Data3D_t Data3D;

typedef struct
{
        u8 Digital[2];
        u16 Analog[32];    // Debugwerte
} __attribute__((packed)) DebugOut_t;

extern DebugOut_t DebugOut;

typedef struct
{
        u8      Digital[2];
        u8      RemoteButtons;
        s8      Nick;
        s8      Roll;
        s8      Yaw;
        u8      Gas;
        s8      Height;
        u8      free;
        u8      Frame;
        u8      Config;
} __attribute__((packed)) ExternControl_t;

extern ExternControl_t ExternControl;

typedef struct
{
        s16 Nick;
        s16 Roll;
        s16 Compass;                                    // angle between north and head of the MK
}  __attribute__((packed)) Attitude_t;

typedef struct
{
        u16 Distance;                                   // distance to target in dm
        s16 Bearing;                                    // course to target in deg
}  __attribute__((packed)) GPS_PosDev_t;

#define NAVIDATA_VERSION 1

typedef struct
{
        u8 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;
        u8  WaypointIndex;                              // index of current waypoints running from 0 to WaypointNumber-1
        u8  WaypointNumber;                             // number of stored waypoints
        u8  SatsInUse;                                  // number of satellites used for position solution
        s16 Altimeter;                                  // hight according to air pressure
        s16 Variometer;                                 // climb(+) and sink(-) rate
        u16 FlyingTime;                                 // in seconds
        u8  UBat;                                               // Battery Voltage in 0.1 Volts
        u16 GroundSpeed;                                // speed over ground in cm/s (2D)
        s16 Heading;                                    // current flight direction in ° as angle to north
        s16     CompassHeading;                         // current compass value in °
        s8  AngleNick;                                  // current Nick angle in 1°
        s8  AngleRoll;                                  // current Rick angle in 1°
        u8  RC_Quality;                                 // RC_Quality
        u8  MKFlags;                                    // Flags from FC
        u8  NCFlags;                                    // Flags from NC
        u8  Errorcode;                                  // 0 --> okay
    u8  OperatingRadius;                        // current operation radius around the Home Position in m
        s16 TopSpeed;                                   // velocity in vertical direction in cm/s
        u8 TargetHoldTime;                              // time in s to stay at the given target, counts down to 0 if target has been reached
        u8  Reserve[4];                                 // for future use
} __attribute__((packed)) NaviData_t;

extern NaviData_t NaviData;
extern u8 Request_NaviData;

#define NC_FLAG_FREE                    0x01
#define NC_FLAG_PH                              0x02
#define NC_FLAG_CH                              0x04
#define NC_FLAG_RANGE_LIMIT             0x08
#define NC_FLAG_NOSERIALLINK    0x10
#define NC_FLAG_TARGET_REACHED  0x20
#define NC_FLAG_MANUAL_CONTROL  0x40
#define NC_FLAG_8                               0x80

extern UART_TypeDef *DebugUART;
extern volatile u8 SerialLinkOkay;


void UART1_Init(void);
void UART1_Transmit(void);
void UART1_TransmitTxData(void);
void UART1_ProcessRxData(void);

s16 uart_putchar (char c);
void SerialPutString(u8 *s);
extern u8 text[100]; // globally used text buffer
extern u8 Request_SendFollowMe;
#endif //_UART1_H