From c9fecafadabb81c22a643291da98deb4d9e9ec44 Mon Sep 17 00:00:00 2001 From: Pascal Langer Date: Sat, 18 May 2019 20:33:32 +0200 Subject: [PATCH] WFly frequency tunning --- Multiprotocol/WFLY_cyrf6936.ino | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Multiprotocol/WFLY_cyrf6936.ino b/Multiprotocol/WFLY_cyrf6936.ino index 1742768..e62102c 100644 --- a/Multiprotocol/WFLY_cyrf6936.ino +++ b/Multiprotocol/WFLY_cyrf6936.ino @@ -80,6 +80,9 @@ static void __attribute__((unused)) WFLY_cyrf_data_config() static uint16_t __attribute__((unused)) WFLY_send_data_packet() { + #ifdef USE_CYRF6936_CH15_TUNING + static uint16_t Channel15=1024; + #endif packet_count++; packet[0] = rx_tx_addr[2]; packet[1] = rx_tx_addr[3]; @@ -134,6 +137,16 @@ static uint16_t __attribute__((unused)) WFLY_send_data_packet() sum += packet[i]; packet[len] = sum; + #ifdef USE_CYRF6936_CH15_TUNING + if(Channel15!=Channel_data[CH15]) + { // adjust frequency + Channel15=Channel_data[CH15]+0x155; // default value is 0x555 = 0x400 + 0x155 + CYRF_WriteRegister(CYRF_1B_TX_OFFSET_LSB, Channel15&0xFF); + CYRF_WriteRegister(CYRF_1C_TX_OFFSET_MSB, Channel15>>8); + Channel15-=0x155; + } + #endif + CYRF_ConfigRFChannel(hopping_frequency[(packet_count)%4]); CYRF_SetPower(0x08); CYRF_WriteDataPacketLen(packet, len+1); @@ -155,9 +168,6 @@ uint16_t ReadWFLY() uint8_t status,len,sum=0,check=0; uint8_t start; static uint8_t retry; - #ifdef USE_CYRF6936_CH15_TUNING - static uint16_t Channel15=1024; - #endif switch(phase) { @@ -239,15 +249,6 @@ uint16_t ReadWFLY() while ((uint8_t)((uint8_t)micros()-(uint8_t)start) < 200) if((CYRF_ReadRegister(CYRF_02_TX_CTRL) & 0x80) == 0x00) break; // Packet transmission complete - #ifdef USE_CYRF6936_CH15_TUNING - if(Channel15!=Channel_data[CH15]) - { // adjust frequency - Channel15=Channel_data[CH15]+0x155; // default value is 0x555 = 0x400 + 0x155 - CYRF_WriteRegister(CYRF_1B_TX_OFFSET_LSB, Channel15&0xFF); - CYRF_WriteRegister(CYRF_1C_TX_OFFSET_MSB, Channel15>>8); - Channel15-=0x155; - } - #endif return WFLY_send_data_packet(); } return 1000;