mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-02-04 16:38:12 +00:00
New protocol KF606
Model: KF606 Protocol: 49 No sub protocol Channels: throttle, aileron and trim on ch5
This commit is contained in:
parent
ded0487ce6
commit
a15a911f8e
116
Multiprotocol/KF606_nrf24l01.ino
Normal file
116
Multiprotocol/KF606_nrf24l01.ino
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
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 KF606 plane.
|
||||
|
||||
#if defined(KF606_NRF24L01_INO)
|
||||
|
||||
#include "iface_nrf24l01.h"
|
||||
|
||||
//#define FORCE_KF606_ORIGINAL_ID
|
||||
|
||||
#define KF606_INITIAL_WAIT 500
|
||||
#define KF606_PACKET_PERIOD 3000
|
||||
#define KF606_RF_BIND_CHANNEL 7
|
||||
#define KF606_PAYLOAD_SIZE 4
|
||||
#define KF606_BIND_COUNT 857 //3sec
|
||||
|
||||
static void __attribute__((unused)) KF606_send_packet()
|
||||
{
|
||||
if(IS_BIND_IN_PROGRESS)
|
||||
{
|
||||
packet[0] = 0xAA;
|
||||
memcpy(&packet[1],rx_tx_addr,3);
|
||||
}
|
||||
else
|
||||
{
|
||||
packet[0]= 0x55;
|
||||
packet[1]= convert_channel_8b(THROTTLE); // 0..255
|
||||
packet[2]= convert_channel_16b_limit(AILERON,0x20,0xE0); // Low:50..80..AF High:3E..80..C1
|
||||
packet[3]= convert_channel_16b_limit(CH5,0xC1,0xDF); // Trim on a separated channel C1..D0..DF
|
||||
}
|
||||
// Power on, TX mode, CRC enabled
|
||||
XN297_Configure(_BV(NRF24L01_00_EN_CRC) | _BV(NRF24L01_00_CRCO) | _BV(NRF24L01_00_PWR_UP));
|
||||
if(IS_BIND_DONE)
|
||||
{
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, hopping_frequency[hopping_frequency_no]);
|
||||
hopping_frequency_no ^= 1; // 2 RF channels
|
||||
}
|
||||
|
||||
NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70);
|
||||
NRF24L01_FlushTx();
|
||||
XN297_WritePayload(packet, KF606_PAYLOAD_SIZE);
|
||||
|
||||
NRF24L01_SetPower(); // Set tx_power
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) KF606_init()
|
||||
{
|
||||
NRF24L01_Initialize();
|
||||
NRF24L01_SetTxRxMode(TX_EN);
|
||||
XN297_SetTXAddr((uint8_t*)"\xe7\xe7\xe7\xe7\xe7", 5);
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, KF606_RF_BIND_CHANNEL); // Bind channel
|
||||
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_250K); // 250Kbps
|
||||
NRF24L01_SetPower();
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) KF606_initialize_txid()
|
||||
{
|
||||
rx_tx_addr[0]=rx_tx_addr[3]; // Use RX_num;
|
||||
hopping_frequency[0]=(rx_tx_addr[0]&0x3F)+9;
|
||||
hopping_frequency[1]=hopping_frequency[0]+3;
|
||||
#ifdef FORCE_KF606_ORIGINAL_ID
|
||||
//TX1
|
||||
rx_tx_addr[0]=0x57;
|
||||
rx_tx_addr[1]=0x02;
|
||||
rx_tx_addr[2]=0x00;
|
||||
hopping_frequency[0]=0x20;
|
||||
hopping_frequency[0]=0x23;
|
||||
//TX2
|
||||
rx_tx_addr[0]=0x25;
|
||||
rx_tx_addr[1]=0x04;
|
||||
rx_tx_addr[2]=0x00;
|
||||
hopping_frequency[0]=0x2E;
|
||||
hopping_frequency[0]=0x31;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint16_t KF606_callback()
|
||||
{
|
||||
if(IS_BIND_IN_PROGRESS)
|
||||
if(--bind_counter==0)
|
||||
{
|
||||
BIND_DONE;
|
||||
XN297_SetTXAddr(rx_tx_addr, 3);
|
||||
}
|
||||
KF606_send_packet();
|
||||
return KF606_PACKET_PERIOD;
|
||||
}
|
||||
|
||||
uint16_t initKF606()
|
||||
{
|
||||
BIND_IN_PROGRESS; // autobind protocol
|
||||
KF606_initialize_txid();
|
||||
KF606_init();
|
||||
hopping_frequency_no = 0;
|
||||
bind_counter=KF606_BIND_COUNT;
|
||||
return KF606_INITIAL_WAIT;
|
||||
}
|
||||
|
||||
#endif
|
@ -45,4 +45,6 @@
|
||||
45,E01X,E012,E015,E016H
|
||||
46,V911S
|
||||
47,GD00X,V1,V2
|
||||
48,V761
|
||||
49,KF606
|
||||
63,XN_DUMP,250K,1M,2M
|
||||
|
@ -19,7 +19,7 @@
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_REVISION 1
|
||||
#define VERSION_PATCH_LEVEL 51
|
||||
#define VERSION_PATCH_LEVEL 52
|
||||
|
||||
//******************
|
||||
// Protocols
|
||||
@ -75,6 +75,7 @@ enum PROTOCOLS
|
||||
PROTO_V911S = 46, // =>NRF24L01
|
||||
PROTO_GD00X = 47, // =>NRF24L01
|
||||
PROTO_V761 = 48, // =>NRF24L01
|
||||
PROTO_KF606 = 49, // =>NRF24L01
|
||||
PROTO_XN297DUMP = 63, // =>NRF24L01
|
||||
};
|
||||
|
||||
@ -611,6 +612,7 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
|
||||
V911S 46
|
||||
GD00X 47
|
||||
V761 48
|
||||
KF606 49
|
||||
BindBit=> 0x80 1=Bind/0=No
|
||||
AutoBindBit=> 0x40 1=Yes /0=No
|
||||
RangeCheck=> 0x20 1=Yes /0=No
|
||||
|
@ -1228,6 +1228,12 @@ static void protocol_init()
|
||||
remote_callback = V761_callback;
|
||||
break;
|
||||
#endif
|
||||
#if defined(KF606_NRF24L01_INO)
|
||||
case PROTO_KF606:
|
||||
next_callback=initKF606();
|
||||
remote_callback = KF606_callback;
|
||||
break;
|
||||
#endif
|
||||
#if defined(XN297DUMP_NRF24L01_INO)
|
||||
case PROTO_XN297DUMP:
|
||||
next_callback=initXN297Dump();
|
||||
|
@ -162,6 +162,7 @@
|
||||
#undef CX10_NRF24L01_INO
|
||||
#undef ESKY_NRF24L01_INO
|
||||
#undef HISKY_NRF24L01_INO
|
||||
#undef KF606_NRF24L01_INO
|
||||
#undef KN_NRF24L01_INO
|
||||
#undef SLT_NRF24L01_INO
|
||||
#undef SYMAX_NRF24L01_INO
|
||||
|
@ -190,6 +190,7 @@
|
||||
#define HISKY_NRF24L01_INO
|
||||
#define HONTAI_NRF24L01_INO
|
||||
#define H8_3D_NRF24L01_INO
|
||||
#define KF606_NRF24L01_INO
|
||||
#define KN_NRF24L01_INO
|
||||
#define MJXQ_NRF24L01_INO
|
||||
#define MT99XX_NRF24L01_INO
|
||||
@ -564,6 +565,8 @@ const PPM_Parameters PPM_prot[14*NBR_BANKS]= {
|
||||
H501
|
||||
PROTO_J6PRO
|
||||
NONE
|
||||
PROTO_KF606
|
||||
NONE
|
||||
PROTO_KN
|
||||
WLTOYS
|
||||
FEILUN
|
||||
|
Loading…
x
Reference in New Issue
Block a user