Subversion Repositories NaviCtrl

Rev

Rev 75 | 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
{
        s16 Distance;                                   // distance to target in cm
        s16 Bearing;                                    // course to target in deg     
}  __attribute__((packed)) GPS_PosDev_t;

typedef struct
{
        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;                                  // no 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 deg as angle to north
        s16     CompassHeading;                         // current compass value
        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
        u8  Reserve[7];                                 // for future use
} __attribute__((packed)) NaviData_t;

extern NaviData_t NaviData;
extern u8 Request_NaviData;
                                                           
#define NC_FLAG_FREE                    1
#define NC_FLAG_PH                              2
#define NC_FLAG_CH                              4
#define NC_FLAG_RANGE_LIMIT             8

typedef struct
{
        u8 SWMajor;
        u8 SWMinor;
        u8 ProtoMajor;
        u8 ProtoMinor;
        u8 SWPatch;
        u8 Reserved[5];
}  __attribute__((packed)) UART_VersionInfo_t;

extern volatile u8 rxd_buffer[RXD_BUFFER_LEN];
extern volatile u8 ReceivedBytes;
extern volatile u8 rxd_buffer_locked;
extern UART_TypeDef *DebugUART;


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];
extern u32 Request_NaviData_Intervall; // in ms
extern u8 Request_SendFollowMe;
#endif //_UART1_H