Skip to content

Commit

Permalink
New protocol Kyosho3/ASF
Browse files Browse the repository at this point in the history
Only 1 ID and 1 frequency for now
  • Loading branch information
pascallanger committed Mar 22, 2024
1 parent f117105 commit debc9de
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 1 deletion.
1 change: 1 addition & 0 deletions Lua_scripts/MultiChan.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,4 @@
96,0,BumbleB
97,0,SGF22,Std,1,Mode,Flip,LED,Pict,Video
61,1,EazyRC
98,0,Kyosho3,ASF,0
122 changes: 122 additions & 0 deletions Multiprotocol/Kyosho3_cyrf6936.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
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(KYOSHO3_CYRF6936_INO)

#include "iface_cyrf6936.h"

#define KYOSHO3_FORCE_ID
//#define KYOSHO3_DEBUG

#define KYOSHO3_BIND_PACKET_SIZE 4
#define KYOSHO3_PACKET_SIZE 9

const uint8_t PROGMEM KYOSHO3_init_vals[][2] = {
//Init from dump
{CYRF_0B_PWR_CTRL, 0x00}, // PMU
{CYRF_32_AUTO_CAL_TIME, 0x3C}, // Default init value
{CYRF_35_AUTOCAL_OFFSET, 0x14}, // Default init value
{CYRF_03_TX_CFG, 0x28 | CYRF_BIND_POWER}, // 8DR Mode, 64 chip codes
{CYRF_10_FRAMING_CFG, 0xA4}, // SOP and LEN enable
{CYRF_1F_TX_OVERRIDE, 0x05}, // Disable CRC, Data invert
{CYRF_1E_RX_OVERRIDE, 0x04}, // CRC check disabled
//{CYRF_11_DATA32_THOLD, 0x04}, // ???Using 64 chip...
{CYRF_12_DATA64_THOLD, 0x0E}, // Default
{CYRF_06_RX_CFG, 0x52}, // AGC disabled, LNA enabled, override enabled
};

static uint16_t __attribute__((unused)) KYOSHO3_send_packet()
{
CYRF_SetPower(0x28);
if(IS_BIND_IN_PROGRESS)
{
packet[0] = 0xAA;
//ID
memcpy(&packet[1],&rx_tx_addr[1],3);
CYRF_WriteDataPacketLen(packet, KYOSHO3_BIND_PACKET_SIZE);
#ifdef KYOSHO3_DEBUG
debug("P:");
for(uint8_t i=0;i<KYOSHO3_BIND_PACKET_SIZE;i++)
debug(" %02X",packet[i]);
debugln("");
#endif
return 2434;
}
else
{
//ID
memcpy(packet,&rx_tx_addr[1],3);
//Channels
for(uint8_t i=0;i<4;i++)
{
packet[3] >>= 2;
packet[3] |= Channel_data[i]<<6;
packet[4+i] = Channel_data[i]>>3;
}
//Checksum
packet[8] = packet[3];
for(uint8_t i=4;i<8;i++)
packet[8] += packet[i];
//Timing
phase ^= 0x01;
CYRF_WriteDataPacketLen(packet, KYOSHO3_PACKET_SIZE);
#ifdef KYOSHO3_DEBUG
debug("P:");
for(uint8_t i=0;i<KYOSHO3_PACKET_SIZE;i++)
debug(" %02X",packet[i]);
debugln("");
#endif
if(phase)
return 9047;
}
return 6957;
}

uint16_t KYOSHO3_callback()
{
if(IS_BIND_IN_PROGRESS)
{
if(--bind_counter==0)
BIND_DONE;
}
return KYOSHO3_send_packet();
}

void KYOSHO3_init()
{
//Config CYRF registers
for(uint8_t i = 0; i < sizeof(KYOSHO3_init_vals) / 2; i++)
CYRF_WriteRegister(pgm_read_byte_near(&KYOSHO3_init_vals[i][0]), pgm_read_byte_near(&KYOSHO3_init_vals[i][1]));
CYRF_WritePreamble(0x333304);

//Find a free even channel
CYRF_FindBestChannels(hopping_frequency,1,1,0x04,0x50);

#ifdef KYOSHO3_FORCE_ID // data taken from TX dump
rx_tx_addr[1]=0x01;
rx_tx_addr[2]=0xAB;
rx_tx_addr[3]=0x31;
hopping_frequency[0] = 0x04;
#endif
#ifdef KYOSHO3_DEBUG
debugln("ID: %02X %02X %02X",rx_tx_addr[1],rx_tx_addr[2],rx_tx_addr[3]);
debugln("RF CH: %02X",hopping_frequency[0]);
#endif

bind_counter=100;
phase=0;
}

#endif
1 change: 1 addition & 0 deletions Multiprotocol/Multi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,4 @@
95,BlueFly
96,BumbleB
97,SGF22
98,Kyosho3
5 changes: 5 additions & 0 deletions Multiprotocol/Multi_Protos.ino
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const char STR_BLUEFLY[] ="BlueFly";
const char STR_BUMBLEB[] ="BumbleB";
const char STR_SGF22[] ="SGF22";
const char STR_EAZYRC[] ="EazyRC";
const char STR_KYOSHO3[] ="Kyosho3";

const char STR_SUBTYPE_FLYSKY[] = "\x04""Std\0""V9x9""V6x6""V912""CX20";
const char STR_SUBTYPE_HUBSAN[] = "\x04""H107""H301""H501";
Expand Down Expand Up @@ -171,6 +172,7 @@ const char STR_SUBTYPE_V761[] = "\x05""3ch\0 ""4ch\0 ""TOPRC";
const char STR_SUBTYPE_RLINK[] = "\x07""Surface""Air\0 ""DumboRC""RC4G\0 ";
const char STR_SUBTYPE_KYOSHO[] = "\x04""FHSS""Hype";
const char STR_SUBTYPE_KYOSHO2[] = "\x05""KT-17";
const char STR_SUBTYPE_KYOSHO3[] = "\x03""ASF";
const char STR_SUBTYPE_FUTABA[] = "\x05""SFHSS";
const char STR_SUBTYPE_JJRC345[] = "\x08""JJRC345\0""SkyTmblr";
const char STR_SUBTYPE_MOULDKG[] = "\x06""Analog""Digit\0";
Expand Down Expand Up @@ -387,6 +389,9 @@ const mm_protocol_definition multi_protocols[] = {
#if defined(KYOSHO2_NRF24L01_INO)
{PROTO_KYOSHO2, STR_KYOSHO2, STR_SUBTYPE_KYOSHO2, 1, OPTION_NONE, 0, 0, SW_NRF, KYOSHO2_init, KYOSHO2_callback },
#endif
#if defined(KYOSHO3_CYRF6936_INO)
{PROTO_KYOSHO3, STR_KYOSHO3, STR_SUBTYPE_KYOSHO3, 1, OPTION_NONE, 0, 0, SW_CYRF, KYOSHO3_init, KYOSHO3_callback },
#endif
#if defined(LOLI_NRF24L01_INO)
{PROTO_LOLI, STR_LOLI, NO_SUBTYPE, 0, OPTION_NONE, 1, 0, SW_NRF, LOLI_init, LOLI_callback },
#endif
Expand Down
3 changes: 2 additions & 1 deletion Multiprotocol/Multiprotocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define VERSION_MAJOR 1
#define VERSION_MINOR 3
#define VERSION_REVISION 4
#define VERSION_PATCH_LEVEL 2
#define VERSION_PATCH_LEVEL 3

#define MODE_SERIAL 0

Expand Down Expand Up @@ -125,6 +125,7 @@ enum PROTOCOLS
PROTO_BLUEFLY = 95, // =>CC2500 & NRF24L01
PROTO_BUMBLEB = 96, // =>CC2500 & NRF24L01
PROTO_SGF22 = 97, // =>NRF24L01
PROTO_KYOSHO3 = 98, // =>CYRF6936


PROTO_NANORF = 126, // =>NRF24L01
Expand Down
2 changes: 2 additions & 0 deletions Multiprotocol/Validate.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
#undef E01X_CYRF6936_INO
#undef E129_CYRF6936_INO
#undef J6PRO_CYRF6936_INO
#undef KYOSHO3_CYRF6936_INO
#undef LOSI_CYRF6936_INO
#undef MLINK_CYRF6936_INO
#undef TRAXXAS_CYRF6936_INO
Expand Down Expand Up @@ -377,6 +378,7 @@
#undef TRAXXAS_CYRF6936_INO
#undef EAZYRC_NRF24L01_INO
#undef KYOSHO2_NRF24L01_INO
#undef KYOSHO3_CYRF6936_INO
#undef MOULDKG_NRF24L01_INO
#undef SHENQI_NRF24L01_INO
#endif
Expand Down
3 changes: 3 additions & 0 deletions Multiprotocol/_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
#define E01X_CYRF6936_INO
#define E129_CYRF6936_INO
#define J6PRO_CYRF6936_INO
#define KYOSHO3_CYRF6936_INO
#define LOSI_CYRF6936_INO //Need DSM to be enabled
#define MLINK_CYRF6936_INO
#define SCORPIO_CYRF6936_INO
Expand Down Expand Up @@ -739,6 +740,8 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= {
KYOSHO_HYPE
PROTO_KYOSHO2
NONE
PROTO_KYOSHO3
NONE
PROTO_LOLI
NONE
PROTO_LOSI
Expand Down
12 changes: 12 additions & 0 deletions Protocols_Details.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ CFlie|38|CFlie||||||||NRF24L01|
[KN](Protocols_Details.md#KN---9)|9|WLTOYS|FEILUN|||||||NRF24L01|
[Kyosho](Protocols_Details.md#Kyosho---73)|73|FHSS|Hype|||||||A7105|
[Kyosho2](Protocols_Details.md#Kyosho2---93)|93|KT-17||||||||NRF24L01|
[Kyosho3](Protocols_Details.md#Kyosho3---98)|98|ASF||||||||CYRF6936|
[LOLI](Protocols_Details.md#LOLI---82)|82|||||||||NRF24L01|
[Losi](Protocols_Details.md#Losi---89)|89|||||||||CYRF6936|
[MJXq](Protocols_Details.md#MJXQ---18)|18|WLH08|X600|X800|H26D|E010*|H26WH|PHOENIX*||NRF24L01|XN297
Expand Down Expand Up @@ -647,6 +648,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

## Kyosho3 - *98*

### Sub_protocol ASF - *0*
Surface protocol ASF. Models: Mini-Z.

Extended limits supported

CH1|CH2|CH3|CH4
---|---|---|---
STEERING|THROTTLE|CH3|CH4

## Losi - *89*
TX: LSR-3000

Expand Down

0 comments on commit debc9de

Please sign in to comment.