mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-03-15 12:59:09 +00:00
UDIRC new protocol / WIP
This commit is contained in:
parent
b2dec9b331
commit
ad8b45773d
@ -113,7 +113,7 @@ const char STR_SGF22[] ="SGF22";
|
||||
const char STR_EAZYRC[] ="EazyRC";
|
||||
const char STR_KYOSHO3[] ="Kyosho3";
|
||||
const char STR_YUXIANG[] ="YuXiang";
|
||||
const char STR_PINECONE[] ="PineCone";
|
||||
const char STR_UDIRC[] ="UDIRC";
|
||||
const char STR_JIABAILE[] ="JIABAILE";
|
||||
|
||||
const char STR_SUBTYPE_FLYSKY[] = "\x04""Std\0""V9x9""V6x6""V912""CX20";
|
||||
@ -436,9 +436,6 @@ const mm_protocol_definition multi_protocols[] = {
|
||||
#if defined(PELIKAN_A7105_INO)
|
||||
{PROTO_PELIKAN, STR_PELIKAN, STR_SUBTYPE_PELIKAN, 3, OPTION_NONE, 0, 1, SW_A7105, PELIKAN_init, PELIKAN_callback },
|
||||
#endif
|
||||
#if defined(PINECONE_CCNRF_INO)
|
||||
{PROTO_PINECONE, STR_PINECONE, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, SW_NRF, PINECONE_init, PINECONE_callback },
|
||||
#endif
|
||||
#if defined(POTENSIC_NRF24L01_INO)
|
||||
{PROTO_POTENSIC, STR_POTENSIC, STR_SUBTYPE_POTENSIC, 1, OPTION_NONE, 0, 0, SW_NRF, POTENSIC_init, POTENSIC_callback },
|
||||
#endif
|
||||
@ -487,6 +484,9 @@ const mm_protocol_definition multi_protocols[] = {
|
||||
#if defined(TRAXXAS_CYRF6936_INO)
|
||||
{PROTO_TRAXXAS, STR_TRAXXAS, STR_SUBTYPE_TRAXXAS, 2, OPTION_NONE, 0, 0, SW_CYRF, TRAXXAS_init, TRAXXAS_callback },
|
||||
#endif
|
||||
#if defined(UDIRC_CCNRF_INO)
|
||||
{PROTO_UDIRC, STR_UDIRC, NO_SUBTYPE, 0, OPTION_NONE, 0, 0, SW_NRF, UDIRC_init, UDIRC_callback },
|
||||
#endif
|
||||
#if defined(V2X2_NRF24L01_INO)
|
||||
{PROTO_V2X2, STR_V2X2, STR_SUBTYPE_V2X2, 3, OPTION_NONE, 0, 0, SW_NRF, V2X2_init, V2X2_callback },
|
||||
#endif
|
||||
|
@ -19,7 +19,7 @@
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_REVISION 4
|
||||
#define VERSION_PATCH_LEVEL 31
|
||||
#define VERSION_PATCH_LEVEL 33
|
||||
|
||||
#define MODE_SERIAL 0
|
||||
|
||||
@ -128,7 +128,7 @@ enum PROTOCOLS
|
||||
PROTO_KYOSHO3 = 98, // =>CYRF6936
|
||||
PROTO_XK2 = 99, // =>CC2500 & NRF24L01
|
||||
PROTO_YUXIANG = 100, // =>NRF24L01
|
||||
PROTO_PINECONE = 101, // =>CC2500 & NRF24L01
|
||||
PROTO_UDIRC = 101, // =>CC2500 & NRF24L01
|
||||
PROTO_JIABAILE = 102, // =>NRF24L01
|
||||
PROTO_H36 = 103, // =>NRF24L01
|
||||
|
||||
|
@ -12,24 +12,24 @@ Multiprotocol is distributed in the hope that it will be useful,
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#if defined(PINECONE_CCNRF_INO)
|
||||
#if defined(UDIRC_CCNRF_INO)
|
||||
|
||||
#include "iface_xn297.h"
|
||||
|
||||
#define FORCE_PINECONE_ORIGINAL_ID
|
||||
#define FORCE_UDIRC_ORIGINAL_ID
|
||||
|
||||
#define PINECONE_PAYLOAD_SIZE 15
|
||||
#define PINECONE_RF_NUM_CHANNELS 4
|
||||
#define PINECONE_PACKET_PERIOD 9000
|
||||
#define PINECONE_BIND_COUNT 2000
|
||||
#define PINECONE_WRITE_TIME 1500
|
||||
#define UDIRC_PAYLOAD_SIZE 15
|
||||
#define UDIRC_RF_NUM_CHANNELS 4
|
||||
#define UDIRC_PACKET_PERIOD 8000
|
||||
#define UDIRC_BIND_COUNT 2000
|
||||
#define UDIRC_WRITE_TIME 1500
|
||||
|
||||
enum {
|
||||
PINECONE_DATA=0,
|
||||
PINECONE_RX,
|
||||
UDIRC_DATA=0,
|
||||
UDIRC_RX,
|
||||
};
|
||||
|
||||
static void __attribute__((unused)) PINECONE_send_packet()
|
||||
static void __attribute__((unused)) UDIRC_send_packet()
|
||||
{
|
||||
if(rf_ch_num==0)
|
||||
{
|
||||
@ -39,7 +39,6 @@ static void __attribute__((unused)) PINECONE_send_packet()
|
||||
hopping_frequency_no &= 3;
|
||||
}
|
||||
|
||||
if(bind_counter==0) bind_counter=2;
|
||||
memset(&packet[3], 0x00, 12);
|
||||
if(bind_counter)
|
||||
{//Bind in progress
|
||||
@ -51,8 +50,9 @@ static void __attribute__((unused)) PINECONE_send_packet()
|
||||
}
|
||||
else
|
||||
{//Switch to normal
|
||||
BIND_DONE;
|
||||
XN297_SetTXAddr(rx_tx_addr, 5);
|
||||
XN297_SetRXAddr(rx_tx_addr, PINECONE_PAYLOAD_SIZE);
|
||||
XN297_SetRXAddr(rx_tx_addr, UDIRC_PAYLOAD_SIZE);
|
||||
}
|
||||
}
|
||||
if(!bind_counter)
|
||||
@ -70,22 +70,22 @@ static void __attribute__((unused)) PINECONE_send_packet()
|
||||
packet[12] = GET_FLAG(CH8_SW, 0x40) //TH.REV
|
||||
|GET_FLAG(CH9_SW, 0x80); //ST.REV
|
||||
//packet[13] = 00 unknown
|
||||
for(uint8_t i=0;i<PINECONE_PAYLOAD_SIZE-1;i++)
|
||||
for(uint8_t i=0;i<UDIRC_PAYLOAD_SIZE-1;i++)
|
||||
packet[14] += packet[i];
|
||||
// Send
|
||||
XN297_SetPower();
|
||||
XN297_SetTxRxMode(TX_EN);
|
||||
XN297_WriteEnhancedPayload(packet, PINECONE_PAYLOAD_SIZE,false);
|
||||
XN297_WriteEnhancedPayload(packet, UDIRC_PAYLOAD_SIZE,false);
|
||||
#ifdef DEBUG_SERIAL
|
||||
for(uint8_t i=0; i < PINECONE_PAYLOAD_SIZE; i++)
|
||||
for(uint8_t i=0; i < UDIRC_PAYLOAD_SIZE; i++)
|
||||
debug("%02X ", packet[i]);
|
||||
debugln();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) PINECONE_initialize_txid()
|
||||
static void __attribute__((unused)) UDIRC_initialize_txid()
|
||||
{
|
||||
#ifdef FORCE_PINECONE_ORIGINAL_ID
|
||||
#ifdef FORCE_UDIRC_ORIGINAL_ID
|
||||
rx_tx_addr[0] = 0xD0;
|
||||
rx_tx_addr[1] = 0x06;
|
||||
rx_tx_addr[2] = 0x00;
|
||||
@ -98,70 +98,72 @@ static void __attribute__((unused)) PINECONE_initialize_txid()
|
||||
#endif
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) PINECONE_RF_init()
|
||||
static void __attribute__((unused)) UDIRC_RF_init()
|
||||
{
|
||||
XN297_Configure(XN297_CRCEN, XN297_SCRAMBLED, XN297_250K);
|
||||
//Bind address
|
||||
XN297_SetTXAddr((uint8_t*)"\x01\x03\x05\x07\x09", 5);
|
||||
XN297_SetRXAddr((uint8_t*)"\x01\x03\x05\x07\x09", PINECONE_PAYLOAD_SIZE);
|
||||
XN297_HoppingCalib(PINECONE_RF_NUM_CHANNELS);
|
||||
XN297_SetRXAddr((uint8_t*)"\x01\x03\x05\x07\x09", UDIRC_PAYLOAD_SIZE);
|
||||
XN297_HoppingCalib(UDIRC_RF_NUM_CHANNELS);
|
||||
}
|
||||
|
||||
uint16_t PINECONE_callback()
|
||||
uint16_t UDIRC_callback()
|
||||
{
|
||||
bool rx;
|
||||
switch(phase)
|
||||
{
|
||||
case PINECONE_DATA:
|
||||
case UDIRC_DATA:
|
||||
rx = XN297_IsRX();
|
||||
XN297_SetTxRxMode(TXRX_OFF);
|
||||
#ifdef MULTI_SYNC
|
||||
telemetry_set_input_sync(PINECONE_PACKET_PERIOD);
|
||||
telemetry_set_input_sync(UDIRC_PACKET_PERIOD);
|
||||
#endif
|
||||
PINECONE_send_packet();
|
||||
UDIRC_send_packet();
|
||||
if(rx)
|
||||
{
|
||||
uint8_t val=XN297_ReadEnhancedPayload(packet_in, PINECONE_PAYLOAD_SIZE);
|
||||
uint8_t val=XN297_ReadEnhancedPayload(packet_in, UDIRC_PAYLOAD_SIZE);
|
||||
debug("RX %d",val);
|
||||
if(val==0)
|
||||
{
|
||||
rf_ch_num = 1;
|
||||
if(bind_counter)
|
||||
bind_counter=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_SERIAL
|
||||
for(uint8_t i=0; i < PINECONE_PAYLOAD_SIZE; i++)
|
||||
for(uint8_t i=0; i < UDIRC_PAYLOAD_SIZE; i++)
|
||||
debug(" %02X", packet_in[i]);
|
||||
debugln();
|
||||
#endif
|
||||
//could check the validity of the packet by looking at the sum...
|
||||
}
|
||||
//else
|
||||
// debug(" NOK");
|
||||
debugln("");
|
||||
}
|
||||
phase++;
|
||||
return PINECONE_WRITE_TIME;
|
||||
default: //PINECONE_RX
|
||||
return UDIRC_WRITE_TIME;
|
||||
default: //UDIRC_RX
|
||||
//Wait for the packet transmission to finish
|
||||
while(XN297_IsPacketSent()==false);
|
||||
//Switch to RX
|
||||
XN297_SetTxRxMode(TXRX_OFF);
|
||||
XN297_SetTxRxMode(RX_EN);
|
||||
phase = PINECONE_DATA;
|
||||
return PINECONE_PACKET_PERIOD - PINECONE_WRITE_TIME;
|
||||
phase = UDIRC_DATA;
|
||||
return UDIRC_PACKET_PERIOD - UDIRC_WRITE_TIME;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PINECONE_init()
|
||||
void UDIRC_init()
|
||||
{
|
||||
PINECONE_initialize_txid();
|
||||
PINECONE_RF_init();
|
||||
UDIRC_initialize_txid();
|
||||
UDIRC_RF_init();
|
||||
|
||||
bind_counter = IS_BIND_IN_PROGRESS ? PINECONE_BIND_COUNT : 1;
|
||||
phase = PINECONE_DATA;
|
||||
bind_counter = IS_BIND_IN_PROGRESS ? UDIRC_BIND_COUNT : 1;
|
||||
phase = UDIRC_DATA;
|
||||
hopping_frequency_no = 0;
|
||||
rf_ch_num = 0;
|
||||
bind_counter = 2000;
|
||||
}
|
||||
|
||||
#endif
|
@ -355,6 +355,7 @@
|
||||
#undef Q303_CCNRF_INO
|
||||
#undef Q90C_CCNRF_INO
|
||||
#undef SLT_CCNRF_INO
|
||||
#undef UDIRC_CCNRF_INO
|
||||
#undef V911S_CCNRF_INO
|
||||
#undef XK_CCNRF_INO
|
||||
#undef XK2_CCNRF_INO
|
||||
@ -391,6 +392,7 @@
|
||||
#undef MOULDKG_NRF24L01_INO
|
||||
#undef SHENQI_NRF24L01_INO
|
||||
#undef JIABAILE_NRF24L01_INO
|
||||
#undef UDIRC_CCNRF_INO
|
||||
#endif
|
||||
|
||||
#ifdef MULTI_SURFACE
|
||||
|
@ -273,6 +273,7 @@
|
||||
#define Q303_CCNRF_INO
|
||||
#define Q90C_CCNRF_INO
|
||||
#define SLT_CCNRF_INO
|
||||
#define UDIRC_CCNRF_INO
|
||||
#define V911S_CCNRF_INO
|
||||
#define XK_CCNRF_INO
|
||||
#define XK2_CCNRF_INO
|
||||
@ -845,6 +846,8 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= {
|
||||
SYMAX5C
|
||||
PROTO_TRAXXAS
|
||||
NONE
|
||||
PROTO_UDIRC
|
||||
NONE
|
||||
PROTO_V2X2
|
||||
V2X2
|
||||
JXD506
|
||||
|
Loading…
x
Reference in New Issue
Block a user