Initial M-LINK release

This commit is contained in:
Pascal Langer 2021-02-05 12:28:35 +01:00
parent 447a58966f
commit 89c00e8f17
5 changed files with 96 additions and 82 deletions

View File

@ -17,9 +17,7 @@
#include "iface_cyrf6936.h"
#undef MLINK_HUB_TELEMETRY
#define MLINK_FORCE_ID
//#define MLINK_FORCE_ID
#define MLINK_BIND_COUNT 696 // around 20s
#define MLINK_NUM_FREQ 78
#define MLINK_BIND_CHANNEL 0x01
@ -31,13 +29,13 @@ enum {
MLINK_BIND_RX,
MLINK_PREP_DATA,
MLINK_SEND1,
MLINK_CHECK1,
MLINK_BUILD1,
MLINK_SEND2,
MLINK_CHECK2,
MLINK_BUILD2,
MLINK_SEND3,
MLINK_CHECK3,
MLINK_BUILD3,
MLINK_RX,
MLINK_CHECK4,
MLINK_BUILD4,
};
uint8_t MLINK_Data_Code[16], MLINK_CRC_Init, MLINK_Unk_6_2;
@ -80,7 +78,7 @@ static void __attribute__((unused)) MLINK_cyrf_config()
CYRF_SetTxRxMode(TX_EN);
}
static void __attribute__((unused)) MLINK_send_bind_data_packet()
static void __attribute__((unused)) MLINK_send_bind_packet()
{
uint8_t p_c=packet_count>>1;
@ -146,7 +144,7 @@ static void __attribute__((unused)) MLINK_send_bind_data_packet()
packet[7] = bit_reverse(crc8); // CRC reflected out
//Debug
#if 1
#if 0
debug("P(%02d):",p_c);
for(uint8_t i=0;i<8;i++)
debug(" %02X",packet[i]);
@ -218,19 +216,27 @@ static void __attribute__((unused)) MLINK_build_data_packet()
#ifdef MLINK_HUB_TELEMETRY
static void __attribute__((unused)) MLINK_Send_Telemetry()
{
if(packet[0]==0x03)
{//Basic telemetry
{ // not sure how MLINK telemetry works, the 2 RXs I have are sending something completly different...
RX_RSSI = TX_LQI;
if(packet_in[0]==0x13)
{ // RX-9-DR : 13 1A C8 00 01 64 00
v_lipo1 = packet_in[5*2]; // Rx_Batt*20
}
if(packet_in[0]==0x03)
{ // RX-5 : 03 15 23 00 00 01 02
//Incoming packet values
RX_RSSI = packet_in[2*2]; // Looks to be the RX RSSI value
RX_RSSI = packet_in[2*2]<<1; // Looks to be the RX RSSI value
RX_LQI = packet_in[5*2]; // Looks to be connection lost
}
// Read TX RSSI
TX_RSSI = CYRF_ReadRegister(CYRF_13_RSSI)&0x1F;
telemetry_counter++; // TX LQI counter
telemetry_counter++; // TX LQI counter
telemetry_link = 1;
if(telemetry_lost)
{
telemetry_lost = 0;
@ -243,9 +249,7 @@ static void __attribute__((unused)) MLINK_build_data_packet()
uint16_t ReadMLINK()
{
uint8_t status;//,len,sum=0,check=0;
uint8_t start;
//uint16_t sum=0;
//static uint8_t retry;
uint16_t start;
switch(phase)
{
@ -300,7 +304,7 @@ uint16_t ReadMLINK()
phase=MLINK_PREP_DATA;
return 22720;
}
MLINK_send_bind_data_packet();
MLINK_send_bind_packet();
if(packet_count == 0 || packet_count > 0x19*2)
{
phase++; // MLINK_BIND_PREP_RX
@ -312,12 +316,14 @@ uint16_t ReadMLINK()
return 22720;
case MLINK_BIND_PREP_RX:
start=micros();
while ((uint8_t)((uint8_t)micros()-(uint8_t)start) < 200) // Wait max 200µs for TX to finish
while ((uint16_t)((uint16_t)micros()-(uint16_t)start) < 200) // Wait max 200µs for TX to finish
if((CYRF_ReadRegister(CYRF_02_TX_CTRL) & 0x80) == 0x00)
break; // Packet transmission complete
CYRF_SetTxRxMode(RX_EN); // Receive mode
CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x82); // Prepare to receive
phase++; //MLINK_BIND_RX
if(packet_count > 0x19*2)
return 28712; // Give more time to the RX to confirm that the bind is ok...
return 28712-4700;
@ -332,56 +338,39 @@ uint16_t ReadMLINK()
telemetry_lost = 1;
#endif
phase++;
case MLINK_SEND1:
MLINK_build_data_packet();
case MLINK_SEND1:
CYRF_WriteRegister(CYRF_02_TX_CTRL, 0x40);
CYRF_WriteRegisterMulti(CYRF_20_TX_BUFFER, packet, MLINK_PACKET_SIZE);
CYRF_WriteRegister(CYRF_02_TX_CTRL, 0x82);
phase++;
return 4880;
case MLINK_CHECK1:
status=CYRF_ReadRegister(CYRF_04_TX_IRQ_STATUS);
//debugln("C1:%02X",status);
CYRF_WriteRegister(CYRF_02_TX_CTRL, 0x00);
case MLINK_BUILD1:
phase++;
MLINK_build_data_packet();
return 1111;
case MLINK_SEND2:
MLINK_build_data_packet();
CYRF_WriteRegister(CYRF_02_TX_CTRL, 0x40);
CYRF_WriteRegisterMulti(CYRF_20_TX_BUFFER, packet, MLINK_PACKET_SIZE);
CYRF_WriteRegister(CYRF_02_TX_CTRL, 0x82);
phase++;
return 4617;
case MLINK_CHECK2:
status=CYRF_ReadRegister(CYRF_04_TX_IRQ_STATUS);
//debugln("C2:%02X",status);
CYRF_WriteRegister(CYRF_02_TX_CTRL, 0x00);
case MLINK_BUILD2:
phase++;
MLINK_build_data_packet();
if(hopping_frequency_no%5==0)
return 1017;
return 1422;
case MLINK_SEND3:
MLINK_build_data_packet();
CYRF_WriteRegister(CYRF_02_TX_CTRL, 0x40);
CYRF_WriteRegisterMulti(CYRF_20_TX_BUFFER, packet, MLINK_PACKET_SIZE);
CYRF_WriteRegister(CYRF_02_TX_CTRL, 0x82);
phase++;
return 4611;
case MLINK_CHECK3:
status=CYRF_ReadRegister(CYRF_04_TX_IRQ_STATUS);
//debugln("C3:%02X",status);
CYRF_WriteRegister(CYRF_02_TX_CTRL, 0x00);
//check RX but there is nothing to check...
status=CYRF_ReadRegister(CYRF_05_RX_CTRL);
//debugln("CTRL:%02X",status);
len=CYRF_ReadRegister(CYRF_09_RX_COUNT);
//debugln("L=%02X",len)
if( len && len<=8 )
CYRF_ReadDataPacketLen(packet, len*2);
CYRF_WriteRegister(CYRF_05_RX_CTRL,0x00);
//Next channel
case MLINK_BUILD3:
//Switch to next channel
hopping_frequency_no++;
if(hopping_frequency_no>=MLINK_NUM_FREQ)
hopping_frequency_no=0;
@ -393,11 +382,12 @@ uint16_t ReadMLINK()
CYRF_SetTxRxMode(RX_EN); // Receive mode
CYRF_WriteRegister(CYRF_05_RX_CTRL, 0x82); // Prepare to receive
phase++; //MLINK_RX
return 8038;
return 8038+2434+410-1000;
}
else
CYRF_SetPower(0x38);
phase=MLINK_SEND1;
MLINK_build_data_packet();
return 4470;
case MLINK_RX:
#ifdef MLINK_HUB_TELEMETRY
@ -414,27 +404,28 @@ uint16_t ReadMLINK()
#endif
status=CYRF_ReadRegister(CYRF_05_RX_CTRL);//CYRF_07_RX_IRQ_STATUS);
debug("T(%02X):",status);
//status=CYRF_ReadRegister(CYRF_05_RX_CTRL);
//if( (status&0x80) == 0 )
if( (status&0x80) == 0 )
{//Packet received
len=CYRF_ReadRegister(CYRF_09_RX_COUNT);
debug("(%X)",len)
if( len && len<=8 )
if( len && len <= MLINK_PACKET_SIZE )
{
CYRF_ReadDataPacketLen(packet_in, len*2);
#ifdef MLINK_HUB_TELEMETRY
if(len==8)
if(len==MLINK_PACKET_SIZE)
{
for(uint8_t i=0;i<8;i++)
//Check CRC
crc8=bit_reverse(MLINK_CRC_Init);
for(uint8_t i=0;i<MLINK_PACKET_SIZE-1;i++)
crc8_update(bit_reverse(packet[i<<1]));
if(packet_in[14] == bit_reverse(crc8)) // Packet CRC is ok
{
MLINK_Send_Telemetry();
for(uint8_t i=0;i<8;i++)
debug(" %02X",packet_in[i*2]);
crc8_update(bit_reverse(packet_in[i<<1]));
debug(" %02X",packet_in[i<<1]);
}
if(packet_in[14] == bit_reverse(crc8)) // Packet CRC is ok
MLINK_Send_Telemetry();
else
debug(" NOK");
}
#endif
}
@ -444,18 +435,9 @@ uint16_t ReadMLINK()
CYRF_WriteRegister(CYRF_0F_XACT_CFG, 0x24); // Force end state
CYRF_WriteRegister(CYRF_29_RX_ABORT, 0x00); // Disable RX abort
CYRF_SetTxRxMode(TX_EN); // Transmit mode
phase++;
return 2434;
case MLINK_CHECK4:
status=CYRF_ReadRegister(CYRF_05_RX_CTRL);
debugln("C4: CTRL:%02X",status);
len=CYRF_ReadRegister(CYRF_09_RX_COUNT);
debugln("L=%02X",len)
if( len && len<=8 )
CYRF_ReadDataPacketLen(packet, len*2);
CYRF_WriteRegister(CYRF_05_RX_CTRL,0x00);
phase=MLINK_SEND2;
return 410;
MLINK_build_data_packet();
return 1000;
}
return 1000;
}
@ -464,19 +446,34 @@ uint16_t initMLINK()
{
MLINK_cyrf_config();
//Init ID and RF freqs
memcpy(MLINK_Data_Code ,rx_tx_addr,4);
calc_fh_channels(MLINK_NUM_FREQ/2);
memcpy(&hopping_frequency[MLINK_NUM_FREQ/2],hopping_frequency,MLINK_NUM_FREQ/2);
MProtocol_id ^= 0x6FBE3201;
set_rx_tx_addr(MProtocol_id);
memcpy(MLINK_Data_Code+4,rx_tx_addr,4);
calc_fh_channels(MLINK_NUM_FREQ/2);
MLINK_CRC_Init = rx_tx_addr[3]; //value sent during bind then used to init the CRC
MLINK_Unk_6_2 = 0x3A; //unknown value sent during bind but doesn't seem to matter
#ifdef MLINK_FORCE_ID
//Cockpit SX
memcpy(MLINK_Data_Code,"\x4C\x97\x9D\xBF\xB8\x3D\xB5\xBE",8);
memcpy(hopping_frequency,"\x0D\x41\x09\x43\x17\x2D\x05\x31\x13\x3B\x1B\x3D\x0B\x41\x11\x45\x09\x2B\x17\x4D\x19\x3F\x03\x3F\x0F\x37\x1F\x47\x1B\x49\x07\x35\x27\x2F\x15\x33\x23\x39\x1F\x33\x19\x45\x0D\x2D\x11\x35\x0B\x47\x25\x3D\x21\x37\x1D\x3B\x05\x2F\x21\x39\x23\x4B\x03\x31\x25\x29\x07\x4F\x1D\x4B\x15\x4D\x13\x4F\x0F\x49\x29\x2B\x27\x43",78);
MLINK_Unk_6_2 = 0x3A; //unknown value sent during bind but doesn't seem to matter
MLINK_CRC_Init = 0x07; //value sent during bind then used to init the CRC
//HFM3
memcpy(MLINK_Data_Code,"\xC0\x90\x8F\xBB\x7C\x8E\x2B\x8E",8);
memcpy(hopping_frequency,"\x05\x41\x27\x4B\x17\x33\x11\x39\x0F\x3F\x05\x2F\x13\x2D\x25\x31\x1F\x2D\x25\x35\x03\x41\x1B\x43\x09\x3D\x1F\x29\x1D\x35\x0D\x3B\x19\x49\x23\x3B\x17\x47\x1D\x2B\x13\x37\x0B\x31\x23\x33\x29\x3F\x07\x37\x07\x43\x11\x2B\x1B\x39\x0B\x4B\x03\x4F\x21\x47\x0F\x4D\x15\x45\x21\x4F\x09\x3D\x19\x2F\x15\x45\x0D\x49\x27\x4D",78);
MLINK_Unk_6_2 = 0x02; //unknown value but doesn't seem to matter
MLINK_CRC_Init = 0x3E; //value sent during bind then used to init the CRC
if(RX_num)
{
//Cockpit SX
memcpy(MLINK_Data_Code,"\x4C\x97\x9D\xBF\xB8\x3D\xB5\xBE",8);
memcpy(hopping_frequency,"\x0D\x41\x09\x43\x17\x2D\x05\x31\x13\x3B\x1B\x3D\x0B\x41\x11\x45\x09\x2B\x17\x4D\x19\x3F\x03\x3F\x0F\x37\x1F\x47\x1B\x49\x07\x35\x27\x2F\x15\x33\x23\x39\x1F\x33\x19\x45\x0D\x2D\x11\x35\x0B\x47\x25\x3D\x21\x37\x1D\x3B\x05\x2F\x21\x39\x23\x4B\x03\x31\x25\x29\x07\x4F\x1D\x4B\x15\x4D\x13\x4F\x0F\x49\x29\x2B\x27\x43",MLINK_NUM_FREQ);
MLINK_Unk_6_2 = 0x3A; //unknown value sent during bind but doesn't seem to matter
MLINK_CRC_Init = 0x07; //value sent during bind then used to init the CRC
}
else
{
//HFM3
memcpy(MLINK_Data_Code,"\xC0\x90\x8F\xBB\x7C\x8E\x2B\x8E",8);
memcpy(hopping_frequency,"\x05\x41\x27\x4B\x17\x33\x11\x39\x0F\x3F\x05\x2F\x13\x2D\x25\x31\x1F\x2D\x25\x35\x03\x41\x1B\x43\x09\x3D\x1F\x29\x1D\x35\x0D\x3B\x19\x49\x23\x3B\x17\x47\x1D\x2B\x13\x37\x0B\x31\x23\x33\x29\x3F\x07\x37\x07\x43\x11\x2B\x1B\x39\x0B\x4B\x03\x4F\x21\x47\x0F\x4D\x15\x45\x21\x4F\x09\x3D\x19\x2F\x15\x45\x0D\x49\x27\x4D",MLINK_NUM_FREQ);
MLINK_Unk_6_2 = 0x02; //unknown value but doesn't seem to matter
MLINK_CRC_Init = 0x3E; //value sent during bind then used to init the CRC
}
//Other TX
//MLINK_Unk_6_2 = 0x7e; //unknown value but doesn't seem to matter
//MLINK_CRC_Init = 0xA2; //value sent during bind then used to init the CRC

View File

@ -19,7 +19,7 @@
#define VERSION_MAJOR 1
#define VERSION_MINOR 3
#define VERSION_REVISION 2
#define VERSION_PATCH_LEVEL 27
#define VERSION_PATCH_LEVEL 28
//******************
// Protocols

View File

@ -428,6 +428,9 @@
#if not defined(DSM_CYRF6936_INO)
#undef DSM_TELEMETRY
#endif
#if not defined(MLINK_CYRF6936_INO)
#undef MLINK_HUB_TELEMETRY
#endif
#if not defined(HOTT_CC2500_INO)
#undef HOTT_FW_TELEMETRY
#endif
@ -437,7 +440,7 @@
#if not defined(LOLI_NRF24L01_INO)
#undef LOLI_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(WFLY2_HUB_TELEMETRY) && not defined(LOLI_HUB_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(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(WFLY2_HUB_TELEMETRY) && not defined(LOLI_HUB_TELEMETRY) && not defined(MLINK_HUB_TELEMETRY)
#undef TELEMETRY
#undef INVERT_TELEMETRY
#undef MULTI_TELEMETRY

View File

@ -184,6 +184,7 @@
#define E010R5_CYRF6936_INO
#define E129_CYRF6936_INO
#define J6PRO_CYRF6936_INO
#define MLINK_CYRF6936_INO
#define TRAXXAS_CYRF6936_INO
#define WFLY_CYRF6936_INO
#define WK2x01_CYRF6936_INO
@ -330,6 +331,7 @@
#define RLINK_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
#define WFLY2_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
#define LOLI_HUB_TELEMETRY // Use FrSkyD Hub format to send telemetry to TX
#define MLINK_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_FW_TELEMETRY // Forward received telemetry packets to be decoded by erskyTX and OpenTX
#define SCANNER_TELEMETRY // Forward spectrum scanner data to TX

View File

@ -113,6 +113,7 @@ CFlie|38|CFlie||||||||NRF24L01|
[Kyosho](Protocols_Details.md#Kyosho---73)|73|FHSS|Hype|||||||A7105|
[LOLI](Protocols_Details.md#LOLI---82)|82|||||||||NRF24L01|
[MJXq](Protocols_Details.md#MJXQ---18)|18|WLH08|X600|X800|H26D|E010*|H26WH|PHOENIX*||NRF24L01|XN297
[MLINK](Protocols_Details.md#MLINK---78)|78|Slow||||||||CYRF6936|
[MT99xx](Protocols_Details.md#MT99XX---17)|17|MT|H7|YZ|LS|FY805||||NRF24L01|XN297
[NCC1701](Protocols_Details.md#NCC1701---44)|44|NCC1701||||||||NRF24L01|
[OMP](Protocols_Details.md#OMP---77)|77|||||||||CC2500&NRF24L01|XN297L
@ -862,6 +863,17 @@ CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12
---|---|---|---|---|---|---|---|---|----|----|----
A|E|T|R|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12
## MLINK - *78*
Extended limits supported
Telemetry: the 2 RXs I have are sending different information in different format, I've done something which might work or not so please report
### Sub_protocol Slow - *0*
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12||CH13|CH14|CH15|CH16
## Traxxas - *43*
Receiver 6519
@ -910,7 +922,7 @@ Models: Eachine H8(C) mini, BayangToys X6/X7/X9, JJRC JJ850, Floureon H101 ...
Option=0 -> normal Bayang protocol
Option=1 -> enable telemetry with [Silverxxx firmware](https://github.com/silver13/H101-acro/tree/master). Value returned to the TX using FrSkyD Hub are RX RSSI, TX RSSI, A1=uncompensated battery voltage (set the ratio to 5.0 and adjust with offset), A2=compensated battery voltage (set the ratio to 5.0 and adjust with offset) and if supported AccX=P, AccY=I, ACCZ=D
Option=1 -> enable telemetry with [Silverxxx firmware](https://github.com/silver13/H101-acro/tree/master). Value returned to the TX using FrSkyD Hub are RX RSSI, TX RSSI, A1=uncompensated battery voltage (set the ratio to 5.0 and adjust with offset), A2=compensated battery voltage (set the ratio to 5.0 and adjust with offset) and if supported AccX=P, AccY=I, ACCZ=D (which you can rename after the sensors discovery)
Option=2 -> enable analog aux channels with [NFE Silverware firmware](https://github.com/NotFastEnuf/NFE_Silverware). Two otherwise static bytes in the protocol overridden to add two 'analog' (non-binary) auxiliary channels.