/trunk/eeprom.c |
---|
353,4 → 353,31 |
if(LuftdruckTemperaturKompensation) UART1_PutString("\r\n Baro Temperature Calibration active\r\n"); |
} |
void WriteBaudrateIndexToEEprom(void) |
{ |
u8 data[2]; |
#define BAUD_KOMPATIBLE 1 |
data[0] = ToFcBaudrateIndex; |
data[1] = ToFcBaudrateIndex + BAUD_KOMPATIBLE; |
EEPROM_WriteBlock(EEPROM_ADR_BAUDRATE_INDEX,(u8 *)&data,2); |
// UART1_PutString(" EE-BD-WRITE:"); UART1_Putchar('0'+ToFcBaudrateIndex); |
} |
void ReadBaudrateIndexfromEEprom(void) |
{ |
u8 data[2]; |
EEPROM_ReadBlock(EEPROM_ADR_BAUDRATE_INDEX,(u8 *)&data,2); |
if(data[0] + BAUD_KOMPATIBLE == data[1]) |
{ |
ToFcBaudrateIndex = data[0]; |
Uart1Baudrate = BAUDRATES[ToFcBaudrateIndex]; |
// UART1_PutString(" EE-BD-OK:"); UART1_Putchar('0'+ToFcBaudrateIndex); |
} |
else UART1_PutString(" EE-BD-ERR "); |
} |
/trunk/eeprom.h |
---|
1,9 → 1,10 |
#ifndef __EEPROM_H |
#define __EEPROM_H |
// two calibrtion sets for extern and intern sensor |
#define EEPROM_ADR_BAUDRATE_INDEX 44 // 44 - 45 |
#define EEPROM_ADR_BARO_KALIBRATION 46 // 46 - 49 |
#define EEPROM_ADR_MAG_CALIBRATION_INTERN 50 |
#define EEPROM_ADR_MAG_CALIBRATION_INTERN 50 // two calibrtion sets for extern and intern sensor |
#define EEPROM_ADR_MAG_CALIBRATION_EXTERN 70 |
#define EEPROM_ADR_LICENSE_DATA_CRC 124// - 600 |
#define EEPROM_ADR_LICENSE_DATA 128// - 600 |
39,6 → 40,8 |
extern void WriteOemNameToEEPROM(void); |
extern void WriteBaroCalibrationToEEprom(void); |
extern void ReadBaroCalibrationfromEEprom(void); |
void WriteBaudrateIndexToEEprom(void); |
void ReadBaudrateIndexfromEEprom(void); |
#endif // EEPROM_H |
/trunk/main.c |
---|
534,7 → 534,7 |
{ |
if(UART1_BaudrateFallbackTimeout) |
{ |
if(--UART1_BaudrateFallbackTimeout == 0) UART1_Configure(57600); |
if(--UART1_BaudrateFallbackTimeout == 0) UART1_Configure(Uart1Baudrate); |
} |
if(CanbusTimeOut >= 2) CanbusTimeOut--; |
755,8 → 755,21 |
// initialize the LEDs (needs Timer 1) |
Led_Init(); |
// initialize the debug UART1 |
Uart1Baudrate = 57600; |
UART1_Init(); |
UART1_PutString("\r\n---------------------------------------------"); |
I2CBus_Init(I2C1); |
ReadBaudrateIndexfromEEprom(); |
if(Uart1Baudrate != 57600) |
{ |
{ |
u8 msg[30]; |
sprintf(msg, "\r\n<%uBd>\r\n\r\n",Uart1Baudrate); |
UART1_PutString(msg); |
} |
DELAY(100); |
UART1_Init(); |
} |
UART1_PutString("\r---------------------------------------------"); |
// initialize timer 2 for servo outputs |
//TIMER2_Init(); |
// initialize UART2 to FLIGHTCTRL |
769,9 → 782,9 |
SPI0_Init(); |
// initialize i2c busses (needs Timer 1) |
InitCamCtrl(); |
// initialize fat16 partition on sd card (needs Timer 1) |
I2CBus_Init(I2C0); |
I2CBus_Init(I2C1); |
// initialize fat16 partition on sd card (needs Timer 1) |
Fat16_Init(); |
// initialize NC params |
NCParams_Init(); |
784,6 → 797,9 |
LED_GRN_ON; |
TimerCheckError = SetDelay(3000); |
TimerSecond = SetDelay(3500); |
GetBaudrateFromSdCard(Uart1Baudrate); |
UART1_PutString("\r\n++++++++++++++++++++++++++++++++++++++++++"); |
UART1_PutString("\r\n Version information:"); |
/trunk/main.h |
---|
13,7 → 13,7 |
//----------------------- |
#define VERSION_MAJOR 2 |
#define VERSION_MINOR 18 |
#define VERSION_MINOR 19 |
#define VERSION_PATCH 0 |
// 0 = A |
// 1 = B |
37,7 → 37,7 |
#define CAN_SLAVE_COMPATIBLE 2 |
#ifndef FOLLOW_ME |
#define FC_SPI_COMPATIBLE 85 // <------------------ |
#define FC_SPI_COMPATIBLE 86 // <------------------ |
#else |
#define FC_SPI_COMPATIBLE 0xFF |
#endif |
405,5 → 405,6 |
#define TRIGGER_PP_EXTERN PIN6_3 |
#define BLITZ_CONNECTED PIN6_4 |
#define IO1_INPUT PIN6_5 |
#define DELAY(ms) { u32 delay; delay = SetDelay(ms); while(!CheckDelay(delay));} |
#endif // _MAIN_H |
/trunk/params.c |
---|
2,6 → 2,7 |
#include "params.h" |
#include "spi_slave.h" |
#include "waypoints.h" |
#include "eeprom.h" |
s16 NCParams[256]; |
u8 NCParamState[256]; |
/trunk/settings.c |
---|
70,7 → 70,7 |
ParamId_t ParamId; |
s8 Name[17]; // 0 terminator is the last byte |
s8 Comment[60]; |
u8 Group; // 0 = reserved 1,2,3,4 |
u8 OnSdCard; // 1 = this paramater was found vald on the SD-Card |
u16 Value; |
u16 Default; |
u16 Min; |
83,27 → 83,28 |
Parameter_t CFG_Parameter[] = |
{ |
//{PID , "1234567890123456" , Comment, Group, Value, Default, Min, Max }, |
{PID_KML_LOGGING , "KMLLOGGING \0" ,"KML logging interval in ms (0 = disabled) ", 1, 200, 500, 0, 60000}, // the log interval for KML logging, 0 = off |
{PID_GPX_LOGGING , "GPXLOGGING \0" ,"GPX logging interval in ms (0 = disabled) ", 1, 500, 500, 0, 60000}, // the log interval for GPX logging, 0 = off |
{PID_LOG_AT_MOTORRUN , "LOG_AT_MOTOR_RUN\0" ,"Start GPX logfile as soon as motors start (0 = off, 1 = on) ", 1, 1, 1, 0, 1}, |
{PID_SPEAK100M , "HOTT_SPEAK_100M \0" ,"HoTT Speaks '100m' when distance or altitude > 100m (1 = on)", 1, 1, 1, 0, 1}, |
// {PID_ABSOLUTE_FLYING_ALT , "MAX_FLYING_ALT \0" ,"max. altitude in m ", 1, 0, 0, 0, 30000}, // in [m] |
// {PID_ABSOLUTE_FLYING_RANGE , "MAX_FLYING_RANGE\0" ,"max. range in m ", 1, 0, 0, 0, 60000}, // in [m] |
// {PID_AUTO_DESCEND_RANGE , "DESCEND_RANGE \0" ,"Auto-descend range in m (0 = disabled) (only comm. License) ", 1, 0, 0, 0, 60000}, // in [m] |
{PID_GPS_SYSTEM_CFG , "GPS_SYSTEM_CFG \0" ,"1:GPS+GLO+GAL 2:GPS+BDS 3:GPS 4:GLO 5:BDS 6:GPS+GLO 7:GAL ", 1, 1, 1, 0, 99}, |
{PID_GPS_SBAS_CONFIG , "GPS_SBAS_DGPS_ON\0" ,"GPS SBAS mode (0 = off, 1 = on) ", 1, 1, 1, 0, 1}, |
{PID_GPS_QZSS_CONFIG , "GPS_QZSS_DGPS_ON\0" ,"GPS QZSS mode (0 = off, 1 = on) (Japan) ", 1, 1, 0, 0, 1}, |
{PID_AUTO_WP_EVENT_VALUE , "AUTO_WP_EVENT \0" ,"value for the WP-Event Trigger at Auto-Distance [10ms] ", 1, 10, 10, 1, 200}, // in 0,1sek |
// {PID_MIN_EVENT_TIME , "MIN_EVENT_TIME \0" ,"minimum time of the Waypoint-Event value (seconds) ", 1, 2, 2, 0, 600}, // in seconds |
{PID_WP_REACHED_TIMEOUT , "WP_TIMEOUT \0" ,"the MK increases the WP-target radius after this timeout [s]", 1, 5, 5, 0, 6000}, // in seconds |
{PID_WP_ACCELERATE , "WAYPOINT DYNAMIC\0" ,"dynamic for flying waypoints in percent (0-200) ", 1, 100, 100, 0, 255}, // in percent or Poti |
{PID_WP_WAIT_FOR_LED , "WAIT_FOR_OUT1 \0" ,"Wait on Waypoint until Out-Pattern is finished (1=on 0=off) ", 1, 1, 1, 0, 1}, |
{PID_SEND_NMEA , "NMEA_INTERVAL \0" ,"NMEA Output interval in ms (0 = disabled) ", 1, 0, 0, 0, 60000}, // the log interval for NMEA output, 0 = off |
{PID_CH_SPEED , "COMINGHOME_SPEED\0" ,"Maximum speed for coming home in 0,1m/sec (80 = 8,0 m/sec) ", 1, 80, 80, 10, 150}, |
{PID_DPH_SPEED , "DYNAMIC_PH_SPEED\0" ,"Maximum speed for dynamic position hold in 0,1m/sec ", 1, 100, 100, 20, 150}, |
{PID_POSITION_ACCURACY , "POS.ACCURACY \0" ,"Desired Accuracy of position in percent ", 1, 100, 100, 0, 255}, |
{PID_IO1_FUNCTION , "IO1_FUNCTION \0" ,"Function for IO1 input 9 = Parachute (license required) ", 1, 1, 0, 0, 255}, |
{PID_GPS_AUTOCONFIG , "GPSAUTOCONFIG \0" ,"GPS configmode (0 = off, 1 = on) ", 1, 1, 1, 0, 1} |
{PID_KML_LOGGING , "KMLLOGGING \0" ,"KML logging interval in ms (0 = disabled) ", 0, 200, 500, 0, 60000}, // the log interval for KML logging, 0 = off |
{PID_GPX_LOGGING , "GPXLOGGING \0" ,"GPX logging interval in ms (0 = disabled) ", 0, 500, 500, 0, 60000}, // the log interval for GPX logging, 0 = off |
{PID_LOG_AT_MOTORRUN , "LOG_AT_MOTOR_RUN\0" ,"Start GPX logfile as soon as motors start (0 = off, 1 = on) ", 0, 1, 1, 0, 1}, |
{PID_SPEAK100M , "HOTT_SPEAK_100M \0" ,"HoTT Speaks '100m' when distance or altitude > 100m (1 = on)", 0, 1, 1, 0, 1}, |
// {PID_ABSOLUTE_FLYING_ALT , "MAX_FLYING_ALT \0" ,"max. altitude in m ", 0, 0, 0, 0, 30000}, // in [m] |
// {PID_ABSOLUTE_FLYING_RANGE , "MAX_FLYING_RANGE\0" ,"max. range in m ", 0, 0, 0, 0, 60000}, // in [m] |
// {PID_AUTO_DESCEND_RANGE , "DESCEND_RANGE \0" ,"Auto-descend range in m (0 = disabled) (only comm. License) ", 0, 0, 0, 0, 60000}, // in [m] |
{PID_GPS_SYSTEM_CFG , "GPS_SYSTEM_CFG \0" ,"1:GPS+GLO+GAL 2:GPS+BDS 3:GPS 4:GLO 5:BDS 6:GPS+GLO 7:GAL ", 0, 1, 1, 0, 99}, |
{PID_GPS_SBAS_CONFIG , "GPS_SBAS_DGPS_ON\0" ,"GPS SBAS mode (0 = off, 1 = on) ", 0, 1, 1, 0, 1}, |
{PID_GPS_QZSS_CONFIG , "GPS_QZSS_DGPS_ON\0" ,"GPS QZSS mode (0 = off, 1 = on) (Japan) ", 0, 1, 0, 0, 1}, |
{PID_AUTO_WP_EVENT_VALUE , "AUTO_WP_EVENT \0" ,"value for the WP-Event Trigger at Auto-Distance [10ms] ", 0, 10, 10, 1, 200}, // in 0,1sek |
// {PID_MIN_EVENT_TIME , "MIN_EVENT_TIME \0" ,"minimum time of the Waypoint-Event value (seconds) ", 0, 2, 2, 0, 600}, // in seconds |
{PID_WP_REACHED_TIMEOUT , "WP_TIMEOUT \0" ,"the MK increases the WP-target radius after this timeout [s]", 0, 5, 5, 0, 6000}, // in seconds |
{PID_WP_ACCELERATE , "WAYPOINT DYNAMIC\0" ,"dynamic for flying waypoints in percent (0-200) ", 0, 100, 100, 0, 255}, // in percent or Poti |
{PID_WP_WAIT_FOR_LED , "WAIT_FOR_OUT1 \0" ,"Wait on Waypoint until Out-Pattern is finished (1=on 0=off) ", 0, 1, 1, 0, 1}, |
{PID_SEND_NMEA , "NMEA_INTERVAL \0" ,"NMEA Output interval in ms (0 = disabled) ", 0, 0, 0, 0, 60000}, // the log interval for NMEA output, 0 = off |
{PID_CH_SPEED , "COMINGHOME_SPEED\0" ,"Maximum speed for coming home in 0,1m/sec (80 = 8,0 m/sec) ", 0, 80, 80, 10, 150}, |
{PID_DPH_SPEED , "DYNAMIC_PH_SPEED\0" ,"Maximum speed for dynamic position hold in 0,1m/sec ", 0, 100, 100, 20, 150}, |
{PID_POSITION_ACCURACY , "POS.ACCURACY \0" ,"Desired Accuracy of position in percent ", 0, 100, 100, 0, 255}, |
{PID_IO1_FUNCTION , "IO1_FUNCTION \0" ,"Function for IO1 input 9 = Parachute (license required) ", 0, 1, 0, 0, 255}, |
{PID_GPS_AUTOCONFIG , "GPSAUTOCONFIG \0" ,"GPS configmode (0 = off, 1 = on) ", 0, 1, 1, 0, 1}, |
{PID_BAUDRATE , "BAUDRATE \0" ,"Baudrate for the PC-UART (57600 = default) - License only ", 0, 57600, 57600, 1200, 57600} |
}; |
146,6 → 147,7 |
UART1_PutString(text); |
CFG_Parameter[i].Value = CFG_Parameter[i].Default; // fallback to default |
} |
else CFG_Parameter[i].OnSdCard = 1; |
retval = 1; // value in range |
break; // end loop |
} |
232,7 → 234,7 |
sprintf(settingsline, "%s = %d\r\n", CFG_Parameter[i].Name, CFG_Parameter[i].Default); |
fputs_(settingsline, fp); // write to file |
} |
fputs_("\r\n", fp); // newline at the end of file |
fputs_("#------------------------------------------------------\r\n\r\n", fp); // write to file |
fclose_(fp); |
UART1_PutString("Default settings file created!"); |
return; |
258,7 → 260,7 |
if(CFG_Parameter[i].ParamId == Pid) |
{ |
*pValue = CFG_Parameter[i].Value; |
retval = 1; |
retval = CFG_Parameter[i].OnSdCard; // this paramater was found valid on the SD-Card |
break; |
} |
} |
/trunk/settings.h |
---|
25,7 → 25,8 |
PID_AUTO_WP_EVENT_VALUE, |
PID_GPS_SYSTEM_CFG, |
PID_GPS_QZSS_CONFIG, |
PID_IO1_FUNCTION |
PID_IO1_FUNCTION, |
PID_BAUDRATE |
} ParamId_t; |
void Settings_Init(void); |
/trunk/spi_slave.c |
---|
113,6 → 113,7 |
u8 CompassCalState = 0; |
u8 RequestConfigFromFC = 0; |
u8 SendOemName = 0; |
u8 ToFcBaudrateIndex = 8; // 8 = 57600bd |
u8 SPI_CommandSequence[] = { SPI_NCCMD_KALMAN, SPI_NCCMD_GPSINFO, SPI_SERIAL_CH,SPI_OEM_NAME, // Achtung: SPI_SERIAL_CH & SPI_OEM_NAME darf nicht am Ende des Arrays stehen (wird gescipped) |
SPI_NCCMD_KALMAN, SPI_NCCMD_HOTT_INFO, |
510,6 → 511,7 |
ToFlightCtrl.Param.Byte[14] = Partner.StatusFlags; |
ToFlightCtrl.Param.Byte[15] = Partner.StatusFlags2; |
ToFlightCtrl.Param.Byte[16] = Partner.StatusFlags3; |
ToFlightCtrl.Param.Byte[17] = ToFcBaudrateIndex; |
// if(AbsoluteFlyingAltitude > 255) ToFlightCtrl.Param.Byte[11] = 0; // then the limitation of the FC doesn't work |
// else ToFlightCtrl.Param.Byte[11] = AbsoluteFlyingAltitude; |
break; |
/trunk/spi_slave.h |
---|
85,6 → 85,7 |
extern u8 SpeakHoTT; |
extern u8 NC_Wait_for_LED; |
extern u8 CntSpiErrorPerSecond; |
extern u8 ToFcBaudrateIndex; // 8 = 57600bd |
#define MAX_RC_IN 16+12+3+4 // 16ch + 12ser + 3stages + 4 reserved |
extern s8 PPM_In[MAX_RC_IN]; |
/trunk/uart1.c |
---|
83,6 → 83,7 |
#include "crc16.h" |
#include "eeprom.h" |
#include "triggerlog.h" |
#include "settings.h" |
#define LIC_CMD_READ_LICENSE 1 |
#define LIC_CMD_WRITE_LICENSE 2 |
91,6 → 92,8 |
#define FALSE 0 |
#define TRUE 1 |
const u32 BAUDRATES[MAX_BD_RATES] = {1200,2400,4800,9600,14400,19200,28800,38400,57600}; |
#define ABO_TIMEOUT 8000 // disable abo after 8 seconds |
u32 UART1_AboTimeOut = 0; |
134,6 → 137,7 |
u8 NaviData_Flags_SpeakHoTT_Processed = 0; |
u8 NewExternalControlFrame = 0; // flag that sends the Frame to FC |
u16 UART1_BaudrateFallbackTimeout = 0; |
u16 Uart1Baudrate = UART1_BAUD_RATE; |
SerialChannel_t SerialChannel; |
u8 NewSerialChannelFrame = 0; // flag that sends the Frame to FC |
233,6 → 237,32 |
u32 NMEA_Timer = 0; |
u32 NMEA_Interval = 0;// in ms |
void GetBaudrateFromSdCard(u32 oldBd) |
{ |
if(Settings_GetParamValue(PID_BAUDRATE,&Uart1Baudrate)) |
{ |
u8 i; |
for(i=0;i<MAX_BD_RATES;i++) if(Uart1Baudrate == BAUDRATES[i]) break; // search the index and check if it is a valid baudrate |
if(i == 0 || i >= MAX_BD_RATES) |
{ |
UART1_PutString(" Unknown!"); |
ToFcBaudrateIndex = 8; |
Uart1Baudrate = UART1_BAUD_RATE; |
} |
ToFcBaudrateIndex = i; |
WriteBaudrateIndexToEEprom(); |
if(Uart1Baudrate != oldBd) |
{ |
u8 msg[30]; |
sprintf(msg, "\r\n -> Changing Baudrate to:%iBd (%u)\n\r",Uart1Baudrate, ToFcBaudrateIndex); |
UART1_PutString(msg); |
DELAY(100); |
UART1_Init(); |
} |
} else if(oldBd != 57600) UART1_PutString("\r\n No Baudrate on the SD-Card"); |
} |
u8 CalculateDebugLableCrc(void) |
{ |
u16 i; |
300,7 → 330,7 |
UART_InitStructure.UART_WordLength = UART_WordLength_8D; |
UART_InitStructure.UART_StopBits = UART_StopBits_1; |
UART_InitStructure.UART_Parity = UART_Parity_No ; |
UART_InitStructure.UART_BaudRate = UART1_BAUD_RATE; |
UART_InitStructure.UART_BaudRate = Uart1Baudrate; |
UART_InitStructure. UART_HardwareFlowControl = UART_HardwareFlowControl_None; |
UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx; |
UART_InitStructure.UART_FIFO = UART_FIFO_Enable; |
337,7 → 367,7 |
PPM_In[PPM_IN_OFF] = -127; |
PPM_In[PPM_IN_MID] = 0; |
UART1_PutString("\r\n UART1 init...ok"); |
// UART1_PutString("\r\n UART1 init...ok"); |
} |
/****************************************************************/ |
/trunk/uart1.h |
---|
17,7 → 17,11 |
#define DISABLE_FC_UART GPIO_WriteBit(GPIO3, GPIO_Pin_7, Bit_SET); |
#define ENABLE_FC_UART GPIO_WriteBit(GPIO3, GPIO_Pin_7, Bit_RESET); |
extern u16 Uart1Baudrate; |
#define MAX_BD_RATES 9 |
extern const u32 BAUDRATES[MAX_BD_RATES]; |
typedef struct |
{ |
u8 SWMajor; |
358,6 → 362,7 |
extern u8 NaviData_Flags_SpeakHoTT_Processed; |
extern void UART1_Configure(u32 baudrate); |
extern void GetBaudrateFromSdCard(u32 oldBd); |
typedef struct |
{ |