mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-07-02 02:37:52 +00:00
Devo basic telemetry
This commit is contained in:
parent
f5720d38bb
commit
6f36473975
@ -284,7 +284,7 @@ void CYRF_FindBestChannels(uint8_t *channels, uint8_t len, uint8_t minspace, uin
|
|||||||
}
|
}
|
||||||
CYRF_WriteRegister(CYRF_29_RX_ABORT, 0x20); // Abort RX operation
|
CYRF_WriteRegister(CYRF_29_RX_ABORT, 0x20); // Abort RX operation
|
||||||
CYRF_SetTxRxMode(TX_EN);
|
CYRF_SetTxRxMode(TX_EN);
|
||||||
CYRF_WriteRegister(CYRF_29_RX_ABORT, 0x20); // Clear abort RX
|
CYRF_WriteRegister(CYRF_29_RX_ABORT, 0x00); // Clear abort RX
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(DEVO_CYRF6936_INO) || defined(J6PRO_CYRF6936_INO)
|
#if defined(DEVO_CYRF6936_INO) || defined(J6PRO_CYRF6936_INO)
|
||||||
|
@ -162,6 +162,31 @@ static void __attribute__((unused)) DEVO_build_data_pkt()
|
|||||||
DEVO_add_pkt_suffix();
|
DEVO_add_pkt_suffix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void __attribute__((unused)) DEVO_parse_telemetry_packet()
|
||||||
|
{
|
||||||
|
DEVO_scramble_pkt(); //This will unscramble the packet
|
||||||
|
|
||||||
|
debugln("RX");
|
||||||
|
if ((((uint32_t)packet[15] << 16) | ((uint32_t)packet[14] << 8) | packet[13]) != (MProtocol_id & 0x00ffffff))
|
||||||
|
return; // ID does not match
|
||||||
|
|
||||||
|
//RSSI
|
||||||
|
TX_RSSI = CYRF_ReadRegister(CYRF_13_RSSI) & 0x1F;
|
||||||
|
TX_RSSI = (TX_RSSI << 1) + TX_RSSI;
|
||||||
|
RX_RSSI = TX_RSSI;
|
||||||
|
telemetry_link = 1;
|
||||||
|
|
||||||
|
//TODO: FW telemetry https://github.com/DeviationTX/deviation/blob/5efb6a28bea697af9a61b5a0ed2528cc8d203f90/src/protocol/devo_cyrf6936.c#L232
|
||||||
|
|
||||||
|
debug("P[0]=%02X",packet[0]);
|
||||||
|
|
||||||
|
if (packet[0] == 0x30) // Volt packet
|
||||||
|
{
|
||||||
|
v_lipo1 = packet[1] << 1;
|
||||||
|
v_lipo2 = packet[3] << 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void __attribute__((unused)) DEVO_cyrf_set_bound_sop_code()
|
static void __attribute__((unused)) DEVO_cyrf_set_bound_sop_code()
|
||||||
{
|
{
|
||||||
/* crc == 0 isn't allowed, so use 1 if the math results in 0 */
|
/* crc == 0 isn't allowed, so use 1 if the math results in 0 */
|
||||||
@ -270,6 +295,82 @@ static void __attribute__((unused)) DEVO_BuildPacket()
|
|||||||
uint16_t devo_callback()
|
uint16_t devo_callback()
|
||||||
{
|
{
|
||||||
static uint8_t txState=0;
|
static uint8_t txState=0;
|
||||||
|
|
||||||
|
#if defined DEVO_HUB_TELEMETRY
|
||||||
|
int delay;
|
||||||
|
|
||||||
|
if (txState == 0)
|
||||||
|
{
|
||||||
|
#ifdef MULTI_SYNC
|
||||||
|
telemetry_set_input_sync(2400);
|
||||||
|
#endif
|
||||||
|
DEVO_BuildPacket();
|
||||||
|
CYRF_WriteDataPacket(packet);
|
||||||
|
txState = 1;
|
||||||
|
return 900;
|
||||||
|
}
|
||||||
|
if (txState == 1)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
uint8_t reg;
|
||||||
|
while (! ((reg = CYRF_ReadRegister(CYRF_04_TX_IRQ_STATUS)) & 0x02))
|
||||||
|
{
|
||||||
|
if (++i >= DEVO_NUM_WAIT_LOOPS)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (((reg & 0x22) == 0x20) || (CYRF_ReadRegister(CYRF_02_TX_CTRL) & 0x80))
|
||||||
|
{
|
||||||
|
CYRF_Reset();
|
||||||
|
DEVO_cyrf_init();
|
||||||
|
DEVO_cyrf_set_bound_sop_code();
|
||||||
|
CYRF_ConfigRFChannel(*hopping_frequency_ptr);
|
||||||
|
//printf("Rst CYRF\n");
|
||||||
|
delay = 1500;
|
||||||
|
txState = 15;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (phase == DEVO_BOUND)
|
||||||
|
{
|
||||||
|
/* exit binding state */
|
||||||
|
phase = DEVO_BOUND_3;
|
||||||
|
DEVO_cyrf_set_bound_sop_code();
|
||||||
|
}
|
||||||
|
if((packet_count != 0) && (bind_counter == 0))
|
||||||
|
{
|
||||||
|
CYRF_SetTxRxMode(RX_EN); //Receive mode
|
||||||
|
CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x87); //0x80??? //Prepare to receive
|
||||||
|
txState = 2;
|
||||||
|
return 1300;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(packet_count == 0)
|
||||||
|
{
|
||||||
|
CYRF_SetPower(0x08); //Keep tx power updated
|
||||||
|
hopping_frequency_ptr = hopping_frequency_ptr == &hopping_frequency[2] ? hopping_frequency : hopping_frequency_ptr + 1;
|
||||||
|
CYRF_ConfigRFChannel(*hopping_frequency_ptr);
|
||||||
|
}
|
||||||
|
delay = 1500;
|
||||||
|
}
|
||||||
|
if(txState == 2)
|
||||||
|
{
|
||||||
|
uint8_t rx_state = CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS);
|
||||||
|
if((rx_state & 0x03) == 0x02)
|
||||||
|
{ // RXC=1, RXE=0 then 2nd check is required (debouncing)
|
||||||
|
rx_state |= CYRF_ReadRegister(CYRF_07_RX_IRQ_STATUS);
|
||||||
|
}
|
||||||
|
if((rx_state & 0x07) == 0x02)
|
||||||
|
{ // good data (complete with no errors)
|
||||||
|
CYRF_WriteRegister(CYRF_07_RX_IRQ_STATUS, 0x80); // need to set RXOW before data read
|
||||||
|
CYRF_ReadDataPacketLen(packet, CYRF_ReadRegister(CYRF_09_RX_COUNT));
|
||||||
|
DEVO_parse_telemetry_packet();
|
||||||
|
}
|
||||||
|
CYRF_SetTxRxMode(TX_EN); //Write mode
|
||||||
|
delay = 200;
|
||||||
|
}
|
||||||
|
txState = 0;
|
||||||
|
return delay;
|
||||||
|
#else
|
||||||
if (txState == 0)
|
if (txState == 0)
|
||||||
{
|
{
|
||||||
#ifdef MULTI_SYNC
|
#ifdef MULTI_SYNC
|
||||||
@ -298,6 +399,7 @@ uint16_t devo_callback()
|
|||||||
CYRF_ConfigRFChannel(*hopping_frequency_ptr);
|
CYRF_ConfigRFChannel(*hopping_frequency_ptr);
|
||||||
}
|
}
|
||||||
return 1200;
|
return 1200;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t DevoInit()
|
uint16_t DevoInit()
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define VERSION_MAJOR 1
|
#define VERSION_MAJOR 1
|
||||||
#define VERSION_MINOR 3
|
#define VERSION_MINOR 3
|
||||||
#define VERSION_REVISION 0
|
#define VERSION_REVISION 0
|
||||||
#define VERSION_PATCH_LEVEL 95
|
#define VERSION_PATCH_LEVEL 96
|
||||||
|
|
||||||
//******************
|
//******************
|
||||||
// Protocols
|
// Protocols
|
||||||
|
@ -751,7 +751,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_DSM) || (protocol==PROTO_CABELL) || (protocol==PROTO_HITEC) || (protocol==PROTO_HOTT) || (protocol==PROTO_FRSKYX2) || (protocol==PROTO_PROPEL))
|
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_DSM) || (protocol==PROTO_CABELL) || (protocol==PROTO_HITEC) || (protocol==PROTO_HOTT) || (protocol==PROTO_FRSKYX2) || (protocol==PROTO_PROPEL) || (protocol==PROTO_DEVO))
|
||||||
#endif
|
#endif
|
||||||
if(IS_DISABLE_TELEM_off)
|
if(IS_DISABLE_TELEM_off)
|
||||||
TelemetryUpdate();
|
TelemetryUpdate();
|
||||||
|
@ -528,7 +528,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_HUBSAN, PROTO_AFHDS2A, PROTO_BAYANG, PROTO_NCC1701, PROTO_CABELL, PROTO_HITEC, PROTO_BUGS, PROTO_BUGSMINI, PROTO_FRSKYX, PROTO_FRSKYX2, PROTO_PROPEL, PROTO_DEVO
|
||||||
frame[1] = v_lipo1;
|
frame[1] = v_lipo1;
|
||||||
frame[2] = v_lipo2;
|
frame[2] = v_lipo2;
|
||||||
frame[3] = RX_RSSI;
|
frame[3] = RX_RSSI;
|
||||||
|
@ -306,6 +306,7 @@
|
|||||||
#undef HOTT_FW_TELEMETRY
|
#undef HOTT_FW_TELEMETRY
|
||||||
#undef BAYANG_RX_TELEMETRY
|
#undef BAYANG_RX_TELEMETRY
|
||||||
#undef BAYANG_RX_NRF24L01_INO
|
#undef BAYANG_RX_NRF24L01_INO
|
||||||
|
#undef DEVO_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.
|
||||||
@ -329,6 +330,9 @@
|
|||||||
#if not defined(BAYANG_NRF24L01_INO)
|
#if not defined(BAYANG_NRF24L01_INO)
|
||||||
#undef BAYANG_HUB_TELEMETRY
|
#undef BAYANG_HUB_TELEMETRY
|
||||||
#endif
|
#endif
|
||||||
|
#if not defined(DEVO_CYRF6936_INO)
|
||||||
|
#undef DEVO_HUB_TELEMETRY
|
||||||
|
#endif
|
||||||
#if not defined(NCC1701_NRF24L01_INO)
|
#if not defined(NCC1701_NRF24L01_INO)
|
||||||
#undef NCC1701_HUB_TELEMETRY
|
#undef NCC1701_HUB_TELEMETRY
|
||||||
#endif
|
#endif
|
||||||
@ -365,7 +369,7 @@
|
|||||||
#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(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)
|
#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(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)
|
||||||
#undef TELEMETRY
|
#undef TELEMETRY
|
||||||
#undef INVERT_TELEMETRY
|
#undef INVERT_TELEMETRY
|
||||||
#undef MULTI_TELEMETRY
|
#undef MULTI_TELEMETRY
|
||||||
|
@ -299,6 +299,7 @@
|
|||||||
#define HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
#define HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
||||||
#define BAYANG_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
#define BAYANG_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
||||||
#define BUGS_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
#define BUGS_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
||||||
|
#define DEVO_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
||||||
#define HUBSAN_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
#define HUBSAN_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
||||||
#define NCC1701_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
|
#define NCC1701_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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user