WFly frequency tunning

This commit is contained in:
Pascal Langer 2019-05-18 20:33:32 +02:00
parent f3ca7ad644
commit c9fecafada

View File

@ -80,6 +80,9 @@ static void __attribute__((unused)) WFLY_cyrf_data_config()
static uint16_t __attribute__((unused)) WFLY_send_data_packet() static uint16_t __attribute__((unused)) WFLY_send_data_packet()
{ {
#ifdef USE_CYRF6936_CH15_TUNING
static uint16_t Channel15=1024;
#endif
packet_count++; packet_count++;
packet[0] = rx_tx_addr[2]; packet[0] = rx_tx_addr[2];
packet[1] = rx_tx_addr[3]; packet[1] = rx_tx_addr[3];
@ -134,6 +137,16 @@ static uint16_t __attribute__((unused)) WFLY_send_data_packet()
sum += packet[i]; sum += packet[i];
packet[len] = sum; 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_ConfigRFChannel(hopping_frequency[(packet_count)%4]);
CYRF_SetPower(0x08); CYRF_SetPower(0x08);
CYRF_WriteDataPacketLen(packet, len+1); CYRF_WriteDataPacketLen(packet, len+1);
@ -155,9 +168,6 @@ uint16_t ReadWFLY()
uint8_t status,len,sum=0,check=0; uint8_t status,len,sum=0,check=0;
uint8_t start; uint8_t start;
static uint8_t retry; static uint8_t retry;
#ifdef USE_CYRF6936_CH15_TUNING
static uint16_t Channel15=1024;
#endif
switch(phase) switch(phase)
{ {
@ -239,15 +249,6 @@ uint16_t ReadWFLY()
while ((uint8_t)((uint8_t)micros()-(uint8_t)start) < 200) while ((uint8_t)((uint8_t)micros()-(uint8_t)start) < 200)
if((CYRF_ReadRegister(CYRF_02_TX_CTRL) & 0x80) == 0x00) if((CYRF_ReadRegister(CYRF_02_TX_CTRL) & 0x80) == 0x00)
break; // Packet transmission complete 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 WFLY_send_data_packet();
} }
return 1000; return 1000;