Subversion Repositories FlightCtrl

Compare Revisions

Ignore whitespace Rev 701 → Rev 702

/branches/V0.68d Code Redesign killagreg/main.c
119,7 → 119,7
TIMER0_Init();
TIMER2_Init();
USART0_Init();
//USART1_Init();
USART1_Init();
rc_sum_init();
ADC_Init();
i2c_init();
181,6 → 181,7
printf("\n\n\r");
 
LCD_Clear();
 
I2CTimeout = 5000;
while (1)
{
/branches/V0.68d Code Redesign killagreg/menu.c
16,6 → 16,7
#include "printf_P.h"
#include "analog.h"
#include "mm3.h"
#include "ubx.h"
#include "_Settings.h"
 
#define ARRAYSIZE 10
47,7 → 48,7
// Display with 20 characters in 4 lines
void LCD_PrintMenu(void)
{
static uint8_t MaxMenuItem = 13, MenuItem=0;
static uint8_t MaxMenuItem = 14, MenuItem=0;
 
// if KEY1 is activated goto previous menu item
if(RemoteButtons & KEY1)
180,7 → 181,32
LCD_printfxy(0,1,"X_Range: %4i",MM3_calib.X_range);
LCD_printfxy(0,2,"Y_Range: %4i",MM3_calib.Y_range);
LCD_printfxy(0,3,"Z_Range: %4i",MM3_calib.Z_range);
break;
break;
case 14://GPS Status
LCD_printfxy(0,0,"GPS Status");
if (GPSInfo.status == INVALID)
{
LCD_printfxy(0,1,"No data available!");
}
else
{
switch (GPSInfo.satfix)
{
case SATFIX_NONE:
LCD_printfxy(0,1,"Satfix: None");
break;
case SATFIX_2D:
LCD_printfxy(0,1,"Satfix: 2D");
break;
case SATFIX_3D:
LCD_printfxy(0,1,"Satfix: 3D");
break;
default:
LCD_printfxy(0,1,"Satfix: Unknown");
break;
}
}
break;
default: MaxMenuItem = MenuItem - 1;
MenuItem = 0;
break;
/branches/V0.68d Code Redesign killagreg/uart1.c
36,19 → 36,16
// disable TX-Interrupt
UCSR1B &= ~(1 << TXCIE1);
// disable DRE-Interrupt
UCSR1B |= (1 << UDRIE1);
UCSR1B &= ~(1 << UDRIE1);
 
// disable receiver and transmitter (will flush the buffers)
UCSR1B &= ~((1 << TXEN1) | (1 << RXEN1));
 
// set direction of RXD1 and TXD1 pins
// set RXD1 (PD2) as an input pin
PORTD |= (1 << PORTD2);
DDRD &= ~(1 << DDD2);
PORTD |= (1 << PORTD2);
 
// set TXD1 (PD3) as an output pin
PORTD |= (1 << PORTD3);
DDRD |= (1 << DDD3);
PORTD |= (1 << PORTD3);
 
// USART0 Baud Rate Register
// set clock divider
79,7 → 76,7
// enable RX-Interrupt
UCSR1B |= (1 << RXCIE1);
// enable TX-Interrupt
//UCSR1B |= (1 << TXCIE1);
UCSR1B |= (1 << TXCIE1);
// enable DRE interrupt
//UCSR1B |= (1 << UDRIE1);
 
89,10 → 86,10
 
// inint FIFO buffer
//fifo_init (&infifo, inbuf, BUFSIZE_IN);
fifo_init (&outfifo, outbuf, BUFSIZE_OUT);
//fifo_init (&outfifo, outbuf, BUFSIZE_OUT);
}
 
int16_t USART1_putc (const uint8_t c)
/*int16_t USART1_putc (const uint8_t c)
{
int16_t ret = fifo_put (&outfifo, c);
// create an data register empty interrupt
100,7 → 97,7
 
return ret;
}
 
*/
/*int16_t USART1_getc_nowait ()
{
return fifo_get_nowait (&infifo);
116,7 → 113,7
/****************************************************************/
/* USART1 data register empty ISR */
/****************************************************************/
ISR(USART1_UDRE_vect)
/*ISR(USART1_UDRE_vect)
{
// Move a character from the output buffer to the data register.
// When the character was processed the next interrupt is generated.
126,15 → 123,16
else
UCSR1B &= ~(1 << UDRIE1);
}
*/
 
/****************************************************************/
/* USART1 transmitter ISR */
/****************************************************************/
ISR(USART1_TX_vect)
/*ISR(USART1_TX_vect)
{
 
}
 
*/
/****************************************************************/
/* USART1 receiver ISR */
/****************************************************************/
141,6 → 139,6
ISR(USART1_RX_vect)
{
uint8_t c;
c = UDR0; // get data byte
c = UDR1; // get data byte
ubx_parser(c); // and put it into the ubx protocol parser
}
/branches/V0.68d Code Redesign killagreg/ubx.c
1,5 → 1,7
#include <inttypes.h>
#include "ubx.h"
#include "main.h"
#include <avr/io.h>
 
// ubx protocol parser state machine
#define UBXSTATE_IDLE 0
30,7 → 32,7
uint8_t res; // reserved
uint32_t TTFF; // Time to first fix (millisecond time tag)
uint32_t MSSS; // Milliseconds since Startup / Reset
uint8_t packetStatus;
uint8_t Status;
} GPS_STATUS_t;
 
typedef struct {
41,7 → 43,7
int32_t HMSL; // mm Height above mean sea level
uint32_t Hacc; // mm Horizontal Accuracy Estimate
uint32_t Vacc; // mm Vertical Accuracy Estimate
uint8_t packetStatus;
uint8_t Status;
} GPS_POSLLH_t;
 
typedef struct {
51,7 → 53,7
int32_t ALT; // cm altitude
uint8_t ZONE; // UTM zone number
uint8_t HEM; // Hemisphere Indicator (0=North, 1=South)
uint8_t packetStatus;
uint8_t Status;
} GPS_POSUTM_t;
 
typedef struct {
64,7 → 66,7
int32_t Heading; // 1e-05 deg Heading 2-D
uint32_t SAcc; // cm/s Speed Accuracy Estimate
uint32_t CAcc; // deg Course / Heading Accuracy Estimate
uint8_t packetStatus;
uint8_t Status;
} GPS_VELNED_t;
 
 
73,36 → 75,40
GPS_POSUTM_t GpsPosUtm;
GPS_VELNED_t GpsVelNed;
 
GPS_INFO_t actualPos;
GPS_INFO_t GPSInfo;
 
void UpdateGPSInfo (void)
{
if (GpsStatus.packetStatus == VALID) // valid packet
if (GpsStatus.Status == VALID) // valid packet
{
actualPos.satfix = GpsStatus.GPSfix;
GpsStatus.packetStatus = PROCESSED; // never update old data
GPSInfo.satfix = GpsStatus.GPSfix;
GpsStatus.Status = PROCESSED; // never update old data
}
if (GpsPosLlh.packetStatus == VALID) // valid packet
if (GpsPosLlh.Status == VALID) // valid packet
{
actualPos.longitude = GpsPosLlh.LON;
actualPos.latitude = GpsPosLlh.LAT;
actualPos.altitude = GpsPosLlh.HEIGHT;
GpsPosLlh.packetStatus = PROCESSED; // never update old data
GPSInfo.longitude = GpsPosLlh.LON;
GPSInfo.latitude = GpsPosLlh.LAT;
GPSInfo.altitude = GpsPosLlh.HEIGHT;
GpsPosLlh.Status = PROCESSED; // never update old data
}
if (GpsPosUtm.packetStatus == VALID) // valid packet
if (GpsPosUtm.Status == VALID) // valid packet
{
actualPos.utmeast = GpsPosUtm.EAST;
actualPos.utmnorth = GpsPosUtm.NORTH;
actualPos.utmalt = GpsPosUtm.ALT;
GpsPosUtm.packetStatus = PROCESSED; // never update old data
GPSInfo.utmeast = GpsPosUtm.EAST;
GPSInfo.utmnorth = GpsPosUtm.NORTH;
GPSInfo.utmalt = GpsPosUtm.ALT;
GpsPosUtm.Status = PROCESSED; // never update old data
}
if (GpsVelNed.packetStatus == VALID) // valid packet
if (GpsVelNed.Status == VALID) // valid packet
{
actualPos.veleast = GpsVelNed.VEL_E;
actualPos.velnorth = GpsVelNed.VEL_N;
actualPos.veltop = -GpsVelNed.VEL_D;
GpsPosUtm.packetStatus = PROCESSED; // never update old data
GPSInfo.veleast = GpsVelNed.VEL_E;
GPSInfo.velnorth = GpsVelNed.VEL_N;
GPSInfo.veltop = -GpsVelNed.VEL_D;
GpsPosUtm.Status = PROCESSED; // never update old data
}
if (GpsStatus.Status | GpsVelNed.Status | GpsPosLlh.Status | GpsPosUtm.Status)
{
GPSInfo.status = VALID;
}
}
 
// this function should be called within the UART RX ISR
136,7 → 142,7
case UBX_ID_POSUTM: // utm position
ubxP = (int8_t *)&GpsPosUtm; // data start pointer
ubxEp = (int8_t *)(&GpsPosUtm + sizeof(GPS_POSUTM_t)); // data end pointer
ubxSp = (int8_t *)&GpsPosUtm.packetStatus; // status pointer
ubxSp = (int8_t *)&GpsPosUtm.Status; // status pointer
 
break;
 
143,19 → 149,19
case UBX_ID_POSLLH: // geodetic position
ubxP = (int8_t *)&GpsStatus; // data start pointer
ubxEp = (int8_t *)(&GpsStatus + sizeof(GPS_STATUS_t)); // data end pointer
ubxSp = (int8_t *)&GpsStatus.packetStatus; // status pointer
ubxSp = (int8_t *)&GpsStatus.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.packetStatus; // status pointer
ubxSp = (int8_t *)&GpsStatus.Status; // status pointer
break;
 
case UBX_ID_VELNED: // velocity vector in tangent plane
ubxP = (int8_t *)&GpsVelNed; // data start pointer
ubxEp = (int8_t *)(&GpsVelNed + sizeof(GPS_VELNED_t)); // data end pointer
ubxSp = (int8_t *)&GpsVelNed.packetStatus; // status pointer
ubxSp = (int8_t *)&GpsVelNed.Status; // status pointer
break;
 
default: // unsupported identifier
208,6 → 214,8
{
*ubxSp = VALID; // new data are availabe
UpdateGPSInfo(); //update GPS info respectively
ROT_FLASH;
 
}
ubxstate = UBXSTATE_IDLE; // ready to parse new data
break;
/branches/V0.68d Code Redesign killagreg/ubx.h
37,7 → 37,7
} GPS_INFO_t;
 
//here you will find the current gps info
extern GPS_INFO_t actualPos; // measured position (last gps record)
extern GPS_INFO_t GPSInfo; // measured position (last gps record)
 
// this function should be called within the UART RX ISR
extern void ubx_parser(uint8_t c);