2021-01-08 21:16:07 +01:00
|
|
|
/*
|
|
|
|
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(E010R5_CYRF6936_INO)
|
|
|
|
|
2021-01-16 15:45:19 +01:00
|
|
|
#include "iface_rf2500.h"
|
2021-01-08 21:16:07 +01:00
|
|
|
|
|
|
|
#define E010R5_FORCE_ID
|
|
|
|
|
2021-01-16 15:45:19 +01:00
|
|
|
#define E010R5_BIND_CH 0x2D //45
|
|
|
|
#define E010R5_PAYLOAD_SIZE 14
|
|
|
|
|
|
|
|
|
2021-01-08 21:16:07 +01:00
|
|
|
static void __attribute__((unused)) E010R5_build_data_packet()
|
|
|
|
{
|
2021-01-16 15:45:19 +01:00
|
|
|
packet[ 0] = 0x0D; // Packet length
|
|
|
|
packet[ 1] = convert_channel_8b(THROTTLE);
|
|
|
|
packet[ 2] = convert_channel_s8b(RUDDER);
|
|
|
|
packet[ 3] = convert_channel_s8b(ELEVATOR);
|
|
|
|
packet[ 4] = convert_channel_s8b(AILERON);
|
|
|
|
packet[ 5] = 0x20; // Trim Rudder
|
|
|
|
packet[ 6] = 0x20; // Trim Elevator
|
|
|
|
packet[ 7] = 0x20; // Trim Aileron
|
|
|
|
packet[ 8] = 0x01 // Flags: high=0x01, low=0x00
|
2021-01-11 12:12:26 +01:00
|
|
|
| GET_FLAG(CH5_SW, 0x04) // flip=0x04
|
|
|
|
| GET_FLAG(CH6_SW, 0x08) // led=0x08
|
|
|
|
| GET_FLAG(CH8_SW, 0x10) // headless=0x10
|
|
|
|
| GET_FLAG(CH9_SW, 0x20); // one key return=0x20
|
2021-01-16 15:45:19 +01:00
|
|
|
packet[ 9] = IS_BIND_IN_PROGRESS ? 0x80 : 0x00 // Flags: bind=0x80
|
2021-01-11 12:12:26 +01:00
|
|
|
| GET_FLAG(CH7_SW, 0x20) // calib=0x20
|
|
|
|
| GET_FLAG(CH10_SW, 0x01); // strange effect=0x01=long press on right button
|
2021-01-16 15:45:19 +01:00
|
|
|
packet[10] = rx_tx_addr[0];
|
|
|
|
packet[11] = rx_tx_addr[1];
|
|
|
|
packet[12] = rx_tx_addr[2];
|
|
|
|
packet[13] = 0x9D; // Check
|
2021-01-08 21:16:07 +01:00
|
|
|
for(uint8_t i=0;i<13;i++)
|
2021-01-16 15:45:19 +01:00
|
|
|
packet[13] += packet[i];
|
2021-01-08 21:16:07 +01:00
|
|
|
|
2021-01-16 15:45:19 +01:00
|
|
|
RF2500_BuildPayload(packet);
|
2021-01-08 21:16:07 +01:00
|
|
|
}
|
|
|
|
|
2021-02-09 18:23:33 +01:00
|
|
|
uint16_t E010R5_callback()
|
2021-01-08 21:16:07 +01:00
|
|
|
{
|
|
|
|
//Bind
|
|
|
|
if(bind_counter)
|
2021-02-12 11:21:42 +01:00
|
|
|
if(--bind_counter==0)
|
2021-01-08 21:16:07 +01:00
|
|
|
BIND_DONE;
|
|
|
|
|
2021-01-16 15:45:19 +01:00
|
|
|
//Send packet
|
|
|
|
RF2500_SendPayload();
|
2021-01-08 21:16:07 +01:00
|
|
|
|
|
|
|
//Timing and hopping
|
|
|
|
packet_count++;
|
|
|
|
switch(packet_count)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
return 1183;
|
|
|
|
default:
|
|
|
|
hopping_frequency_no++;
|
|
|
|
hopping_frequency_no &= 3;
|
|
|
|
if(IS_BIND_IN_PROGRESS)
|
2021-01-09 18:39:31 +01:00
|
|
|
rf_ch_num = 0x30 + (hopping_frequency_no<<3);
|
2021-01-08 21:16:07 +01:00
|
|
|
else
|
|
|
|
rf_ch_num = hopping_frequency[hopping_frequency_no];
|
2021-01-16 15:45:19 +01:00
|
|
|
RF2500_RFChannel(rf_ch_num);
|
|
|
|
RF2500_SetPower();
|
2021-01-08 21:16:07 +01:00
|
|
|
packet_count = 0;
|
|
|
|
case 3:
|
|
|
|
E010R5_build_data_packet();
|
|
|
|
return 3400;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-02-09 18:23:33 +01:00
|
|
|
void E010R5_init()
|
2021-01-08 21:16:07 +01:00
|
|
|
{
|
2021-01-16 15:45:19 +01:00
|
|
|
BIND_IN_PROGRESS; // Autobind protocol
|
2021-01-21 15:31:37 +01:00
|
|
|
bind_counter = 2600;
|
2021-01-08 21:16:07 +01:00
|
|
|
|
2021-01-21 15:31:37 +01:00
|
|
|
//RF2500 emu init
|
2021-01-16 15:45:19 +01:00
|
|
|
RF2500_Init(E010R5_PAYLOAD_SIZE, false); // 14 bytes, not scrambled
|
2021-01-21 15:31:37 +01:00
|
|
|
RF2500_SetTXAddr((uint8_t*)"\x0E\x54\x96\xEE"); // Same address for bind and normal packets
|
2021-01-16 15:45:19 +01:00
|
|
|
|
2021-01-21 15:31:37 +01:00
|
|
|
#ifdef E010R5_FORCE_ID
|
2021-02-13 09:26:03 +01:00
|
|
|
switch(rx_tx_addr[3]&0x03)
|
2021-01-21 15:31:37 +01:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
//TX1
|
|
|
|
hopping_frequency[0]=0x35; //53
|
|
|
|
hopping_frequency[1]=0x30; //48
|
|
|
|
rx_tx_addr[1]=0x45;
|
|
|
|
rx_tx_addr[2]=0x46;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
//TX2
|
|
|
|
hopping_frequency[0]=0x35; //53
|
|
|
|
hopping_frequency[1]=0x3C; //60
|
|
|
|
rx_tx_addr[1]=0x1B;
|
|
|
|
rx_tx_addr[2]=0x9E;
|
|
|
|
break;
|
2021-02-13 09:26:03 +01:00
|
|
|
case 2:
|
|
|
|
//TX4
|
|
|
|
hopping_frequency[0]=0x30; //48
|
|
|
|
hopping_frequency[1]=0x38; //56
|
|
|
|
rx_tx_addr[1]=0x2E;
|
|
|
|
rx_tx_addr[2]=0xAE;
|
|
|
|
break;
|
2021-01-21 15:31:37 +01:00
|
|
|
default:
|
|
|
|
//TX3
|
|
|
|
hopping_frequency[0]=0x30; //48
|
|
|
|
hopping_frequency[1]=0x38; //56
|
|
|
|
rx_tx_addr[1]=0x17;
|
|
|
|
rx_tx_addr[2]=0x0D;
|
|
|
|
break;
|
|
|
|
}
|
2021-01-08 21:16:07 +01:00
|
|
|
#endif
|
2021-01-21 15:31:37 +01:00
|
|
|
rx_tx_addr[0]=0x00;
|
|
|
|
// This is the same as the E010 v1...
|
|
|
|
hopping_frequency[2]=hopping_frequency[0]+0x10;
|
|
|
|
hopping_frequency[3]=hopping_frequency[1]+0x10;
|
2021-01-08 21:16:07 +01:00
|
|
|
|
|
|
|
E010R5_build_data_packet();
|
2021-01-16 15:45:19 +01:00
|
|
|
RF2500_RFChannel(hopping_frequency[0]);
|
2021-01-08 21:16:07 +01:00
|
|
|
hopping_frequency_no=0;
|
|
|
|
packet_count=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|