New protocol ZSX

Model JJRC ZSX-280
Protocol number 52 ,no sub protocol
CH3: Throttle
CH4: Rudder
CH5: Light
This commit is contained in:
Pascal Langer 2019-08-10 21:43:14 +02:00
parent 6f33abb25e
commit ad29409407
7 changed files with 144 additions and 4 deletions

View File

@ -40,7 +40,7 @@
40,WFLY
41,BUGS
42,BUGSMINI,BUGSMINI,BUGS3H
43,Traxxas
43,Traxxas,RX6519
44,NCC1701
45,E01X,E012,E015,E016H
46,V911S
@ -49,4 +49,5 @@
49,KF606
50,REDPINE,FAST,SLOW
51,POTENSIC,A20
52,ZSX,280
63,XN_DUMP,250K,1M,2M

View File

@ -19,7 +19,7 @@
#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_REVISION 1
#define VERSION_PATCH_LEVEL 69
#define VERSION_PATCH_LEVEL 70
//******************
// Protocols
@ -78,6 +78,7 @@ enum PROTOCOLS
PROTO_KF606 = 49, // =>NRF24L01
PROTO_REDPINE = 50, // =>CC2500
PROTO_POTENSIC = 51, // =>NRF24L01
PROTO_ZSX = 52, // =>NRF24L01
PROTO_XN297DUMP = 63, // =>NRF24L01
};
@ -628,6 +629,7 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
KF606 49
REDPINE 50
POTENSIC 51
ZSX 52
BindBit=> 0x80 1=Bind/0=No
AutoBindBit=> 0x40 1=Yes /0=No
RangeCheck=> 0x20 1=Yes /0=No

View File

@ -1261,6 +1261,12 @@ static void protocol_init()
remote_callback = POTENSIC_callback;
break;
#endif
#if defined(ZSX_NRF24L01_INO)
case PROTO_ZSX:
next_callback=initZSX();
remote_callback = ZSX_callback;
break;
#endif
#if defined(XN297DUMP_NRF24L01_INO)
case PROTO_XN297DUMP:
next_callback=initXN297Dump();

View File

@ -201,6 +201,7 @@
#undef V911S_NRF24L01_INO
#undef XN297L_CC2500_EMU
#undef POTENSIC_NRF24L01_INO
#undef ZSX_NRF24L01_INO
#endif
//Make sure telemetry is selected correctly

View File

@ -0,0 +1,117 @@
/*
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/>.
*/
// Compatible with JJRC ZSX-280 plane.
#if defined(ZSX_NRF24L01_INO)
#include "iface_xn297l.h"
//#define FORCE_ZSX_ORIGINAL_ID
#define ZSX_INITIAL_WAIT 500
#define ZSX_PACKET_PERIOD 10093
#define ZSX_RF_BIND_CHANNEL 7
#define ZSX_PAYLOAD_SIZE 6
#define ZSX_BIND_COUNT 50
#define ZSX_RF_NUM_CHANNELS 1
static void __attribute__((unused)) ZSX_send_packet()
{
memcpy(&packet[1],rx_tx_addr,3);
if(IS_BIND_IN_PROGRESS)
{
packet[0] = 0xAA;
packet[4] = 0x00;
packet[5] = 0x00;
}
else
{
packet[0]= 0x55;
packet[4]= 0xFF-convert_channel_8b(RUDDER); // FF..80..01
packet[5]= convert_channel_8b(THROTTLE)>>1 // 0..7F
| GET_FLAG(CH5_SW, 0x80); // Light
}
XN297_Configure(_BV(NRF24L01_00_EN_CRC) | _BV(NRF24L01_00_CRCO) | _BV(NRF24L01_00_PWR_UP));
NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70);
NRF24L01_FlushTx();
XN297_WritePayload(packet, ZSX_PAYLOAD_SIZE);
NRF24L01_SetPower(); // Set tx_power
}
static void __attribute__((unused)) ZSX_initialize_txid()
{
rx_tx_addr[0]=rx_tx_addr[3]; // Use RX_num;
#ifdef FORCE_ZSX_ORIGINAL_ID
//TX1
rx_tx_addr[0]=0x03;
rx_tx_addr[1]=0x01;
rx_tx_addr[2]=0xC3;
#endif
}
static void __attribute__((unused)) ZSX_init()
{
NRF24L01_Initialize();
NRF24L01_SetTxRxMode(TX_EN);
NRF24L01_FlushTx();
NRF24L01_FlushRx();
NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70); // Clear data ready, data sent, and retransmit
NRF24L01_WriteReg(NRF24L01_01_EN_AA, 0x00); // No Auto Acknowldgement on all data pipes
NRF24L01_WriteReg(NRF24L01_02_EN_RXADDR, 0x01); // Enable data pipe 0 only
NRF24L01_SetBitrate(NRF24L01_BR_1M); // 1Mbps
NRF24L01_SetPower();
XN297_SetTXAddr((uint8_t*)"\xc1\xc2\xc3", 3);
NRF24L01_WriteReg(NRF24L01_05_RF_CH, ZSX_RF_BIND_CHANNEL); // Set bind channel
}
uint16_t ZSX_callback()
{
if(IS_BIND_IN_PROGRESS)
if(--bind_counter==0)
{
BIND_DONE;
XN297_SetTXAddr(rx_tx_addr, 3);
NRF24L01_WriteReg(NRF24L01_05_RF_CH, 0x00);
}
ZSX_send_packet();
return ZSX_PACKET_PERIOD;
}
uint16_t initZSX()
{
BIND_IN_PROGRESS; // autobind protocol
ZSX_initialize_txid();
ZSX_init();
bind_counter=ZSX_BIND_COUNT;
return ZSX_INITIAL_WAIT;
}
#endif
// XN297 spped 1Mb, scrambled
// Bind
// channel 7
// address: C1 C2 C3
// P(6)= AA 03 01 C3 00 00
// 03 01 C3 <- normal address
// Normal
// channel 0 and seems to be fixed
// address: 03 01 C3
// P(6)= 55 03 01 C3 80 00
// 03 01 C3 <- normal address
// 80 <- rudder FF..80..01
// 00 <- throttle 00..7F, light flag 0x80

View File

@ -209,6 +209,7 @@
#define V761_NRF24L01_INO
#define V911S_NRF24L01_INO
#define YD717_NRF24L01_INO
#define ZSX_NRF24L01_INO
/***************************/
@ -272,11 +273,11 @@
//Comment if you don't want to send Multi status telemetry frames (Protocol available, Bind in progress, version...)
//Use with er9x/erksy9x, for OpenTX MULTI_TELEMETRY below is preferred instead
#define MULTI_STATUS
//#define MULTI_STATUS
//Uncomment to send Multi status and allow OpenTX to autodetect the telemetry format
//Supported by OpenTX version 2.2 RC9 and newer. NOT supported by er9x/ersky9x use MULTI_STATUS instead.
//#define MULTI_TELEMETRY
#define MULTI_TELEMETRY
//Comment a line to disable a specific protocol telemetry
#define DSM_TELEMETRY // Forward received telemetry packet directly to TX to be decoded by er9x, ersky9x and OpenTX
@ -643,4 +644,6 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= {
SYMAX4
XINXUN
NIHUI
PROTO_ZSX
NONE
*/

View File

@ -118,6 +118,7 @@ CFlie|38|CFlie||||||||NRF24L01
[WFly](Protocols_Details.md#WFLY---40)|40|WFLY||||||||CYRF6936
[WK2x01](Protocols_Details.md#WK2X01---30)|30|WK2801|WK2401|W6_5_1|W6_6_1|W6_HEL|W6_HEL_I|||CYRF6936
[YD717](Protocols_Details.md#YD717---8)|8|YD717|SKYWLKR|SYMAX4|XINXUN|NIHUI||||NRF24L01
[ZSX](Protocols_Details.md#ZSX---52)|52|280||||||||NRF24L01
* "*" Sub Protocols designated by * suffix will use the NRF24L01 module by default to emulate the XN297L RF chip.
* If a CC2500 module is installed it will be used instead as it is proving to be a better option for the XN297L@250kbps. Each specific sub protocol has a more detailed explanation.
@ -1193,6 +1194,15 @@ A|E|T|R|FLIP|LIGHT|PICTURE|VIDEO|HEADLESS
### Sub_protocol NIHUI - *4*
Same channels assignement as above.
## ZSX - *52*
Model: JJRC ZSX-280
Autobind protocol
CH1|CH2|CH3|CH4|CH5
---|---|---|---|---
||T|R|LIGHT
# OpenLRS module
## OpenLRS - *27*