Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 751 → Rev 752

/branches/V0.68d Code Redesign killagreg/GPS.c
107,8 → 107,8
void GPS_Main(void)
{
static uint8_t GPS_Task = TSK_IDLE;
int16_t satbeep;
 
 
// poti2 enables the gps feature
if(Poti2 < 70) GPS_Task = TSK_IDLE;
else if (Poti2 < 160) GPS_Task = TSK_HOLD;
119,7 → 119,10
{
case INVALID: // invalid gps data
GPS_Neutral();
if(GPS_Task != TSK_IDLE) BeepTime = 50; // beep if signal is neccesary
if(GPS_Task != TSK_IDLE)
{
BeepTime = 100; // beep if signal is neccesary
}
break;
case PROCESSED: // if gps data are already processed
// downcount timeout
199,9 → 202,13
else // no 3D-SATFIX
{ // disable gps control
GPS_Neutral();
if(GPS_Task != TSK_IDLE) BeepTime = 50;
if(GPS_Task != TSK_IDLE)
{
satbeep = 2048 - (int16_t)GPSInfo.satnum * 256; // is zero at 8 sats
if (satbeep < 0) satbeep = 0;
BeepTime = 50 + (uint16_t)satbeep;
}
}
 
// set current data as processed to avoid further calculations on the same gps data
GPSInfo.status = PROCESSED;
break;
/branches/V0.68d Code Redesign killagreg/main.c
121,7 → 121,9
TIMER0_Init();
TIMER2_Init();
USART0_Init();
if (BoardRelease != 10) USART1_Init();
#if defined (__AVR_ATmega644p__)
if (BoardRelease != 10) USART1_Init();
#endif
RC_Init();
ADC_Init();
I2C_Init();
236,7 → 238,6
if(BeepModulation == 0xFFFF)
{
BeepTime = 6000; // 0.6 seconds
BeepModulation = 0x0300;
}
}
//SPI_StartTransmitPacket();//#
/branches/V0.68d Code Redesign killagreg/makefile
76,8 → 76,10
# List C source files here. (C dependencies are automatically generated.)
SRC = main.c uart.c printf_P.c timer0.c timer2.c analog.c menu.c
SRC += twimaster.c rc.c fc.c GPS.c spi.c eeprom.c mm3.c
SRC += mymath.c ubx.c fifo.c uart1.c
 
SRC += mymath.c ubx.c fifo.c
ifeq ($(MCU), atmega644p)
SRC += uart1.c
endif
##########################################################################################################
 
 
/branches/V0.68d Code Redesign killagreg/menu.c
19,6 → 19,7
#include "ubx.h"
#include "_Settings.h"
 
 
#define ARRAYSIZE 10
uint8_t Array[ARRAYSIZE] = {1,2,3,4,5,6,7,8,9,10};
#define DISPLAYBUFFSIZE 80
48,7 → 49,7
// Display with 20 characters in 4 lines
void LCD_PrintMenu(void)
{
static uint8_t MaxMenuItem = 16, MenuItem=0;
static uint8_t MaxMenuItem = 14, MenuItem=0;
 
// if KEY1 is activated goto previous menu item
if(RemoteButtons & KEY1)
170,7 → 171,7
LCD_printfxy(0,2,"Gs:%4i Ya:%4i ",ExternControl.Thrust, ExternControl.Yaw);
LCD_printfxy(0,3,"Hi:%4i Cf:%4i ",ExternControl.Hight, ExternControl.Config);
break;
case 12:// MM3 Kompass
case 12:// MM3 Kompass
LCD_printfxy(0,0,"MM3 Offset");
LCD_printfxy(0,1,"X_Offset: %3i",MM3_calib.X_off);
LCD_printfxy(0,2,"Y_Offset: %3i",MM3_calib.Y_off);
192,16 → 193,16
switch (GPSInfo.satfix)
{
case SATFIX_NONE:
LCD_printfxy(0,0,"Satfix: None ");
LCD_printfxy(0,0,"Sats: %d Fix: No", GPSInfo.satnum);
break;
case SATFIX_2D:
LCD_printfxy(0,0,"Satfix: 2D ");
LCD_printfxy(0,0,"Sats: %d Fix: 2D", GPSInfo.satnum);
break;
case SATFIX_3D:
LCD_printfxy(0,0,"Satfix: 3D ");
LCD_printfxy(0,0,"Sats: %d Fix: 3D", GPSInfo.satnum);
break;
default:
LCD_printfxy(0,0,"Satfix: Unknown");
LCD_printfxy(0,0,"Sats: %d Fix: ??", GPSInfo.satnum);
break;
}
LCD_printfxy(0,1,"Lon: %d.%d deg",GPSInfo.longitude/10000000L, (GPSInfo.longitude%10000000L)/10000L);
209,60 → 210,6
LCD_printfxy(0,3,"Alt: %d.%d m",GPSInfo.altitude/1000L,GPSInfo.altitude%1000L);
}
break;
case 15://GPS UTM coords
if (GPSInfo.status == INVALID)
{
LCD_printfxy(0,0,"No data available!");
}
else
{
switch (GPSInfo.satfix)
{
case SATFIX_NONE:
LCD_printfxy(0,0,"No Satfix ");
break;
case SATFIX_2D:
LCD_printfxy(0,0,"Satfix: 2D ");
break;
case SATFIX_3D:
LCD_printfxy(0,0,"Satfix: 3D ");
break;
default:
LCD_printfxy(0,0,"Unknown Satfix ");
break;
}
LCD_printfxy(0,1,"N: %d",(int16_t)(GPSInfo.utmnorth/100L));
LCD_printfxy(0,2,"E: %d",(int16_t)(GPSInfo.utmeast/100L));
LCD_printfxy(0,3,"A: %d",(int16_t)(GPSInfo.utmalt/100L));
}
break;
case 16://GPS UTM velocity
if (GPSInfo.status == INVALID)
{
LCD_printfxy(0,0,"No data available!");
}
else
{
switch (GPSInfo.satfix)
{
case SATFIX_NONE:
LCD_printfxy(0,0,"No Satfix ");
break;
case SATFIX_2D:
LCD_printfxy(0,0,"Satfix: 2D ");
break;
case SATFIX_3D:
LCD_printfxy(0,0,"Satfix: 3D ");
break;
default:
LCD_printfxy(0,0,"Unknown Satfix ");
break;
}
LCD_printfxy(0,1,"VN: %d",GPSInfo.velnorth);
LCD_printfxy(0,2,"VE: %d",GPSInfo.veleast);
LCD_printfxy(0,3,"VA: %d",GPSInfo.veltop);
}
break;
default: MaxMenuItem = MenuItem - 1;
MenuItem = 0;
break;
/branches/V0.68d Code Redesign killagreg/ubx.c
18,23 → 18,35
 
// ublox protocoll identifier
#define UBX_CLASS_NAV 0x01
 
#define UBX_ID_POSLLH 0x02
#define UBX_ID_SOL 0x06
#define UBX_ID_POSUTM 0x08
#define UBX_ID_STATUS 0x03
#define UBX_ID_VELNED 0x12
 
#define UBX_SYNC1_CHAR 0xB5
#define UBX_SYNC2_CHAR 0x62
 
typedef struct {
uint32_t ITOW; // ms GPS Millisecond Time of Week
int32_t Frac; // ns remainder of rounded ms above
int16_t week; // GPS week
uint8_t GPSfix; // GPSfix Type, range 0..6
uint8_t Flags; // Navigation Status Flags
uint8_t DiffS; // Differential Status
uint8_t res; // reserved
uint32_t TTFF; // Time to first fix (millisecond time tag)
uint32_t MSSS; // Milliseconds since Startup / Reset
int32_t ECEF_X; // cm ECEF X coordinate
int32_t ECEF_Y; // cm ECEF Y coordinate
int32_t ECEF_Z; // cm ECEF Z coordinate
uint32_t PAcc; // cm 3D Position Accuracy Estimate
int32_t ECEFVX; // cm/s ECEF X velocity
int32_t ECEFVY; // cm/s ECEF Y velocity
int32_t ECEFVZ; // cm/s ECEF Z velocity
uint32_t SAcc; // cm/s Speed Accuracy Estimate
uint16_t PDOP; // 0.01 Position DOP
uint8_t res1; // reserved
uint8_t numSV; // Number of SVs used in navigation solution
uint32_t res2; // reserved
uint8_t Status;
} GPS_STATUS_t;
} GPS_SOL_t;
 
typedef struct {
uint32_t ITOW; // ms GPS Millisecond Time of Week
70,8 → 82,7
uint8_t Status;
} GPS_VELNED_t;
 
 
GPS_STATUS_t GpsStatus = {0,0,0,0,0,0,0, INVALID};
GPS_SOL_t GpsSol = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, INVALID};
GPS_POSLLH_t GpsPosLlh = {0,0,0,0,0,0,0, INVALID};
GPS_POSUTM_t GpsPosUtm = {0,0,0,0,0,0, INVALID};
GPS_VELNED_t GpsVelNed = {0,0,0,0,0,0,0,0,0, INVALID};
81,10 → 92,13
 
void UpdateGPSInfo (void)
{
if (GpsStatus.Status == VALID) // valid packet
if (GpsSol.Status == VALID) // valid packet
{
GPSInfo.satfix = GpsStatus.GPSfix;
GpsStatus.Status = PROCESSED; // never update old data
GPSInfo.satfix = GpsSol.GPSfix;
GPSInfo.satnum = GpsSol.numSV;
GPSInfo.PAcc = GpsSol.PAcc;
GPSInfo.VAcc = GpsSol.SAcc;
GpsSol.Status = PROCESSED; // never update old data
}
if (GpsPosLlh.Status == VALID) // valid packet
{
107,7 → 121,7
GPSInfo.veltop = -GpsVelNed.VEL_D;
GpsVelNed.Status = PROCESSED; // never update old data
}
if (GpsStatus.Status != INVALID)
if ((GpsSol.Status != INVALID) && (GpsPosLlh.Status != INVALID) && (GpsPosUtm.Status != INVALID) && (GpsVelNed.Status != INVALID))
{
GPSInfo.status = VALID; // set valid if data are updated
}
154,10 → 168,10
ubxSp = (int8_t *)&GpsPosLlh.Status; // status pointer
break;
 
case UBX_ID_STATUS: // receiver status
ubxP = (int8_t *)&GpsStatus; // data start pointer
ubxEp = (int8_t *)(&GpsStatus + sizeof(GPS_STATUS_t)); // data end pointer
ubxSp = (int8_t *)&GpsStatus.Status; // status pointer
case UBX_ID_SOL: // navigation solution
ubxP = (int8_t *)&GpsSol; // data start pointer
ubxEp = (int8_t *)(&GpsSol + sizeof(GPS_SOL_t)); // data end pointer
ubxSp = (int8_t *)&GpsSol.Status; // status pointer
break;
 
case UBX_ID_VELNED: // velocity vector in tangent plane
/branches/V0.68d Code Redesign killagreg/ubx.h
18,7 → 18,7
 
/* enable the UBX protocol at the gps receiver with the following messages enabled
01-02 NAV - POSLLH
01-03 NAV - STATUS
01-06 Nav - SOL
01-08 NAV - POSUTM
01-12 NAV - VELNED */
 
25,13 → 25,16
 
typedef struct
{
uint8_t satnum; // number of satelites
uint8_t satfix; // type of satfix
int32_t utmnorth; // in cm (+ = north)
int32_t utmeast; // in cm (+ = east)
int32_t utmalt; // in cm (+ = top)
uint32_t PAcc; // in cm 3d position accuracy
int32_t velnorth; // in cm/s
int32_t veleast; // in cm/s
int32_t veltop; // in cm/s
uint32_t VAcc; // in cm/s 3d velocity accuracy
int32_t longitude; // in 1e-07 deg
int32_t latitude; // in 1e-07 deg
int32_t altitude; // in mm