Compare commits

..

No commits in common. "d03a8787d1ec5ac43861121ec6a23b94dee6f6e3" and "b901bedad6c8f90ab0b5930278317a7bf2700515" have entirely different histories.

3 changed files with 23 additions and 68 deletions

View File

@ -23,13 +23,12 @@ Multiprotocol is distributed in the hope that it will be useful,
#define JIABAILE_RF_NUM_CHANNELS 3
#define JIABAILE_BIND_PACKET_PERIOD 12700
#define JIABAILE_PACKET_PERIOD 2408
#define JIABAILE_BIND_COUNT 160 //2 sec
#define JIABAILE_BIND_COUNT 2000
#define JIABAILE_WRITE_TIME 1000
enum {
JIABAILE_BIND=0,
JIABAILE_RX,
JIABAILE_PREP_DATA,
JIABAILE_DATA,
};
@ -71,15 +70,6 @@ static void __attribute__((unused)) JIABAILE_send_packet()
if(!CH5_SW && Channel_data[CH5] > CHANNEL_MIN_COMMAND)
packet[3] |= 0x10; //Mid speed
}
else
{
bind_counter--;
if(!bind_counter)
{
BIND_DONE;
phase = JIABAILE_PREP_DATA;
}
}
packet[7] = 0x55 + hopping_frequency[hopping_frequency_no];
for(uint8_t i=0;i<JIABAILE_PAYLOAD_SIZE-1;i++)
packet[7] += packet[i];
@ -120,13 +110,9 @@ static void __attribute__((unused)) JIABAILE_RF_init()
uint16_t JIABAILE_callback()
{
uint8_t sum;
uint16_t addr;
switch(phase)
{
case JIABAILE_BIND:
phase++; // JIABAILE_RX but is overwritten if RX or bind timeout
if(XN297_IsRX())
{
if(XN297_ReadPayload(packet_in, JIABAILE_RX_PAYLOAD_SIZE))
@ -141,24 +127,33 @@ uint16_t JIABAILE_callback()
if(memcmp(packet_in,rx_tx_addr,3)==0)
{//TX ID match
//Check packet
sum=0xAA + hopping_frequency[hopping_frequency_no];
uint8_t sum=0xAA + hopping_frequency[hopping_frequency_no];
for(uint8_t i=0; i < JIABAILE_RX_PAYLOAD_SIZE-1; i++)
sum+=packet_in[i];
if(sum==packet_in[6])
{
//Write the RXID
//Write the RXID in the address
memcpy(&rx_id[1],&packet_in[3],3);
XN297_SetTxRxMode(TXRX_OFF);
XN297_SetTXAddr(rx_id, 5);
//Set the normal frequencies
sum=packet_in[3]&0x07;
hopping_frequency[0] = (sum>4?30:8) + sum;
if(sum==4 || sum ==7)
hopping_frequency[0]++;
hopping_frequency[1] = 40 + sum;
if((sum & 0x06) == 0x06)
hopping_frequency[1] += 21;
hopping_frequency[2] = 70 + sum;
#ifdef DEBUG_SERIAL
debug("RXID ");
debug("RF");
for(uint8_t i=0; i < 3; i++)
debug(" %02X", packet_in[3+i]);
debug(" %d", hopping_frequency[i]);
debugln();
#endif
addr=JIABAILE_EEPROM_OFFSET+RX_num*3;
for(uint8_t i=0;i<3;i++)
eeprom_write_byte((EE_ADDR)(addr+i),packet_in[3+i]);
//Switch to normal mode
BIND_DONE;
phase = JIABAILE_PREP_DATA;
phase = JIABAILE_DATA;
}
#ifdef DEBUG_SERIAL
else
@ -177,6 +172,7 @@ uint16_t JIABAILE_callback()
}
XN297_SetTxRxMode(TXRX_OFF);
JIABAILE_send_packet();
phase++;
return JIABAILE_WRITE_TIME;
case JIABAILE_RX:
//Wait for the packet transmission to finish
@ -186,34 +182,6 @@ uint16_t JIABAILE_callback()
XN297_SetTxRxMode(RX_EN);
phase = JIABAILE_BIND;
return JIABAILE_BIND_PACKET_PERIOD - JIABAILE_WRITE_TIME;
case JIABAILE_PREP_DATA:
//Read the RXID
addr=JIABAILE_EEPROM_OFFSET+RX_num*3;
for(uint8_t i=0;i<3;i++)
rx_id[i+1] = eeprom_read_byte((EE_ADDR)(addr+i));
#ifdef DEBUG_SERIAL
debug("RXID ");
for(uint8_t i=0; i < 3; i++)
debug(" %02X", rx_id[i+1]);
#endif
XN297_SetTxRxMode(TXRX_OFF);
XN297_SetTXAddr(rx_id, 5);
//Set the normal frequencies
sum=rx_id[1]&0x07;
hopping_frequency[0] = (sum>4?30:8) + sum;
if(sum==4 || sum ==7)
hopping_frequency[0]++;
hopping_frequency[1] = 40 + sum;
if((sum & 0x06) == 0x06)
hopping_frequency[1] += 21;
hopping_frequency[2] = 70 + sum;
#ifdef DEBUG_SERIAL
debug(" RF");
for(uint8_t i=0; i < 3; i++)
debug(" %d", hopping_frequency[i]);
debugln();
#endif
phase++;
default: //JIABAILE_DATA
#ifdef MULTI_SYNC
telemetry_set_input_sync(JIABAILE_PACKET_PERIOD);
@ -226,15 +194,10 @@ uint16_t JIABAILE_callback()
void JIABAILE_init()
{
BIND_IN_PROGRESS; // Autobind protocol
JIABAILE_initialize_txid();
JIABAILE_RF_init();
if(IS_BIND_IN_PROGRESS)
{
phase = JIABAILE_BIND;
bind_counter = JIABAILE_BIND_COUNT;
}
else
phase = JIABAILE_PREP_DATA;
phase = JIABAILE_BIND;
hopping_frequency_no = 0;
}

View File

@ -856,8 +856,7 @@ enum {
#define DSM_CLONE_EEPROM_OFFSET 1074 // (4) TX ID, (1) Initialized, end is 1079
#define TRAXXAS_EEPROM_OFFSET 1079 // RX ID and SOP index, 3 bytes per model id, end is 1079+192=1271
#define XK2_EEPROM_OFFSET 1271 // RX ID checksum, 1 byte per model, end is 1271+64=1335
#define JIABAILE_EEPROM_OFFSET 1335 // RX ID, 3 bytes per model, end is 1335+64*3=1527
//#define CONFIG_EEPROM_OFFSET 1527 // Current configuration of the multimodule
//#define CONFIG_EEPROM_OFFSET 1335 // Current configuration of the multimodule
/* STM32 Flash Size */
#ifndef DISABLE_FLASH_SIZE_CHECK

View File

@ -701,8 +701,6 @@ A|E|T|R
## Traxxas - *43*
You must assign a different RX number for each receiver/car. Otherwise the new receiver/car ID will overwrite the previous one.
### Sub_protocol TQ2 - *0*
Transmitter TQ, Receivers: 6519, 2218(X), ECM-2.5
@ -1518,8 +1516,6 @@ Models: WLtoys cars 284131/284161/284010/124016/124017/144010 and Eachine EAT14
## XK2 - *99*
You must assign a different RX number for each receiver/plane. Otherwise the new receiver/plane ID will overwrite the previous one.
### Sub_protocol X4 - *0*
Transmitter: XK X4-A160, X5S, model: XK A160S, XK A280, XK A300
@ -1928,10 +1924,7 @@ ARM|
### Sub_protocol FQ777_951 - *3*
## JIABAILE - *102*
Models: JBL-430x without gyro
You must assign a different RX number for each car. Otherwise the new car ID will overwrite the previous one.
Autobind protocol
CH1|CH2|CH3|CH4|CH5|CH6|CH7
---|---|---|---|---|---|---