/beta/Code Redesign killagreg/spectrum.c |
---|
File deleted |
/beta/Code Redesign killagreg/spectrum.h |
---|
File deleted |
/beta/Code Redesign killagreg/FlightControl.pnproj |
---|
1,0 → 0,0 |
<Project name="FlightControl"><Folder name="Sources"><File path="ubx.c"></File><File path="analog.c"></File><File path="dsl.c"></File><File path="eeprom.c"></File><File path="fc.c"></File><File path="gps.c"></File><File path="led.c"></File><File path="main.c"></File><File path="menu.c"></File><File path="mk3mag.c"></File><File path="mm3.c"></File><File path="mymath.c"></File><File path="printf_P.c"></File><File path="rc.c"></File><File path="spectrum.c"></File><File path="spi.c"></File><File path="timer0.c"></File><File path="timer2.c"></File><File path="twimaster.c"></File><File path="uart0.c"></File><File path="uart1.c"></File><File path="isqrt.S"></File></Folder><Folder name="Header"><File path="ubx.h"></File><File path="analog.h"></File><File path="dsl.h"></File><File path="eeprom.h"></File><File path="fc.h"></File><File path="gps.h"></File><File path="led.h"></File><File path="main.h"></File><File path="menu.h"></File><File path="mk3mag.h"></File><File path="mm3.h"></File><File path="mymath.h"></File><File path="old_macros.h"></File><File path="printf_P.h"></File><File path="rc.h"></File><File path="spectrum.h"></File><File path="spi.h"></File><File path="timer0.h"></File><File path="timer2.h"></File><File path="twimaster.h"></File><File path="uart0.h"></File><File path="uart1.h"></File></Folder><File path="License.txt"></File><File path="makefile"></File><File path="version.txt"></File></Project> |
<Project name="FlightControl"><Folder name="Sources"><File path="ubx.c"></File><File path="analog.c"></File><File path="dsl.c"></File><File path="eeprom.c"></File><File path="fc.c"></File><File path="gps.c"></File><File path="led.c"></File><File path="main.c"></File><File path="menu.c"></File><File path="mk3mag.c"></File><File path="mm3.c"></File><File path="mymath.c"></File><File path="printf_P.c"></File><File path="rc.c"></File><File path="spi.c"></File><File path="timer0.c"></File><File path="timer2.c"></File><File path="twimaster.c"></File><File path="uart0.c"></File><File path="uart1.c"></File><File path="isqrt.S"></File><File path="spektrum.c"></File></Folder><Folder name="Header"><File path="ubx.h"></File><File path="analog.h"></File><File path="dsl.h"></File><File path="eeprom.h"></File><File path="fc.h"></File><File path="gps.h"></File><File path="led.h"></File><File path="main.h"></File><File path="menu.h"></File><File path="mk3mag.h"></File><File path="mm3.h"></File><File path="mymath.h"></File><File path="old_macros.h"></File><File path="printf_P.h"></File><File path="rc.h"></File><File path="spi.h"></File><File path="timer0.h"></File><File path="timer2.h"></File><File path="twimaster.h"></File><File path="uart0.h"></File><File path="uart1.h"></File><File path="spektrum.h"></File><File path="libfcinit.h"></File></Folder><File path="License.txt"></File><File path="makefile"></File><File path="version.txt"></File></Project> |
/beta/Code Redesign killagreg/FlightControl.pnps |
---|
1,0 → 0,0 |
<pd><ViewState><e p="FlightControl" x="true"></e><e p="FlightControl\Header" x="false"></e><e p="FlightControl\Sources" x="true"></e></ViewState></pd> |
<pd><ViewState><e p="FlightControl" x="true"></e><e p="FlightControl\Header" x="true"></e><e p="FlightControl\Sources" x="true"></e></ViewState></pd> |
/beta/Code Redesign killagreg/dsl.c |
---|
106,10 → 106,15 |
ChannelPair_t ChannelPair; |
void Dsl_Init(void) |
{ |
} |
// This function is called, when a new servo signal is properly received. |
// Parameters: servo - servo number (0-9) |
// signal - servo signal between 7373 (1ms) and 14745 (2ms) |
void dsl_new_signal(uint8_t channel, int16_t signal) |
void Dsl_new_signal(uint8_t channel, int16_t signal) |
{ |
int16_t tmp; |
uint8_t index = channel + 1; // mk channels start with 1 |
153,7 → 158,7 |
// This function is called within dsl_parser(), when a complete |
// data packet with valid checksum has been received. |
void dsl_decode_packet(void) |
void Dsl_decode_packet(void) |
{ |
uint8_t i; |
189,8 → 194,8 |
ChannelPair.byte[0] = PacketBuffer[2]; |
ChannelPair.byte[3] = PacketBuffer[3]; |
ChannelPair.byte[2] = PacketBuffer[4]; |
dsl_new_signal(i, ChannelPair.Servo[0]); |
dsl_new_signal(i+1,ChannelPair.Servo[1]); |
Dsl_new_signal(i, ChannelPair.Servo[0]); |
Dsl_new_signal(i+1,ChannelPair.Servo[1]); |
} |
} |
} // EOF header condition |
198,7 → 203,7 |
// this function should be called within the UART RX ISR |
void dsl_parser(uint8_t c) |
void Dsl_Parser(uint8_t c) |
{ |
static uint8_t last_c = 0; |
static uint8_t crc = 0; |
224,7 → 229,7 |
crc = ~crc; |
if (crc == 0xFF) crc = 0xFE; |
// if crc matches decode the packet |
if (c == crc) dsl_decode_packet(); |
if (c == crc) Dsl_decode_packet(); |
// handle next packet |
cnt = 0; |
crc = 0; |
/beta/Code Redesign killagreg/dsl.h |
---|
4,12 → 4,15 |
#include <inttypes.h> |
extern uint8_t dsl_RSSI; // Received signal strength indicator |
extern uint8_t dsl_Battery; // Battery voltage (0-255 [0V - 8.2V]) |
extern uint8_t dsl_Allocation; // Frequency allocation (35,40,72) |
extern uint8_t dsl_Battery; // Battery voltage (0-255 [0V - 8.2V]) |
extern uint8_t dsl_Allocation; // Frequency allocation (35,40,72) |
#define USART1_BAUD 38400 |
// initialization |
extern void Dsl_Init(void); |
// this function should be called within the UART RX ISR |
extern void dsl_parser(uint8_t c); |
extern void Dsl_Parser(uint8_t c); |
#endif //_DSL_H |
/beta/Code Redesign killagreg/eeprom.c |
---|
143,7 → 143,7 |
ParamSet.LowVoltageWarning = 33; // automatic cell detection for values < 50 |
ParamSet.EmergencyGas = 35; |
ParamSet.EmergencyGasDuration = 30; |
ParamSet.UfoArrangement = 0; |
ParamSet.Receiver = 0; |
ParamSet.IFactor = 32; |
ParamSet.UserParam1 = 0; |
ParamSet.UserParam2 = 0; |
246,7 → 246,7 |
ParamSet.LowVoltageWarning = 33; // auto cell detection for values < 50 |
ParamSet.EmergencyGas = 35; |
ParamSet.EmergencyGasDuration = 30; |
ParamSet.UfoArrangement = 0; |
ParamSet.Receiver = 0; |
ParamSet.IFactor = 32; |
ParamSet.UserParam1 = 0; |
ParamSet.UserParam2 = 0; |
349,7 → 349,7 |
ParamSet.LowVoltageWarning = 33; // auto cell detection for values < 50 |
ParamSet.EmergencyGas = 35; |
ParamSet.EmergencyGasDuration = 20; |
ParamSet.UfoArrangement = 0; |
ParamSet.Receiver = 0; |
ParamSet.IFactor = 16; |
ParamSet.UserParam1 = 0; |
ParamSet.UserParam2 = 0; |
/beta/Code Redesign killagreg/eeprom.h |
---|
79,6 → 79,12 |
#define CFG2_RES4 0x40 |
#define CFG2_RES5 0x80 |
#define RECV_PPMONLY 0 |
#define RECV_SPEKTRUM 1 |
#define RECV_JETI 2 |
#define RECV_ACT_DSL 3 |
#define RECV_ACT_S3D 4 |
// defines for lookup ParamSet.ChannelAssignment |
#define CH_NICK 0 |
#define CH_ROLL 1 |
135,7 → 141,7 |
uint8_t LowVoltageWarning; // Value : 0-247 |
uint8_t EmergencyGas; // Value : 0-247 //Gaswert bei Empängsverlust |
uint8_t EmergencyGasDuration; // Value : 0-247 // Zeitbis auf EmergencyGas geschaltet wird, wg. Rx-Problemen |
uint8_t UfoArrangement; // x or + Formation |
uint8_t Receiver; // Value : 0= Summensignal, 1 = Spektrum, 2 = Jeti, 3 = ACT DSL, 4 = ACT S3D |
uint8_t IFactor; // Value : 0-247 |
uint8_t UserParam1; // Value : 0-247 |
uint8_t UserParam2; // Value : 0-247 |
/beta/Code Redesign killagreg/fc.c |
---|
1458,7 → 1458,7 |
DebugOut.Analog[11] = YawGyroHeading / GYRO_DEG_FACTOR; |
DebugOut.Analog[19] = CompassCalState; |
DebugOut.Analog[20] = ServoNickValue; |
//DebugOut.Analog[29] = NCSerialDataOkay; |
DebugOut.Analog[29] = NCSerialDataOkay; |
DebugOut.Analog[30] = GPSStickNick; |
DebugOut.Analog[31] = GPSStickRoll; |
} |
/beta/Code Redesign killagreg/fc.h |
---|
158,7 → 158,7 |
#define FCFLAG_EMERGENCY_LANDING 0x10 |
#define FCFLAG_LOWBAT 0x20 |
#define FCFLAG_SPI_RX_ERR 0x40 |
#define FCFLAG_RESERVE1 0x80 |
#define FCFLAG_I2C_ERR 0x80 |
extern volatile uint8_t FCFlags; |
/beta/Code Redesign killagreg/led.c |
---|
74,6 → 74,7 |
{ |
static uint8_t delay = 0; |
static uint8_t J16Bitmask = 0, J17Bitmask = 0; |
static uint8_t J16Warn = 0, J17Warn = 0; |
80,60 → 81,87 |
if(!delay--) // 10 ms intervall |
{ |
delay = 4; |
if(FCFlags & FCFLAG_LOWBAT) |
if(FCFlags & (FCFLAG_LOWBAT|FCFLAG_EMERGENCY_LANDING|FCFLAG_I2C_ERR)) |
{ |
J16Bitmask = ParamSet.J16Bitmask_Warning; |
J17Bitmask = ParamSet.J17Bitmask_Warning; |
if(ParamSet.J16Bitmask_Warning) |
{ |
if(!J16Warn) J16Blinkcount = 4; |
J16Warn = 1; |
} |
if(ParamSet.J17Bitmask_Warning) |
{ |
if(!J17Warn) J17Blinkcount = 4; |
J17Warn = 1; |
} |
} |
else |
{ |
J16Warn = 0; |
J17Warn = 0; |
J16Bitmask = ParamSet.J16Bitmask; |
J17Bitmask = ParamSet.J17Bitmask; |
} |
if( (ParamSet.Config1 & CFG1_MOTOR_BLINK) && !(FCFlags & FCFLAG_MOTOR_RUN)) |
if(!J16Warn) |
{ |
if(ParamSet.Config1 & CFG1_MOTOR_OFF_LED1) J16_ON; |
else J16_OFF; |
if( (ParamSet.Config1 & CFG1_MOTOR_BLINK) && !(FCFlags & FCFLAG_MOTOR_RUN)) |
{ |
if(ParamSet.Config1 & CFG1_MOTOR_OFF_LED1) J16_ON; |
else J16_OFF; |
} |
else if((ParamSet.J16Timing > 247) && (FCParam.J16Timing > 220)) |
{ |
if(J16Bitmask & 128) J16_ON; |
else J16_OFF; |
} |
else if ((ParamSet.J16Timing > 247) && (FCParam.J16Timing < 10)) |
{ |
if(J16Bitmask & 128) J16_OFF; |
else J16_ON; |
} |
else if(!J16Blinkcount--) |
{ |
J16Blinkcount = FCParam.J16Timing - 1; |
if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2; |
if(J16Mask & J16Bitmask) J16_ON; else J16_OFF; |
} |
} |
else if((ParamSet.J16Timing > 247) && (FCParam.J16Timing > 220)) |
{ |
if(J16Bitmask & 128) J16_ON; |
else J16_OFF; |
} |
else if ((ParamSet.J16Timing > 247) && (FCParam.J16Timing < 10)) |
{ |
if(J16Bitmask & 128) J16_OFF; |
else J16_ON; |
} |
else if(!J16Blinkcount--) |
{ |
J16Blinkcount = FCParam.J16Timing - 1; |
J16Blinkcount = 10-1; |
if(J16Mask == 1) J16Mask = 128; else J16Mask /= 2; |
if(J16Mask & J16Bitmask) J16_ON; else J16_OFF; |
if(J16Mask & ParamSet.J16Bitmask_Warning) J16_ON; else J16_OFF; |
} |
if( (ParamSet.Config1 & CFG1_MOTOR_BLINK) && !(FCFlags & FCFLAG_MOTOR_RUN)) |
if(!J17Warn) |
{ |
if(ParamSet.Config1 & CFG1_MOTOR_OFF_LED2) J17_ON; |
else J17_OFF; |
if( (ParamSet.Config1 & CFG1_MOTOR_BLINK) && !(FCFlags & FCFLAG_MOTOR_RUN)) |
{ |
if(ParamSet.Config1 & CFG1_MOTOR_OFF_LED2) J17_ON; |
else J17_OFF; |
} |
else if((ParamSet.J17Timing > 247) && (FCParam.J17Timing > 220)) |
{ |
if(J17Bitmask & 128) J17_ON; |
else J17_OFF; |
} |
else if ((ParamSet.J17Timing > 247) && (FCParam.J17Timing < 10)) |
{ |
if(J17Bitmask & 128) J17_OFF; |
else J17_ON; |
} |
else if(!J17Blinkcount--) |
{ |
J17Blinkcount = FCParam.J17Timing - 1; |
if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2; |
if(J17Mask & J17Bitmask) J17_ON; else J17_OFF; |
} |
else if(!J17Blinkcount--) |
{ |
J17Blinkcount = 10-1; |
if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2; |
if(J17Mask & ParamSet.J17Bitmask_Warning) J17_ON; else J17_OFF; |
} |
} |
else if((ParamSet.J17Timing > 247) && (FCParam.J17Timing > 220)) |
{ |
if(J17Bitmask & 128) J17_ON; |
else J17_OFF; |
} |
else if ((ParamSet.J17Timing > 247) && (FCParam.J17Timing < 10)) |
{ |
if(J17Bitmask & 128) J17_OFF; |
else J17_ON; |
} |
else if(!J17Blinkcount--) |
{ |
J17Blinkcount = FCParam.J17Timing - 1; |
if(J17Mask == 1) J17Mask = 128; else J17Mask /= 2; |
if(J17Mask & J17Bitmask) J17_ON; else J17_OFF; |
} |
} |
} |
/beta/Code Redesign killagreg/main.c |
---|
78,8 → 78,8 |
#endif |
#include "twimaster.h" |
#include "eeprom.h" |
#include "libfcinit.h" |
uint8_t BoardRelease = 10; |
uint8_t CPUType = ATMEGA644; |
uint8_t LowVoltageWarning = 94; |
165,7 → 165,7 |
int16_t main (void) |
{ |
uint16_t timer, flighttimer; |
uint16_t timer, flighttimer, pollingtimer; |
uint8_t i; |
// disable interrupts global |
194,7 → 194,6 |
TIMER0_Init(); |
TIMER2_Init(); |
USART0_Init(); |
if(CPUType == ATMEGA644P) USART1_Init(); |
RC_Init(); |
ADC_Init(); |
I2C_Init(); |
208,6 → 207,9 |
MK3MAG_Init(); |
#endif |
if(CPUType == ATMEGA644P) USART1_Init(); |
InitFC(); // libfcinit |
// enable interrupts global |
sei(); |
331,10 → 333,19 |
printf("\n\r===================================\n\r"); |
timer = SetDelay(2000); |
pollingtimer = SetDelay(250); |
// begin of main loop |
while (1) |
{ |
if(CheckDelay(pollingtimer)) |
{ |
pollingtimer = SetDelay(100); |
Polling(); // libfcinit |
} |
if(UpdateMotor && ADReady) // control interval |
{ |
UpdateMotor = 0; // reset Flag, is enabled every 2 ms by ISR of timer0 |
349,7 → 360,7 |
if(RC_Quality) RC_Quality--; |
else PPM_INPUT_ON; // if RC-Quality is lost, enable PPM input (could be disabled by a receiver on uart1) |
if(!--I2CTimeout || MissingMotor) // try to reset the i2c if motor is missing ot timeout |
if(!--I2CTimeout || MissingMotor) // try to reset the i2c if motor is missing or timeout |
{ |
RED_ON; |
if(!I2CTimeout) |
357,6 → 368,7 |
I2C_Reset(); |
I2CTimeout = 5; |
DebugOut.Analog[28]++; // I2C-Error |
FCFlags |= FCFLAG_I2C_ERR; |
} |
if((BeepModulation == 0xFFFF) && (FCFlags & FCFLAG_MOTOR_RUN) ) |
{ |
367,6 → 379,7 |
else |
{ |
RED_OFF; |
if(!BeepTime) FCFlags &= ~FCFLAG_I2C_ERR; |
} |
// allow Serial Data Transmit if motors must not updated or motors are not running |
396,7 → 409,7 |
if(NCDataOkay) |
{ |
NCDataOkay--; |
FCFlags &= ~FCFLAG_SPI_RX_ERR; |
if(!BeepTime) FCFlags &= ~FCFLAG_SPI_RX_ERR; |
} |
else // no data from NC |
{ // set gps control sticks neutral |
416,7 → 429,7 |
} |
else |
{ |
FCFlags &= ~FCFLAG_LOWBAT; |
if(!BeepTime) FCFlags &= ~FCFLAG_LOWBAT; |
} |
#ifdef USE_NAVICTRL |
SPI_StartTransmitPacket(); |
/beta/Code Redesign killagreg/makefile |
---|
129,7 → 129,7 |
SRC += dsl.c |
endif |
ifeq ($(RC), SPEKTRUM) |
SRC += spectrum.c |
SRC += spektrum.c |
endif |
endif |
########################################################################################################## |
221,7 → 221,10 |
# -lm = math library |
LDFLAGS += -lm |
# extern lib |
LDFLAGS += libfcinit.a |
##LDFLAGS += -T./linkerfile/avr5.x |
/beta/Code Redesign killagreg/spektrum.c |
---|
0,0 → 1,219 |
#include <stdlib.h> |
#include "spektrum.h" |
#include "rc.h" |
uint8_t SpektrumTimer; |
/* |
Code derived from: |
Copyright (c) Rainer Walther |
RC-routines from original MK rc.c (c) H&I |
Useful infos from Walter: http://www.rcgroups.com/forums/showthread.php?t=714299&page=2 |
only for non-profit use |
Connection of Spectrum Sattelite to SV1 of FC: |
Orange: 3V from the FC (never connect 5V!) |
Black: GND |
Gray: RXD1 (Pin 3) |
If a receiver is connected via PPM input at the same time, the PPM input will be disabled |
if a stable signal can be captured by the uart. |
Data are send at every 20 ms @ 115200 Baud 8-N-1 |
DX7/DX6i: One data-frame @ 115200 Baud 8-N-1 every 22ms. |
DX7se: One data-frame @ 115200 Baud 8-N-1 every 11ms. |
Frame consist of: |
byte1: unknown |
byte2: unknown |
byte3: and byte4: channel data |
byte5: and byte6: channel data |
byte7: and byte8: channel data |
byte9: and byte10: channel data |
byte11: and byte12: channel data |
byte13: and byte14: channel data |
byte15: and byte16: channel data |
DS9 (9 Channel): One data-frame @ 115200 Baud 8-N-1 every 11ms, |
alternating frame 1/2 for CH1-7 / CH8-9 |
1st Frame consist of: |
byte1: unknown |
byte2: unknown |
byte3: and byte4: channel data |
byte5: and byte6: channel data |
byte7: and byte8: channel data |
byte9: and byte10: channel data |
byte11: and byte12: channel data |
byte13: and byte14: channel data |
byte15: and byte16: channel data |
2nd Frame consist of: |
byte1: unknown |
byte2: unknown |
byte3: and byte4: channel data |
byte5: and byte6: channel data |
byte7: and byte8: 0xffff |
byte9: and byte10: 0xffff |
byte11: and byte12: 0xffff |
byte13: and byte14: 0xffff |
byte15: and byte16: 0xffff |
Each channel data (16 bit = 2byte, first msb, second lsb) is arranged as: |
Bits: F 0 C3 C2 C1 C0 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 |
0 means a '0' bit |
F: 0 = indicate first frame, 1 = indicates beginning of 2nd frame for CH8-9 (DS9 only) |
C3 to C0 is the channel number. 0 to 9 (4 bit, as assigned in the transmitter) |
D9 to D0 is the channel data (10 bit) 0xaa..0x200..0x356 for 100% transmitter-travel |
*/ |
void Spektrum_Init(void) |
{ |
} |
#define MIN_FRAMEGAP 68 // 7ms |
#define MAX_BYTEGAP 3 // 375us |
void Spektrum_Parser(uint8_t c) |
{ |
static uint8_t Sync = 0, FrameCnt = 0, ByteHigh = 0, ReSync = 1, Frame2 = 0; |
uint16_t Channel, index; |
int16_t signal; //tmp; |
int16_t bCheckDelay; |
if (ReSync == 1) |
{ |
// wait for beginning of new frame |
ReSync = 0; |
SpektrumTimer = MIN_FRAMEGAP; |
FrameCnt = 0; |
Sync = 0; |
ByteHigh = 0; |
} |
else |
{ |
if(!SpektrumTimer) bCheckDelay = 1; |
else bCheckDelay = 0; |
if ( Sync == 0 ) |
{ |
if(bCheckDelay) |
{ |
// nach einer Pause von mind. 7ms erstes Sync-Character gefunden |
// Zeichen ignorieren, da Bedeutung unbekannt |
SpektrumTimer = MAX_BYTEGAP; |
FrameCnt++; |
Sync = 1; |
} |
else |
{ |
// Zeichen kam vor Ablauf der 7ms Sync-Pause |
// warten auf erstes Sync-Zeichen |
SpektrumTimer = MIN_FRAMEGAP; |
FrameCnt = 0; |
Sync = 0; |
ByteHigh = 0; |
} |
} |
else if((Sync == 1) && !bCheckDelay) |
{ |
// zweites Sync-Character ignorieren, Bedeutung unbekannt |
SpektrumTimer = MAX_BYTEGAP; |
Sync = 2; |
FrameCnt++; |
} |
else if((Sync == 2) && !bCheckDelay) |
{ |
// Datenbyte high |
SpektrumTimer = MAX_BYTEGAP; |
ByteHigh = c; |
if (FrameCnt == 2) |
{ |
// is 1st Byte of Channel-data |
// Frame 1 with Channel 1-7 comming next |
Frame2 = 0; |
if(ByteHigh & 0x80) |
{ |
// DS9: Frame 2 with Channel 8-9 comming next |
Frame2 = 1; |
} |
} |
Sync = 3; |
FrameCnt ++; |
} |
else if((Sync == 3) && !bCheckDelay) |
{ |
// Datenbyte low |
// High-Byte for next channel comes next |
SpektrumTimer = MAX_BYTEGAP; |
Sync = 2; |
FrameCnt ++; |
index = (ByteHigh >> 2) & 0x0f; |
index ++; |
Channel = ((uint16_t)ByteHigh << 8) | c; |
signal = Channel & 0x3ff; |
signal -= 0x200; // Offset, range 0x000..0x3ff? |
signal = signal/3; // scaling to fit PPM resolution |
if(index > 0 && index < MAX_RC_CHANNELS) |
{ |
if(RC_Channels < index) RC_Channels = index; |
// Stabiles Signal |
if(abs(signal - PPM_in[index]) < 6) |
{ |
if(RC_Quality < 200) |
{ |
RC_Quality += 10; |
} |
else |
{ |
RC_Quality = 200; |
PPM_INPUT_OFF; // disable PPM input at ICP |
} |
} |
tmp = (3 * PPM_in[index] + signal)/4; |
if(tmp > signal+1) tmp--; |
else if(tmp < signal-1) tmp++; |
// calculate signal difference on good signal level |
if(RC_Quality >= 180) PPM_diff[index] = ((signal - PPM_in[index]) / 3) * 3; |
else PPM_diff[index] = 0; |
PPM_in[index] = signal; |
} |
else if(index > 17) ReSync = 1; // hier stimmt was nicht: neu synchronisieren |
} |
else |
{ |
// hier stimmt was nicht: neu synchronisieren |
SpektrumTimer = MIN_FRAMEGAP; // next frame expexted after 7ms |
ReSync = 1; |
FrameCnt = 0; |
Frame2 = 0; |
} |
// 16 Bytes per frame --> frame complete |
if(FrameCnt >= 16) |
{ |
// Frame complete |
if(Frame2 == 0) |
{ |
// Null bedeutet: Neue Daten |
// nur beim ersten Frame (CH 0-7) setzen |
if(!ReSync) NewPpmData = 0; |
} |
SpektrumTimer = MIN_FRAMEGAP; |
FrameCnt = 0; |
Frame2 = 0; |
Sync = 0; |
} |
} |
} |
/beta/Code Redesign killagreg/spektrum.h |
---|
0,0 → 1,15 |
#ifndef _SPEKTRUM_H |
#define _SPEKTRUM_H |
#include <inttypes.h> |
#define USART1_BAUD 115200 |
extern uint8_t SpektrumTimer; |
// initalization |
extern void Spektrum_Init(void); |
// this function should be called within the UART RX ISR |
extern void Spektrum_Parser(uint8_t c); |
#endif //_SPEKTRUM_H |
/beta/Code Redesign killagreg/timer0.c |
---|
63,7 → 63,7 |
#include "mk3mag.h" |
#endif |
#ifdef USE_RC_SPEKTRUM |
#include "spectrum.h" |
#include "spektrum.h" |
#endif |
/beta/Code Redesign killagreg/uart1.c |
---|
60,7 → 60,7 |
#include "dsl.h" |
#endif |
#ifdef USE_RC_SPEKTRUM |
#include "spectrum.h" |
#include "spektrum.h" |
#endif |
#endif |
163,10 → 163,10 |
ubx_parser(c); // and put it into the ubx protocol parser |
#else |
#ifdef USE_RC_DSL |
dsl_parser(c); // parse dsl data stream |
Dsl_Parser(c); // parse dsl data stream |
#endif |
#ifdef USE_RC_SPEKTRUM |
spectrum_parser(c); // parse spectrum data stream |
Spektrum_Parser(c); // parse spectrum data stream |
#endif |
#endif |
} |
/beta/Code Redesign killagreg/version.txt |
---|
352,10 → 352,13 |
- Servos3-5 einstellbar |
- neues Kommando "f" -> schaltet auf anderen Parametersatz um |
0.77b H.Buss 09.12.2009 |
- JetiBox: Menü wird übertragen |
- neu: FCFlags |= FCFLAG_I2CERR; |
- LED-Warn-Blinken nun mit festem Timing und abschaltbar |
Anpassungen bzgl. V0.77a |
G.Stobrawa 26.11.2009: |
G.Stobrawa 10.12.2009: |
- Code stärker modularisiert und restrukturiert |
- viele Kommentare zur Erklärug eingefügt |