/branches/V0.76g_FC-JN-Receiver/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="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><File path="F:\Projekte\uKopter\Projects LPD\JNFlight-Ctrl\J0.74d\jennic.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="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><File path="F:\Projekte\uKopter\Projects LPD\JNFlight-Ctrl\J0.74d\jennic.h"></File></Folder><File path="License.txt"></File><File path="makefile"></File><File path="version.txt"></File></Project> |
/branches/V0.76g_FC-JN-Receiver/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> |
/branches/V0.76g_FC-JN-Receiver/jennic.c |
---|
0,0 → 1,175 |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// This code (protocol) is inspired by the RCDSL implementation of Stefan Engelke. |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
/* |
Copyright (c) 2008 Stefan Engelke <stefan@tinkerer.eu> |
Permission is hereby granted, free of charge, to any person |
obtaining a copy of this software and associated documentation |
files (the "Software"), to deal in the Software without |
restriction, including without limitation the rights to use, copy, |
modify, merge, publish, distribute, sublicense, and/or sell copies |
of the Software, and to permit persons to whom the Software is |
furnished to do so, subject to the following conditions: |
The above copyright notice and this permission notice shall be |
included in all copies or substantial portions of the Software. |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
DEALINGS IN THE SOFTWARE. |
*/ |
/*********************************************************************************************************** |
* FC_JN_RECEIVER by DLP |
************************************************************************************************************ |
Connection of receiver to SV1 of FC: |
TXD <--> pin 3 (RXD1 Atmega644p) |
RXD <--> pin 4 (TXD1 Atmega644p) |
Data is sent at every 20 ms @ 57600 Baud 8-N-1 |
************************************************************************************************************ |
Data Frame Jennic: |0xFF|0xFF|STATUS|CHN|CH0D1|CH0D0|CH1D1|CH1D0|CRC| |
STATUS = Jennic Network Status (0 = OK, 1 = Coordinator not available, 2 = General Error) |
CHN = Channel Pair (0 = Channel 0 & 1 ...etc) |
Channel Pair: |CHN|CHnD1|CHnD0|CHnD1|CHnD0|CRC| |
CHN is the lower Channel index of the Channel Pair |
n is the Channel |
D1D0 is servo value as u16 in range of 7373 (1ms) to 14745 (2ms) |
there are 8 channels submitted, i.e 4 servo pairs |
Frame example with signal received: |
FFFF 00 0036012B1E7f |
FFFF 00 022AFB2AECC2 |
FFFF 00 042B4D2B4414 |
FFFF 00 0636872B33DE |
Frame example with no signal received: |
FFFF 01 (Network Coordinator not Accessible) |
or |
FFFF 02 (General Error) |
***********************************************************************************************************/ |
#include <stdlib.h> |
#include "jennic.h" |
#include "rc.h" |
#include "uart0.h" |
uint8_t jen_status = 0; |
uint8_t PacketBuffer[9]; |
typedef union |
{ |
int16_t Servo[2]; |
uint8_t byte[4]; |
} ChannelPair_t; |
ChannelPair_t ChannelPair; |
// to be called within the UART RX ISR |
void jen_parser (uint8_t c) |
{ |
static uint8_t last_c = 0; |
static uint8_t crc = 0; |
static uint8_t cnt = 0; |
uint8_t packet_len = 5; |
// sync condition |
if ((c==0xFF) && (last_c==0xFF)) |
{ |
cnt = 0; // reset counter |
crc = 0; // reset checksum |
return; |
} |
if (cnt > packet_len) // packet complete, crc received |
{ |
// calculate checksum |
crc = ~crc; |
if (crc == 0xFF) crc = 0xFE; |
// decode packet if checksum correct |
if (c == crc) jen_decode_packet (); |
// handle next packet |
cnt = 0; |
crc = 0; |
} |
else // collect channel data bytes |
{ |
PacketBuffer[cnt++] = c; |
crc += c; |
} |
last_c = c; // store last byte for sync check |
} |
void jen_decode_packet (void) |
{ |
uint8_t i; |
jen_status = PacketBuffer[0]; |
// header condition |
if (!(PacketBuffer[1] & 0xF0)) |
{ |
if (!jen_status) RC_Quality = 200; |
else if (jen_status) |
{ |
RC_Quality = 0; |
for (i = 0; i<5; i++) |
{ |
PPM_diff[i] = 0; |
PPM_in[i] = 0; |
} |
} |
i = PacketBuffer[1] & 0x0F; // lower nibble header indicates the channel pair |
if (i < 10) // maximum 12 channels |
{ |
// big to little endian |
ChannelPair.byte[1] = PacketBuffer[2]; |
ChannelPair.byte[0] = PacketBuffer[3]; |
ChannelPair.byte[3] = PacketBuffer[4]; |
ChannelPair.byte[2] = PacketBuffer[5]; |
// new servo signal properly received |
jen_new_signal (i, ChannelPair.Servo[0]); |
jen_new_signal (i+1, ChannelPair.Servo[1]); |
} |
} // end of header condition |
} |
// Parameters: channel - channel number (0-9) |
// signal - signal between 7363 and 14875 |
void jen_new_signal (uint8_t channel, int16_t signal) |
{ |
int16_t tmp; |
uint8_t index = channel + 1; // mk channels start with 1 |
signal-= 11059; // shift to neutral |
signal/= 24; // scale to mk rc resolution |
// calculate exponential history for signal |
tmp = (3 * (PPM_in[index]) + signal) / 4; |
if (tmp > signal+1) tmp--; |
else if (tmp < signal-1) tmp++; |
if (RC_Quality == 200) PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3; // cut off lower 3 bit for noise reduction |
else PPM_diff[index] = 0; |
PPM_in[index] = tmp; // update channel value |
if(index < 5) DebugOut.Analog[(20+index)] = PPM_in[index]; // debug output is handy whilst developing |
if (index == 4) NewPpmData = 0; |
} |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
Added: svn:keywords |
+Revision LastChangedBy LastChangedDate |
\ No newline at end of property |
/branches/V0.76g_FC-JN-Receiver/jennic.h |
---|
0,0 → 1,12 |
#ifndef _JENNIC_H |
#define _JENNIC_H |
#include <inttypes.h> |
extern void jen_parser (uint8_t c); |
void jen_decode_packet (void); |
void jen_new_signal (uint8_t channel, int16_t signal); |
#define USART1_BAUD 38400 |
#endif //_JENNIC_H |
Property changes: |
Added: svn:eol-style |
+native |
\ No newline at end of property |
Added: svn:keywords |
+Revision LastChangedBy LastChangedDate |
\ No newline at end of property |
/branches/V0.76g_FC-JN-Receiver/main.c |
---|
81,7 → 81,7 |
uint8_t BoardRelease = 10; |
uint8_t CPUType = ATMEGA644; |
uint8_t CPUType = ATMEGA644P; |
uint8_t LowVoltageWarning = 94; |
uint16_t FlightMinutes = 0, FlightMinutesTotal = 0; |
279,26 → 279,29 |
} |
#ifdef USE_NAVICTRL |
printf("\n\rSupport for NaviCtrl"); |
#ifdef USE_RC_DSL |
printf("\r\nSupport for DSL RC at 2nd UART"); |
printf("\n\rSupport for NaviCtrl"); |
#ifdef USE_RC_DSL |
printf("\r\nSupport for DSL RC at 2nd UART"); |
#endif |
#ifdef USE_RC_SPECTRUM |
printf("\r\nSupport for SPEKTRUM RC at 2nd UART"); |
#endif |
#ifdef USE_RC_JENNIC // LPD: FC_JN_Receiver support added |
printf("\r\nSupport for JENNIC RC at 2nd UART"); |
#endif |
#endif |
#ifdef USE_RC_SPECTRUM |
printf("\r\nSupport for SPEKTRUM RC at 2nd UART"); |
#endif |
#endif |
#ifdef USE_KILLAGREG |
printf("\n\rSupport for MicroMag3 Compass"); |
printf("\n\rSupport for MicroMag3 Compass"); |
#endif |
#ifdef USE_MK3MAG |
printf("\n\rSupport for MK3MAG Compass"); |
printf("\n\rSupport for MK3MAG Compass"); |
#endif |
#if (defined (USE_KILLAGREG) || defined (USE_MK3MAG)) |
if(CPUType == ATMEGA644P) printf("\n\rSupport for GPS at 2nd UART"); |
else printf("\n\rSupport for GPS at 1st UART"); |
if(CPUType == ATMEGA644P) printf("\n\rSupport for GPS at 2nd UART"); |
else printf("\n\rSupport for GPS at 1st UART"); |
#endif |
// init variables |
/branches/V0.76g_FC-JN-Receiver/makefile |
---|
20,7 → 20,9 |
#EXT = MK3MAG |
# Use optional one the RCs if EXT = NAVICTRL has been used |
RC = DSL |
#LPD: FC_JN_Receiver support added |
RC = JENNIC |
#RC = DSL |
#RC = SPEKTRUM |
#------------------------------------------------------------------- |
118,20 → 120,24 |
SRC += twimaster.c rc.c fc.c eeprom.c uart1.c mymath.c |
ifeq ($(EXT), KILLAGREG) |
SRC += mm3.c gps.c ubx.c |
SRC += mm3.c gps.c ubx.c |
endif |
ifeq ($(EXT), MK3MAG) |
SRC += mk3mag.c gps.c ubx.c |
SRC += mk3mag.c gps.c ubx.c |
endif |
ifeq ($(EXT), NAVICTRL) |
SRC += spi.c |
ifeq ($(RC), DSL) |
SRC += dsl.c |
SRC += spi.c |
ifeq ($(RC), DSL) |
SRC += dsl.c |
endif |
ifeq ($(RC), SPEKTRUM) |
SRC += spectrum.c |
endif |
#LPD: FC_JN_Receiver support added |
ifeq ($(RC), JENNIC) |
SRC += jennic.c |
endif |
endif |
ifeq ($(RC), SPEKTRUM) |
SRC += spectrum.c |
endif |
endif |
########################################################################################################## |
176,20 → 182,24 |
CFLAGS += -DF_CPU=$(F_CPU) -DVERSION_MAJOR=$(VERSION_MAJOR) -DVERSION_MINOR=$(VERSION_MINOR) -DVERSION_PATCH=$(VERSION_PATCH) -DVERSION_SERIAL_MAJOR=$(VERSION_SERIAL_MAJOR) -DVERSION_SERIAL_MINOR=$(VERSION_SERIAL_MINOR) -DNC_SPI_COMPATIBLE=$(NC_SPI_COMPATIBLE) |
ifeq ($(EXT), KILLAGREG) |
CFLAGS += -DUSE_KILLAGREG |
CFLAGS += -DUSE_KILLAGREG |
endif |
ifeq ($(EXT), MK3MAG) |
CFLAGS += -DUSE_MK3MAG |
CFLAGS += -DUSE_MK3MAG |
endif |
ifeq ($(EXT), NAVICTRL) |
CFLAGS += -DUSE_NAVICTRL |
ifeq ($(RC), DSL) |
CFLAGS += -DUSE_RC_DSL |
CFLAGS += -DUSE_NAVICTRL |
ifeq ($(RC), DSL) |
CFLAGS += -DUSE_RC_DSL |
endif |
ifeq ($(RC), SPEKTRUM) |
CFLAGS += -DUSE_RC_SPEKTRUM |
endif |
#LPD: FC_JN_Receiver support added |
ifeq ($(RC), JENNIC) |
CFLAGS += -DUSE_RC_JENNIC |
endif |
endif |
ifeq ($(RC), SPEKTRUM) |
CFLAGS += -DUSE_RC_SPEKTRUM |
endif |
endif |
/branches/V0.76g_FC-JN-Receiver/rc.c |
---|
80,9 → 80,11 |
// disable all interrupts before reconfiguration |
cli(); |
// PPM-signal is connected to the Input Capture Pin (PD6) of timer 1 |
DDRD &= ~(1<<DDD6); |
PORTD |= (1<<PORTD6); |
#ifndef USE_RC_JENNIC // LPD: FC_JN_Receiver support added |
// PPM-signal is connected to the Input Capture Pin (PD6) of timer 1 |
DDRD &= ~(1<<DDD6); |
PORTD |= (1<<PORTD6); |
#endif |
// Channel 5,6,7 is decoded to servo signals at pin PD5 (J3), PD4(J4), PD3(J5) |
// set as output |
156,6 → 158,7 |
the syncronization gap. |
*/ |
#ifndef USE_RC_JENNIC // LPD: FC_JN_Receiver support added |
#ifndef ACT_S3D_SUMSIGNAL |
ISR(TIMER1_CAPT_vect) // typical rate of 1 ms to 2 ms |
389,7 → 392,7 |
} // eof within the PPM frame |
} |
#endif |
#endif |
/branches/V0.76g_FC-JN-Receiver/uart0.c |
---|
150,12 → 150,12 |
"MK3MAG CalState ", |
"NickServo ", //20 |
"Hoovergas ", |
"FC_JN Input 1 ", // LPD: FC_JN_Receiver support added |
"FC_JN Input 2 ", |
"FC_JN Input 3 ", |
"FC_JN Input 4 ", //25 |
" ", |
" ", |
" ", |
" ", //25 |
" ", |
" ", |
"I2C-Error ", |
" ", |
"GPS Nick ", //30 |
/branches/V0.76g_FC-JN-Receiver/uart1.c |
---|
53,19 → 53,23 |
#include <avr/interrupt.h> |
#include "main.h" |
#include "uart1.h" |
#if defined (USE_KILLAGREG) || defined (USE_MK3MAG) |
#include "ubx.h" |
#include "ubx.h" |
#else |
#ifdef USE_RC_DSL |
#include "dsl.h" |
#ifdef USE_RC_DSL |
#include "dsl.h" |
#endif |
#ifdef USE_RC_SPEKTRUM |
#include "spectrum.h" |
#endif |
#ifdef USE_RC_JENNIC // LPD: FC_JN_Receiver support added |
#include "jennic.h" |
#endif |
#endif |
#ifdef USE_RC_SPEKTRUM |
#include "spectrum.h" |
#endif |
#endif |
#ifndef USART1_BAUD |
#define USART1_BAUD 57600 |
#define USART1_BAUD 57600 |
#endif |
/****************************************************************/ |
160,13 → 164,16 |
uint8_t c; |
c = UDR1; // get data byte |
#if (defined (USE_KILLAGREG) || defined (USE_MK3MAG)) |
ubx_parser(c); // and put it into the ubx protocol parser |
ubx_parser(c); // and put it into the ubx protocol parser |
#else |
#ifdef USE_RC_DSL |
dsl_parser(c); // parse dsl data stream |
#ifdef USE_RC_DSL |
dsl_parser(c); // parse dsl data stream |
#endif |
#ifdef USE_RC_SPEKTRUM |
spectrum_parser(c); // parse spectrum data stream |
#endif |
#ifdef USE_RC_JENNIC // LPD: FC_JN_Receiver support added |
jen_parser(c); // parse jennic data stream |
#endif |
#endif |
#ifdef USE_RC_SPEKTRUM |
spectrum_parser(c); // parse spectrum data stream |
#endif |
#endif |
} |