MT99XX Dragon telem prep

This commit is contained in:
Pascal Langer 2021-02-17 10:26:38 +01:00
parent 4b36656246
commit ae842f0bdc
2 changed files with 139 additions and 6 deletions

View File

@ -0,0 +1,108 @@
/*
This project is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Multiprotocol is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
*/
#if defined(FAKE_NRF24L01_INO)
#include "iface_nrf250k.h"
static void __attribute__((unused)) FAKE_send_packet()
{
for(uint8_t i=0;i<5;i++)
packet[i]=i;
NRF24L01_WriteReg(NRF24L01_07_STATUS, (_BV(NRF24L01_07_RX_DR) | _BV(NRF24L01_07_TX_DS) | _BV(NRF24L01_07_MAX_RT)));
NRF24L01_FlushTx();
NRF24L01_WritePayload(packet, 5);
}
static void __attribute__((unused)) FAKE_init()
{
// BIND_IN_PROGRESS;
//CC2500
option=1;
XN297L_Init();
CC2500_WriteReg(CC2500_07_PKTCTRL1, 0x01); // Packet Automation Control
CC2500_WriteReg(CC2500_08_PKTCTRL0, 0x00); // Packet Automation Control
CC2500_WriteReg(CC2500_12_MDMCFG2, 0x12); // Modem Configuration
CC2500_WriteReg(CC2500_13_MDMCFG1, 0x13); // Modem Configuration
CC2500_WriteReg(CC2500_04_SYNC1, 0x11);
CC2500_WriteReg(CC2500_05_SYNC0, 0x33);
CC2500_WriteReg(CC2500_09_ADDR, 0x99);
CC2500_WriteReg(CC2500_06_PKTLEN, 10);
CC2500_SetTxRxMode(RX_EN);
CC2500_Strobe(CC2500_SIDLE);
CC2500_Strobe(CC2500_SRX);
//CC2500_SetTxRxMode(TX_EN);
XN297L_RFChannel(0);
//NRF
/* option=0;
PE1_on; //NRF24L01 antenna RF3 by default
PE2_off; //NRF24L01 antenna RF3 by default
NRF24L01_Initialize();
NRF24L01_WriteReg(NRF24L01_00_CONFIG, 0x7f);
NRF24L01_WriteReg(NRF24L01_01_EN_AA, 0x00);//0x3f); // AA on all pipes
NRF24L01_WriteReg(NRF24L01_02_EN_RXADDR, 0x3f); // Enable all pipes
NRF24L01_WriteReg(NRF24L01_03_SETUP_AW, 0x03); // 5-byte address
NRF24L01_WriteReg(NRF24L01_04_SETUP_RETR, 0x36); // retransmit 1ms, 6 times
NRF24L01_SetBitrate(NRF24L01_BR_250K); // 1Mbps
NRF24L01_SetPower();
NRF24L01_WriteRegisterMulti(NRF24L01_0A_RX_ADDR_P0, (uint8_t *)"\x99\x33\x11\xAA\xAA", 5); //Bind address
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, (uint8_t *)"\x99\x33\x11\xAA\xAA", 5); //Bind address
NRF24L01_WriteReg(NRF24L01_05_RF_CH, 0);
NRF24L01_Activate(0x73); // Activate feature register
NRF24L01_WriteReg(NRF24L01_1C_DYNPD, 0x3f); // Enable dynamic payload length
NRF24L01_WriteReg(NRF24L01_1D_FEATURE, 0x07); // Enable all features
*/
/*NRF24L01_FlushTx();
NRF24L01_SetTxRxMode(TX_EN);*/
}
uint16_t FAKE_callback()
{
len = CC2500_ReadReg(CC2500_3B_RXBYTES | CC2500_READ_BURST) & 0x7F;
if(len) debug("L=%d, ",len);
if(len && len < sizeof(packet_in))
{
CC2500_ReadData(packet_in, len);
debug("P:");
for(uint8_t i=0;i<len;i++)
debug(" %02X", packet_in[i]);
}
if(len) debugln("");
CC2500_Strobe(CC2500_SFRX);
CC2500_Strobe(CC2500_SIDLE);
CC2500_Strobe(CC2500_SRX);
option=0;
//FAKE_send_packet();
PE1_off; //antenna RF2
PE2_on;
/*packet[0]=0x99;
for(uint8_t i=1;i<5;i++)
packet[i]=i;
CC2500_WriteData(packet, 5);*/
return 10000;
}
uint16_t initFAKE()
{
FAKE_init();
return 5000;
}
#endif

View File

@ -18,7 +18,7 @@
#if defined(MT99XX_NRF24L01_INO)
#include "iface_nrf24l01.h"
#include "iface_xn297.h"
#include "iface_nrf250k.h"
#define MT99XX_BIND_COUNT 928
#define MT99XX_PACKET_PERIOD_FY805 2460
@ -89,6 +89,10 @@ const uint8_t ls_mys_byte[] = {
const uint8_t yz_p4_seq[] = {0xa0, 0x20, 0x60};
#ifdef DRAGON_HUB_TELEMETRY
const uint8_t DRAGON_seq[] = {0x20, 0x60, 0x20, 0x80};
#endif
static void __attribute__((unused)) MT99XX_send_packet()
{
static uint8_t seq_num=0;
@ -185,9 +189,30 @@ static void __attribute__((unused)) MT99XX_send_packet()
packet[5] |= 0x40;
packet[6] = FLAG_DRAGON_RATE
| GET_FLAG( CH6_SW, FLAG_DRAGON_RTH );
//packet[6] |= 0x04; // On the 1st rf channel, 1x4, 11x0, 2x4, 11x0, 2x4, 10x0, 2x4, 11x0, 2x4, 11x0, 2x4, 10x0, 2x4, 11x0, 2x4, 11x0 and restart... Not sure what's on the other channels
packet[7] = 0x20; // On the 1st rf channel, seq: 20 80 20 60 20 80 20 60... Not sure what's on the other channels
break;
#ifdef DRAGON_HUB_TELEMETRY
//Telemetry
// C=48 S=Y A= 6C 00 22 CC CC P(9)= 6C 00 22 27 00 00 00 00 60
// C=48 S=Y A= 6C 00 22 CC CC P(9)= 6C 00 22 28 00 00 00 00 61
// C=18 S=Y A= 6C 00 22 CC CC P(9)= 6C 00 22 24 00 00 00 00 5D
// 6C 00 22 = TX address, 27/28/24=vbatt, check = sum(P[0..7]) + AB, where AB comes from? Is it constant?
if(hopping_frequency_no == 0)
{
seq_num++;
seq_num &= 0x03;
packet_count++;
if(packet_count > 11)
packet_count = 0;
}
if(packet_count > 10) // Telemetry packet request every 10 or 11 packets
packet[6] |= 0x04; // Request telemetry flag
packet[7] = DRAGON_seq[seq_num]; // seq: 20 80 20 60 20 80 20 60... 80 changes to 80+batt from telem
if(seq_num==3)
packet[7] |= v_lipo1;
break;
#else
packet[7] = 0x20;
#endif
}
uint8_t result=crc8;
for(uint8_t i=0; i<8; i++)
@ -296,8 +321,8 @@ static void __attribute__((unused)) MT99XX_initialize_txid()
rx_tx_addr[0] = 0x6C; // Laurie ID
rx_tx_addr[1] = 0x00;
rx_tx_addr[2] = 0x22;
//crc8 = 0x
//channel_offset = 0x
//crc8 = 0x8E
//channel_offset = 0x06
break;
#endif
default: //MT99 & H7 & A180 & DRAGON