/trunk/compass.c |
---|
60,6 → 60,7 |
#include "ncmag.h" |
#include "uart1.h" |
#include "fifo.h" |
#include "led.h" |
u8 CompassCalStateQueue[10]; |
76,10 → 77,19 |
void Compass_Init(void) |
{ |
Compass_Device = COMPASS_NONE; |
UART1_PutString("\r\n Looking for compass"); |
if( MK3MAG_Init() ) Compass_Device = COMPASS_MK3MAG; |
else if( NCMAG_Init() ) Compass_Device = COMPASS_NCMAG; |
else Compass_Device = COMPASS_NONE; |
if(Version_HW > 11) |
{ |
if( NCMAG_Init() ) Compass_Device = COMPASS_NCMAG; |
else if( MK3MAG_Init()) Compass_Device = COMPASS_MK3MAG; |
} |
else |
{ |
if( MK3MAG_Init() ) Compass_Device = COMPASS_MK3MAG; |
else if( NCMAG_Init() ) Compass_Device = COMPASS_NCMAG; |
} |
fifo_init(&CompassCalcStateFiFo, CompassCalStateQueue, sizeof(CompassCalStateQueue), NO_ITLine, NO_ITLine); |
} |
/trunk/eeprom.c |
---|
61,6 → 61,7 |
#include "uart1.h" |
#include "timer1.h" |
#include "eeprom.h" |
#include "led.h" |
// The EEPROM M24C64 (64k) ist connected via I2C1 interface to the controller. |
200,3 → 201,20 |
} |
return(retval); |
} |
u8 EEPROM_Init(void) |
{ |
u8 data[20]; |
u8 i, retval = 0; |
UART1_PutString("\r\n EEprom init.."); |
// check if data can be read from eeprom |
for(i=0;i<10;i++) |
{ |
UART1_Putchar('.'); |
if(EEPROM_SUCCESS == EEPROM_ReadBlock(0, data, 20)) retval = 1; |
if(retval) break; |
} |
if(retval) UART1_PutString("ok"); |
else UART1_PutString("failed"); |
return(retval); |
} |
/trunk/eeprom.h |
---|
14,7 → 14,7 |
EEPROM_ERROR_UNKNOWN |
} EEPROM_Result_t; |
u8 EEPROM_Init(void); |
EEPROM_Result_t EEPROM_WriteBlock(u16 Address, u8 *pData, u16 DataLen); |
EEPROM_Result_t EEPROM_ReadBlock(u16 Address, u8 *pData, u16 DataLen); |
/trunk/led.c |
---|
1,23 → 1,63 |
#include "91x_lib.h" |
#include "led.h" |
u8 Version_HW = 0; |
u8 Led_Grn_Inv = 0; |
u8 Led_Red_Inv = 0; |
void Led_Init(void) |
{ |
GPIO_InitTypeDef GPIO_InitStructure; |
u8 p5; |
u16 i; |
GPIO_InitTypeDef GPIO_InitStructure; |
SCU_APBPeriphClockConfig(__GPIO5, ENABLE); // Enable the GPIO5 Clock |
/*Configure LED_GRN at pin GPIO5.6 and LED_ROT at pin GPIO5.7*/ |
SCU_APBPeriphClockConfig(__GPIO5, ENABLE); // Enable the GPIO5 Clock |
/*Configure LED_GRN at pin GPIO5.6 and LED_RED at pin GPIO5.7 as output*/ |
GPIO_StructInit(&GPIO_InitStructure); |
GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1 ; |
GPIO_Init(GPIO5, &GPIO_InitStructure); |
GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1; |
GPIO_Init(GPIO5, &GPIO_InitStructure); |
// set both ports low |
GPIO_WriteBit(GPIO5, GPIO_Pin_6, Bit_RESET); |
GPIO_WriteBit(GPIO5, GPIO_Pin_7, Bit_RESET); |
// Check LED Polarity |
/*Configure LED_GRN at pin GPIO5.6 and LED_RED at pin GPIO5.7 as input*/ |
GPIO_StructInit(&GPIO_InitStructure); |
GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull; |
GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1; |
GPIO_Init(GPIO5, &GPIO_InitStructure); |
// get polarity of LED ports |
for(i=0;i<500;i++) p5 = GPIO_Read(GPIO5); |
Led_Grn_Inv = 0x01 & (p5>>6); |
Led_Red_Inv = 0x01 & (p5>>7); |
/*Configure LED_GRN at pin GPIO5.6 and LED_RED at pin GPIO5.7 as output*/ |
GPIO_StructInit(&GPIO_InitStructure); |
GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; |
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; |
GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; |
GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1; |
GPIO_Init(GPIO5, &GPIO_InitStructure); |
LED_GRN_OFF; |
LED_RED_OFF; |
} |
LED_RED_OFF; |
if(Led_Grn_Inv) |
{ |
if(Led_Red_Inv) Version_HW = 30; //future use |
else Version_HW = 20; // NC 2.0 |
} |
else |
{ |
if(Led_Red_Inv) Version_HW = 40; // future use |
else Version_HW = 11; // NC 1.x |
} |
} |
/trunk/led.h |
---|
1,16 → 1,18 |
#ifndef _LED_H |
#define _LED_H |
#define LED_GRN_ON GPIO_WriteBit(GPIO5, GPIO_Pin_6, Bit_SET) |
#define LED_GRN_OFF GPIO_WriteBit(GPIO5, GPIO_Pin_6, Bit_RESET) |
#define LED_GRN_TOGGLE if (GPIO_ReadBit(GPIO5, GPIO_Pin_6)) LED_GRN_OFF; else LED_GRN_ON; |
extern u8 Led_Grn_Inv; |
extern u8 Led_Red_Inv; |
#define LED_RED_ON GPIO_WriteBit(GPIO5, GPIO_Pin_7, Bit_SET) |
#define LED_RED_OFF GPIO_WriteBit(GPIO5, GPIO_Pin_7, Bit_RESET) |
#define LED_RED_TOGGLE if (GPIO_ReadBit(GPIO5, GPIO_Pin_7)) LED_RED_OFF; else LED_RED_ON; |
#define LED_GRN_ON {if(Led_Grn_Inv) GPIO_WriteBit(GPIO5, GPIO_Pin_6, Bit_RESET); else GPIO_WriteBit(GPIO5, GPIO_Pin_6, Bit_SET);} |
#define LED_GRN_OFF {if(Led_Grn_Inv) GPIO_WriteBit(GPIO5, GPIO_Pin_6, Bit_SET); else GPIO_WriteBit(GPIO5, GPIO_Pin_6, Bit_RESET);} |
#define LED_GRN_TOGGLE if (GPIO_ReadBit(GPIO5, GPIO_Pin_6)) GPIO_WriteBit(GPIO5, GPIO_Pin_6, Bit_RESET); else GPIO_WriteBit(GPIO5, GPIO_Pin_6, Bit_SET); |
#define LED_RED_ON {if(Led_Red_Inv) GPIO_WriteBit(GPIO5, GPIO_Pin_7, Bit_RESET); else GPIO_WriteBit(GPIO5, GPIO_Pin_7, Bit_SET);} |
#define LED_RED_OFF {if(Led_Red_Inv) GPIO_WriteBit(GPIO5, GPIO_Pin_7, Bit_SET); else GPIO_WriteBit(GPIO5, GPIO_Pin_7, Bit_RESET);} |
#define LED_RED_TOGGLE if (GPIO_ReadBit(GPIO5, GPIO_Pin_7)) GPIO_WriteBit(GPIO5, GPIO_Pin_7, Bit_RESET); else GPIO_WriteBit(GPIO5, GPIO_Pin_7, Bit_SET); |
extern u8 Version_HW; |
void Led_Init(void); |
#endif //_LED_H |
/trunk/main.c |
---|
82,7 → 82,6 |
#include "eeprom.h" |
u8 BoardRelease = 0; |
u32 TimerCheckError; |
u8 ErrorCode = 0; |
u16 BeepTime; |
123,8 → 122,8 |
void GetNaviCtrlVersion(void) |
{ |
u8 msg[25]; |
sprintf(msg,"\n\r NaviCtrl V%d.%d%c", VERSION_MAJOR, VERSION_MINOR, 'a'+ VERSION_PATCH); |
sprintf(msg,"\n\r NaviCtrl HW: V%d.%d SW: V%d.%d%c", Version_HW/10, Version_HW%10, VERSION_MAJOR, VERSION_MINOR, 'a'+ VERSION_PATCH); |
UART1_PutString(msg); |
} |
/trunk/main.h |
---|
52,6 → 52,7 |
#define NCERR_FLAG_MKGPS_COMMUNICATION 0x00000010 |
#define NCERR_FLAG_BAD_COMPASS_HEADING 0x00000020 |
#define NCERR_FLAG_RC_SIGNAL_LOST 0x00000040 |
#define NCERR_FLAG_EEPROM_NOT_FOUND 0x00000080 |
#define LIMIT_MIN(value, min) {if(value <= min) value = min;} |
58,7 → 59,6 |
#define LIMIT_MAX(value, max) {if(value >= max) value = max;} |
#define LIMIT_MIN_MAX(value, min, max) {if(value <= min) value = min; else if(value >= max) value = max;} |
extern u8 BoardRelease; |
extern u16 BeepTime; |
extern u8 NCFlags; |
extern u8 ClearFCStatusFlags; |
/trunk/menu.c |
---|
57,6 → 57,7 |
#include <stdlib.h> |
#include "91x_lib.h" |
#include "main.h" |
#include "led.h" |
#include "ubx.h" |
#include "GPS.h" |
#include "timer1.h" |
112,10 → 113,13 |
// Version Info |
case 0: |
LCD_printfxy(0,0,"++ Navi-Ctrl ++"); |
LCD_printfxy(0,1," V%d.%d%c ", VERSION_MAJOR, VERSION_MINOR, 'a'+ VERSION_PATCH); |
if(ErrorCode) LCD_printfxy(11,1," Err:%d",ErrorCode) else LCD_printfxy(11,1," "); |
LCD_printfxy(0,2,"%s",ErrorMSG); |
LCD_printfxy(0,3,"(c) Buss, Busker"); |
LCD_printfxy(0,1,"HW V%d.%d SW V%d.%d%c", Version_HW/10, Version_HW%10, VERSION_MAJOR, VERSION_MINOR, 'a'+ VERSION_PATCH); |
if(ErrorCode) |
{ |
LCD_printfxy(0,2,"Error: %d",ErrorCode); |
LCD_printfxy(0,3,"%s",ErrorMSG); |
} |
else LCD_printfxy(0,3,"(c) Buss, Busker"); |
break; |
case 1: |
if (GPSData.Status == INVALID) |
/trunk/ncmag.c |
---|
734,8 → 734,12 |
else |
{ |
NCMAG_Present = 1; |
NCMAG_IsCalibrated = NCMag_CalibrationRead(); |
if(!NCMAG_IsCalibrated) UART1_PutString("\r\n Not calibrated!"); |
if(EEPROM_Init()) |
{ |
NCMAG_IsCalibrated = NCMag_CalibrationRead(); |
if(!NCMAG_IsCalibrated) UART1_PutString("\r\n Not calibrated!"); |
} |
else UART1_PutString("\r\n Calibration data not available!"); |
} |
} |
else |
/trunk/spi_slave.c |
---|
302,7 → 302,7 |
ToFlightCtrl.Param.Byte[1] = VERSION_MINOR; |
ToFlightCtrl.Param.Byte[2] = VERSION_PATCH; |
ToFlightCtrl.Param.Byte[3] = FC_SPI_COMPATIBLE; |
ToFlightCtrl.Param.Byte[4] = BoardRelease; |
ToFlightCtrl.Param.Byte[4] = Version_HW; |
ToFlightCtrl.Param.Byte[5] = DebugOut.Status[0]; |
ToFlightCtrl.Param.Byte[6] = DebugOut.Status[1]; |
ToFlightCtrl.Param.Byte[7] = ErrorCode; |
/trunk/ubx.c |
---|
279,8 → 279,6 |
/********************************************************/ |
void Update_GPSData(void) |
{ |
static u32 LastTimeStamp = 0; |
u32 TimeStamp; |
static u32 last_itow = 0; |
// if a new set of ubx messages was collected |
288,8 → 286,6 |
{ // and the itow is equal (same time base) |
if((UbxSol.itow == UbxPosLlh.itow) && (UbxPosLlh.itow == UbxVelNed.itow)) |
{ |
DebugOut.Analog[23] = (u16)(UbxSol.itow-last_itow); |
last_itow = UbxSol.itow; // update last itow |
UBX_Timeout = SetDelay(UBX_TIMEOUT); |
DebugOut.Analog[9]++; |
// update GPS data only if the status is INVALID or PROCESSED |
297,9 → 293,8 |
{ // wait for new data at all neccesary ubx messages |
GPSData.Status = INVALID; |
// update message cycle time |
TimeStamp = CountMilliseconds; |
GPSData.MsgCycleTime = (u16)(TimeStamp - LastTimeStamp); |
LastTimeStamp = TimeStamp; |
GPSData.MsgCycleTime = (u16)(UbxSol.itow-last_itow); |
last_itow = UbxSol.itow; // update last itow |
DebugOut.Analog[16] = GPSData.MsgCycleTime; |
// NAV SOL |
GPSData.Flags = UbxSol.Flags; |