Subversion Repositories NaviCtrl

Compare Revisions

Ignore whitespace Rev 20 → Rev 21

/branches/V0.1 killagreg/GPS.c
118,7 → 118,7
static File_t *GPSLogFile = 0;
s16 i1, i2, i3;
 
if((GPS_Data.Status != INVALID) && (GPS_Data.SatFix == SATFIX_3D))
if((GPSData.Status != INVALID) && (GPSData.SatFix == SATFIX_3D))
{
// if logfile is not opened
if(!GPSLogFile)
131,18 → 131,18
// if logfile
if(GPSLogFile)
{
i1 = (s16)(GPS_Data.Longitude/10000000L);
i2 = abs((s16)((GPS_Data.Longitude%10000000L)/10000L));
i3 = abs((s16)(((GPS_Data.Longitude%10000000L)%10000L)/10L));
i1 = (s16)(GPSData.Longitude/10000000L);
i2 = abs((s16)((GPSData.Longitude%10000000L)/10000L));
i3 = abs((s16)(((GPSData.Longitude%10000000L)%10000L)/10L));
sprintf(logtext,"%03d.%.3d%.3d\t",i1, i2, i3);
fputs_(logtext, GPSLogFile);
i1 = (s16)(GPS_Data.Latitude/10000000L);
i2 = abs((s16)((GPS_Data.Latitude%10000000L)/10000L));
i3 = abs((s16)(((GPS_Data.Latitude%10000000L)%10000L)/10L));
i1 = (s16)(GPSData.Latitude/10000000L);
i2 = abs((s16)((GPSData.Latitude%10000000L)/10000L));
i3 = abs((s16)(((GPSData.Latitude%10000000L)%10000L)/10L));
sprintf(logtext,"%03d.%.3d%.3d\t",i1, i2, i3);
fputs_(logtext, GPSLogFile);
i1 = (s16)(GPS_Data.Altitude/1000L);
i2 = abs((s16)(GPS_Data.Altitude%1000L));
i1 = (s16)(GPSData.Altitude/1000L);
i2 = abs((s16)(GPSData.Altitude%1000L));
sprintf(logtext,"%d.%.3d\r\n",i1, i2);
fputs_(logtext, GPSLogFile);
if(CheckDelay(Flushtime))
190,37 → 190,37
else if(GPSParameter.ModeSwitch < 180) GpsFlightMode = GPS_MODE_FREE;
else GpsFlightMode = GPS_MODE_HOME;
// Mode changed?
if(GpsFlightMode != oldGpsFlightMode) BeepTime = 100; // indicate that mode has switched
if(GpsFlightMode != oldGpsFlightMode) BeepTime = 100; // indicate that mode has switched
 
// look for new data from GPS
switch(GPS_Data.Status)
switch(GPSData.Status)
{
case INVALID: // no gps data available
case INVALID: // no gps data available
break;
case NEWDATA: // handle new gps data
// wait maximum of 3 times the normal data update time
GPSDataTimeout = SetDelay(3*GPS_Data.UpdateTime);
GPSDataTimeout = SetDelay(3*GPSData.UpdateTime);
LogGPSData(); // write gps position to file
// set debug values
DebugOut.Analog[21] = (s16)GPS_Data.Speed_North;
DebugOut.Analog[22] = (s16)GPS_Data.Speed_East;
DebugOut.Analog[31] = GPS_Data.NumOfSats;
GPS_Data.Status = PROCESSED; // mark as processed
DebugOut.Analog[21] = (s16)GPSData.Speed_North;
DebugOut.Analog[22] = (s16)GPSData.Speed_East;
DebugOut.Analog[31] = GPSData.NumOfSats;
GPSData.Status = PROCESSED; // mark as processed
break;
case PROCESSED:
if(CheckDelay(GPSDataTimeout)) GPS_Data.Status = INVALID;
if(CheckDelay(GPSDataTimeout)) GPSData.Status = INVALID;
break;
}
 
 
 
if((GPS_Data.Status != INVALID)) // there are valid data from the GPS
if((GPSData.Status != INVALID)) // there are valid data from the GPS
{
 
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+ Fix okay and enough sats
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if((GPS_Data.Flags & FLAG_GPSFIXOK) && (GPS_Data.NumOfSats >= GPS_SAT_MIN))
if((GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.NumOfSats >= GPS_SAT_MIN))
{
// here is a good place to put your GPS code...
GPSStick.Nick = 0; // do nothing
232,19 → 232,19
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
GPS_Neutral(); // disable gps control
if(!(GPS_Data.Flags & FLAG_GPSFIXOK) && !(beep_rythm % 5)) BeepTime = 100;
else if (GPS_Data.NumOfSats < GPS_SAT_MIN && !(beep_rythm % 5)) BeepTime = 10;
 
if(!(GPSData.Flags & FLAG_GPSFIXOK) && !(beep_rythm % 5)) BeepTime = 100;
else if (GPSData.NumOfSats < GPS_SAT_MIN && !(beep_rythm % 5)) BeepTime = 10;
}
}
else // GPS Data are invalid
{
GPS_Neutral(); // disable gps control
GPS_Neutral(); // disable gps control
}
 
DebugOut.Analog[29] = GPSStick.Nick;
DebugOut.Analog[30] = GPSStick.Roll;
 
return (0);
}
 
/branches/V0.1 killagreg/GPSUart.c
7,14 → 7,14
// + FOR NON COMMERCIAL USE ONLY
// + www.MikroKopter.com
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation),
// + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist.
// + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt
// + bzgl. der Nutzungsbedingungen aufzunehmen.
// + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation),
// + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist.
// + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt
// + bzgl. der Nutzungsbedingungen aufzunehmen.
// + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen,
// + Verkauf von Luftbildaufnahmen, usw.
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht,
// + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht,
// + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts
25,21 → 25,21
// + Benutzung auf eigene Gefahr
// + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Die PORTIERUNG der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur
// + Die PORTIERUNG der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur
// + mit unserer Zustimmung zulässig
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Redistributions of source code (with or without modifications) must retain the above copyright notice,
// + Redistributions of source code (with or without modifications) must retain the above copyright notice,
// + this list of conditions and the following disclaimer.
// + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived
// + from this software without specific prior written permission.
// + * The use of this project (hardware, software, binary files, sources and documentation) is only permitted
// + * The use of this project (hardware, software, binary files, sources and documentation) is only permitted
// + for non-commercial use (directly or indirectly)
// + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted
// + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted
// + with our written permission
// + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be
// + clearly linked as origin
// + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be
// + clearly linked as origin
// + * PORTING this software (or part of it) to systems (other than hardware from www.mikrokopter.de) is NOT allowed
//
// + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
52,7 → 52,7
// + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// + POSSIBILITY OF SUCH DAMAGE.
// + POSSIBILITY OF SUCH DAMAGE.
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#include <stdio.h>
#include "91x_lib.h"
64,7 → 64,7
// defines
 
 
#define DAYS_FROM_JAN01YEAR0001_TO_JAN6_1980 722819L
#define DAYS_FROM_JAN01YEAR0001_TO_JAN6_1980 722819L // the year 0 does not exist!
#define DAYS_PER_YEAR 165L
#define DAYS_PER_LEAPYEAR 166L
#define DAYS_PER_4YEARS ((3L * DAYS_PER_YEAR) + DAYS_PER_LEAPYEAR) // years dividable by 4 are leap years
77,11 → 77,13
#define SECONDS_PER_HOUR (SECONDS_PER_MINUTE * MINUTES_PER_HOUR)
#define SECONDS_PER_DAY (SECONDS_PER_HOUR * HOURS_PER_DAY)
 
 
const u32 Leap[ 13 ] = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 };
const u32 Normal[ 13 ] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
 
#define LEAP_SECONDS_FROM_1980 13
#define GPSWEEK_ROLLOVER 1 // number of rollovers since Jan 6th 1980
#define GPSWEEK_OVERFLOW 1024
#define GPSWEEK_OVERFLOW 1024
 
// message sync bytes
#define UBX_SYNC1_CHAR 0xB5
96,8 → 98,8
// ------------------------------------------------------------------------------------------------
// typedefs
 
// ubx parser state
typedef enum
// ubx parser state
typedef enum
{
UBXSTATE_IDLE,
UBXSTATE_SYNC1,
133,7 → 135,7
} __attribute__((packed)) ubx_nav_sol_t;
 
 
typedef struct
typedef struct
{
u32 itow; // ms GPS Millisecond Time of Week
s32 VEL_N; // cm/s NED north velocity
147,7 → 149,7
Status_t Status; // invalid/newdata/processed
} __attribute__((packed)) ubx_nav_velned_t;
 
typedef struct
typedef struct
{
u32 itow; // ms GPS Millisecond Time of Week
s32 LON; // 1e-07 deg Longitude
169,8 → 171,8
ubx_nav_posllh_t UbxPosLlh = {0,0,0,0,0,0,0, INVALID};
ubx_nav_velned_t UbxVelNed = {0,0,0,0,0,0,0,0,0, INVALID};
 
// shared buffer
gps_data_t GPS_Data = {0,0,0,0,0,0,0,0,0,0, INVALID};
// shared buffer
gps_data_t GPSData = {0,0,0,0,0,0,0,0,0,0, INVALID};
DateTime_t GPSDateTime = {0,0,0,0,0,0,0, INVALID};
 
//------------------------------------------------------------------------------------
194,28 → 196,28
Seconds = UbxSol.itow / 1000L;
// if GPS data show valid time data
if((UbxSol.Status != INVALID) && (UbxSol.Flags & FLAG_WKNSET) && (UbxSol.Flags & FLAG_TOWSET) )
{
Days = DAYS_FROM_JAN01YEAR0001_TO_JAN6_1980;
{
Days = DAYS_FROM_JAN01YEAR0001_TO_JAN6_1980;
Days += (((u32)UbxSol.week + GPSWEEK_ROLLOVER * GPSWEEK_OVERFLOW) * DAYS_PER_WEEK);
Days += Seconds / SECONDS_PER_DAY; // seperate days from GPS seconds of week
 
GPSDateTime.Year = 1;
YearPart = (u16)(Days / DAYS_PER_400YEARS);
GPSDateTime.Year += YearPart * 400;
Days = Days % DAYS_PER_400YEARS;
Days = Days % DAYS_PER_400YEARS;
YearPart = (u16)(Days / DAYS_PER_100YEARS);
GPSDateTime.Year += YearPart * 100;
GPSDateTime.Year += YearPart * 100;
Days = Days % DAYS_PER_100YEARS;
YearPart = (u16)(Days / DAYS_PER_4YEARS);
GPSDateTime.Year += YearPart * 4;
Days = Days % DAYS_PER_4YEARS;
if(Days < 3 * DAYS_PER_YEAR) YearPart = (u16)(Days / DAYS_PER_YEAR);
if(Days < 3 * DAYS_PER_YEAR) YearPart = (u16)(Days / DAYS_PER_YEAR);
else YearPart = 3;
GPSDateTime.Year += YearPart;
// calculate remaining days of year
Days -= (u32)YearPart * DAYS_PER_YEAR;
// check if current year is a leap year
if(IsLeapYear(GPSDateTime.Year)) MonthDayTab = (u32*)Leap;
if(IsLeapYear(GPSDateTime.Year)) MonthDayTab = (u32*)Leap;
else MonthDayTab = (u32*)Normal;
// seperate month and day from days of year
for ( i = 0; i < 12; i++ )
238,7 → 240,7
}
else
{
GPSDateTime.Status = INVALID;
GPSDateTime.Status = INVALID;
}
}
 
291,7 → 293,7
{
GPIO_InitTypeDef GPIO_InitStructure;
 
SCU_APBPeriphClockConfig(__GPIO5, ENABLE);
SCU_APBPeriphClockConfig(__GPIO5, ENABLE);
// unmap UART0 from GPS
// set port pin 6.6 (serial data from gps) to input and disconnect from IP
GPIO_InitStructure.GPIO_Direction = GPIO_PinInput;
333,11 → 335,11
UART_InitTypeDef UART_InitStructure;
 
SerialPutString("GPS init...");
SCU_APBPeriphClockConfig(__UART0, ENABLE); // Enable the UART0 Clock
Connect_UART0_to_GPS(); // initialize pins to GPS serial interface
 
SCU_APBPeriphClockConfig(__UART0, ENABLE); // Enable the UART0 Clock
 
Connect_UART0_to_GPS(); // initialize pins to GPS serial interface
 
/* UART1 configured as follow:
- Word Length = 8 Bits
- One Stop Bit
364,7 → 366,7
UbxSol.Status = INVALID;
UbxPosLlh.Status = INVALID;
UbxVelNed.Status = INVALID;
GPS_Data.Status = INVALID;
GPSData.Status = INVALID;
 
// enable uart 0 interrupts selective
UART_ITConfig(UART0, UART_IT_Receive | UART_IT_ReceiveTimeOut, ENABLE);
371,8 → 373,8
UART_Cmd(UART0, ENABLE); // enable uart 0
// configure the uart 0 interupt line as an IRQ with priority 10 (0 is highest)
VIC_Config(UART0_ITLine, VIC_IRQ, 10);
// enable the uart 0 IRQ
VIC_ITCmd(UART0_ITLine, ENABLE);
// enable the uart 0 IRQ
VIC_ITCmd(UART0_ITLine, ENABLE);
 
SerialPutString("ok\n\r");
}
380,37 → 382,37
/********************************************************/
/* Upate GPS data stcructure */
/********************************************************/
void Update_GPS_Data (void)
void Update_GPSData (void)
{
static u32 lasttime = 0;
LED_RED_TOGGLE;
// update GPS data only if the status is INVALID or PROCESSED
if(GPS_Data.Status != NEWDATA)
if(GPSData.Status != NEWDATA)
{ // wait for new data at all neccesary ubx messages
if ((UbxSol.Status == NEWDATA) && (UbxPosLlh.Status == NEWDATA) && (UbxVelNed.Status == NEWDATA))
{
// NAV SOL
GPS_Data.Flags = UbxSol.Flags;
GPS_Data.NumOfSats = UbxSol.numSV;
GPS_Data.SatFix = UbxSol.GPSfix;
GPS_Data.Position_Accuracy = UbxSol.PAcc;
GPS_Data.Speed_Accuracy = UbxSol.SAcc;
GPSData.Flags = UbxSol.Flags;
GPSData.NumOfSats = UbxSol.numSV;
GPSData.SatFix = UbxSol.GPSfix;
GPSData.Position_Accuracy = UbxSol.PAcc;
GPSData.Speed_Accuracy = UbxSol.SAcc;
Update_GPSDateTime(UbxSol.week, UbxSol.itow);
UbxSol.Status = PROCESSED; // ready for new data
// NAV POSLLH
GPS_Data.UpdateTime = UbxPosLlh.itow - lasttime;
GPSData.UpdateTime = UbxPosLlh.itow - lasttime;
lasttime = UbxPosLlh.itow;
GPS_Data.Longitude = UbxPosLlh.LON;
GPS_Data.Latitude = UbxPosLlh.LAT;
GPS_Data.Altitude = UbxPosLlh.HMSL;
GPSData.Longitude = UbxPosLlh.LON;
GPSData.Latitude = UbxPosLlh.LAT;
GPSData.Altitude = UbxPosLlh.HMSL;
UbxPosLlh.Status = PROCESSED; // ready for new data
// NAV VELNED
GPS_Data.Speed_East = UbxVelNed.VEL_E;
GPS_Data.Speed_North = UbxVelNed.VEL_N;
GPS_Data.Speed_Top = -UbxVelNed.VEL_D;
GPS_Data.Speed_Ground = UbxVelNed.GSpeed;
GPSData.Speed_East = UbxVelNed.VEL_E;
GPSData.Speed_North = UbxVelNed.VEL_N;
GPSData.Speed_Top = -UbxVelNed.VEL_D;
GPSData.Speed_Ground = UbxVelNed.GSpeed;
UbxVelNed.Status = PROCESSED; // ready for new data
GPS_Data.Status = NEWDATA; // new data available
GPSData.Status = NEWDATA; // new data available
}
}
}
435,7 → 437,7
// repeat until no byte is in the RxFIFO
while (UART_GetFlagStatus(UART0, UART_FLAG_RxFIFOEmpty) != SET)
{
c = UART_ReceiveData(UART0); // read byte from RxFIFO
c = UART_ReceiveData(UART0); // read byte from RxFIFO
//state machine
switch (ubxState) // ubx message parser
{
448,12 → 450,12
if (c == UBX_SYNC2_CHAR) ubxState = UBXSTATE_SYNC2;
else ubxState = UBXSTATE_IDLE; // out of synchronization
break;
 
case UBXSTATE_SYNC2: // check msg class to be NAV
if (c == UBX_CLASS_NAV) ubxState = UBXSTATE_CLASS;
else ubxState = UBXSTATE_IDLE; // unsupported message class
break;
 
case UBXSTATE_CLASS: // check message identifier
switch(c)
{
493,7 → 495,7
ckb += cka;
ubxState = UBXSTATE_LEN2;
break;
 
case UBXSTATE_LEN2: // 2nd message length byte
msglen += ((u16)c)<<8; // high byte last
cka += c;
503,7 → 505,7
if ( *ubxSp == NEWDATA )
{
ubxState = UBXSTATE_IDLE;
Update_GPS_Data(); //update GPS info respectively
Update_GPSData(); //update GPS info respectively
}
else // data invalid or allready processd
{
511,7 → 513,7
ubxState = UBXSTATE_DATA;
}
break;
 
case UBXSTATE_DATA: // collecting data
if (ubxP < ubxEp) *ubxP++ = c; // copy curent data byte if any space is left
cka += c;
518,7 → 520,7
ckb += cka;
if (--msglen == 0) ubxState = UBXSTATE_CKA; // switch to next state if all data was read
break;
 
case UBXSTATE_CKA:
if (c == cka) ubxState = UBXSTATE_CKB;
else
527,12 → 529,12
ubxState = UBXSTATE_IDLE;
}
break;
 
case UBXSTATE_CKB:
if (c == ckb)
{
*ubxSp = NEWDATA; // new data are valid
Update_GPS_Data(); //update GPS info respectively
Update_GPSData(); //update GPS info respectively
}
else
{ // if checksum not match then set data invalid
540,7 → 542,7
}
ubxState = UBXSTATE_IDLE; // ready to parse new data
break;
 
default: // unknown ubx state
ubxState = UBXSTATE_IDLE;
break;
/branches/V0.1 killagreg/GPSUart.h
1,7 → 1,7
#ifndef __GPSUART_H
#define __GPSUART_H
 
// Satfix types for GPS_Data.SatFix
// Satfix types for GPSData.SatFix
#define SATFIX_NONE 0x00
#define SATFIX_DEADRECKOING 0x01
#define SATFIX_2D 0x02
8,14 → 8,14
#define SATFIX_3D 0x03
#define SATFIX_GPS_DEADRECKOING 0x04
#define SATFIX_TIMEONLY 0x05
// Flags for interpretation of the GPS_Data.Flags
// Flags for interpretation of the GPSData.Flags
#define FLAG_GPSFIXOK 0x01 // (i.e. within DOP & ACC Masks)
#define FLAG_DIFFSOLN 0x02 // (is DGPS used)
#define FLAG_WKNSET 0x04 // (is Week Number valid)
#define FLAG_TOWSET 0x08 // (is Time of Week valid)
 
typedef enum
{
typedef enum
{
INVALID,
NEWDATA,
PROCESSED
23,11 → 23,11
 
typedef struct
{
u8 Flags; // Status Flags
u8 Flags; // Status Flags
u8 NumOfSats; // number of satelites
u8 SatFix; // type of satfix
s32 Longitude; // in 1e-07 deg
s32 Latitude; // in 1e-07 deg
s32 Longitude; // in 1e-07 deg
s32 Latitude; // in 1e-07 deg
s32 Altitude; // in mm
u32 Position_Accuracy; // in cm 3d position accuracy
s32 Speed_North; // in cm/s
34,14 → 34,14
s32 Speed_East; // in cm/s
s32 Speed_Top; // in cm/s
u32 Speed_Ground; // 2D ground speed in cm/s
u32 Speed_Accuracy; // in cm/s 3d velocity accuracy
u32 Speed_Accuracy; // in cm/s 3d velocity accuracy
u32 UpdateTime; // in ms is the time since the last data frame was received (typical 200 ms)
Status_t Status; // status of data
} __attribute__((packed)) gps_data_t;
 
// The data are valid if the GPS_Data.Status is NEWDATA or PROCESSED.
// To achieve new data after reading the GPS_Data.Status should be set to PROCESSED.
extern gps_data_t GPS_Data;
// The data are valid if the GPSData.Status is NEWDATA or PROCESSED.
// To achieve new data after reading the GPSData.Status should be set to PROCESSED.
extern gps_data_t GPSData;
 
typedef struct{
u16 Year;
/branches/V0.1 killagreg/HexFiles/LEA-4H Config-H&I.txt
0,0 → 1,58
MON-VER - 0A 04 46 00 35 2E 30 30 20 20 20 20 4A 61 6E 20 30 39 20 32 30 30 36 20 31 32 3A 30 30 3A 30 30 00 01 30 30 30 34 30 30 30 31 00 00 4D 34 48 31 2E 31 20 20 4A 61 6E 20 30 39 20 32 30 30 36 20 31 35 3A 33 39 3A 35 34 00 00
CFG-ANT - 06 13 04 00 0B 00 0F 38
CFG-DAT - 06 06 02 00 00 00
CFG-FXN - 06 0E 24 00 12 00 00 00 C0 D4 01 00 C0 D4 01 00 C0 27 09 00 C0 27 09 00 A0 8C 00 00 40 77 1B 00 00 00 00 00 00 00 00 00
CFG-INF - 06 02 08 00 00 00 00 00 00 00 87 00
CFG-INF - 06 02 08 00 01 00 00 00 00 87 00 87
CFG-INF - 06 02 08 00 03 00 00 00 00 00 00 00
CFG-MSG - 06 01 06 00 01 01 00 00 00 00
CFG-MSG - 06 01 06 00 01 02 00 01 00 00
CFG-MSG - 06 01 06 00 01 03 00 00 00 00
CFG-MSG - 06 01 06 00 01 04 00 00 00 00
CFG-MSG - 06 01 06 00 01 06 00 01 00 00
CFG-MSG - 06 01 06 00 01 08 00 01 00 00
CFG-MSG - 06 01 06 00 01 11 00 00 00 00
CFG-MSG - 06 01 06 00 01 12 00 01 00 00
CFG-MSG - 06 01 06 00 01 20 00 00 00 00
CFG-MSG - 06 01 06 00 01 21 00 00 00 00
CFG-MSG - 06 01 06 00 01 22 00 00 00 00
CFG-MSG - 06 01 06 00 01 30 00 00 00 00
CFG-MSG - 06 01 06 00 01 31 00 00 00 00
CFG-MSG - 06 01 06 00 01 32 00 00 00 00
CFG-MSG - 06 01 06 00 02 10 00 00 00 00
CFG-MSG - 06 01 06 00 02 11 00 00 00 00
CFG-MSG - 06 01 06 00 02 20 00 00 00 00
CFG-MSG - 06 01 06 00 0A 01 00 00 00 00
CFG-MSG - 06 01 06 00 0A 02 00 00 00 00
CFG-MSG - 06 01 06 00 0A 03 00 00 00 00
CFG-MSG - 06 01 06 00 0A 06 00 00 00 00
CFG-MSG - 06 01 06 00 0A 07 00 00 00 00
CFG-MSG - 06 01 06 00 0A 08 00 00 01 00
CFG-MSG - 06 01 06 00 0A 09 00 00 00 00
CFG-MSG - 06 01 06 00 0B 00 00 00 00 00
CFG-MSG - 06 01 06 00 0B 30 00 00 00 00
CFG-MSG - 06 01 06 00 0B 31 00 00 00 00
CFG-MSG - 06 01 06 00 0D 01 00 00 00 00
CFG-MSG - 06 01 06 00 0D 03 00 00 00 00
CFG-MSG - 06 01 06 00 F0 00 00 00 00 01
CFG-MSG - 06 01 06 00 F0 01 00 00 00 01
CFG-MSG - 06 01 06 00 F0 02 00 00 00 01
CFG-MSG - 06 01 06 00 F0 03 00 00 00 01
CFG-MSG - 06 01 06 00 F0 04 00 00 00 01
CFG-MSG - 06 01 06 00 F0 05 00 00 00 01
CFG-MSG - 06 01 06 00 F0 06 00 00 00 00
CFG-MSG - 06 01 06 00 F0 07 00 00 00 00
CFG-MSG - 06 01 06 00 F0 08 00 00 00 01
CFG-MSG - 06 01 06 00 F1 00 00 00 00 00
CFG-MSG - 06 01 06 00 F1 01 00 00 00 00
CFG-MSG - 06 01 06 00 F1 03 00 00 00 00
CFG-MSG - 06 01 06 00 F1 04 00 00 00 00
CFG-NAV2 - 06 1A 28 00 05 00 00 00 04 04 10 03 50 C3 00 00 18 14 05 3C 00 01 00 00 FA 00 FA 00 64 00 2C 01 00 00 00 00 00 00 00 00 00 00 00 00
CFG-NMEA - 06 17 04 00 00 23 00 02
CFG-PRT - 06 00 14 00 01 00 00 00 D0 08 08 00 00 E1 00 00 07 00 01 00 00 00 00 00
CFG-PRT - 06 00 14 00 02 00 00 00 D0 08 08 00 00 E1 00 00 07 00 03 00 00 00 00 00
CFG-PRT - 06 00 14 00 03 00 00 00 00 00 00 00 00 00 00 00 03 00 03 00 00 00 00 00
CFG-RATE - 06 08 06 00 C8 00 01 00 00 00
CFG-RXM - 06 11 02 00 03 00
CFG-SBAS - 06 16 08 00 01 01 01 00 00 00 00 00
CFG-TP - 06 07 14 00 40 42 0F 00 A0 BB 0D 00 FF 01 00 00 32 00 34 03 00 00 00 00
/branches/V0.1 killagreg/menu.c
130,7 → 130,7
LCD_printfxy(0,3,"(c) I.B. H.B. ");
break;
case 1:
if (GPS_Data.Status == INVALID)
if (GPSData.Status == INVALID)
{
LCD_printfxy(0,0,"No GPS data! ");
LCD_printfxy(0,1," ");
139,36 → 139,36
}
else // newdata or processed
{
switch (GPS_Data.SatFix)
switch (GPSData.SatFix)
{
case SATFIX_NONE:
LCD_printfxy(0,0,"Sats:%02d Fix:None", GPS_Data.NumOfSats);
LCD_printfxy(0,0,"Sats:%02d Fix:None", GPSData.NumOfSats);
break;
case SATFIX_2D:
LCD_printfxy(0,0,"Sats:%02d Fix:2D ", GPS_Data.NumOfSats);
LCD_printfxy(0,0,"Sats:%02d Fix:2D ", GPSData.NumOfSats);
break;
case SATFIX_3D:
LCD_printfxy(0,0,"Sats:%02d Fix:3D ", GPS_Data.NumOfSats);
LCD_printfxy(0,0,"Sats:%02d Fix:3D ", GPSData.NumOfSats);
break;
default:
LCD_printfxy(0,0,"Sats:%02d Fix:?? ", GPS_Data.NumOfSats);
LCD_printfxy(0,0,"Sats:%02d Fix:?? ", GPSData.NumOfSats);
break;
}
i1 = (s16)(GPS_Data.Longitude/10000000L);
i2 = abs((s16)((GPS_Data.Longitude%10000000L)/10000L));
i3 = abs((s16)(((GPS_Data.Longitude%10000000L)%10000L)/10L));
i1 = (s16)(GPSData.Longitude/10000000L);
i2 = abs((s16)((GPSData.Longitude%10000000L)/10000L));
i3 = abs((s16)(((GPSData.Longitude%10000000L)%10000L)/10L));
LCD_printfxy(0,1,"Lon: %3d.%.3d%.3d deg",i1, i2, i3);
i1 = (s16)(GPS_Data.Latitude/10000000L);
i2 = abs((s16)((GPS_Data.Latitude%10000000L)/10000L));
i3 = abs((s16)(((GPS_Data.Latitude%10000000L)%10000L)/10L));
i1 = (s16)(GPSData.Latitude/10000000L);
i2 = abs((s16)((GPSData.Latitude%10000000L)/10000L));
i3 = abs((s16)(((GPSData.Latitude%10000000L)%10000L)/10L));
LCD_printfxy(0,2,"Lat: %3d.%.3d%.3d deg",i1, i2, i3);
i1 = (s16)(GPS_Data.Altitude/1000L);
i2 = abs((s16)(GPS_Data.Altitude%1000L));
i1 = (s16)(GPSData.Altitude/1000L);
i2 = abs((s16)(GPSData.Altitude%1000L));
LCD_printfxy(0,3,"Alt: %3d.%.3d m",i1, i2);
}
break;
case 2:
if (GPS_Data.Status == INVALID)
if (GPSData.Status == INVALID)
{
LCD_printfxy(0,0,"No GPS data! ");
LCD_printfxy(0,1," ");
177,24 → 177,24
}
else // newdata or processed
{
switch (GPS_Data.SatFix)
switch (GPSData.SatFix)
{
case SATFIX_NONE:
LCD_printfxy(0,0,"Sats:%02d Fix:None", GPS_Data.NumOfSats);
LCD_printfxy(0,0,"Sats:%02d Fix:None", GPSData.NumOfSats);
break;
case SATFIX_2D:
LCD_printfxy(0,0,"Sats:%02d Fix:2D ", GPS_Data.NumOfSats);
LCD_printfxy(0,0,"Sats:%02d Fix:2D ", GPSData.NumOfSats);
break;
case SATFIX_3D:
LCD_printfxy(0,0,"Sats:%02d Fix:3D ", GPS_Data.NumOfSats);
LCD_printfxy(0,0,"Sats:%02d Fix:3D ", GPSData.NumOfSats);
break;
default:
LCD_printfxy(0,0,"Sats:%02d Fix:?? ", GPS_Data.NumOfSats);
LCD_printfxy(0,0,"Sats:%02d Fix:?? ", GPSData.NumOfSats);
break;
}
i1 = (s16)(GPS_Data.Speed_North);
i2 = (s16)(GPS_Data.Speed_East);
i3 = (s16)(GPS_Data.Speed_Top);
i1 = (s16)(GPSData.Speed_North);
i2 = (s16)(GPSData.Speed_East);
i3 = (s16)(GPSData.Speed_Top);
LCD_printfxy(0,1,"Speed N: %4i cm/s",i1);
LCD_printfxy(0,2,"Speed E: %4i cm/s",i2);
LCD_printfxy(0,3,"Speed T: %4i cm/s",i3);
/branches/V0.1 killagreg/spi_slave.c
295,8 → 295,8
break;
 
case SPI_CMD_GPS_POS:
ToFlightCtrl.Param.Long[0] = GPS_Data.Longitude;
ToFlightCtrl.Param.Long[1] = GPS_Data.Latitude;
ToFlightCtrl.Param.Long[0] = GPSData.Longitude;
ToFlightCtrl.Param.Long[1] = GPSData.Latitude;
break;
 
case SPI_CMD_GPS_TARGET:
/branches/V0.1 killagreg/timer.c
7,14 → 7,14
// + FOR NON COMMERCIAL USE ONLY
// + www.MikroKopter.com
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation),
// + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist.
// + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt
// + bzgl. der Nutzungsbedingungen aufzunehmen.
// + Es gilt für das gesamte Projekt (Hardware, Software, Binärfiles, Sourcecode und Dokumentation),
// + dass eine Nutzung (auch auszugsweise) nur für den privaten (nicht-kommerziellen) Gebrauch zulässig ist.
// + Sollten direkte oder indirekte kommerzielle Absichten verfolgt werden, ist mit uns (info@mikrokopter.de) Kontakt
// + bzgl. der Nutzungsbedingungen aufzunehmen.
// + Eine kommerzielle Nutzung ist z.B.Verkauf von MikroKoptern, Bestückung und Verkauf von Platinen oder Bausätzen,
// + Verkauf von Luftbildaufnahmen, usw.
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht,
// + Werden Teile des Quellcodes (mit oder ohne Modifikation) weiterverwendet oder veröffentlicht,
// + unterliegen sie auch diesen Nutzungsbedingungen und diese Nutzungsbedingungen incl. Copyright müssen dann beiliegen
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Sollte die Software (auch auszugesweise) oder sonstige Informationen des MikroKopter-Projekts
25,21 → 25,21
// + Benutzung auf eigene Gefahr
// + Wir übernehmen keinerlei Haftung für direkte oder indirekte Personen- oder Sachschäden
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Die PORTIERUNG der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur
// + Die PORTIERUNG der Software (oder Teile davon) auf andere Systeme (ausser der Hardware von www.mikrokopter.de) ist nur
// + mit unserer Zustimmung zulässig
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Die Funktion printf_P() unterliegt ihrer eigenen Lizenz und ist hiervon nicht betroffen
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Redistributions of source code (with or without modifications) must retain the above copyright notice,
// + Redistributions of source code (with or without modifications) must retain the above copyright notice,
// + this list of conditions and the following disclaimer.
// + * Neither the name of the copyright holders nor the names of contributors may be used to endorse or promote products derived
// + from this software without specific prior written permission.
// + * The use of this project (hardware, software, binary files, sources and documentation) is only permitted
// + * The use of this project (hardware, software, binary files, sources and documentation) is only permitted
// + for non-commercial use (directly or indirectly)
// + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted
// + Commercial use (for excample: selling of MikroKopters, selling of PCBs, assembly, ...) is only permitted
// + with our written permission
// + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be
// + clearly linked as origin
// + * If sources or documentations are redistributet on other webpages, out webpage (http://www.MikroKopter.de) must be
// + clearly linked as origin
// + * PORTING this software (or part of it) to systems (other than hardware from www.mikrokopter.de) is NOT allowed
//
// + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
52,7 → 52,7
// + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// + POSSIBILITY OF SUCH DAMAGE.
// + POSSIBILITY OF SUCH DAMAGE.
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#include "91x_lib.h"
#include "uart.h"
62,9 → 62,9
 
//----------------------------------------------------------------------------------------------------
void TIM1_IRQHandler(void)
{
TIM1->OC1R += 200; // Timerfreq is 200kHz, generate an interrupt every 1ms
{
TIM1->OC1R += 200; // Timerfreq is 200kHz, generate an interrupt every 1ms
 
CountMilliseconds++;
//if (GPIO_ReadBit(GPIO6, GPIO_Pin_3)) GPIO_WriteBit(GPIO6, GPIO_Pin_3, Bit_RESET); else GPIO_WriteBit(GPIO6, GPIO_Pin_3, Bit_SET);
TIM_ClearFlag(TIM1, TIM_FLAG_OC1); // clear irq pending bit
76,14 → 76,14
void TIMER1_Init(void)
{
TIM_InitTypeDef TIM_InitStructure;
 
SerialPutString("Timer init...");
#define TIM1_FREQ 200000 // 200kHz
 
#define TIM1_FREQ 200000 // 200kHz
// TimerOCR set in IntHandler
 
SCU_APBPeriphClockConfig(__TIM01, ENABLE);
 
TIM_StructInit(&TIM_InitStructure);
TIM_InitStructure.TIM_Mode = TIM_OCM_CHANNEL_1;
TIM_InitStructure.TIM_OC1_Modes = TIM_TIMING;
99,13 → 99,13
 
CountMilliseconds = 0;
SerialPutString("ok\n\r");
 
}
 
// -----------------------------------------------------------------------
u32 SetDelay (u32 t)
{
return(CountMilliseconds + t -1);
return(CountMilliseconds + t -1);
}
 
// -----------------------------------------------------------------------