Frsky telemetry update

This commit is contained in:
pascallanger 2016-01-26 13:46:22 +01:00
parent ee6eed5ac5
commit ae0478a7e9
4 changed files with 32 additions and 13 deletions

View File

@ -110,7 +110,6 @@ uint16_t cyrf_state;
uint8_t crcidx; uint8_t crcidx;
uint8_t binding; uint8_t binding;
uint16_t crc; uint16_t crc;
uint8_t model;
/* /*
#ifdef USE_FIXED_MFGID #ifdef USE_FIXED_MFGID
@ -128,7 +127,7 @@ static void build_bind_packet()
packet[0] = crc >> 8; packet[0] = crc >> 8;
packet[1] = crc & 0xff; packet[1] = crc & 0xff;
packet[2] = 0xff ^ cyrfmfg_id[2]; packet[2] = 0xff ^ cyrfmfg_id[2];
packet[3] = (0xff ^ cyrfmfg_id[3]) + model; packet[3] = (0xff ^ cyrfmfg_id[3]) + RX_num;
packet[4] = packet[0]; packet[4] = packet[0];
packet[5] = packet[1]; packet[5] = packet[1];
packet[6] = packet[2]; packet[6] = packet[2];
@ -187,13 +186,13 @@ static void build_data_packet(uint8_t upper)//
if (sub_protocol==DSMX) if (sub_protocol==DSMX)
{ {
packet[0] = cyrfmfg_id[2]; packet[0] = cyrfmfg_id[2];
packet[1] = cyrfmfg_id[3] + model; packet[1] = cyrfmfg_id[3] + RX_num;
bits=11; bits=11;
} }
else else
{ {
packet[0] = (0xff ^ cyrfmfg_id[2]); packet[0] = (0xff ^ cyrfmfg_id[2]);
packet[1] = (0xff ^ cyrfmfg_id[3]) + model; packet[1] = (0xff ^ cyrfmfg_id[3]) + RX_num;
bits=10; bits=10;
} }
// //
@ -513,8 +512,6 @@ uint16_t initDsm2()
sop_col = (cyrfmfg_id[0] + cyrfmfg_id[1] + cyrfmfg_id[2] + 2) & 0x07;//Ok sop_col = (cyrfmfg_id[0] + cyrfmfg_id[1] + cyrfmfg_id[2] + 2) & 0x07;//Ok
data_col = 7 - sop_col;//ok data_col = 7 - sop_col;//ok
model=MProtocol_id-MProtocol_id_master; // RxNum for serial or 0 for ppm
CYRF_SetTxRxMode(TX_EN); CYRF_SetTxRxMode(TX_EN);
// //
if(IS_AUTOBIND_FLAG_on) if(IS_AUTOBIND_FLAG_on)

View File

@ -18,9 +18,11 @@
#include "iface_cc2500.h" #include "iface_cc2500.h"
//##########Variables######## //##########Variables########
uint32_t state; //uint32_t state;
uint8_t len; //uint8_t len;
uint8_t telemetry_counter=0;
/*
enum { enum {
FRSKY_BIND = 0, FRSKY_BIND = 0,
FRSKY_BIND_DONE = 1000, FRSKY_BIND_DONE = 1000,
@ -30,6 +32,7 @@ enum {
FRSKY_DATA4, FRSKY_DATA4,
FRSKY_DATA5 FRSKY_DATA5
}; };
*/
uint16_t initFrSky_2way() uint16_t initFrSky_2way()
{ {
@ -124,6 +127,8 @@ static void check_telemetry(uint8_t *pkt,uint8_t len)
for (uint8_t i=3;i<len;i++) for (uint8_t i=3;i<len;i++)
pktt[i]=pkt[i]; pktt[i]=pkt[i];
telemetry_link=1; telemetry_link=1;
if(pktt[6]>0)
telemetry_counter=(telemetry_counter+1)%32;
} }
} }
@ -231,7 +236,7 @@ static void frsky2way_build_bind_packet()
packet[17] = 0x01; packet[17] = 0x01;
} }
uint8_t telemetry_counter=0;
static void frsky2way_data_frame() static void frsky2way_data_frame()
{//pachet[4] is telemetry user frame counter(hub) {//pachet[4] is telemetry user frame counter(hub)
@ -241,7 +246,8 @@ static void frsky2way_data_frame()
packet[1] = rx_tx_addr[3]; packet[1] = rx_tx_addr[3];
packet[2] = rx_tx_addr[2]; packet[2] = rx_tx_addr[2];
packet[3] = counter;// packet[3] = counter;//
packet[4] = pkt[6]?(telemetry_counter++)%32:0; packet[4]=telemetry_counter;
packet[5] = 0x01; packet[5] = 0x01;
// //
packet[10] = 0; packet[10] = 0;

View File

@ -65,6 +65,10 @@ uint8_t hopping_frequency_no=0;
uint8_t rf_ch_num; uint8_t rf_ch_num;
uint8_t throttle, rudder, elevator, aileron; uint8_t throttle, rudder, elevator, aileron;
uint8_t flags; uint8_t flags;
//
uint32_t state;
uint8_t len;
uint8_t RX_num;
// Mode_select variables // Mode_select variables
uint8_t mode_select; uint8_t mode_select;
@ -159,7 +163,8 @@ void setup()
mode_select--; mode_select--;
cur_protocol[0] = PPM_prot[mode_select].protocol; cur_protocol[0] = PPM_prot[mode_select].protocol;
sub_protocol = PPM_prot[mode_select].sub_proto; sub_protocol = PPM_prot[mode_select].sub_proto;
MProtocol_id = PPM_prot[mode_select].rx_num + MProtocol_id_master; RX_num = PPM_prot[mode_select].rx_num;
MProtocol_id = RX_num + MProtocol_id_master;
option = PPM_prot[mode_select].option; option = PPM_prot[mode_select].option;
if(PPM_prot[mode_select].power) POWER_FLAG_on; if(PPM_prot[mode_select].power) POWER_FLAG_on;
if(PPM_prot[mode_select].autobind) AUTOBIND_FLAG_on; if(PPM_prot[mode_select].autobind) AUTOBIND_FLAG_on;
@ -208,7 +213,7 @@ void loop()
} }
update_led_status(); update_led_status();
#if defined(TELEMETRY) #if defined(TELEMETRY)
if(((cur_protocol[0]&0x1F)==MODE_FRSKY)||((cur_protocol[0]&0x1F)==MODE_HUBSAN)) if( ((cur_protocol[0]&0x1F)==MODE_FRSKY) || ((cur_protocol[0]&0x1F)==MODE_HUBSAN) || ((cur_protocol[0]&0x1F)==MODE_FRSKYX) )
frskyUpdate(); frskyUpdate();
#endif #endif
if (remote_callback != 0) if (remote_callback != 0)
@ -445,7 +450,8 @@ static void update_serial_data()
cur_protocol[1] = rx_ok_buff[1]&0x7F; //store current protocol cur_protocol[1] = rx_ok_buff[1]&0x7F; //store current protocol
CHANGE_PROTOCOL_FLAG_on; //change protocol CHANGE_PROTOCOL_FLAG_on; //change protocol
sub_protocol=(rx_ok_buff[1]>>4)& 0x07; //subprotocol no (0-7) bits 4-6 sub_protocol=(rx_ok_buff[1]>>4)& 0x07; //subprotocol no (0-7) bits 4-6
MProtocol_id=MProtocol_id_master+(rx_ok_buff[1]& 0x0F); //personalized RX bind + rx num // rx_num bits 0---3 RX_num=rx_ok_buff[1]& 0x0F;
MProtocol_id=MProtocol_id_master+RX_num; //personalized RX bind + rx num // rx_num bits 0---3
} }
else else
if( ((rx_ok_buff[0]&0x80)!=0) && ((cur_protocol[0]&0x80)==0) ) // Bind flag has been set if( ((rx_ok_buff[0]&0x80)!=0) && ((cur_protocol[0]&0x80)==0) ) // Bind flag has been set

View File

@ -16,6 +16,16 @@
#ifndef _IFACE_CC2500_H_ #ifndef _IFACE_CC2500_H_
#define _IFACE_CC2500_H_ #define _IFACE_CC2500_H_
enum {
FRSKY_BIND = 0,
FRSKY_BIND_DONE = 1000,
FRSKY_DATA1,
FRSKY_DATA2,
FRSKY_DATA3,
FRSKY_DATA4,
FRSKY_DATA5
};
enum { enum {
CC2500_00_IOCFG2 = 0x00, // GDO2 output pin configuration CC2500_00_IOCFG2 = 0x00, // GDO2 output pin configuration
CC2500_01_IOCFG1 = 0x01, // GDO1 output pin configuration CC2500_01_IOCFG1 = 0x01, // GDO1 output pin configuration