diff --git a/Multiprotocol/CYRF6936_SPI.ino b/Multiprotocol/CYRF6936_SPI.ino index 83db4e9bf..37b39eef8 100644 --- a/Multiprotocol/CYRF6936_SPI.ino +++ b/Multiprotocol/CYRF6936_SPI.ino @@ -249,7 +249,7 @@ void CYRF_WriteDataPacket(const uint8_t dpbuffer[]) } */ //NOTE: This routine will reset the CRC Seed -void CYRF_FindBestChannels(uint8_t *channels, uint8_t len, uint8_t minspace, uint8_t min, uint8_t max) +void CYRF_FindBestChannels(uint8_t *channels, uint8_t len, uint8_t minspace, uint8_t min, uint8_t max, uint8_t forced) { #define NUM_FREQ 80 #define FREQ_OFFSET 4 @@ -269,7 +269,12 @@ void CYRF_FindBestChannels(uint8_t *channels, uint8_t len, uint8_t minspace, uin delayMilliseconds(1); for(i = 0; i < NUM_FREQ; i++) { - CYRF_ConfigRFChannel(protocol==PROTO_LOSI?i|1:i); + if(((i&1) && forced == FIND_CHANNEL_EVEN) || (!(i&1) && forced == FIND_CHANNEL_ODD)) + { + rssi[i] = 0xFF; + continue; + } + CYRF_ConfigRFChannel(i); //protocol==PROTO_LOSI?i|1:i); delayMicroseconds(270); //slow channel require 270usec for synthesizer to settle if( !(CYRF_ReadRegister(CYRF_05_RX_CTRL) & 0x80)) { CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x80); //Prepare to receive diff --git a/Multiprotocol/DSM_cyrf6936.ino b/Multiprotocol/DSM_cyrf6936.ino index 4e08228a4..f5c4f8278 100644 --- a/Multiprotocol/DSM_cyrf6936.ino +++ b/Multiprotocol/DSM_cyrf6936.ino @@ -618,7 +618,7 @@ void DSM_init() else if(sub_protocol != DSMR) { uint8_t tmpch[10]; - CYRF_FindBestChannels(tmpch, 10, 5, 3, 75); + CYRF_FindBestChannels(tmpch, 10, 5, 3, 75, FIND_CHANNEL_ANY); // uint8_t idx = random(0xfefefefe) % 10; hopping_frequency[0] = tmpch[idx]; diff --git a/Multiprotocol/Devo_cyrf6936.ino b/Multiprotocol/Devo_cyrf6936.ino index 61bacc952..d351bd403 100644 --- a/Multiprotocol/Devo_cyrf6936.ino +++ b/Multiprotocol/Devo_cyrf6936.ino @@ -365,7 +365,7 @@ static void __attribute__((unused)) DEVO_cyrf_init() static void __attribute__((unused)) DEVO_set_radio_channels() { - CYRF_FindBestChannels(hopping_frequency, 3, 4, 4, 80); + CYRF_FindBestChannels(hopping_frequency, 3, 4, 4, 80, FIND_CHANNEL_ANY); hopping_frequency[3] = hopping_frequency[0]; hopping_frequency[4] = hopping_frequency[1]; } diff --git a/Multiprotocol/J6Pro_cyrf6936.ino b/Multiprotocol/J6Pro_cyrf6936.ino index a62827ef2..11caa0ce3 100644 --- a/Multiprotocol/J6Pro_cyrf6936.ino +++ b/Multiprotocol/J6Pro_cyrf6936.ino @@ -124,7 +124,7 @@ static void __attribute__((unused)) j6pro_set_radio_channels() { //FIXME: Query free channels //lowest channel is 0x08, upper channel is 0x4d? - CYRF_FindBestChannels(hopping_frequency, 3, 5, 8, 77); + CYRF_FindBestChannels(hopping_frequency, 3, 5, 8, 77, FIND_CHANNEL_ANY); hopping_frequency[3] = hopping_frequency[0]; } diff --git a/Multiprotocol/Kyosho3_cyrf6936.ino b/Multiprotocol/Kyosho3_cyrf6936.ino index e00484f29..75dfc07e4 100644 --- a/Multiprotocol/Kyosho3_cyrf6936.ino +++ b/Multiprotocol/Kyosho3_cyrf6936.ino @@ -17,7 +17,7 @@ #include "iface_cyrf6936.h" -#define KYOSHO3_FORCE_ID +//#define KYOSHO3_FORCE_ID //#define KYOSHO3_DEBUG #define KYOSHO3_BIND_PACKET_SIZE 4 @@ -102,7 +102,8 @@ void KYOSHO3_init() CYRF_WritePreamble(0x333304); //Find a free even channel - CYRF_FindBestChannels(hopping_frequency,1,1,0x04,0x50); + CYRF_FindBestChannels(hopping_frequency,1,1,0x04,0x50, FIND_CHANNEL_EVEN); + hopping_frequency[0] = 0x04; #ifdef KYOSHO3_FORCE_ID // data taken from TX dump rx_tx_addr[1]=0x01; @@ -114,6 +115,7 @@ void KYOSHO3_init() debugln("ID: %02X %02X %02X",rx_tx_addr[1],rx_tx_addr[2],rx_tx_addr[3]); debugln("RF CH: %02X",hopping_frequency[0]); #endif + CYRF_ConfigRFChannel(hopping_frequency[0]); bind_counter=1000; diff --git a/Multiprotocol/Losi_cyrf6936.ino b/Multiprotocol/Losi_cyrf6936.ino index f619a7495..453a9baf5 100644 --- a/Multiprotocol/Losi_cyrf6936.ino +++ b/Multiprotocol/Losi_cyrf6936.ino @@ -169,8 +169,7 @@ void LOSI_init() { LOSI_cyrf_init(); - CYRF_FindBestChannels(hopping_frequency, 1, 0, 0x07, 0x4F); // 0x07 and 0x4F are unknown limits, this routine resets the CRC Seed to 0 - hopping_frequency[0] |= 1; // Only odd channels are used, integrated in CYRF code... + CYRF_FindBestChannels(hopping_frequency, 1, 0, 0x07, 0x4F, FIND_CHANNEL_ODD); // 0x07 and 0x4F are unknown limits, this routine resets the CRC Seed to 0 crc8 = 0; crc8 = (uint16_t)LOSI_check(((rx_tx_addr[2]&0x0F) << 8) + rx_tx_addr[3]) >> 12; diff --git a/Multiprotocol/Multiprotocol.h b/Multiprotocol/Multiprotocol.h index 93a1a167c..d98c5f8fa 100644 --- a/Multiprotocol/Multiprotocol.h +++ b/Multiprotocol/Multiprotocol.h @@ -19,7 +19,7 @@ #define VERSION_MAJOR 1 #define VERSION_MINOR 3 #define VERSION_REVISION 4 -#define VERSION_PATCH_LEVEL 4 +#define VERSION_PATCH_LEVEL 5 #define MODE_SERIAL 0 diff --git a/Multiprotocol/TRAXXAS_cyrf6936.ino b/Multiprotocol/TRAXXAS_cyrf6936.ino index 4bfc5d7db..3f1fb6948 100644 --- a/Multiprotocol/TRAXXAS_cyrf6936.ino +++ b/Multiprotocol/TRAXXAS_cyrf6936.ino @@ -241,7 +241,7 @@ void TRAXXAS_init() //Read CYRF ID CYRF_GetMfgData(cyrfmfg_id); //cyrfmfg_id[0]+=RX_num; // Not needed since the TX and RX have to match - CYRF_FindBestChannels(hopping_frequency,1,1,0x02,0x21); + CYRF_FindBestChannels(hopping_frequency,1,1,0x02,0x21, FIND_CHANNEL_ANY); #ifdef TRAXXAS_FORCE_ID // data taken from TX dump cyrfmfg_id[0]=0x65; // CYRF MFG ID cyrfmfg_id[1]=0xE2; diff --git a/Multiprotocol/WK2x01_cyrf6936.ino b/Multiprotocol/WK2x01_cyrf6936.ino index ae4a0c63a..a781f0262 100644 --- a/Multiprotocol/WK2x01_cyrf6936.ino +++ b/Multiprotocol/WK2x01_cyrf6936.ino @@ -487,7 +487,7 @@ void WK_init() CYRF_SetTxRxMode(TX_EN); hopping_frequency_no=0; - CYRF_FindBestChannels(hopping_frequency, 3, 4, 4, 80); + CYRF_FindBestChannels(hopping_frequency, 3, 4, 4, 80, FIND_CHANNEL_ANY); CYRF_ConfigRFChannel(hopping_frequency[0]); packet_count = 0; diff --git a/Multiprotocol/iface_cyrf6936.h b/Multiprotocol/iface_cyrf6936.h index 433548afc..ad4366315 100644 --- a/Multiprotocol/iface_cyrf6936.h +++ b/Multiprotocol/iface_cyrf6936.h @@ -71,7 +71,11 @@ enum CYRF_PWR { CYRF_PWR_DEFAULT, }; - +enum FIND_CHANNEL { + FIND_CHANNEL_ANY = 0, + FIND_CHANNEL_EVEN = 1, + FIND_CHANNEL_ODD = 2, +}; /* SPI CYRF6936 */ /*