mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-10 00:28:13 +00:00
WFLYRF: fixed normal mode, added telemetry, bind is not working yet
This commit is contained in:
parent
abd36dc6a4
commit
b01462e36b
@ -821,7 +821,7 @@ bool Update_All()
|
|||||||
update_led_status();
|
update_led_status();
|
||||||
#if defined(TELEMETRY)
|
#if defined(TELEMETRY)
|
||||||
#if ( !( defined(MULTI_TELEMETRY) || defined(MULTI_STATUS) ) )
|
#if ( !( defined(MULTI_TELEMETRY) || defined(MULTI_STATUS) ) )
|
||||||
if((protocol == PROTO_BAYANG_RX) || (protocol == PROTO_AFHDS2A_RX) || (protocol == PROTO_FRSKY_RX) || (protocol == PROTO_SCANNER) || (protocol==PROTO_FRSKYD) || (protocol==PROTO_BAYANG) || (protocol==PROTO_NCC1701) || (protocol==PROTO_BUGS) || (protocol==PROTO_BUGSMINI) || (protocol==PROTO_HUBSAN) || (protocol==PROTO_AFHDS2A) || (protocol==PROTO_FRSKYX) || (protocol==PROTO_FRSKYX2) || (protocol==PROTO_DSM) || (protocol==PROTO_CABELL) || (protocol==PROTO_HITEC) || (protocol==PROTO_HOTT) || (protocol==PROTO_PROPEL) || (protocol==PROTO_OMP) || (protocol==PROTO_DEVO) || (protocol==PROTO_DSM_RX) || (protocol==PROTO_FRSKY_R9) || (protocol==PROTO_RLINK))
|
if((protocol == PROTO_BAYANG_RX) || (protocol == PROTO_AFHDS2A_RX) || (protocol == PROTO_FRSKY_RX) || (protocol == PROTO_SCANNER) || (protocol==PROTO_FRSKYD) || (protocol==PROTO_BAYANG) || (protocol==PROTO_NCC1701) || (protocol==PROTO_BUGS) || (protocol==PROTO_BUGSMINI) || (protocol==PROTO_HUBSAN) || (protocol==PROTO_AFHDS2A) || (protocol==PROTO_FRSKYX) || (protocol==PROTO_FRSKYX2) || (protocol==PROTO_DSM) || (protocol==PROTO_CABELL) || (protocol==PROTO_HITEC) || (protocol==PROTO_HOTT) || (protocol==PROTO_PROPEL) || (protocol==PROTO_OMP) || (protocol==PROTO_DEVO) || (protocol==PROTO_DSM_RX) || (protocol==PROTO_FRSKY_R9) || (protocol==PROTO_RLINK) || (protocol==PROTO_WFLYRF))
|
||||||
#endif
|
#endif
|
||||||
if(IS_DISABLE_TELEM_off)
|
if(IS_DISABLE_TELEM_off)
|
||||||
TelemetryUpdate();
|
TelemetryUpdate();
|
||||||
@ -2290,7 +2290,7 @@ void pollBoot()
|
|||||||
#if defined(TELEMETRY)
|
#if defined(TELEMETRY)
|
||||||
void PPM_Telemetry_serial_init()
|
void PPM_Telemetry_serial_init()
|
||||||
{
|
{
|
||||||
if( (protocol==PROTO_FRSKYD) || (protocol==PROTO_HUBSAN) || (protocol==PROTO_AFHDS2A) || (protocol==PROTO_BAYANG)|| (protocol==PROTO_NCC1701) || (protocol==PROTO_CABELL) || (protocol==PROTO_HITEC) || (protocol==PROTO_BUGS) || (protocol==PROTO_BUGSMINI) || (protocol==PROTO_PROPEL) || (protocol==PROTO_OMP) || (protocol==PROTO_RLINK)
|
if( (protocol==PROTO_FRSKYD) || (protocol==PROTO_HUBSAN) || (protocol==PROTO_AFHDS2A) || (protocol==PROTO_BAYANG)|| (protocol==PROTO_NCC1701) || (protocol==PROTO_CABELL) || (protocol==PROTO_HITEC) || (protocol==PROTO_BUGS) || (protocol==PROTO_BUGSMINI) || (protocol==PROTO_PROPEL) || (protocol==PROTO_OMP) || (protocol==PROTO_RLINK) || (protocol==PROTO_WFLYRF)
|
||||||
#ifdef TELEMETRY_FRSKYX_TO_FRSKYD
|
#ifdef TELEMETRY_FRSKYX_TO_FRSKYD
|
||||||
|| (protocol==PROTO_FRSKYX) || (protocol==PROTO_FRSKYX2)
|
|| (protocol==PROTO_FRSKYX) || (protocol==PROTO_FRSKYX2)
|
||||||
#endif
|
#endif
|
||||||
|
@ -531,7 +531,7 @@ void frsky_link_frame()
|
|||||||
telemetry_link |= 2 ; // Send hub if available
|
telemetry_link |= 2 ; // Send hub if available
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{//PROTO_HUBSAN, PROTO_AFHDS2A, PROTO_BAYANG, PROTO_NCC1701, PROTO_CABELL, PROTO_HITEC, PROTO_BUGS, PROTO_BUGSMINI, PROTO_FRSKYX, PROTO_FRSKYX2, PROTO_PROPEL, PROTO_DEVO, PROTO_RLINK, PROTO_OMP
|
{//PROTO_HUBSAN, PROTO_AFHDS2A, PROTO_BAYANG, PROTO_NCC1701, PROTO_CABELL, PROTO_HITEC, PROTO_BUGS, PROTO_BUGSMINI, PROTO_FRSKYX, PROTO_FRSKYX2, PROTO_PROPEL, PROTO_DEVO, PROTO_RLINK, PROTO_OMP, PROTO_WFLYRF
|
||||||
frame[1] = v_lipo1;
|
frame[1] = v_lipo1;
|
||||||
frame[2] = v_lipo2;
|
frame[2] = v_lipo2;
|
||||||
frame[3] = RX_RSSI;
|
frame[3] = RX_RSSI;
|
||||||
|
@ -355,6 +355,7 @@
|
|||||||
#undef RLINK_HUB_TELEMETRY
|
#undef RLINK_HUB_TELEMETRY
|
||||||
#undef DSM_RX_CYRF6936_INO
|
#undef DSM_RX_CYRF6936_INO
|
||||||
#undef DSM_FWD_PGM
|
#undef DSM_FWD_PGM
|
||||||
|
#undef WFLYRF_HUB_TELEMETRY
|
||||||
#else
|
#else
|
||||||
#if defined(MULTI_TELEMETRY) && defined(MULTI_STATUS)
|
#if defined(MULTI_TELEMETRY) && defined(MULTI_STATUS)
|
||||||
#error You should choose either MULTI_TELEMETRY or MULTI_STATUS but not both.
|
#error You should choose either MULTI_TELEMETRY or MULTI_STATUS but not both.
|
||||||
@ -426,7 +427,10 @@
|
|||||||
#if not defined(HOTT_CC2500_INO)
|
#if not defined(HOTT_CC2500_INO)
|
||||||
#undef HOTT_FW_TELEMETRY
|
#undef HOTT_FW_TELEMETRY
|
||||||
#endif
|
#endif
|
||||||
#if not defined(HOTT_FW_TELEMETRY) && not defined(DSM_TELEMETRY) && not defined(SPORT_TELEMETRY) && not defined(HUB_TELEMETRY) && not defined(HUBSAN_HUB_TELEMETRY) && not defined(BUGS_HUB_TELEMETRY) && not defined(NCC1701_HUB_TELEMETRY) && not defined(BAYANG_HUB_TELEMETRY) && not defined(CABELL_HUB_TELEMETRY) && not defined(RLINK_HUB_TELEMETRY) && not defined(AFHDS2A_HUB_TELEMETRY) && not defined(AFHDS2A_FW_TELEMETRY) && not defined(MULTI_TELEMETRY) && not defined(MULTI_STATUS) && not defined(HITEC_HUB_TELEMETRY) && not defined(HITEC_FW_TELEMETRY) && not defined(SCANNER_TELEMETRY) && not defined(FRSKY_RX_TELEMETRY) && not defined(AFHDS2A_RX_TELEMETRY) && not defined(BAYANG_RX_TELEMETRY) && not defined(DEVO_HUB_TELEMETRY) && not defined(PROPEL_HUB_TELEMETRY) && not defined(OMP_HUB_TELEMETRY)
|
#if not defined(WFLYRF_A7105_INO)
|
||||||
|
#undef WFLYRF_HUB_TELEMETRY
|
||||||
|
#endif
|
||||||
|
#if not defined(HOTT_FW_TELEMETRY) && not defined(DSM_TELEMETRY) && not defined(SPORT_TELEMETRY) && not defined(HUB_TELEMETRY) && not defined(HUBSAN_HUB_TELEMETRY) && not defined(BUGS_HUB_TELEMETRY) && not defined(NCC1701_HUB_TELEMETRY) && not defined(BAYANG_HUB_TELEMETRY) && not defined(CABELL_HUB_TELEMETRY) && not defined(RLINK_HUB_TELEMETRY) && not defined(AFHDS2A_HUB_TELEMETRY) && not defined(AFHDS2A_FW_TELEMETRY) && not defined(MULTI_TELEMETRY) && not defined(MULTI_STATUS) && not defined(HITEC_HUB_TELEMETRY) && not defined(HITEC_FW_TELEMETRY) && not defined(SCANNER_TELEMETRY) && not defined(FRSKY_RX_TELEMETRY) && not defined(AFHDS2A_RX_TELEMETRY) && not defined(BAYANG_RX_TELEMETRY) && not defined(DEVO_HUB_TELEMETRY) && not defined(PROPEL_HUB_TELEMETRY) && not defined(OMP_HUB_TELEMETRY) && not defined(WFLYRF_HUB_TELEMETRY)
|
||||||
#undef TELEMETRY
|
#undef TELEMETRY
|
||||||
#undef INVERT_TELEMETRY
|
#undef INVERT_TELEMETRY
|
||||||
#undef MULTI_TELEMETRY
|
#undef MULTI_TELEMETRY
|
||||||
|
@ -130,13 +130,38 @@ static void __attribute__((unused)) WFLYRF_build_packet()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#define WFLYRF_PACKET_PERIOD 3600
|
#ifdef WFLYRF_HUB_TELEMETRY
|
||||||
#define WFLYRF_BUFFER_TIME 1500
|
static void __attribute__((unused)) WFLYRF_Send_Telemetry()
|
||||||
#define WFLYRF_WRITE_TIME 942
|
{
|
||||||
|
//Incoming packet values
|
||||||
|
v_lipo1=packet[3]<<1; // RX_batt*10 in V
|
||||||
|
RX_RSSI=(255-packet[7])>>1; // Looks to be the RX RSSI value direct from A7105
|
||||||
|
|
||||||
|
// Read TX RSSI
|
||||||
|
TX_RSSI=255-A7105_ReadReg(A7105_1D_RSSI_THOLD);
|
||||||
|
|
||||||
|
telemetry_counter++; // LQI counter
|
||||||
|
telemetry_link=1;
|
||||||
|
if(telemetry_lost)
|
||||||
|
{
|
||||||
|
telemetry_lost = 0;
|
||||||
|
packet_count = 100;
|
||||||
|
telemetry_counter = 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define WFLYRF_PACKET_PERIOD 3600 //3600
|
||||||
|
#define WFLYRF_BUFFER_TIME 1500 //1500
|
||||||
|
#define WFLYRF_WRITE_TIME 800 //942
|
||||||
|
|
||||||
uint16_t ReadWFLYRF()
|
uint16_t ReadWFLYRF()
|
||||||
{
|
{
|
||||||
uint16_t start;
|
uint16_t start;
|
||||||
|
#ifdef WFLYRF_HUB_TELEMETRY
|
||||||
|
uint8_t status;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef FORCE_WFLYRF_TUNING
|
#ifndef FORCE_WFLYRF_TUNING
|
||||||
A7105_AdjustLOBaseFreq(1);
|
A7105_AdjustLOBaseFreq(1);
|
||||||
#endif
|
#endif
|
||||||
@ -158,10 +183,10 @@ uint16_t ReadWFLYRF()
|
|||||||
#ifdef MULTI_SYNC
|
#ifdef MULTI_SYNC
|
||||||
telemetry_set_input_sync(WFLYRF_PACKET_PERIOD);
|
telemetry_set_input_sync(WFLYRF_PACKET_PERIOD);
|
||||||
#endif
|
#endif
|
||||||
//Build packet
|
//Build data packet
|
||||||
WFLYRF_build_packet();
|
WFLYRF_build_packet();
|
||||||
|
|
||||||
//Fill the buffer
|
//Fill the TX buffer without sending
|
||||||
A7105_WriteReg(A7105_03_FIFOI, 0x1F);
|
A7105_WriteReg(A7105_03_FIFOI, 0x1F);
|
||||||
A7105_CSN_off;
|
A7105_CSN_off;
|
||||||
SPI_Write(A7105_RST_WRPTR);
|
SPI_Write(A7105_RST_WRPTR);
|
||||||
@ -170,42 +195,78 @@ uint16_t ReadWFLYRF()
|
|||||||
SPI_Write(packet[i]);
|
SPI_Write(packet[i]);
|
||||||
A7105_CSN_on;
|
A7105_CSN_on;
|
||||||
|
|
||||||
|
#ifdef WFLYRF_HUB_TELEMETRY
|
||||||
|
//LQI calculation
|
||||||
|
packet_count++;
|
||||||
|
if(packet_count>=100)
|
||||||
|
{
|
||||||
|
packet_count=0;
|
||||||
|
TX_LQI=telemetry_counter;
|
||||||
|
if(telemetry_counter==0)
|
||||||
|
telemetry_lost = 1;
|
||||||
|
telemetry_counter = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
phase++; // WFLYRF_PLL_TX
|
phase++; // WFLYRF_PLL_TX
|
||||||
return WFLYRF_BUFFER_TIME;
|
return WFLYRF_BUFFER_TIME;
|
||||||
|
|
||||||
case WFLYRF_PLL_TX:
|
case WFLYRF_PLL_TX:
|
||||||
|
#ifdef WFLYRF_HUB_TELEMETRY
|
||||||
|
//Check RX status
|
||||||
|
status=A7105_ReadReg(A7105_00_MODE);
|
||||||
|
//debugln("S:%02X", status);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//PLL
|
||||||
A7105_Strobe(A7105_PLL);
|
A7105_Strobe(A7105_PLL);
|
||||||
//Check if RX
|
|
||||||
//if((A7105_ReadReg(A7105_00_MODE) & 0x01) && !(A7105_ReadReg(A7105_00_MODE) & (1<<5 | 1<<6)))
|
#ifdef WFLYRF_HUB_TELEMETRY
|
||||||
if(!(A7105_ReadReg(A7105_00_MODE) & (1<<5 | 1<<6)))
|
//Read incoming packet even if bad/not present to not change too much the TX timing, might want to reorg the code...
|
||||||
{ // RX+FECF+CRCF Ok
|
|
||||||
A7105_ReadData(WFLYRF_PACKET_SIZE);
|
A7105_ReadData(WFLYRF_PACKET_SIZE);
|
||||||
|
|
||||||
|
//Read telemetry
|
||||||
|
if((status & 0x21)==0)
|
||||||
|
{ // Packet received and CRC OK
|
||||||
//Debug
|
//Debug
|
||||||
#if 0
|
#if 1
|
||||||
debug("T:");
|
debug("T:");
|
||||||
for(uint8_t i=0; i<WFLYRF_PACKET_SIZE; i++)
|
for(uint8_t i=0; i<WFLYRF_PACKET_SIZE-20; i++) // Can't send the full telemetry at full speed
|
||||||
debug(" %02X", packet[i]);
|
debug(" %02X", packet[i]);
|
||||||
debugln("");
|
debugln("");
|
||||||
#endif
|
#endif
|
||||||
|
//Packet match the ID ?
|
||||||
|
if(packet[0]==0 && packet[1]==rx_tx_addr[3] && packet[2]==rx_tx_addr[2]) //need to check if this is the full rx_tx_addr[2] or the partial one...
|
||||||
|
WFLYRF_Send_Telemetry(); // Packet looks good do send telem to the radio
|
||||||
}
|
}
|
||||||
//Change channel
|
#endif
|
||||||
A7105_WriteReg(A7105_0F_PLL_I, rf_ch_num);
|
|
||||||
//Send
|
//Change RF channel
|
||||||
|
A7105_WriteReg(A7105_0F_PLL_I, (rf_ch_num<<1)+0x10);
|
||||||
|
|
||||||
|
//Switch to TX
|
||||||
A7105_SetPower();
|
A7105_SetPower();
|
||||||
A7105_SetTxRxMode(TX_EN);
|
A7105_SetTxRxMode(TX_EN);
|
||||||
A7105_Strobe(A7105_TX);
|
A7105_Strobe(A7105_TX);
|
||||||
|
|
||||||
phase++; // WFLYRF_RX
|
phase++; // WFLYRF_RX
|
||||||
return WFLYRF_WRITE_TIME;
|
return WFLYRF_WRITE_TIME;
|
||||||
|
|
||||||
case WFLYRF_RX:
|
case WFLYRF_RX:
|
||||||
//Wait for TX completion
|
//Wait for TX completion
|
||||||
start=micros();
|
start=micros();
|
||||||
while ((uint16_t)((uint16_t)micros()-start) < 700) // Wait max 700µs
|
while ((uint16_t)((uint16_t)micros()-start) < 700) // Wait max 700µs
|
||||||
if(!(A7105_ReadReg(A7105_00_MODE) & 0x01))
|
if(!(A7105_ReadReg(A7105_00_MODE) & 0x01))
|
||||||
break;
|
break;
|
||||||
A7105_WriteReg(A7105_0F_PLL_I, rf_ch_num);
|
|
||||||
|
//A7105_WriteReg(A7105_0F_PLL_I, (rf_ch_num<<1)+0x10); // Again in dumps?? It should not be needed...
|
||||||
|
|
||||||
|
//Switch to RX
|
||||||
A7105_SetTxRxMode(RX_EN);
|
A7105_SetTxRxMode(RX_EN);
|
||||||
A7105_Strobe(A7105_RX);
|
A7105_Strobe(A7105_RX);
|
||||||
|
|
||||||
phase = WFLYRF_DATA;
|
phase = WFLYRF_DATA;
|
||||||
return WFLYRF_PACKET_PERIOD-WFLYRF_WRITE_TIME-WFLYRF_PLL_TX;
|
return WFLYRF_PACKET_PERIOD-WFLYRF_WRITE_TIME-WFLYRF_BUFFER_TIME;
|
||||||
}
|
}
|
||||||
return WFLYRF_PACKET_PERIOD; // never reached, please the compiler
|
return WFLYRF_PACKET_PERIOD; // never reached, please the compiler
|
||||||
}
|
}
|
||||||
@ -236,6 +297,10 @@ uint16_t initWFLYRF()
|
|||||||
A7105_WriteID(MProtocol_id);
|
A7105_WriteID(MProtocol_id);
|
||||||
phase = WFLYRF_DATA;
|
phase = WFLYRF_DATA;
|
||||||
}
|
}
|
||||||
|
#ifdef WFLYRF_HUB_TELEMETRY
|
||||||
|
packet_count = 0;
|
||||||
|
telemetry_lost = 1;
|
||||||
|
#endif
|
||||||
return 2000;
|
return 2000;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -323,6 +323,7 @@
|
|||||||
#define PROPEL_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
#define PROPEL_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
||||||
#define CABELL_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
#define CABELL_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
||||||
#define RLINK_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
#define RLINK_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
||||||
|
#define WFLYRF_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
||||||
#define HITEC_HUB_TELEMETRY // Use FrSkyD Hub format to send basic telemetry to the radios which can decode it like er9x, erskyTX and OpenTX
|
#define HITEC_HUB_TELEMETRY // Use FrSkyD Hub format to send basic telemetry to the radios which can decode it like er9x, erskyTX and OpenTX
|
||||||
#define HITEC_FW_TELEMETRY // Forward received telemetry packets to be decoded by erskyTX and OpenTX
|
#define HITEC_FW_TELEMETRY // Forward received telemetry packets to be decoded by erskyTX and OpenTX
|
||||||
#define SCANNER_TELEMETRY // Forward spectrum scanner data to TX
|
#define SCANNER_TELEMETRY // Forward spectrum scanner data to TX
|
||||||
|
Loading…
x
Reference in New Issue
Block a user