mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-07-03 20:17:52 +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"
|
#include "iface_nrf24l01.h"
|
||||||
|
|
||||||
#define CFLIE_BIND_COUNT 60
|
#define CFLIE_BIND_COUNT 60
|
||||||
|
//#define CFLIE_USE_CRTP_RPYT
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
// CRTP (Crazy RealTime Protocol) Implementation
|
// 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)
|
static void set_rate_channel(uint8_t rate, uint8_t channel)
|
||||||
{
|
{
|
||||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, channel); // Defined by model id
|
NRF24L01_WriteReg(NRF24L01_05_RF_CH, channel);
|
||||||
NRF24L01_SetBitrate(rate); // Defined by model id
|
NRF24L01_SetBitrate(rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_search_packet()
|
static void send_search_packet()
|
||||||
@ -232,6 +233,8 @@ static void send_search_packet()
|
|||||||
NRF24L01_WriteReg(NRF24L01_07_STATUS, (BV(NRF24L01_07_TX_DS) | BV(NRF24L01_07_MAX_RT)));
|
NRF24L01_WriteReg(NRF24L01_07_STATUS, (BV(NRF24L01_07_TX_DS) | BV(NRF24L01_07_MAX_RT)));
|
||||||
NRF24L01_FlushTx();
|
NRF24L01_FlushTx();
|
||||||
|
|
||||||
|
if (sub_protocol == CFLIE_AUTO)
|
||||||
|
{
|
||||||
if (rf_ch_num++ > 125)
|
if (rf_ch_num++ > 125)
|
||||||
{
|
{
|
||||||
rf_ch_num = 0;
|
rf_ch_num = 0;
|
||||||
@ -248,6 +251,7 @@ static void send_search_packet()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
set_rate_channel(data_rate, rf_ch_num);
|
set_rate_channel(data_rate, rf_ch_num);
|
||||||
|
|
||||||
NRF24L01_WritePayload(buf, sizeof(buf));
|
NRF24L01_WritePayload(buf, sizeof(buf));
|
||||||
@ -355,7 +359,7 @@ static void send_crtp_rpyt_packet()
|
|||||||
send_packet();
|
send_packet();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static void send_crtp_cppm_emu_packet()
|
static void send_crtp_cppm_emu_packet()
|
||||||
{
|
{
|
||||||
struct CommanderPacketCppmEmu {
|
struct CommanderPacketCppmEmu {
|
||||||
struct {
|
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
|
// 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 = Model.num_channels - 4;
|
||||||
uint8_t numAuxChannels = 2; // TODO: Figure this out correctly
|
uint8_t numAuxChannels = 4;
|
||||||
if(numAuxChannels > MAX_CPPM_AUX_CHANNELS)
|
if(numAuxChannels > MAX_CPPM_AUX_CHANNELS)
|
||||||
{
|
{
|
||||||
numAuxChannels = MAX_CPPM_AUX_CHANNELS;
|
numAuxChannels = MAX_CPPM_AUX_CHANNELS;
|
||||||
@ -385,16 +389,16 @@ static void send_crtp_rpyt_packet()
|
|||||||
cpkt.hdr.numAuxChannels = numAuxChannels;
|
cpkt.hdr.numAuxChannels = numAuxChannels;
|
||||||
|
|
||||||
// Remap AETR to AERT (RPYT)
|
// 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);
|
cpkt.channelPitch = convert_channel_16b_limit(ELEVATOR,1000,2000);
|
||||||
// Note: T & R Swapped:
|
// Note: T & R Swapped:
|
||||||
cpkt.channelYaw = convert_channel_16b_limit(RUDDER, 1000, 2000);
|
cpkt.channelYaw = convert_channel_16b_limit(RUDDER, 1000, 2000);
|
||||||
cpkt.channelThrust = convert_channel_16b_limit(THROTTLE, 1000, 2000);
|
cpkt.channelThrust = convert_channel_16b_limit(THROTTLE, 1000, 2000);
|
||||||
|
|
||||||
// Rescale the rest of the aux channels - RC channel 4 and up
|
// 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
|
// Total size of the commander packet is a 1-byte header, 4 2-byte channels and
|
||||||
@ -409,26 +413,20 @@ static void send_crtp_rpyt_packet()
|
|||||||
memcpy(&packet[2], (char*)&cpkt, commanderPacketSize); // Why not use sizeof(cpkt) here??
|
memcpy(&packet[2], (char*)&cpkt, commanderPacketSize); // Why not use sizeof(cpkt) here??
|
||||||
tx_payload_len = 2 + commanderPacketSize; // CRTP header, commander type, and packet
|
tx_payload_len = 2 + commanderPacketSize; // CRTP header, commander type, and packet
|
||||||
send_packet();
|
send_packet();
|
||||||
}*/
|
}
|
||||||
|
|
||||||
static void send_cmd_packet()
|
static void send_cmd_packet()
|
||||||
{
|
{
|
||||||
// TODO: Fix this so we can actually configure the packet type
|
#if defined(CFLIE_USE_CRTP_RPYT)
|
||||||
// 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();
|
send_crtp_rpyt_packet();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
send_crtp_cppm_emu_packet();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// State machine for setting up CRTP logging
|
// State machine for setting up CRTP logging
|
||||||
// returns 1 when the state machine has completed, 0 otherwise
|
// returns 1 when the state machine has completed, 0 otherwise
|
||||||
@ -794,40 +792,24 @@ static uint8_t CFLIE_initialize_rx_tx_addr()
|
|||||||
rx_tx_addr[3] =
|
rx_tx_addr[3] =
|
||||||
rx_tx_addr[4] = 0xE7; // CFlie uses fixed address
|
rx_tx_addr[4] = 0xE7; // CFlie uses fixed address
|
||||||
|
|
||||||
// if (Model.fixed_id) {
|
switch (sub_protocol) {
|
||||||
// rf_ch_num = Model.fixed_id % 100;
|
case CFLIE_2Mbps:
|
||||||
// switch (Model.fixed_id / 100) {
|
data_rate = NRF24L01_BR_2M;
|
||||||
// case 0:
|
rf_ch_num = option;
|
||||||
// data_rate = NRF24L01_BR_250K;
|
break;
|
||||||
// break;
|
case CFLIE_1Mbps:
|
||||||
// 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;
|
data_rate = NRF24L01_BR_1M;
|
||||||
rf_ch_num = 10;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// Default 2
|
|
||||||
// data_rate = NRF24L01_BR_2M;
|
|
||||||
// rf_ch_num = 110;
|
|
||||||
return CFLIE_INIT_SEARCH;
|
return CFLIE_INIT_SEARCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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_KF606[] = "\x06""KF606\0""MIG320";
|
||||||
const char STR_SUBTYPE_E129[] = "\x04""E129""C186";
|
const char STR_SUBTYPE_E129[] = "\x04""E129""C186";
|
||||||
const char STR_SUBTYPE_FX[] = "\x03""816""620";
|
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
|
#define NO_SUBTYPE nullptr
|
||||||
|
|
||||||
#ifdef SEND_CPPM
|
#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 },
|
{PROTO_CABELL, STR_CABELL, STR_SUBTYPE_CABELL, 8, OPTION_OPTION, 0, 0, SW_NRF, CABELL_init, CABELL_callback },
|
||||||
#endif
|
#endif
|
||||||
#if defined(CFLIE_NRF24L01_INO)
|
#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
|
#endif
|
||||||
#if defined(CG023_NRF24L01_INO)
|
#if defined(CG023_NRF24L01_INO)
|
||||||
{PROTO_CG023, STR_CG023, STR_SUBTYPE_CG023, 2, OPTION_NONE, 0, 0, SW_NRF, CG023_init, CG023_callback },
|
{PROTO_CG023, STR_CG023, STR_SUBTYPE_CG023, 2, OPTION_NONE, 0, 0, SW_NRF, CG023_init, CG023_callback },
|
||||||
|
@ -460,6 +460,13 @@ enum FX
|
|||||||
FX816 = 0,
|
FX816 = 0,
|
||||||
FX620 = 1,
|
FX620 = 1,
|
||||||
};
|
};
|
||||||
|
enum CFLIE
|
||||||
|
{
|
||||||
|
CFLIE_AUTO = 0,
|
||||||
|
CFLIE_2Mbps = 1,
|
||||||
|
CFLIE_1Mbps = 2,
|
||||||
|
CFLIE_250kbps = 3,
|
||||||
|
};
|
||||||
|
|
||||||
#define NONE 0
|
#define NONE 0
|
||||||
#define P_HIGH 1
|
#define P_HIGH 1
|
||||||
|
@ -220,11 +220,11 @@
|
|||||||
#define BAYANG_NRF24L01_INO
|
#define BAYANG_NRF24L01_INO
|
||||||
#define BAYANG_RX_NRF24L01_INO
|
#define BAYANG_RX_NRF24L01_INO
|
||||||
#define BUGSMINI_NRF24L01_INO
|
#define BUGSMINI_NRF24L01_INO
|
||||||
#define CABELL_NRF24L01_INO
|
//#define CABELL_NRF24L01_INO
|
||||||
//#define CFLIE_NRF24L01_INO
|
#define CFLIE_NRF24L01_INO
|
||||||
#define CG023_NRF24L01_INO
|
//#define CG023_NRF24L01_INO
|
||||||
#define CX10_NRF24L01_INO //Include Q2X2 protocol
|
#define CX10_NRF24L01_INO //Include Q2X2 protocol
|
||||||
#define DM002_NRF24L01_INO
|
//#define DM002_NRF24L01_INO
|
||||||
#define E016H_NRF24L01_INO
|
#define E016H_NRF24L01_INO
|
||||||
#define ESKY_NRF24L01_INO
|
#define ESKY_NRF24L01_INO
|
||||||
#define ESKY150_NRF24L01_INO
|
#define ESKY150_NRF24L01_INO
|
||||||
@ -576,7 +576,10 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= {
|
|||||||
CABELL_SET_FAIL_SAFE
|
CABELL_SET_FAIL_SAFE
|
||||||
CABELL_UNBIND
|
CABELL_UNBIND
|
||||||
PROTO_CFLIE
|
PROTO_CFLIE
|
||||||
NONE
|
CFLIE_AUTO
|
||||||
|
CFLIE_2Mbps
|
||||||
|
CFLIE_1Mbps
|
||||||
|
CFLIE_250kbps
|
||||||
PROTO_CG023
|
PROTO_CG023
|
||||||
CG023
|
CG023
|
||||||
YD829
|
YD829
|
||||||
|
Loading…
x
Reference in New Issue
Block a user