mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-07-01 18:27:53 +00:00
Updating CFLIE protocol - CPPM EMU as default istead of CRTP RPYT, allowing fixed RF channel and bitrate
This commit is contained in:
parent
d7f9ef6967
commit
bb6d5c2d8d
@ -20,6 +20,7 @@
|
||||
#include "iface_nrf24l01.h"
|
||||
|
||||
#define CFLIE_BIND_COUNT 60
|
||||
//#define CFLIE_USE_CRTP_RPYT
|
||||
|
||||
//=============================================================================
|
||||
// CRTP (Crazy RealTime Protocol) Implementation
|
||||
@ -220,8 +221,8 @@ static uint8_t packet_ack()
|
||||
|
||||
static void set_rate_channel(uint8_t rate, uint8_t channel)
|
||||
{
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, channel); // Defined by model id
|
||||
NRF24L01_SetBitrate(rate); // Defined by model id
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, channel);
|
||||
NRF24L01_SetBitrate(rate);
|
||||
}
|
||||
|
||||
static void send_search_packet()
|
||||
@ -232,23 +233,26 @@ static void send_search_packet()
|
||||
NRF24L01_WriteReg(NRF24L01_07_STATUS, (BV(NRF24L01_07_TX_DS) | BV(NRF24L01_07_MAX_RT)));
|
||||
NRF24L01_FlushTx();
|
||||
|
||||
if (rf_ch_num++ > 125)
|
||||
{
|
||||
rf_ch_num = 0;
|
||||
switch(data_rate)
|
||||
{
|
||||
case NRF24L01_BR_250K:
|
||||
data_rate = NRF24L01_BR_1M;
|
||||
break;
|
||||
case NRF24L01_BR_1M:
|
||||
data_rate = NRF24L01_BR_2M;
|
||||
break;
|
||||
case NRF24L01_BR_2M:
|
||||
data_rate = NRF24L01_BR_250K;
|
||||
break;
|
||||
}
|
||||
}
|
||||
set_rate_channel(data_rate, rf_ch_num);
|
||||
if (sub_protocol == CFLIE_AUTO)
|
||||
{
|
||||
if (rf_ch_num++ > 125)
|
||||
{
|
||||
rf_ch_num = 0;
|
||||
switch(data_rate)
|
||||
{
|
||||
case NRF24L01_BR_250K:
|
||||
data_rate = NRF24L01_BR_1M;
|
||||
break;
|
||||
case NRF24L01_BR_1M:
|
||||
data_rate = NRF24L01_BR_2M;
|
||||
break;
|
||||
case NRF24L01_BR_2M:
|
||||
data_rate = NRF24L01_BR_250K;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
set_rate_channel(data_rate, rf_ch_num);
|
||||
|
||||
NRF24L01_WritePayload(buf, sizeof(buf));
|
||||
|
||||
@ -355,7 +359,7 @@ static void send_crtp_rpyt_packet()
|
||||
send_packet();
|
||||
}
|
||||
|
||||
/*static void send_crtp_cppm_emu_packet()
|
||||
static void send_crtp_cppm_emu_packet()
|
||||
{
|
||||
struct CommanderPacketCppmEmu {
|
||||
struct {
|
||||
@ -376,7 +380,7 @@ static void send_crtp_rpyt_packet()
|
||||
|
||||
// Make sure the number of aux channels in use is capped to MAX_CPPM_AUX_CHANNELS
|
||||
// uint8_t numAuxChannels = Model.num_channels - 4;
|
||||
uint8_t numAuxChannels = 2; // TODO: Figure this out correctly
|
||||
uint8_t numAuxChannels = 4;
|
||||
if(numAuxChannels > MAX_CPPM_AUX_CHANNELS)
|
||||
{
|
||||
numAuxChannels = MAX_CPPM_AUX_CHANNELS;
|
||||
@ -385,16 +389,16 @@ static void send_crtp_rpyt_packet()
|
||||
cpkt.hdr.numAuxChannels = numAuxChannels;
|
||||
|
||||
// Remap AETR to AERT (RPYT)
|
||||
cpkt.channelRoll = convert_channel_16b_limit(AILERON,1000,2000);
|
||||
cpkt.channelRoll = convert_channel_16b_limit(AILERON,2000,1000);
|
||||
cpkt.channelPitch = convert_channel_16b_limit(ELEVATOR,1000,2000);
|
||||
// Note: T & R Swapped:
|
||||
cpkt.channelYaw = convert_channel_16b_limit(RUDDER, 1000, 2000);
|
||||
cpkt.channelThrust = convert_channel_16b_limit(THROTTLE, 1000, 2000);
|
||||
|
||||
// Rescale the rest of the aux channels - RC channel 4 and up
|
||||
for (uint8_t i = 4; i < 14; i++)
|
||||
for (uint8_t i = 0; i < 10; i++)
|
||||
{
|
||||
cpkt.channelAux[i] = convert_channel_16b_limit(i, 1000, 2000);
|
||||
cpkt.channelAux[i] = convert_channel_16b_limit(i+4, 2000, 1000);
|
||||
}
|
||||
|
||||
// Total size of the commander packet is a 1-byte header, 4 2-byte channels and
|
||||
@ -409,25 +413,19 @@ static void send_crtp_rpyt_packet()
|
||||
memcpy(&packet[2], (char*)&cpkt, commanderPacketSize); // Why not use sizeof(cpkt) here??
|
||||
tx_payload_len = 2 + commanderPacketSize; // CRTP header, commander type, and packet
|
||||
send_packet();
|
||||
}*/
|
||||
}
|
||||
|
||||
static void send_cmd_packet()
|
||||
{
|
||||
// TODO: Fix this so we can actually configure the packet type
|
||||
// switch(Model.proto_opts[PROTOOPTS_CRTP_MODE])
|
||||
// {
|
||||
// case CRTP_MODE_CPPM:
|
||||
// send_crtp_cppm_emu_packet();
|
||||
// break;
|
||||
// case CRTP_MODE_RPYT:
|
||||
// send_crtp_rpyt_packet();
|
||||
// break;
|
||||
// default:
|
||||
// send_crtp_rpyt_packet();
|
||||
// }
|
||||
|
||||
// send_crtp_cppm_emu_packet(); // oh maAAAn
|
||||
send_crtp_rpyt_packet();
|
||||
#if defined(CFLIE_USE_CRTP_RPYT)
|
||||
{
|
||||
send_crtp_rpyt_packet();
|
||||
}
|
||||
#else
|
||||
{
|
||||
send_crtp_cppm_emu_packet();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// State machine for setting up CRTP logging
|
||||
@ -794,40 +792,24 @@ static uint8_t CFLIE_initialize_rx_tx_addr()
|
||||
rx_tx_addr[3] =
|
||||
rx_tx_addr[4] = 0xE7; // CFlie uses fixed address
|
||||
|
||||
// if (Model.fixed_id) {
|
||||
// rf_ch_num = Model.fixed_id % 100;
|
||||
// switch (Model.fixed_id / 100) {
|
||||
// case 0:
|
||||
// data_rate = NRF24L01_BR_250K;
|
||||
// break;
|
||||
// case 1:
|
||||
// data_rate = NRF24L01_BR_1M;
|
||||
// break;
|
||||
// case 2:
|
||||
// data_rate = NRF24L01_BR_2M;
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
|
||||
// if (Model.proto_opts[PROTOOPTS_TELEMETRY] == TELEM_ON_CRTPLOG) {
|
||||
// return CFLIE_INIT_CRTP_LOG;
|
||||
// } else {
|
||||
// return CFLIE_INIT_DATA;
|
||||
// }
|
||||
// } else {
|
||||
// data_rate = NRF24L01_BR_250K;
|
||||
// rf_ch_num = 10;
|
||||
// return CFLIE_INIT_SEARCH;
|
||||
// }
|
||||
|
||||
// Default 1
|
||||
data_rate = NRF24L01_BR_1M;
|
||||
rf_ch_num = 10;
|
||||
|
||||
// Default 2
|
||||
// data_rate = NRF24L01_BR_2M;
|
||||
// rf_ch_num = 110;
|
||||
switch (sub_protocol) {
|
||||
case CFLIE_2Mbps:
|
||||
data_rate = NRF24L01_BR_2M;
|
||||
rf_ch_num = option;
|
||||
break;
|
||||
case CFLIE_1Mbps:
|
||||
data_rate = NRF24L01_BR_1M;
|
||||
rf_ch_num = option;
|
||||
break;
|
||||
case CFLIE_250kbps:
|
||||
data_rate = NRF24L01_BR_250K;
|
||||
rf_ch_num = option;
|
||||
break;
|
||||
default:
|
||||
data_rate = NRF24L01_BR_2M;
|
||||
rf_ch_num = 80;
|
||||
}
|
||||
|
||||
return CFLIE_INIT_SEARCH;
|
||||
}
|
||||
|
||||
@ -835,11 +817,11 @@ void CFLIE_init(void)
|
||||
{
|
||||
BIND_IN_PROGRESS; // autobind protocol
|
||||
|
||||
phase = CFLIE_initialize_rx_tx_addr();
|
||||
crtp_log_setup_state = CFLIE_CRTP_LOG_SETUP_STATE_INIT;
|
||||
packet_count=0;
|
||||
phase = CFLIE_initialize_rx_tx_addr();
|
||||
crtp_log_setup_state = CFLIE_CRTP_LOG_SETUP_STATE_INIT;
|
||||
packet_count=0;
|
||||
|
||||
CFLIE_RF_init();
|
||||
CFLIE_RF_init();
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -166,6 +166,7 @@ const char STR_SUBTYPE_MOULKG[] = "\x06""Analog""Digit\0";
|
||||
const char STR_SUBTYPE_KF606[] = "\x06""KF606\0""MIG320";
|
||||
const char STR_SUBTYPE_E129[] = "\x04""E129""C186";
|
||||
const char STR_SUBTYPE_FX[] = "\x03""816""620";
|
||||
const char STR_SUBTYPE_CFLIE[] = "\x07""Auto\0 ""2Mbps\0 ""1Mbps\0 ""250kbps";
|
||||
#define NO_SUBTYPE nullptr
|
||||
|
||||
#ifdef SEND_CPPM
|
||||
@ -219,7 +220,7 @@ const mm_protocol_definition multi_protocols[] = {
|
||||
{PROTO_CABELL, STR_CABELL, STR_SUBTYPE_CABELL, 8, OPTION_OPTION, 0, 0, SW_NRF, CABELL_init, CABELL_callback },
|
||||
#endif
|
||||
#if defined(CFLIE_NRF24L01_INO)
|
||||
{PROTO_CFLIE, STR_CFLIE, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, SW_NRF, CFLIE_init, CFLIE_callback }, // review protocol
|
||||
{PROTO_CFLIE, STR_CFLIE, STR_SUBTYPE_CFLIE, 4, OPTION_RFCHAN, 0, 0, SW_NRF, CFLIE_init, CFLIE_callback }, // review protocol
|
||||
#endif
|
||||
#if defined(CG023_NRF24L01_INO)
|
||||
{PROTO_CG023, STR_CG023, STR_SUBTYPE_CG023, 2, OPTION_NONE, 0, 0, SW_NRF, CG023_init, CG023_callback },
|
||||
@ -545,4 +546,4 @@ uint16_t PROTOLIST_callback()
|
||||
}
|
||||
return 1000;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -460,6 +460,13 @@ enum FX
|
||||
FX816 = 0,
|
||||
FX620 = 1,
|
||||
};
|
||||
enum CFLIE
|
||||
{
|
||||
CFLIE_AUTO = 0,
|
||||
CFLIE_2Mbps = 1,
|
||||
CFLIE_1Mbps = 2,
|
||||
CFLIE_250kbps = 3,
|
||||
};
|
||||
|
||||
#define NONE 0
|
||||
#define P_HIGH 1
|
||||
|
@ -220,11 +220,11 @@
|
||||
#define BAYANG_NRF24L01_INO
|
||||
#define BAYANG_RX_NRF24L01_INO
|
||||
#define BUGSMINI_NRF24L01_INO
|
||||
#define CABELL_NRF24L01_INO
|
||||
//#define CFLIE_NRF24L01_INO
|
||||
#define CG023_NRF24L01_INO
|
||||
//#define CABELL_NRF24L01_INO
|
||||
#define CFLIE_NRF24L01_INO
|
||||
//#define CG023_NRF24L01_INO
|
||||
#define CX10_NRF24L01_INO //Include Q2X2 protocol
|
||||
#define DM002_NRF24L01_INO
|
||||
//#define DM002_NRF24L01_INO
|
||||
#define E016H_NRF24L01_INO
|
||||
#define ESKY_NRF24L01_INO
|
||||
#define ESKY150_NRF24L01_INO
|
||||
@ -576,7 +576,10 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= {
|
||||
CABELL_SET_FAIL_SAFE
|
||||
CABELL_UNBIND
|
||||
PROTO_CFLIE
|
||||
NONE
|
||||
CFLIE_AUTO
|
||||
CFLIE_2Mbps
|
||||
CFLIE_1Mbps
|
||||
CFLIE_250kbps
|
||||
PROTO_CG023
|
||||
CG023
|
||||
YD829
|
||||
|
Loading…
x
Reference in New Issue
Block a user