mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2025-11-26 05:59:41 +00:00
Compare commits
96 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d90e698a15 | ||
|
|
f4d6f88e5c | ||
|
|
799dce4b13 | ||
|
|
a025d028d4 | ||
|
|
8cfa9a891d | ||
|
|
5b44439dd2 | ||
|
|
44fb7dcdaa | ||
|
|
4f5d1ba26b | ||
|
|
0a08b09d70 | ||
|
|
35eedda352 | ||
|
|
05fb8bc742 | ||
|
|
795df2937e | ||
|
|
5607740e77 | ||
|
|
d4287d3046 | ||
|
|
71ef72bae3 | ||
|
|
c310d698ca | ||
|
|
13ce3d1c92 | ||
|
|
122ed79a98 | ||
|
|
6d655242a6 | ||
|
|
09cab9d825 | ||
|
|
d8bd38c124 | ||
|
|
abc8bf0e62 | ||
|
|
24106ac3d2 | ||
|
|
bf506d382f | ||
|
|
84b1a9bbec | ||
|
|
d67afd4396 | ||
|
|
9f2f7eff5b | ||
|
|
c863d5976b | ||
|
|
d6338e9daf | ||
|
|
b393d2666d | ||
|
|
c5b1e73312 | ||
|
|
fa65222228 | ||
|
|
38e57ccd71 | ||
|
|
86d3d26273 | ||
|
|
db8e4a03a8 | ||
|
|
c90db8594a | ||
|
|
855ca77194 | ||
|
|
4f23af070e | ||
|
|
626613b545 | ||
|
|
c26de3bd67 | ||
|
|
c059915bd3 | ||
|
|
d2d70dcb38 | ||
|
|
846292442c | ||
|
|
11283a2199 | ||
|
|
4c8a0b9a63 | ||
|
|
54accbf21f | ||
|
|
08dc0db2e2 | ||
|
|
38c6330a2a | ||
|
|
2f983f42fe | ||
|
|
b9e45c4bb0 | ||
|
|
9d3b1d75d1 | ||
|
|
ac78ddcc82 | ||
|
|
f912d84ab6 | ||
|
|
85548d6e8e | ||
|
|
c74de12ceb | ||
|
|
017a21c17f | ||
|
|
9a63038a5f | ||
|
|
304fc2536b | ||
|
|
365169a9fb | ||
|
|
4b82ead18b | ||
|
|
141d7cc268 | ||
|
|
ee8e94cfb0 | ||
|
|
b50bedef39 | ||
|
|
a689ce4de9 | ||
|
|
ae0478a7e9 | ||
|
|
ee6eed5ac5 | ||
|
|
9140c426c4 | ||
|
|
a41bfabede | ||
|
|
5d26357025 | ||
|
|
644c10e994 | ||
|
|
b3ca0beead | ||
|
|
93300c6821 | ||
|
|
2bd8d7ee32 | ||
|
|
95c339ef74 | ||
|
|
76ad1d5ef7 | ||
|
|
151e82a2c3 | ||
|
|
3fcaf93788 | ||
|
|
b8927d66e9 | ||
|
|
9273f364fc | ||
|
|
bc42dbf88a | ||
|
|
481d4c15d6 | ||
|
|
563030e732 | ||
|
|
4f9137d009 | ||
|
|
ed1b4d1885 | ||
|
|
6bbcd9020e | ||
|
|
0ba916a7d6 | ||
|
|
cf498462eb | ||
|
|
e8b8b861a4 | ||
|
|
4afb045234 | ||
|
|
ef5c876085 | ||
|
|
7fbcfeec9c | ||
|
|
2981a8ef83 | ||
|
|
b1e8bfe2ab | ||
|
|
623d568eb9 | ||
|
|
3625834be3 | ||
|
|
925a4f4a57 |
@@ -140,19 +140,18 @@ void A7105_WriteID(uint32_t ida) {
|
||||
CS_on;
|
||||
}
|
||||
|
||||
void A7105_SetPower_Value(int power)
|
||||
/*
|
||||
static void A7105_SetPower_Value(int power)
|
||||
{
|
||||
/*
|
||||
Power amp is ~+16dBm so:
|
||||
TXPOWER_100uW = -23dBm == PAC=0 TBG=0
|
||||
TXPOWER_300uW = -20dBm == PAC=0 TBG=1
|
||||
TXPOWER_1mW = -16dBm == PAC=0 TBG=2
|
||||
TXPOWER_3mW = -11dBm == PAC=0 TBG=4
|
||||
TXPOWER_10mW = -6dBm == PAC=1 TBG=5
|
||||
TXPOWER_30mW = 0dBm == PAC=2 TBG=7
|
||||
TXPOWER_100mW = 1dBm == PAC=3 TBG=7
|
||||
TXPOWER_150mW = 1dBm == PAC=3 TBG=7
|
||||
*/
|
||||
//Power amp is ~+16dBm so:
|
||||
//TXPOWER_100uW = -23dBm == PAC=0 TBG=0
|
||||
//TXPOWER_300uW = -20dBm == PAC=0 TBG=1
|
||||
//TXPOWER_1mW = -16dBm == PAC=0 TBG=2
|
||||
//TXPOWER_3mW = -11dBm == PAC=0 TBG=4
|
||||
//TXPOWER_10mW = -6dBm == PAC=1 TBG=5
|
||||
//TXPOWER_30mW = 0dBm == PAC=2 TBG=7
|
||||
//TXPOWER_100mW = 1dBm == PAC=3 TBG=7
|
||||
//TXPOWER_150mW = 1dBm == PAC=3 TBG=7
|
||||
uint8_t pac, tbg;
|
||||
switch(power) {
|
||||
case 0: pac = 0; tbg = 0; break;
|
||||
@@ -167,6 +166,7 @@ void A7105_SetPower_Value(int power)
|
||||
};
|
||||
A7105_WriteReg(0x28, (pac << 3) | tbg);
|
||||
}
|
||||
*/
|
||||
|
||||
void A7105_SetPower()
|
||||
{
|
||||
@@ -196,6 +196,8 @@ const uint8_t PROGMEM FLYSKY_A7105_regs[] = {
|
||||
0x13, 0xc3, 0x00, 0xff, 0x00, 0x00, 0x3b, 0x00, 0x17, 0x47, 0x80, 0x03, 0x01, 0x45, 0x18, 0x00,
|
||||
0x01, 0x0f, 0xff
|
||||
};
|
||||
#define ID_NORMAL 0x55201041
|
||||
#define ID_PLUS 0xAA201041
|
||||
void A7105_Init(uint8_t protocol)
|
||||
{
|
||||
void *A7105_Regs;
|
||||
@@ -207,7 +209,7 @@ void A7105_Init(uint8_t protocol)
|
||||
}
|
||||
else
|
||||
{
|
||||
A7105_WriteID(0x55201041);
|
||||
A7105_WriteID(ID_NORMAL);
|
||||
A7105_Regs=(void *)HUBSAN_A7105_regs;
|
||||
}
|
||||
for (uint8_t i = 0; i < 0x33; i++){
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
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,
|
||||
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.
|
||||
@@ -12,7 +12,8 @@
|
||||
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 EAchine H8 mini, H10, BayangToys X6/X7/X9, JJRC JJ850 ...
|
||||
// Compatible with EAchine H8 mini, H10, BayangToys X6/X7/X9, JJRC JJ850 ...
|
||||
// Last sync with hexfet new_protocols/bayang_nrf24l01.c dated 2015-12-22
|
||||
|
||||
#if defined(BAYANG_NRF24L01_INO)
|
||||
|
||||
@@ -30,15 +31,14 @@ enum BAYANG_FLAGS {
|
||||
// flags going to packet[2]
|
||||
BAYANG_FLAG_RTH = 0x01,
|
||||
BAYANG_FLAG_HEADLESS = 0x02,
|
||||
BAYANG_FLAG_FLIP = 0x08
|
||||
BAYANG_FLAG_FLIP = 0x08,
|
||||
BAYANG_FLAG_VIDEO = 0x10,
|
||||
BAYANG_FLAG_PICTURE = 0x20,
|
||||
// flags going to packet[3]
|
||||
BAYANG_FLAG_INVERTED = 0x80 // inverted flight on Floureon H101
|
||||
};
|
||||
|
||||
enum BAYANG_PHASES {
|
||||
BAYANG_BIND = 0,
|
||||
BAYANG_DATA
|
||||
};
|
||||
|
||||
void BAYANG_send_packet(uint8_t bind)
|
||||
static void __attribute__((unused)) BAYANG_send_packet(uint8_t bind)
|
||||
{
|
||||
uint8_t i;
|
||||
if (bind)
|
||||
@@ -48,8 +48,8 @@ void BAYANG_send_packet(uint8_t bind)
|
||||
packet[i+1]=rx_tx_addr[i];
|
||||
for(i=0;i<4;i++)
|
||||
packet[i+6]=hopping_frequency[i];
|
||||
packet[10] = rx_tx_addr[0];
|
||||
packet[11] = rx_tx_addr[1];
|
||||
packet[10] = rx_tx_addr[0]; // txid[0]
|
||||
packet[11] = rx_tx_addr[1]; // txid[1]
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -57,16 +57,22 @@ void BAYANG_send_packet(uint8_t bind)
|
||||
packet[0] = 0xA5;
|
||||
packet[1] = 0xFA; // normal mode is 0xf7, expert 0xfa
|
||||
|
||||
//Flags
|
||||
packet[2] =0x00;
|
||||
if(Servo_data[AUX1] > PPM_SWITCH)
|
||||
packet[2] |= BAYANG_FLAG_FLIP;
|
||||
if(Servo_data[AUX2] > PPM_SWITCH)
|
||||
packet[2] |= BAYANG_FLAG_HEADLESS;
|
||||
if(Servo_data[AUX3] > PPM_SWITCH)
|
||||
//Flags packet[2]
|
||||
packet[2] = 0x00;
|
||||
if(Servo_AUX1)
|
||||
packet[2] = BAYANG_FLAG_FLIP;
|
||||
if(Servo_AUX2)
|
||||
packet[2] |= BAYANG_FLAG_RTH;
|
||||
|
||||
if(Servo_AUX3)
|
||||
packet[2] |= BAYANG_FLAG_PICTURE;
|
||||
if(Servo_AUX4)
|
||||
packet[2] |= BAYANG_FLAG_VIDEO;
|
||||
if(Servo_AUX5)
|
||||
packet[2] |= BAYANG_FLAG_HEADLESS;
|
||||
//Flags packet[3]
|
||||
packet[3] = 0x00;
|
||||
if(Servo_AUX6)
|
||||
packet[3] = BAYANG_FLAG_INVERTED;
|
||||
|
||||
//Aileron
|
||||
val = convert_channel_10b(AILERON);
|
||||
@@ -85,7 +91,7 @@ void BAYANG_send_packet(uint8_t bind)
|
||||
packet[10] = (val>>8) + (val>>2 & 0xFC);
|
||||
packet[11] = val & 0xFF;
|
||||
}
|
||||
packet[12] = rx_tx_addr[2];
|
||||
packet[12] = rx_tx_addr[2]; // txid[2]
|
||||
packet[13] = 0x0A;
|
||||
packet[14] = 0;
|
||||
for (uint8_t i=0; i < BAYANG_PACKET_SIZE-1; i++)
|
||||
@@ -95,10 +101,7 @@ void BAYANG_send_packet(uint8_t bind)
|
||||
// Why CRC0? xn297 does not interpret it - either 16-bit CRC or nothing
|
||||
XN297_Configure(BV(NRF24L01_00_EN_CRC) | BV(NRF24L01_00_CRCO) | BV(NRF24L01_00_PWR_UP));
|
||||
|
||||
if (bind)
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, BAYANG_RF_BIND_CHANNEL);
|
||||
else
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, hopping_frequency[hopping_frequency_no++]);
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, bind ? BAYANG_RF_BIND_CHANNEL:hopping_frequency[hopping_frequency_no++]);
|
||||
hopping_frequency_no%=BAYANG_RF_NUM_CHANNELS;
|
||||
|
||||
// clear packet status bits and TX FIFO
|
||||
@@ -109,7 +112,7 @@ void BAYANG_send_packet(uint8_t bind)
|
||||
NRF24L01_SetPower(); // Set tx_power
|
||||
}
|
||||
|
||||
void BAYANG_init()
|
||||
static void __attribute__((unused)) BAYANG_init()
|
||||
{
|
||||
NRF24L01_Initialize();
|
||||
NRF24L01_SetTxRxMode(TX_EN);
|
||||
@@ -118,49 +121,40 @@ void BAYANG_init()
|
||||
|
||||
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_WriteReg(NRF24L01_03_SETUP_AW, 0x03);
|
||||
NRF24L01_WriteReg(NRF24L01_04_SETUP_RETR, 0x00); // no retransmits
|
||||
NRF24L01_SetBitrate(NRF24L01_BR_1M); // 1Mbps
|
||||
NRF24L01_SetPower();
|
||||
|
||||
NRF24L01_Activate(0x73); // Activate feature register
|
||||
NRF24L01_WriteReg(NRF24L01_1C_DYNPD, 0x00); // Disable dynamic payload length on all pipes
|
||||
NRF24L01_WriteReg(NRF24L01_1D_FEATURE, 0x01);
|
||||
NRF24L01_Activate(0x73);
|
||||
NRF24L01_WriteReg(NRF24L01_02_EN_RXADDR, 0x01); // Enable data pipe 0 only
|
||||
NRF24L01_SetBitrate(NRF24L01_BR_1M); // 1Mbps
|
||||
NRF24L01_SetPower();
|
||||
}
|
||||
|
||||
uint16_t BAYANG_callback()
|
||||
{
|
||||
switch (phase)
|
||||
if(IS_BIND_DONE_on)
|
||||
BAYANG_send_packet(0);
|
||||
else
|
||||
{
|
||||
case BAYANG_BIND:
|
||||
if (bind_counter == 0)
|
||||
{
|
||||
XN297_SetTXAddr(rx_tx_addr, BAYANG_ADDRESS_LENGTH);
|
||||
phase = BAYANG_DATA;
|
||||
BIND_DONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
BAYANG_send_packet(1);
|
||||
bind_counter--;
|
||||
}
|
||||
break;
|
||||
case BAYANG_DATA:
|
||||
BAYANG_send_packet(0);
|
||||
break;
|
||||
if (bind_counter == 0)
|
||||
{
|
||||
XN297_SetTXAddr(rx_tx_addr, BAYANG_ADDRESS_LENGTH);
|
||||
BIND_DONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
BAYANG_send_packet(1);
|
||||
bind_counter--;
|
||||
}
|
||||
}
|
||||
return BAYANG_PACKET_PERIOD;
|
||||
}
|
||||
|
||||
void BAYANG_initialize_txid()
|
||||
static void __attribute__((unused)) BAYANG_initialize_txid()
|
||||
{
|
||||
// Strange txid, rx_tx_addr and rf_channels could be anything so I will use on rx_tx_addr for all of them...
|
||||
// Strange also that there is no check of duplicated rf channels... I think we need to implement that later...
|
||||
for(uint8_t i=0; i<BAYANG_RF_NUM_CHANNELS; i++)
|
||||
hopping_frequency[i]=rx_tx_addr[i]%42;
|
||||
//Could be using txid[0..2] but using rx_tx_addr everywhere instead...
|
||||
hopping_frequency[0]=0;
|
||||
hopping_frequency[1]=(rx_tx_addr[0]&0x1F)+0x10;
|
||||
hopping_frequency[2]=hopping_frequency[1]+0x20;
|
||||
hopping_frequency[3]=hopping_frequency[2]+0x20;
|
||||
hopping_frequency_no=0;
|
||||
}
|
||||
|
||||
@@ -169,9 +163,8 @@ uint16_t initBAYANG(void)
|
||||
BIND_IN_PROGRESS; // autobind protocol
|
||||
bind_counter = BAYANG_BIND_COUNT;
|
||||
BAYANG_initialize_txid();
|
||||
phase=BAYANG_BIND;
|
||||
BAYANG_init();
|
||||
return BAYANG_INITIAL_WAIT+BAYANG_PACKET_PERIOD;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@@ -36,7 +36,7 @@ static void ReadRegisterMulti(uint8_t address, uint8_t data[], uint8_t length)
|
||||
|
||||
//*********************************************
|
||||
|
||||
void CC2500_WriteRegisterMulti(uint8_t address, const uint8_t data[], uint8_t length)
|
||||
static void CC2500_WriteRegisterMulti(uint8_t address, const uint8_t data[], uint8_t length)
|
||||
{
|
||||
CC25_CSN_off;
|
||||
cc2500_spi_write(CC2500_WRITE_BURST | address);
|
||||
@@ -53,7 +53,7 @@ void cc2500_writeFifo(uint8_t *dpbuffer, uint8_t len)
|
||||
}
|
||||
|
||||
//--------------------------------------
|
||||
void cc2500_spi_write(uint8_t command) {
|
||||
static void cc2500_spi_write(uint8_t command) {
|
||||
uint8_t n=8;
|
||||
|
||||
SCK_off;//SCK start low
|
||||
@@ -81,7 +81,7 @@ void cc2500_writeReg(uint8_t address, uint8_t data) {//same as 7105
|
||||
CC25_CSN_on;
|
||||
}
|
||||
|
||||
uint8_t cc2500_spi_read(void)
|
||||
static uint8_t cc2500_spi_read(void)
|
||||
{
|
||||
uint8_t result;
|
||||
uint8_t i;
|
||||
@@ -101,7 +101,7 @@ uint8_t cc2500_spi_read(void)
|
||||
}
|
||||
|
||||
//--------------------------------------------
|
||||
uint8_t cc2500_readReg(uint8_t address)
|
||||
static uint8_t cc2500_readReg(uint8_t address)
|
||||
{
|
||||
uint8_t result;
|
||||
CC25_CSN_off;
|
||||
@@ -119,7 +119,7 @@ void cc2500_strobe(uint8_t address)
|
||||
CC25_CSN_on;
|
||||
}
|
||||
//------------------------
|
||||
void cc2500_resetChip(void)
|
||||
/*static void cc2500_resetChip(void)
|
||||
{
|
||||
// Toggle chip select signal
|
||||
CC25_CSN_on;
|
||||
@@ -131,7 +131,7 @@ void cc2500_resetChip(void)
|
||||
cc2500_strobe(CC2500_SRES);
|
||||
_delay_ms(100);
|
||||
}
|
||||
|
||||
*/
|
||||
uint8_t CC2500_Reset()
|
||||
{
|
||||
cc2500_strobe(CC2500_SRES);
|
||||
@@ -139,8 +139,8 @@ uint8_t CC2500_Reset()
|
||||
CC2500_SetTxRxMode(TXRX_OFF);
|
||||
return cc2500_readReg(CC2500_0E_FREQ1) == 0xC4;//check if reset
|
||||
}
|
||||
|
||||
void CC2500_SetPower_Value(uint8_t power)
|
||||
/*
|
||||
static void CC2500_SetPower_Value(uint8_t power)
|
||||
{
|
||||
const unsigned char patable[8]= {
|
||||
0xC5, // -12dbm
|
||||
@@ -156,7 +156,7 @@ void CC2500_SetPower_Value(uint8_t power)
|
||||
power = 7;
|
||||
cc2500_writeReg(CC2500_3E_PATABLE, patable[power]);
|
||||
}
|
||||
|
||||
*/
|
||||
void CC2500_SetPower()
|
||||
{
|
||||
uint8_t power=CC2500_BIND_POWER;
|
||||
@@ -185,4 +185,4 @@ void CC2500_SetTxRxMode(uint8_t mode)
|
||||
cc2500_writeReg(CC2500_02_IOCFG0, 0x2F);
|
||||
cc2500_writeReg(CC2500_00_IOCFG2, 0x2F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
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 EAchine 3D X4, CG023/CG031, Attop YD-822/YD-829/YD-829C and H8_3D/JJRC H20/H22
|
||||
// Merged CG023 and H8_3D protocols
|
||||
// compatible with EAchine 3D X4, CG023/CG031, Attop YD-822/YD-829/YD-829C and H8_3D/JJRC H20
|
||||
// Last sync with hexfet new_protocols/cg023_nrf24l01.c dated 2015-10-03
|
||||
// Last sync with hexfet new_protocols/h8_3d_nrf24l01.c dated 2015-11-18
|
||||
|
||||
#if defined(CG023_NRF24L01_INO)
|
||||
|
||||
@@ -58,8 +60,9 @@ enum H8_3D_FLAGS {
|
||||
H8_3D_FLAG_FLIP = 0x01,
|
||||
H8_3D_FLAG_RATE_MID = 0x02,
|
||||
H8_3D_FLAG_RATE_HIGH = 0x04,
|
||||
H8_3D_FLAG_HEADLESS = 0x10, // RTH + headless on H8, headless on JJRC H20
|
||||
H8_3D_FLAG_RTH = 0x40, // 360 flip mode on H8 3D, RTH on JJRC H20
|
||||
H8_3D_FLAG_LIGTH = 0x08, // Light on H22
|
||||
H8_3D_FLAG_HEADLESS = 0x10, // RTH + headless on H8, headless on JJRC H20, RTH on H22
|
||||
H8_3D_FLAG_RTH = 0x20, // 360 flip mode on H8 3D and H22, RTH on JJRC H20
|
||||
};
|
||||
|
||||
enum H8_3D_FLAGS_2 {
|
||||
@@ -67,12 +70,7 @@ enum H8_3D_FLAGS_2 {
|
||||
H8_3D_FLAG_CALIBRATE = 0x20, // accelerometer calibration
|
||||
};
|
||||
|
||||
enum CG023_PHASES {
|
||||
CG023_BIND = 0,
|
||||
CG023_DATA
|
||||
};
|
||||
|
||||
void CG023_send_packet(uint8_t bind)
|
||||
static void __attribute__((unused)) CG023_send_packet(uint8_t bind)
|
||||
{
|
||||
// throttle : 0x00 - 0xFF
|
||||
throttle=convert_channel_8b(THROTTLE);
|
||||
@@ -92,7 +90,7 @@ void CG023_send_packet(uint8_t bind)
|
||||
packet[0] = 0x13;
|
||||
packet[3] = rx_tx_addr[2];
|
||||
packet[4] = rx_tx_addr[3];
|
||||
packet[8] = (rx_tx_addr[0]+rx_tx_addr[1]+rx_tx_addr[2]+rx_tx_addr[3]) & 0xff; // txid checksum
|
||||
packet[8] = rx_tx_addr[0]+rx_tx_addr[1]+rx_tx_addr[2]+rx_tx_addr[3]; // txid checksum
|
||||
memset(&packet[9], 0, 10);
|
||||
if (bind)
|
||||
{
|
||||
@@ -106,6 +104,8 @@ void CG023_send_packet(uint8_t bind)
|
||||
packet[6] = 0x08;
|
||||
packet[7] = 0x03;
|
||||
packet[9] = throttle;
|
||||
if(rudder==0x01) rudder=0; // Small deadband
|
||||
if(rudder==0x81) rudder=0; // Small deadband
|
||||
packet[10] = rudder;
|
||||
packet[11] = elevator;
|
||||
packet[12] = aileron;
|
||||
@@ -114,16 +114,12 @@ void CG023_send_packet(uint8_t bind)
|
||||
packet[14] = 0x20;
|
||||
packet[15] = 0x20;
|
||||
packet[16] = 0x20;
|
||||
packet[17] = H8_3D_FLAG_RATE_HIGH;
|
||||
if(Servo_data[AUX1] > PPM_SWITCH)
|
||||
packet[17] |= H8_3D_FLAG_FLIP;
|
||||
if(Servo_data[AUX2] > PPM_SWITCH)
|
||||
packet[17] |= H8_3D_FLAG_HEADLESS;
|
||||
if(Servo_data[AUX3] > PPM_SWITCH)
|
||||
packet[17] |= H8_3D_FLAG_RTH; // 180/360 flip mode on H8 3D
|
||||
|
||||
// both sticks bottom left: calibrate acc
|
||||
if(packet[9] <= 0x05 && packet[10] >= 0xa7 && packet[11] <= 0x57 && packet[12] >= 0xa7)
|
||||
packet[17] = H8_3D_FLAG_RATE_HIGH
|
||||
| GET_FLAG(Servo_AUX1,H8_3D_FLAG_FLIP)
|
||||
| GET_FLAG(Servo_AUX2,H8_3D_FLAG_LIGTH) //H22 light
|
||||
| GET_FLAG(Servo_AUX3,H8_3D_FLAG_HEADLESS)
|
||||
| GET_FLAG(Servo_AUX4,H8_3D_FLAG_RTH); // 180/360 flip mode on H8 3D
|
||||
if(Servo_AUX5)
|
||||
packet[18] = H8_3D_FLAG_CALIBRATE;
|
||||
}
|
||||
uint8_t sum = packet[9];
|
||||
@@ -154,32 +150,21 @@ void CG023_send_packet(uint8_t bind)
|
||||
if(sub_protocol==CG023)
|
||||
{
|
||||
// rate
|
||||
packet[13] = CG023_FLAG_RATE_HIGH;
|
||||
// flags
|
||||
if(Servo_data[AUX1] > PPM_SWITCH)
|
||||
packet[13] |= CG023_FLAG_FLIP;
|
||||
if(Servo_data[AUX2] > PPM_SWITCH)
|
||||
packet[13] |= CG023_FLAG_LED_OFF;
|
||||
if(Servo_data[AUX3] > PPM_SWITCH)
|
||||
packet[13] |= CG023_FLAG_STILL;
|
||||
if(Servo_data[AUX4] > PPM_SWITCH)
|
||||
packet[13] |= CG023_FLAG_VIDEO;
|
||||
if(Servo_data[AUX5] > PPM_SWITCH)
|
||||
packet[13] |= CG023_FLAG_EASY;
|
||||
packet[13] = CG023_FLAG_RATE_HIGH
|
||||
| GET_FLAG(Servo_AUX1,CG023_FLAG_FLIP)
|
||||
| GET_FLAG(Servo_AUX2,CG023_FLAG_LED_OFF)
|
||||
| GET_FLAG(Servo_AUX3,CG023_FLAG_STILL)
|
||||
| GET_FLAG(Servo_AUX4,CG023_FLAG_VIDEO)
|
||||
| GET_FLAG(Servo_AUX5,CG023_FLAG_EASY);
|
||||
}
|
||||
else
|
||||
{// YD829
|
||||
// rate
|
||||
packet[13] = YD829_FLAG_RATE_HIGH;
|
||||
// flags
|
||||
if(Servo_data[AUX1] > PPM_SWITCH)
|
||||
packet[13] |= YD829_FLAG_FLIP;
|
||||
if(Servo_data[AUX3] > PPM_SWITCH)
|
||||
packet[13] |= YD829_FLAG_STILL;
|
||||
if(Servo_data[AUX4] > PPM_SWITCH)
|
||||
packet[13] |= YD829_FLAG_VIDEO;
|
||||
if(Servo_data[AUX5] > PPM_SWITCH)
|
||||
packet[13] |= YD829_FLAG_HEADLESS;
|
||||
packet[13] = YD829_FLAG_RATE_HIGH
|
||||
| GET_FLAG(Servo_AUX1,YD829_FLAG_FLIP)
|
||||
| GET_FLAG(Servo_AUX3,YD829_FLAG_STILL)
|
||||
| GET_FLAG(Servo_AUX4,YD829_FLAG_VIDEO)
|
||||
| GET_FLAG(Servo_AUX5,YD829_FLAG_HEADLESS);
|
||||
}
|
||||
packet[14] = 0;
|
||||
}
|
||||
@@ -207,7 +192,7 @@ void CG023_send_packet(uint8_t bind)
|
||||
NRF24L01_SetPower(); // Set tx_power
|
||||
}
|
||||
|
||||
void CG023_init()
|
||||
static void __attribute__((unused)) CG023_init()
|
||||
{
|
||||
NRF24L01_Initialize();
|
||||
NRF24L01_SetTxRxMode(TX_EN);
|
||||
@@ -227,33 +212,22 @@ void CG023_init()
|
||||
|
||||
uint16_t CG023_callback()
|
||||
{
|
||||
switch (phase)
|
||||
{
|
||||
case CG023_BIND:
|
||||
if (bind_counter == 0)
|
||||
{
|
||||
phase = CG023_DATA;
|
||||
BIND_DONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
CG023_send_packet(1);
|
||||
bind_counter--;
|
||||
}
|
||||
break;
|
||||
case CG023_DATA:
|
||||
CG023_send_packet(0);
|
||||
break;
|
||||
}
|
||||
if(sub_protocol==CG023)
|
||||
return CG023_PACKET_PERIOD;
|
||||
if(IS_BIND_DONE_on)
|
||||
CG023_send_packet(0);
|
||||
else
|
||||
if(sub_protocol==YD829)
|
||||
return YD829_PACKET_PERIOD;
|
||||
return H8_3D_PACKET_PERIOD;
|
||||
{
|
||||
if (bind_counter == 0)
|
||||
BIND_DONE;
|
||||
else
|
||||
{
|
||||
CG023_send_packet(1);
|
||||
bind_counter--;
|
||||
}
|
||||
}
|
||||
return packet_period;
|
||||
}
|
||||
|
||||
void CG023_initialize_txid()
|
||||
static void __attribute__((unused)) CG023_initialize_txid()
|
||||
{
|
||||
if(sub_protocol==H8_3D)
|
||||
{
|
||||
@@ -262,10 +236,10 @@ void CG023_initialize_txid()
|
||||
rx_tx_addr[2] = rx_tx_addr[2] % 0x20;
|
||||
rx_tx_addr[3] = rx_tx_addr[3] % 0x11;
|
||||
|
||||
hopping_frequency[0] = 0x06 + (((rx_tx_addr[0]>>8) + (rx_tx_addr[0]&0x0f)) % 0x0f);
|
||||
hopping_frequency[1] = 0x15 + (((rx_tx_addr[1]>>8) + (rx_tx_addr[1]&0x0f)) % 0x0f);
|
||||
hopping_frequency[2] = 0x24 + (((rx_tx_addr[2]>>8) + (rx_tx_addr[2]&0x0f)) % 0x0f);
|
||||
hopping_frequency[3] = 0x33 + (((rx_tx_addr[3]>>8) + (rx_tx_addr[3]&0x0f)) % 0x0f);
|
||||
hopping_frequency[0] = 0x06 + ((rx_tx_addr[0]&0x0f) % 0x0f);
|
||||
hopping_frequency[1] = 0x15 + ((rx_tx_addr[1]&0x0f) % 0x0f);
|
||||
hopping_frequency[2] = 0x24 + ((rx_tx_addr[2]&0x0f) % 0x0f);
|
||||
hopping_frequency[3] = 0x33 + ((rx_tx_addr[3]&0x0f) % 0x0f);
|
||||
}
|
||||
else
|
||||
{ // CG023 and YD829
|
||||
@@ -282,13 +256,14 @@ uint16_t initCG023(void)
|
||||
bind_counter = CG023_BIND_COUNT;
|
||||
CG023_initialize_txid();
|
||||
CG023_init();
|
||||
phase=CG023_BIND;
|
||||
if(sub_protocol==CG023)
|
||||
return CG023_INITIAL_WAIT+CG023_PACKET_PERIOD;
|
||||
packet_period=CG023_PACKET_PERIOD;
|
||||
else
|
||||
if(sub_protocol==YD829)
|
||||
return CG023_INITIAL_WAIT+YD829_PACKET_PERIOD;
|
||||
return CG023_INITIAL_WAIT+H8_3D_PACKET_PERIOD;
|
||||
packet_period=YD829_PACKET_PERIOD;
|
||||
else
|
||||
packet_period=H8_3D_PACKET_PERIOD;
|
||||
return CG023_INITIAL_WAIT+YD829_PACKET_PERIOD;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,19 +12,22 @@
|
||||
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 Cheerson CX-10 blue & newer red pcb, CX-10A, CX11, CX-10 green pcb, DM007, Floureon FX-10, CX-Stars
|
||||
// compatible with Cheerson CX-10 blue & newer red pcb, CX-10A, CX11, CX-10 green pcb, DM007, Floureon FX-10, JXD 509 (Q282)
|
||||
// Last sync with hexfet new_protocols/cx10_nrf24l01.c dated 2015-11-26
|
||||
|
||||
#if defined(CX10_NRF24L01_INO)
|
||||
|
||||
#include "iface_nrf24l01.h"
|
||||
|
||||
#define CX10_BIND_COUNT 4360 // 6 seconds
|
||||
#define CX10_PACKET_SIZE 15
|
||||
#define CX10A_PACKET_SIZE 19 // CX10 blue board packets have 19-byte payload
|
||||
#define CX10_PACKET_PERIOD 1316 // Timeout for callback in uSec
|
||||
#define CX10A_PACKET_PERIOD 6000
|
||||
#define CX10_BIND_COUNT 4360 // 6 seconds
|
||||
#define CX10_PACKET_SIZE 15
|
||||
#define CX10A_PACKET_SIZE 19 // CX10 blue board packets have 19-byte payload
|
||||
#define Q282_PACKET_SIZE 21
|
||||
#define CX10_PACKET_PERIOD 1316 // Timeout for callback in uSec
|
||||
#define CX10A_PACKET_PERIOD 6000
|
||||
#define CX10A_BIND_COUNT 400 // 2 seconds
|
||||
|
||||
#define INITIAL_WAIT 500
|
||||
#define CX10_INITIAL_WAIT 500
|
||||
|
||||
// flags
|
||||
#define CX10_FLAG_FLIP 0x10 // goes to rudder channel
|
||||
@@ -35,17 +38,16 @@
|
||||
#define CX10_FLAG_SNAPSHOT 0x04
|
||||
|
||||
// frequency channel management
|
||||
#define RF_BIND_CHANNEL 0x02
|
||||
#define NUM_RF_CHANNELS 4
|
||||
#define CX10_RF_BIND_CHANNEL 0x02
|
||||
#define CX10_NUM_RF_CHANNELS 4
|
||||
|
||||
enum {
|
||||
CX10_INIT1 = 0,
|
||||
CX10_BIND1,
|
||||
CX10_BIND1 = 0,
|
||||
CX10_BIND2,
|
||||
CX10_DATA
|
||||
};
|
||||
|
||||
void CX10_Write_Packet(uint8_t bind)
|
||||
static void __attribute__((unused)) CX10_Write_Packet(uint8_t bind)
|
||||
{
|
||||
uint8_t offset = 0;
|
||||
if(sub_protocol == CX10_BLUE)
|
||||
@@ -66,42 +68,94 @@ void CX10_Write_Packet(uint8_t bind)
|
||||
packet[12+offset]= highByte(Servo_data[RUDDER]);
|
||||
|
||||
// Channel 5 - flip flag
|
||||
if(Servo_data[AUX1] > PPM_SWITCH)
|
||||
if(Servo_AUX1)
|
||||
packet[12+offset] |= CX10_FLAG_FLIP; // flip flag
|
||||
|
||||
// Channel 6 - mode
|
||||
if(Servo_data[AUX2] > PPM_MAX_COMMAND) // mode 3 / headless on CX-10A
|
||||
packet[13+offset] = 0x02;
|
||||
//flags=0; // packet 13
|
||||
uint8_t flags2=0; // packet 14
|
||||
|
||||
// Channel 6 - rate mode is 2 lsb of packet 13
|
||||
if(Servo_data[AUX2] > PPM_MAX_COMMAND) // rate 3 / headless on CX-10A
|
||||
flags = 0x02;
|
||||
else
|
||||
if(Servo_data[AUX2] < PPM_MIN_COMMAND)
|
||||
packet[13+offset] = 0x00; // mode 1
|
||||
flags = 0x00; // rate 1
|
||||
else
|
||||
packet[13+offset] = 0x01; // mode 2
|
||||
flags = 0x01; // rate 2
|
||||
|
||||
flags=0;
|
||||
if(sub_protocol == DM007)
|
||||
uint8_t video_state=packet[14] & 0x21;
|
||||
switch(sub_protocol)
|
||||
{
|
||||
// Channel 7 - snapshot
|
||||
if(Servo_data[AUX3] > PPM_SWITCH)
|
||||
flags |= CX10_FLAG_SNAPSHOT;
|
||||
// Channel 8 - video
|
||||
if(Servo_data[AUX4] > PPM_SWITCH)
|
||||
flags |= CX10_FLAG_VIDEO;
|
||||
// Channel 9 - headless
|
||||
if(Servo_data[AUX5] > PPM_SWITCH)
|
||||
packet[13+offset] |= CX10_FLAG_HEADLESS;
|
||||
case CX10_BLUE:
|
||||
flags |= GET_FLAG(!Servo_AUX3, 0x10) // Channel 7 - picture
|
||||
|GET_FLAG( Servo_AUX4, 0x08); // Channel 8 - video
|
||||
break;
|
||||
case Q282:
|
||||
case Q242:
|
||||
memcpy(&packet[15], "\x10\x10\xaa\xaa\x00\x00", 6);
|
||||
//FLIP|LED|PICTURE|VIDEO|HEADLESS|RTH|XCAL|YCAL
|
||||
flags2 = GET_FLAG(Servo_AUX1, 0x80) // Channel 5 - FLIP
|
||||
|GET_FLAG(Servo_AUX2, 0x40) // Channel 6 - LED
|
||||
|GET_FLAG(Servo_AUX5, 0x08) // Channel 9 - HEADLESS
|
||||
|GET_FLAG(Servo_AUX7, 0x04) // Channel 11 - XCAL
|
||||
|GET_FLAG(Servo_AUX8, 0x02); // Channel 12 - YCAL or Start/Stop motors on JXD 509
|
||||
|
||||
if(sub_protocol==Q282)
|
||||
{
|
||||
flags=3;
|
||||
if(Servo_AUX4) // Channel 8 - video
|
||||
{
|
||||
if (!(video_state & 0x20)) video_state ^= 0x21;
|
||||
}
|
||||
else
|
||||
if (video_state & 0x20) video_state &= 0x01;
|
||||
flags2 |= video_state
|
||||
|GET_FLAG(Servo_AUX3,0x10); // Channel 7 - picture
|
||||
}
|
||||
else
|
||||
{
|
||||
flags=2;
|
||||
flags2|= GET_FLAG(Servo_AUX3,0x01) // Channel 7 - picture
|
||||
|GET_FLAG(Servo_AUX4,0x10); // Channel 8 - video
|
||||
packet[17]=0x00;
|
||||
packet[18]=0x00;
|
||||
}
|
||||
if(Servo_AUX6) flags |=0x80; // Channel 10 - RTH
|
||||
break;
|
||||
case DM007:
|
||||
//FLIP|MODE|PICTURE|VIDEO|HEADLESS
|
||||
flags2= GET_FLAG(Servo_AUX3,CX10_FLAG_SNAPSHOT) // Channel 7 - picture
|
||||
|GET_FLAG(Servo_AUX4,CX10_FLAG_VIDEO); // Channel 8 - video
|
||||
if(Servo_AUX5) flags |= CX10_FLAG_HEADLESS; // Channel 9 - headless
|
||||
break;
|
||||
case JC3015_2:
|
||||
//FLIP|MODE|LED|DFLIP
|
||||
if(Servo_AUX4) packet[12] &= ~CX10_FLAG_FLIP;
|
||||
case JC3015_1:
|
||||
//FLIP|MODE|PICTURE|VIDEO
|
||||
flags2= GET_FLAG(Servo_AUX3,_BV(3)) // Channel 7
|
||||
|GET_FLAG(Servo_AUX4,_BV(4)); // Channel 8
|
||||
break;
|
||||
case MK33041:
|
||||
//FLIP|MODE|PICTURE|VIDEO|HEADLESS|RTH
|
||||
flags|=GET_FLAG(Servo_AUX3,_BV(7)) // Channel 7 - picture
|
||||
|GET_FLAG(Servo_AUX6,_BV(2)); // Channel 10 - rth
|
||||
flags2=GET_FLAG(Servo_AUX4,_BV(0)) // Channel 8 - video
|
||||
|GET_FLAG(Servo_AUX5,_BV(5)); // Channel 9 - headless
|
||||
break;
|
||||
}
|
||||
packet[14+offset] = flags;
|
||||
packet[13+offset]=flags;
|
||||
packet[14+offset]=flags2;
|
||||
|
||||
// Power on, TX mode, 2byte CRC
|
||||
// Why CRC0? xn297 does not interpret it - either 16-bit CRC or nothing
|
||||
XN297_Configure(BV(NRF24L01_00_EN_CRC) | BV(NRF24L01_00_CRCO) | BV(NRF24L01_00_PWR_UP));
|
||||
if (bind)
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, RF_BIND_CHANNEL);
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, CX10_RF_BIND_CHANNEL);
|
||||
else
|
||||
{
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, hopping_frequency[hopping_frequency_no++]);
|
||||
hopping_frequency_no %= NUM_RF_CHANNELS;
|
||||
hopping_frequency_no %= CX10_NUM_RF_CHANNELS;
|
||||
}
|
||||
// clear packet status bits and TX FIFO
|
||||
NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70);
|
||||
@@ -111,7 +165,7 @@ void CX10_Write_Packet(uint8_t bind)
|
||||
NRF24L01_SetPower();
|
||||
}
|
||||
|
||||
void CX10_init()
|
||||
static void __attribute__((unused)) CX10_init()
|
||||
{
|
||||
NRF24L01_Initialize();
|
||||
NRF24L01_SetTxRxMode(TX_EN);
|
||||
@@ -123,16 +177,13 @@ void CX10_init()
|
||||
NRF24L01_WriteReg(NRF24L01_01_EN_AA, 0x00); // No Auto Acknowledgment on all data pipes
|
||||
NRF24L01_WriteReg(NRF24L01_02_EN_RXADDR, 0x01); // Enable data pipe 0 only
|
||||
NRF24L01_WriteReg(NRF24L01_11_RX_PW_P0, packet_length); // rx pipe 0 (used only for blue board)
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, RF_BIND_CHANNEL);
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, CX10_RF_BIND_CHANNEL);
|
||||
NRF24L01_SetBitrate(NRF24L01_BR_1M); // 1Mbps
|
||||
NRF24L01_SetPower();
|
||||
}
|
||||
|
||||
uint16_t CX10_callback() {
|
||||
switch (phase) {
|
||||
case CX10_INIT1:
|
||||
phase = bind_phase;
|
||||
break;
|
||||
case CX10_BIND1:
|
||||
if (bind_counter == 0)
|
||||
{
|
||||
@@ -146,20 +197,29 @@ uint16_t CX10_callback() {
|
||||
}
|
||||
break;
|
||||
case CX10_BIND2:
|
||||
bind_counter--;
|
||||
if(bind_counter==0)
|
||||
{ // Needed for some CX-10A to properly finish the bind
|
||||
CX10_init();
|
||||
bind_counter=CX10A_BIND_COUNT;
|
||||
}
|
||||
if( NRF24L01_ReadReg(NRF24L01_07_STATUS) & BV(NRF24L01_07_RX_DR))
|
||||
{ // RX fifo data ready
|
||||
XN297_ReadPayload(packet, packet_length);
|
||||
NRF24L01_SetTxRxMode(TXRX_OFF);
|
||||
NRF24L01_SetTxRxMode(TX_EN);
|
||||
if(packet[9] == 1)
|
||||
{
|
||||
phase = CX10_BIND1;
|
||||
bind_counter=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NRF24L01_SetTxRxMode(TXRX_OFF);
|
||||
NRF24L01_SetTxRxMode(TX_EN);
|
||||
CX10_Write_Packet(1);
|
||||
delay(1); // used to be 300µs in deviation but not working so 1ms now
|
||||
delayMicroseconds(400); // 300µs in deviation but not working so using 400µs instead
|
||||
// switch to RX mode
|
||||
NRF24L01_SetTxRxMode(TXRX_OFF);
|
||||
NRF24L01_FlushRx();
|
||||
@@ -174,41 +234,61 @@ uint16_t CX10_callback() {
|
||||
return packet_period;
|
||||
}
|
||||
|
||||
void initialize_txid()
|
||||
static void __attribute__((unused)) CX10_initialize_txid()
|
||||
{
|
||||
rx_tx_addr[1]%= 0x30;
|
||||
hopping_frequency[0] = 0x03 + (rx_tx_addr[0] & 0x0F);
|
||||
hopping_frequency[1] = 0x16 + (rx_tx_addr[0] >> 4);
|
||||
hopping_frequency[2] = 0x2D + (rx_tx_addr[1] & 0x0F);
|
||||
hopping_frequency[3] = 0x40 + (rx_tx_addr[1] >> 4);
|
||||
if(sub_protocol==Q282)
|
||||
{
|
||||
hopping_frequency[0] = 0x46;
|
||||
hopping_frequency[1] = 0x48;
|
||||
hopping_frequency[2] = 0x4a;
|
||||
hopping_frequency[3] = 0x4c;
|
||||
}
|
||||
else
|
||||
if(sub_protocol==Q242)
|
||||
{
|
||||
hopping_frequency[0] = 0x48;
|
||||
hopping_frequency[1] = 0x4a;
|
||||
hopping_frequency[2] = 0x4c;
|
||||
hopping_frequency[3] = 0x4e;
|
||||
}
|
||||
else
|
||||
{
|
||||
hopping_frequency[0] = 0x03 + (rx_tx_addr[0] & 0x0F);
|
||||
hopping_frequency[1] = 0x16 + (rx_tx_addr[0] >> 4);
|
||||
hopping_frequency[2] = 0x2D + (rx_tx_addr[1] & 0x0F);
|
||||
hopping_frequency[3] = 0x40 + (rx_tx_addr[1] >> 4);
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t initCX10(void)
|
||||
{
|
||||
switch(sub_protocol)
|
||||
if(sub_protocol==CX10_BLUE)
|
||||
{
|
||||
case CX10_GREEN:
|
||||
case DM007:
|
||||
packet_length = CX10_PACKET_SIZE;
|
||||
packet_period = CX10_PACKET_PERIOD;
|
||||
bind_phase = CX10_BIND1;
|
||||
bind_counter = CX10_BIND_COUNT;
|
||||
break;
|
||||
case CX10_BLUE:
|
||||
packet_length = CX10A_PACKET_SIZE;
|
||||
packet_period = CX10A_PACKET_PERIOD;
|
||||
bind_phase = CX10_BIND2;
|
||||
bind_counter=0;
|
||||
for(uint8_t i=0; i<4; i++)
|
||||
packet[5+i] = 0xff; // clear aircraft id
|
||||
packet[9] = 0;
|
||||
break;
|
||||
packet_length = CX10A_PACKET_SIZE;
|
||||
packet_period = CX10A_PACKET_PERIOD;
|
||||
|
||||
phase = CX10_BIND2;
|
||||
bind_counter=CX10A_BIND_COUNT;
|
||||
|
||||
for(uint8_t i=0; i<4; i++)
|
||||
packet[5+i] = 0xff; // clear aircraft id
|
||||
packet[9] = 0;
|
||||
}
|
||||
initialize_txid();
|
||||
else
|
||||
{
|
||||
if(sub_protocol==Q282||sub_protocol==Q242)
|
||||
packet_length = Q282_PACKET_SIZE;
|
||||
else
|
||||
packet_length = CX10_PACKET_SIZE;
|
||||
packet_period = CX10_PACKET_PERIOD;
|
||||
phase = CX10_BIND1;
|
||||
bind_counter = CX10_BIND_COUNT;
|
||||
}
|
||||
CX10_initialize_txid();
|
||||
CX10_init();
|
||||
phase = CX10_INIT1;
|
||||
BIND_IN_PROGRESS; // autobind protocol
|
||||
return INITIAL_WAIT;
|
||||
return CX10_INITIAL_WAIT+packet_period;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
#include "iface_cyrf6936.h"
|
||||
|
||||
void cyrf_spi_write(uint8_t command)
|
||||
static void cyrf_spi_write(uint8_t command)
|
||||
{
|
||||
uint8_t n=8;
|
||||
SCK_off;//SCK start low
|
||||
@@ -32,7 +32,7 @@ void cyrf_spi_write(uint8_t command)
|
||||
SDI_on;
|
||||
}
|
||||
|
||||
uint8_t cyrf_spi_read()
|
||||
static uint8_t cyrf_spi_read()
|
||||
{
|
||||
uint8_t result;
|
||||
uint8_t i;
|
||||
@@ -59,7 +59,7 @@ void CYRF_WriteRegister(uint8_t address, uint8_t data)
|
||||
CYRF_CSN_on;
|
||||
}
|
||||
|
||||
void CYRF_WriteRegisterMulti(uint8_t address, const uint8_t data[], uint8_t length)
|
||||
static void CYRF_WriteRegisterMulti(uint8_t address, const uint8_t data[], uint8_t length)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
@@ -70,7 +70,7 @@ void CYRF_WriteRegisterMulti(uint8_t address, const uint8_t data[], uint8_t leng
|
||||
CYRF_CSN_on;
|
||||
}
|
||||
|
||||
void CYRF_ReadRegisterMulti(uint8_t address, uint8_t data[], uint8_t length)
|
||||
static void CYRF_ReadRegisterMulti(uint8_t address, uint8_t data[], uint8_t length)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
@@ -149,11 +149,13 @@ void CYRF_ConfigRFChannel(uint8_t ch)
|
||||
CYRF_WriteRegister(CYRF_00_CHANNEL,ch);
|
||||
}
|
||||
|
||||
void CYRF_SetPower_Value(uint8_t power)
|
||||
/*
|
||||
static void CYRF_SetPower_Value(uint8_t power)
|
||||
{
|
||||
uint8_t val = CYRF_ReadRegister(CYRF_03_TX_CFG) & 0xF8;
|
||||
CYRF_WriteRegister(CYRF_03_TX_CFG, val | (power & 0x07));
|
||||
}
|
||||
*/
|
||||
|
||||
void CYRF_SetPower(uint8_t val)
|
||||
{
|
||||
@@ -203,22 +205,22 @@ void CYRF_WritePreamble(uint32_t preamble)
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void CYRF_StartReceive()
|
||||
static void CYRF_StartReceive()
|
||||
{
|
||||
CYRF_WriteRegister(CYRF_05_RX_CTRL,0x87);
|
||||
}
|
||||
|
||||
void CYRF_ReadDataPacket(uint8_t dpbuffer[])
|
||||
/*static void CYRF_ReadDataPacket(uint8_t dpbuffer[])
|
||||
{
|
||||
CYRF_ReadRegisterMulti(CYRF_21_RX_BUFFER, dpbuffer, 0x10);
|
||||
}
|
||||
|
||||
void CYRF_ReadDataPacketLen(uint8_t dpbuffer[], uint8_t length)
|
||||
*/
|
||||
/*static void CYRF_ReadDataPacketLen(uint8_t dpbuffer[], uint8_t length)
|
||||
{
|
||||
ReadRegisterMulti(CYRF_21_RX_BUFFER, dpbuffer, length);
|
||||
}
|
||||
|
||||
void CYRF_WriteDataPacketLen(const uint8_t dpbuffer[], uint8_t len)
|
||||
*/
|
||||
static void CYRF_WriteDataPacketLen(const uint8_t dpbuffer[], uint8_t len)
|
||||
{
|
||||
CYRF_WriteRegister(CYRF_01_TX_LENGTH, len);
|
||||
CYRF_WriteRegister(CYRF_02_TX_CTRL, 0x40);
|
||||
@@ -231,7 +233,7 @@ void CYRF_WriteDataPacket(const uint8_t dpbuffer[])
|
||||
CYRF_WriteDataPacketLen(dpbuffer, 16);
|
||||
}
|
||||
|
||||
uint8_t CYRF_ReadRSSI(uint8_t dodummyread)
|
||||
/*static uint8_t CYRF_ReadRSSI(uint8_t dodummyread)
|
||||
{
|
||||
uint8_t result;
|
||||
if(dodummyread)
|
||||
@@ -241,7 +243,7 @@ uint8_t CYRF_ReadRSSI(uint8_t dodummyread)
|
||||
result = CYRF_ReadRegister(CYRF_13_RSSI);
|
||||
return (result & 0x0F);
|
||||
}
|
||||
|
||||
*/
|
||||
//NOTE: This routine will reset the CRC Seed
|
||||
void CYRF_FindBestChannels(uint8_t *channels, uint8_t len, uint8_t minspace, uint8_t min, uint8_t max)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
#include "iface_cyrf6936.h"
|
||||
|
||||
#define DSM2_NUM_CHANNELS 7
|
||||
#define RANDOM_CHANNELS 0 // disabled
|
||||
//#define RANDOM_CHANNELS 1 // enabled
|
||||
#define BIND_CHANNEL 0x0d //13 This can be any odd channel
|
||||
@@ -42,8 +41,7 @@ enum {
|
||||
DSM2_CH2_READ_B = BIND_COUNT1 + 10,
|
||||
};
|
||||
|
||||
|
||||
const uint8_t pncodes[5][9][8] = {
|
||||
const uint8_t PROGMEM pncodes[5][9][8] = {
|
||||
/* Note these are in order transmitted (LSB 1st) */
|
||||
{ /* Row 0 */
|
||||
/* Col 0 */ {0x03, 0xBC, 0x6E, 0x8A, 0xEF, 0xBD, 0xFE, 0xF8},
|
||||
@@ -102,6 +100,12 @@ const uint8_t pncodes[5][9][8] = {
|
||||
},
|
||||
};
|
||||
|
||||
static void __attribute__((unused)) read_code(uint8_t *buf, uint8_t row, uint8_t col, uint8_t len)
|
||||
{
|
||||
for(uint8_t i=0;i<len;i++)
|
||||
buf[i]=pgm_read_byte_near( &pncodes[row][col][i] );
|
||||
}
|
||||
|
||||
//
|
||||
uint8_t chidx;
|
||||
uint8_t sop_col;
|
||||
@@ -109,26 +113,15 @@ uint8_t data_col;
|
||||
uint16_t cyrf_state;
|
||||
uint8_t crcidx;
|
||||
uint8_t binding;
|
||||
uint16_t crc;
|
||||
uint8_t model;
|
||||
|
||||
/*
|
||||
#ifdef USE_FIXED_MFGID
|
||||
const uint8_t cyrfmfg_id[6] = {0x5e, 0x28, 0xa3, 0x1b, 0x00, 0x00}; //dx8
|
||||
const uint8_t cyrfmfg_id[6] = {0xd4, 0x62, 0xd6, 0xad, 0xd3, 0xff}; //dx6i
|
||||
#else
|
||||
//uint8_t cyrfmfg_id[6];
|
||||
#endif
|
||||
*/
|
||||
|
||||
void build_bind_packet()
|
||||
static void __attribute__((unused)) build_bind_packet()
|
||||
{
|
||||
uint8_t i;
|
||||
uint16_t sum = 384 - 0x10;//
|
||||
packet[0] = crc >> 8;
|
||||
packet[1] = crc & 0xff;
|
||||
packet[2] = 0xff ^ cyrfmfg_id[2];
|
||||
packet[3] = (0xff ^ cyrfmfg_id[3]) + model;
|
||||
packet[3] = (0xff ^ cyrfmfg_id[3]) + RX_num;
|
||||
packet[4] = packet[0];
|
||||
packet[5] = packet[1];
|
||||
packet[6] = packet[2];
|
||||
@@ -138,15 +131,11 @@ void build_bind_packet()
|
||||
packet[8] = sum >> 8;
|
||||
packet[9] = sum & 0xff;
|
||||
packet[10] = 0x01; //???
|
||||
packet[11] = DSM2_NUM_CHANNELS;
|
||||
packet[11] = option>3?option:option+4;
|
||||
if(sub_protocol==DSMX) //DSMX type
|
||||
packet[12] = 0xb2; // Telemetry off: packet[12] = num_channels < 8 && Model.proto_opts[PROTOOPTS_TELEMETRY] == TELEM_OFF ? 0xa2 : 0xb2;
|
||||
else
|
||||
#if DSM2_NUM_CHANNELS < 8
|
||||
packet[12] = 0x01;
|
||||
#else
|
||||
packet[12] = 0x02;
|
||||
#endif
|
||||
packet[12] = option<8?0x01:0x02;
|
||||
packet[13] = 0x00; //???
|
||||
for(i = 8; i < 14; i++)
|
||||
sum += packet[i];
|
||||
@@ -154,46 +143,66 @@ void build_bind_packet()
|
||||
packet[15] = sum & 0xff;
|
||||
}
|
||||
|
||||
void build_data_packet(uint8_t upper)//
|
||||
static uint8_t __attribute__((unused)) PROTOCOL_SticksMoved(uint8_t init)
|
||||
{
|
||||
#if DSM2_NUM_CHANNELS==4
|
||||
const uint8_t ch_map[] = {0, 1, 2, 3, 0xff, 0xff, 0xff}; //Guess
|
||||
#elif DSM2_NUM_CHANNELS==5
|
||||
const uint8_t ch_map[] = {0, 1, 2, 3, 4, 0xff, 0xff}; //Guess
|
||||
#elif DSM2_NUM_CHANNELS==6
|
||||
const uint8_t ch_map[] = {1, 5, 2, 3, 0, 4, 0xff}; //HP6DSM
|
||||
#elif DSM2_NUM_CHANNELS==7
|
||||
const uint8_t ch_map[] = {1, 5, 2, 4, 3, 6, 0}; //DX6i
|
||||
#elif DSM2_NUM_CHANNELS==8
|
||||
const uint8_t ch_map[] = {1, 5, 2, 3, 6, 0xff, 0xff, 4, 0, 7, 0xff, 0xff, 0xff, 0xff}; //DX8
|
||||
#elif DSM2_NUM_CHANNELS==9
|
||||
const uint8_t ch_map[] = {3, 2, 1, 5, 0, 4, 6, 7, 8, 0xff, 0xff, 0xff, 0xff, 0xff}; //DM9
|
||||
#elif DSM2_NUM_CHANNELS==10
|
||||
const uint8_t ch_map[] = {3, 2, 1, 5, 0, 4, 6, 7, 8, 9, 0xff, 0xff, 0xff, 0xff};
|
||||
#elif DSM2_NUM_CHANNELS==11
|
||||
const uint8_t ch_map[] = {3, 2, 1, 5, 0, 4, 6, 7, 8, 9, 10, 0xff, 0xff, 0xff};
|
||||
#elif DSM2_NUM_CHANNELS==12
|
||||
const uint8_t ch_map[] = {3, 2, 1, 5, 0, 4, 6, 7, 8, 9, 10, 11, 0xff, 0xff};
|
||||
#endif
|
||||
#define STICK_MOVEMENT 15*(PPM_MAX-PPM_MIN)/100 // defines when the bind dialog should be interrupted (stick movement STICK_MOVEMENT %)
|
||||
static uint16_t ele_start, ail_start;
|
||||
uint16_t ele = Servo_data[ELEVATOR];//CHAN_ReadInput(MIXER_MapChannel(INP_ELEVATOR));
|
||||
uint16_t ail = Servo_data[AILERON];//CHAN_ReadInput(MIXER_MapChannel(INP_AILERON));
|
||||
if(init) {
|
||||
ele_start = ele;
|
||||
ail_start = ail;
|
||||
return 0;
|
||||
}
|
||||
uint16_t ele_diff = ele_start - ele;//abs(ele_start - ele);
|
||||
uint16_t ail_diff = ail_start - ail;//abs(ail_start - ail);
|
||||
return ((ele_diff + ail_diff) > STICK_MOVEMENT);//
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) build_data_packet(uint8_t upper)//
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t bits;
|
||||
|
||||
uint8_t ch_map[] = {3, 2, 1, 5, 0, 4, 6, 7, 8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; //9 Channels - DM9 TX
|
||||
switch(option>3?option:option+4) // Create channel map based on number of channels
|
||||
{
|
||||
case 12:
|
||||
ch_map[11]=11; // 12 channels
|
||||
case 11:
|
||||
ch_map[10]=10; // 11 channels
|
||||
case 10:
|
||||
ch_map[9]=9; // 10 channels
|
||||
break;
|
||||
case 8:
|
||||
memcpy(ch_map,"\x01\x05\x02\x03\x06\xFF\xFF\x04\x00\x07",10); // 8 channels - DX8 TX
|
||||
break;
|
||||
case 7:
|
||||
memcpy(ch_map,"\x01\x05\x02\x04\x03\x06\x00",7); // 7 channels - DX6i TX
|
||||
break;
|
||||
case 6:
|
||||
memcpy(ch_map,"\x01\x05\x02\x03\x00\x04\xFF",7); // 6 channels - HP6DSM TX
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
memcpy(ch_map,"\x00\x01\x02\x03\xFF\xFF\xFF",7); // 4 channels - Guess
|
||||
if(option&0x01)
|
||||
ch_map[4]=4; // 5 channels - Guess
|
||||
break;
|
||||
}
|
||||
//
|
||||
if( binding && PROTOCOL_SticksMoved(0) )
|
||||
{
|
||||
//BIND_DONE;
|
||||
binding = 0;
|
||||
}
|
||||
if (sub_protocol==DSMX)
|
||||
{
|
||||
packet[0] = cyrfmfg_id[2];
|
||||
packet[1] = cyrfmfg_id[3] + model;
|
||||
packet[1] = cyrfmfg_id[3] + RX_num;
|
||||
bits=11;
|
||||
}
|
||||
else
|
||||
{
|
||||
packet[0] = (0xff ^ cyrfmfg_id[2]);
|
||||
packet[1] = (0xff ^ cyrfmfg_id[3]) + model;
|
||||
packet[1] = (0xff ^ cyrfmfg_id[3]) + RX_num;
|
||||
bits=10;
|
||||
}
|
||||
//
|
||||
@@ -252,23 +261,7 @@ void build_data_packet(uint8_t upper)//
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t PROTOCOL_SticksMoved(uint8_t init)
|
||||
{
|
||||
#define STICK_MOVEMENT 15*(PPM_MAX-PPM_MIN)/100 // defines when the bind dialog should be interrupted (stick movement STICK_MOVEMENT %)
|
||||
static uint16_t ele_start, ail_start;
|
||||
uint16_t ele = Servo_data[ELEVATOR];//CHAN_ReadInput(MIXER_MapChannel(INP_ELEVATOR));
|
||||
uint16_t ail = Servo_data[AILERON];//CHAN_ReadInput(MIXER_MapChannel(INP_AILERON));
|
||||
if(init) {
|
||||
ele_start = ele;
|
||||
ail_start = ail;
|
||||
return 0;
|
||||
}
|
||||
uint16_t ele_diff = ele_start - ele;//abs(ele_start - ele);
|
||||
uint16_t ail_diff = ail_start - ail;//abs(ail_start - ail);
|
||||
return ((ele_diff + ail_diff) > STICK_MOVEMENT);//
|
||||
}
|
||||
|
||||
uint8_t get_pn_row(uint8_t channel)
|
||||
static uint8_t __attribute__((unused)) get_pn_row(uint8_t channel)
|
||||
{
|
||||
return (sub_protocol == DSMX ? (channel - 2) % 5 : channel % 5);
|
||||
}
|
||||
@@ -300,7 +293,7 @@ const uint8_t init_vals[][2] = {
|
||||
{CYRF_01_TX_LENGTH, 0x10}, //16byte packet
|
||||
};
|
||||
|
||||
void cyrf_config()
|
||||
static void __attribute__((unused)) cyrf_config()
|
||||
{
|
||||
for(uint8_t i = 0; i < sizeof(init_vals) / 2; i++)
|
||||
CYRF_WriteRegister(init_vals[i][0], init_vals[i][1]);
|
||||
@@ -308,19 +301,22 @@ void cyrf_config()
|
||||
CYRF_ConfigRFChannel(0x61);
|
||||
}
|
||||
|
||||
void initialize_bind_state()
|
||||
static void __attribute__((unused)) initialize_bind_state()
|
||||
{
|
||||
const uint8_t pn_bind[] = { 0xc6,0x94,0x22,0xfe,0x48,0xe6,0x57,0x4e };
|
||||
uint8_t data_code[32];
|
||||
uint8_t code[32];
|
||||
|
||||
CYRF_ConfigRFChannel(BIND_CHANNEL); //This seems to be random?
|
||||
uint8_t pn_row = get_pn_row(BIND_CHANNEL);
|
||||
//printf("Ch: %d Row: %d SOP: %d Data: %d\n", BIND_CHANNEL, pn_row, sop_col, data_col);
|
||||
CYRF_ConfigCRCSeed(crc);
|
||||
CYRF_ConfigSOPCode(pncodes[pn_row][sop_col]);
|
||||
memcpy(data_code, pncodes[pn_row][data_col], 16);
|
||||
memcpy(data_code + 16, pncodes[0][8], 8);
|
||||
memcpy(data_code + 24, pn_bind, 8);
|
||||
CYRF_ConfigDataCode(data_code, 32);
|
||||
|
||||
read_code(code,pn_row,sop_col,8);
|
||||
CYRF_ConfigSOPCode(code);
|
||||
read_code(code,pn_row,data_col,16);
|
||||
read_code(code+16,0,8,8);
|
||||
memcpy(code + 24, "\xc6\x94\x22\xfe\x48\xe6\x57\x4e", 8);
|
||||
CYRF_ConfigDataCode(code, 32);
|
||||
|
||||
build_bind_packet();
|
||||
}
|
||||
|
||||
@@ -342,20 +338,25 @@ const uint8_t data_vals[][2] = {
|
||||
{CYRF_10_FRAMING_CFG, 0xea},
|
||||
};
|
||||
|
||||
void cyrf_configdata()
|
||||
static void __attribute__((unused)) cyrf_configdata()
|
||||
{
|
||||
for(uint8_t i = 0; i < sizeof(data_vals) / 2; i++)
|
||||
CYRF_WriteRegister(data_vals[i][0], data_vals[i][1]);
|
||||
}
|
||||
|
||||
void set_sop_data_crc()
|
||||
static void __attribute__((unused)) set_sop_data_crc()
|
||||
{
|
||||
uint8_t code[16];
|
||||
uint8_t pn_row = get_pn_row(hopping_frequency[chidx]);
|
||||
//printf("Ch: %d Row: %d SOP: %d Data: %d\n", ch[chidx], pn_row, sop_col, data_col);
|
||||
CYRF_ConfigRFChannel(hopping_frequency[chidx]);
|
||||
CYRF_ConfigCRCSeed(crcidx ? ~crc : crc);
|
||||
CYRF_ConfigSOPCode(pncodes[pn_row][sop_col]);
|
||||
CYRF_ConfigDataCode(pncodes[pn_row][data_col], 16);
|
||||
|
||||
read_code(code,pn_row,sop_col,8);
|
||||
CYRF_ConfigSOPCode(code);
|
||||
read_code(code,pn_row,data_col,16);
|
||||
CYRF_ConfigDataCode(code, 16);
|
||||
|
||||
if(sub_protocol == DSMX)
|
||||
chidx = (chidx + 1) % 23;
|
||||
else
|
||||
@@ -363,7 +364,7 @@ void set_sop_data_crc()
|
||||
crcidx = !crcidx;
|
||||
}
|
||||
|
||||
void calc_dsmx_channel()
|
||||
static void __attribute__((unused)) calc_dsmx_channel()
|
||||
{
|
||||
uint8_t idx = 0;
|
||||
uint32_t id = ~(((uint32_t)cyrfmfg_id[0] << 24) | ((uint32_t)cyrfmfg_id[1] << 16) | ((uint32_t)cyrfmfg_id[2] << 8) | (cyrfmfg_id[3] << 0));
|
||||
@@ -461,12 +462,16 @@ uint16_t ReadDsm2()
|
||||
set_sop_data_crc();
|
||||
if (cyrf_state == DSM2_CH2_CHECK_A)
|
||||
{
|
||||
#if DSM2_NUM_CHANNELS < 8
|
||||
cyrf_state = DSM2_CH1_WRITE_A; // change from CH2_CHECK_A to CH1_WRITE_A (ie no upper)
|
||||
return 11000 - CH1_CH2_DELAY - WRITE_DELAY ; // Original is 22000 from deviation but it works better this way
|
||||
#else
|
||||
cyrf_state = DSM2_CH1_WRITE_B; // change from CH2_CHECK_A to CH1_WRITE_A (to transmit upper)
|
||||
#endif
|
||||
if(option < 8)
|
||||
{
|
||||
cyrf_state = DSM2_CH1_WRITE_A; // change from CH2_CHECK_A to CH1_WRITE_A (ie no upper)
|
||||
if(option>3)
|
||||
return 11000 - CH1_CH2_DELAY - WRITE_DELAY ; // force 11ms if option>3 ie 4,5,6,7 channels @11ms
|
||||
else
|
||||
return 22000 - CH1_CH2_DELAY - WRITE_DELAY ; // normal 22ms mode if option<=3 ie 4,5,6,7 channels @22ms
|
||||
}
|
||||
else
|
||||
cyrf_state = DSM2_CH1_WRITE_B; // change from CH2_CHECK_A to CH1_WRITE_A (to transmit upper)
|
||||
}
|
||||
else
|
||||
cyrf_state = DSM2_CH1_WRITE_A; // change from CH2_CHECK_B to CH1_WRITE_A (upper already transmitted so transmit lower)
|
||||
@@ -513,8 +518,6 @@ uint16_t initDsm2()
|
||||
sop_col = (cyrfmfg_id[0] + cyrfmfg_id[1] + cyrfmfg_id[2] + 2) & 0x07;//Ok
|
||||
data_col = 7 - sop_col;//ok
|
||||
|
||||
model=MProtocol_id-MProtocol_id_master; // RxNum for serial or 0 for ppm
|
||||
|
||||
CYRF_SetTxRxMode(TX_EN);
|
||||
//
|
||||
if(IS_AUTOBIND_FLAG_on)
|
||||
|
||||
@@ -66,7 +66,7 @@ uint8_t ch_idx;
|
||||
uint8_t use_fixed_id;
|
||||
uint8_t failsafe_pkt;
|
||||
|
||||
void scramble_pkt()
|
||||
static void __attribute__((unused)) scramble_pkt()
|
||||
{
|
||||
#ifdef NO_SCRAMBLE
|
||||
return;
|
||||
@@ -77,7 +77,7 @@ void scramble_pkt()
|
||||
#endif
|
||||
}
|
||||
|
||||
void add_pkt_suffix()
|
||||
static void __attribute__((unused)) add_pkt_suffix()
|
||||
{
|
||||
uint8_t bind_state;
|
||||
if (use_fixed_id)
|
||||
@@ -97,7 +97,7 @@ void add_pkt_suffix()
|
||||
packet[15] = (fixed_id >> 16) & 0xff;
|
||||
}
|
||||
|
||||
void build_beacon_pkt(uint8_t upper)
|
||||
static void __attribute__((unused)) build_beacon_pkt(uint8_t upper)
|
||||
{
|
||||
packet[0] = ((DEVO_NUM_CHANNELS << 4) | 0x07);
|
||||
// uint8_t enable = 0;
|
||||
@@ -116,7 +116,7 @@ void build_beacon_pkt(uint8_t upper)
|
||||
add_pkt_suffix();
|
||||
}
|
||||
|
||||
void build_bind_pkt()
|
||||
static void __attribute__((unused)) build_bind_pkt()
|
||||
{
|
||||
packet[0] = (DEVO_NUM_CHANNELS << 4) | 0x0a;
|
||||
packet[1] = bind_counter & 0xff;
|
||||
@@ -136,7 +136,7 @@ void build_bind_pkt()
|
||||
packet[15] ^= cyrfmfg_id[2];
|
||||
}
|
||||
|
||||
void build_data_pkt()
|
||||
static void __attribute__((unused)) build_data_pkt()
|
||||
{
|
||||
uint8_t i;
|
||||
packet[0] = (DEVO_NUM_CHANNELS << 4) | (0x0b + ch_idx);
|
||||
@@ -161,7 +161,7 @@ void build_data_pkt()
|
||||
add_pkt_suffix();
|
||||
}
|
||||
|
||||
void cyrf_set_bound_sop_code()
|
||||
static void __attribute__((unused)) cyrf_set_bound_sop_code()
|
||||
{
|
||||
/* crc == 0 isn't allowed, so use 1 if the math results in 0 */
|
||||
uint8_t crc = (cyrfmfg_id[0] + (cyrfmfg_id[1] >> 6) + cyrfmfg_id[2]);
|
||||
@@ -174,7 +174,7 @@ void cyrf_set_bound_sop_code()
|
||||
CYRF_SetPower(0x08);
|
||||
}
|
||||
|
||||
void cyrf_init()
|
||||
static void __attribute__((unused)) cyrf_init()
|
||||
{
|
||||
/* Initialise CYRF chip */
|
||||
CYRF_WriteRegister(CYRF_1D_MODE_OVERRIDE, 0x39);
|
||||
@@ -201,7 +201,7 @@ void cyrf_init()
|
||||
CYRF_WriteRegister(CYRF_0F_XACT_CFG, 0x28);
|
||||
}
|
||||
|
||||
void set_radio_channels()
|
||||
static void __attribute__((unused)) set_radio_channels()
|
||||
{
|
||||
//int i;
|
||||
CYRF_FindBestChannels(hopping_frequency, 3, 4, 4, 80);
|
||||
@@ -217,7 +217,7 @@ void set_radio_channels()
|
||||
hopping_frequency[4] = hopping_frequency[1];
|
||||
}
|
||||
|
||||
void DEVO_BuildPacket()
|
||||
static void __attribute__((unused)) DEVO_BuildPacket()
|
||||
{
|
||||
switch(phase)
|
||||
{
|
||||
@@ -302,7 +302,7 @@ uint16_t devo_callback()
|
||||
return 1200;
|
||||
}
|
||||
|
||||
void devo_bind()
|
||||
/*static void __attribute__((unused)) devo_bind()
|
||||
{
|
||||
fixed_id = Model_fixed_id;
|
||||
bind_counter = DEVO_BIND_COUNT;
|
||||
@@ -310,8 +310,8 @@ void devo_bind()
|
||||
//PROTOCOL_SetBindState(0x1388 * 2400 / 1000); //msecs 12000ms
|
||||
}
|
||||
|
||||
/*
|
||||
void generate_fixed_id_bind(){
|
||||
|
||||
static void __attribute__((unused)) generate_fixed_id_bind(){
|
||||
if(BIND_0){
|
||||
//randomSeed((uint32_t)analogRead(A6)<<10|analogRead(A7));//seed
|
||||
uint8_t txid[4];
|
||||
|
||||
171
Multiprotocol/ESky_nrf24l01.ino
Normal file
171
Multiprotocol/ESky_nrf24l01.ino
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
// Last sync with hexfet new_protocols/esky_nrf24l01.c dated 2015-02-13
|
||||
|
||||
#if defined(ESKY_NRF24L01_INO)
|
||||
|
||||
#include "iface_nrf24l01.h"
|
||||
|
||||
#define ESKY_BIND_COUNT 1000
|
||||
#define ESKY_PACKET_PERIOD 3333
|
||||
#define ESKY_PAYLOAD_SIZE 13
|
||||
#define ESKY_PACKET_CHKTIME 100 // Time to wait for packet to be sent (no ACK, so very short)
|
||||
|
||||
static void __attribute__((unused)) ESKY_set_data_address()
|
||||
{
|
||||
NRF24L01_WriteReg(NRF24L01_03_SETUP_AW, 0x02); // 4-byte RX/TX address for regular packets
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_0A_RX_ADDR_P0, rx_tx_addr, 4);
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, rx_tx_addr, 4);
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) ESKY_init(uint8_t bind)
|
||||
{
|
||||
NRF24L01_Initialize();
|
||||
|
||||
// 2-bytes CRC, radio off
|
||||
NRF24L01_WriteReg(NRF24L01_00_CONFIG, BV(NRF24L01_00_EN_CRC) | BV(NRF24L01_00_CRCO));
|
||||
NRF24L01_WriteReg(NRF24L01_01_EN_AA, 0x00); // No Auto Acknowledgement
|
||||
NRF24L01_WriteReg(NRF24L01_02_EN_RXADDR, 0x01); // Enable data pipe 0
|
||||
if (bind)
|
||||
{
|
||||
NRF24L01_WriteReg(NRF24L01_03_SETUP_AW, 0x01); // 3-byte RX/TX address for bind packets
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_0A_RX_ADDR_P0, (uint8_t*)"\x00\x00\x00", 3);
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, (uint8_t*)"\x00\x00\x00", 3);
|
||||
}
|
||||
else
|
||||
ESKY_set_data_address();
|
||||
NRF24L01_WriteReg(NRF24L01_04_SETUP_RETR, 0); // No auto retransmission
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, 50); // Channel 50 for bind packets
|
||||
NRF24L01_SetBitrate(NRF24L01_BR_1M); // 1Mbps
|
||||
NRF24L01_SetPower();
|
||||
NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70); // Clear data ready, data sent, and retransmit
|
||||
NRF24L01_WriteReg(NRF24L01_11_RX_PW_P0, ESKY_PAYLOAD_SIZE); // bytes of data payload for pipe 0
|
||||
NRF24L01_WriteReg(NRF24L01_12_RX_PW_P1, ESKY_PAYLOAD_SIZE);
|
||||
NRF24L01_WriteReg(NRF24L01_13_RX_PW_P2, ESKY_PAYLOAD_SIZE);
|
||||
NRF24L01_WriteReg(NRF24L01_14_RX_PW_P3, ESKY_PAYLOAD_SIZE);
|
||||
NRF24L01_WriteReg(NRF24L01_15_RX_PW_P4, ESKY_PAYLOAD_SIZE);
|
||||
NRF24L01_WriteReg(NRF24L01_16_RX_PW_P5, ESKY_PAYLOAD_SIZE);
|
||||
NRF24L01_WriteReg(NRF24L01_17_FIFO_STATUS, 0x00); // Just in case, no real bits to write here
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) ESKY_init2()
|
||||
{
|
||||
NRF24L01_FlushTx();
|
||||
packet_sent = 0;
|
||||
hopping_frequency_no = 0;
|
||||
uint16_t channel_ord = rx_tx_addr[0] % 74;
|
||||
hopping_frequency[12] = 10 + (uint8_t)channel_ord; //channel_code
|
||||
uint8_t channel1, channel2;
|
||||
channel1 = 10 + (uint8_t)((37 + channel_ord*5) % 74);
|
||||
channel2 = 10 + (uint8_t)(( channel_ord*5) % 74) ;
|
||||
|
||||
hopping_frequency[0] = channel1;
|
||||
hopping_frequency[1] = channel1;
|
||||
hopping_frequency[2] = channel1;
|
||||
hopping_frequency[3] = channel2;
|
||||
hopping_frequency[4] = channel2;
|
||||
hopping_frequency[5] = channel2;
|
||||
|
||||
//end_bytes
|
||||
hopping_frequency[6] = 6;
|
||||
hopping_frequency[7] = channel1*2;
|
||||
hopping_frequency[8] = channel2*2;
|
||||
hopping_frequency[9] = 6;
|
||||
hopping_frequency[10] = channel1*2;
|
||||
hopping_frequency[11] = channel2*2;
|
||||
|
||||
// Turn radio power on
|
||||
NRF24L01_SetTxRxMode(TX_EN);
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) ESKY_send_packet(uint8_t bind)
|
||||
{
|
||||
uint8_t rf_ch = 50; // bind channel
|
||||
if (bind)
|
||||
{
|
||||
// Bind packet
|
||||
packet[0] = rx_tx_addr[2];
|
||||
packet[1] = rx_tx_addr[1];
|
||||
packet[2] = rx_tx_addr[0];
|
||||
packet[3] = hopping_frequency[12]; // channel_code encodes pair of channels to transmit on
|
||||
packet[4] = 0x18;
|
||||
packet[5] = 0x29;
|
||||
packet[6] = 0;
|
||||
packet[7] = 0;
|
||||
packet[8] = 0;
|
||||
packet[9] = 0;
|
||||
packet[10] = 0;
|
||||
packet[11] = 0;
|
||||
packet[12] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Regular packet
|
||||
// Each data packet is repeated 3 times on one channel, and 3 times on another channel
|
||||
// For arithmetic simplicity, channels are repeated in rf_channels array
|
||||
if (hopping_frequency_no == 0)
|
||||
{
|
||||
const uint8_t ch[]={AILERON, ELEVATOR, THROTTLE, RUDDER, AUX1, AUX2};
|
||||
for (uint8_t i = 0; i < 6; i++)
|
||||
{
|
||||
packet[i*2] = Servo_data[ch[i]]>>8; //high byte of servo timing(1000-2000us)
|
||||
packet[i*2+1] = Servo_data[ch[i]]&0xFF; //low byte of servo timing(1000-2000us)
|
||||
}
|
||||
}
|
||||
rf_ch = hopping_frequency[hopping_frequency_no];
|
||||
packet[12] = hopping_frequency[hopping_frequency_no+6]; // end_bytes
|
||||
hopping_frequency_no++;
|
||||
if (hopping_frequency_no > 6) hopping_frequency_no = 0;
|
||||
}
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, rf_ch);
|
||||
NRF24L01_FlushTx();
|
||||
NRF24L01_WritePayload(packet, ESKY_PAYLOAD_SIZE);
|
||||
packet_sent = 1;
|
||||
if (! rf_ch_num)
|
||||
NRF24L01_SetPower(); //Keep transmit power updated
|
||||
}
|
||||
|
||||
uint16_t ESKY_callback()
|
||||
{
|
||||
if(IS_BIND_DONE_on)
|
||||
{
|
||||
if (packet_sent && NRF24L01_packet_ack() != PKT_ACKED)
|
||||
return ESKY_PACKET_CHKTIME;
|
||||
ESKY_send_packet(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (packet_sent && NRF24L01_packet_ack() != PKT_ACKED)
|
||||
return ESKY_PACKET_CHKTIME;
|
||||
ESKY_send_packet(1);
|
||||
if (--bind_counter == 0)
|
||||
{
|
||||
ESKY_set_data_address();
|
||||
BIND_DONE;
|
||||
}
|
||||
}
|
||||
return ESKY_PACKET_PERIOD;
|
||||
}
|
||||
|
||||
uint16_t initESKY(void)
|
||||
{
|
||||
bind_counter = ESKY_BIND_COUNT;
|
||||
rx_tx_addr[3] = 0xBB;
|
||||
ESKY_init(IS_AUTOBIND_FLAG_on);
|
||||
ESKY_init2();
|
||||
return 50000;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -12,6 +12,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// Last sync with hexfet new_protocols/flysky_a7105.c dated 2015-09-28
|
||||
|
||||
#if defined(FLYSKY_A7105_INO)
|
||||
|
||||
@@ -44,7 +45,7 @@ enum {
|
||||
FLAG_V9X9_VIDEO = 0x40,
|
||||
FLAG_V9X9_CAMERA= 0x80,
|
||||
// flags going to byte 12
|
||||
FLAG_V9X9_UNK = 0x10, // undocumented ?
|
||||
FLAG_V9X9_FLIP = 0x10,
|
||||
FLAG_V9X9_LED = 0x20,
|
||||
};
|
||||
|
||||
@@ -72,44 +73,45 @@ uint8_t chanrow;
|
||||
uint8_t chancol;
|
||||
uint8_t chanoffset;
|
||||
|
||||
void flysky_apply_extension_flags()
|
||||
static void __attribute__((unused)) flysky_apply_extension_flags()
|
||||
{
|
||||
const uint8_t V912_X17_SEQ[10] = { 0x14, 0x31, 0x40, 0x49, 0x49, // sometime first byte is 0x15 ?
|
||||
0x49, 0x49, 0x49, 0x49, 0x49, };
|
||||
static uint8_t seq_counter;
|
||||
switch(sub_protocol) {
|
||||
switch(sub_protocol)
|
||||
{
|
||||
case V9X9:
|
||||
if(Servo_data[AUX1] > PPM_SWITCH)
|
||||
packet[12] |= FLAG_V9X9_UNK;
|
||||
if(Servo_data[AUX2] > PPM_SWITCH)
|
||||
if(Servo_AUX1)
|
||||
packet[12] |= FLAG_V9X9_FLIP;
|
||||
if(Servo_AUX2)
|
||||
packet[12] |= FLAG_V9X9_LED;
|
||||
if(Servo_data[AUX3] > PPM_SWITCH)
|
||||
if(Servo_AUX3)
|
||||
packet[10] |= FLAG_V9X9_CAMERA;
|
||||
if(Servo_data[AUX4] > PPM_SWITCH)
|
||||
if(Servo_AUX4)
|
||||
packet[10] |= FLAG_V9X9_VIDEO;
|
||||
break;
|
||||
|
||||
case V6X6:
|
||||
packet[13] = 0x03; // 3 = 100% rate (0=40%, 1=60%, 2=80%)
|
||||
packet[14] = 0x00;
|
||||
if(Servo_data[AUX1] > PPM_SWITCH)
|
||||
if(Servo_AUX1)
|
||||
packet[14] |= FLAG_V6X6_FLIP;
|
||||
if(Servo_data[AUX2] > PPM_SWITCH)
|
||||
if(Servo_AUX2)
|
||||
packet[14] |= FLAG_V6X6_LED;
|
||||
if(Servo_data[AUX3] > PPM_SWITCH)
|
||||
if(Servo_AUX3)
|
||||
packet[14] |= FLAG_V6X6_CAMERA;
|
||||
if(Servo_data[AUX4] > PPM_SWITCH)
|
||||
if(Servo_AUX4)
|
||||
packet[14] |= FLAG_V6X6_VIDEO;
|
||||
if(Servo_data[AUX5] > PPM_SWITCH)
|
||||
if(Servo_AUX5)
|
||||
{
|
||||
packet[13] |= FLAG_V6X6_HLESS1;
|
||||
packet[14] |= FLAG_V6X6_HLESS2;
|
||||
}
|
||||
if(Servo_data[AUX6] > PPM_SWITCH) //use option to manipulate these bytes
|
||||
if(Servo_AUX6) //use option to manipulate these bytes
|
||||
packet[14] |= FLAG_V6X6_RTH;
|
||||
if(Servo_data[AUX7] > PPM_SWITCH)
|
||||
if(Servo_AUX7)
|
||||
packet[14] |= FLAG_V6X6_XCAL;
|
||||
if(Servo_data[AUX8] > PPM_SWITCH)
|
||||
if(Servo_AUX8)
|
||||
packet[14] |= FLAG_V6X6_YCAL;
|
||||
packet[15] = 0x10; // unknown
|
||||
packet[16] = 0x10; // unknown
|
||||
@@ -126,9 +128,9 @@ void flysky_apply_extension_flags()
|
||||
packet[12] |= 0x20; // bit 6 is always set ?
|
||||
packet[13] = 0x00; // unknown
|
||||
packet[14] = 0x00;
|
||||
if(Servo_data[AUX1] > PPM_SWITCH)
|
||||
packet[14] |= FLAG_V912_BTMBTN;
|
||||
if(Servo_data[AUX2] > PPM_SWITCH)
|
||||
if(Servo_AUX1)
|
||||
packet[14] = FLAG_V912_BTMBTN;
|
||||
if(Servo_AUX2)
|
||||
packet[14] |= FLAG_V912_TOPBTN;
|
||||
packet[15] = 0x27; // [15] and [16] apparently hold an analog channel with a value lower than 1000
|
||||
packet[16] = 0x03; // maybe it's there for a pitch channel for a CP copter ?
|
||||
@@ -146,7 +148,7 @@ void flysky_apply_extension_flags()
|
||||
}
|
||||
}
|
||||
|
||||
void flysky_build_packet(uint8_t init)
|
||||
static void __attribute__((unused)) flysky_build_packet(uint8_t init)
|
||||
{
|
||||
uint8_t i;
|
||||
//servodata timing range for flysky.
|
||||
@@ -159,7 +161,7 @@ void flysky_build_packet(uint8_t init)
|
||||
packet[2] = rx_tx_addr[2];
|
||||
packet[3] = rx_tx_addr[1];
|
||||
packet[4] = rx_tx_addr[0];
|
||||
uint8_t ch[]={AILERON, ELEVATOR, THROTTLE, RUDDER, AUX1, AUX2, AUX3, AUX4};
|
||||
const uint8_t ch[]={AILERON, ELEVATOR, THROTTLE, RUDDER, AUX1, AUX2, AUX3, AUX4};
|
||||
for(i = 0; i < 8; i++)
|
||||
{
|
||||
packet[5+2*i]=lowByte(Servo_data[ch[i]]); //low byte of servo timing(1000-2000us)
|
||||
|
||||
@@ -1,21 +1,309 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
/* **************************
|
||||
* By Midelic on RCGroups *
|
||||
**************************
|
||||
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(FRSKYX_CC2500_INO)
|
||||
|
||||
#include "iface_cc2500.h"
|
||||
|
||||
uint8_t chanskip;
|
||||
uint8_t calData[48][3];
|
||||
uint8_t channr;
|
||||
uint8_t pass_ = 1 ;
|
||||
uint8_t counter_rst;
|
||||
uint8_t ctr;
|
||||
uint8_t FS_flag=0;
|
||||
// uint8_t ptr[4]={0x01,0x12,0x23,0x30};
|
||||
//uint8_t ptr[4]={0x00,0x11,0x22,0x33};
|
||||
|
||||
const PROGMEM uint8_t hop_data[]={
|
||||
0x02, 0xD4, 0xBB, 0xA2, 0x89,
|
||||
0x70, 0x57, 0x3E, 0x25, 0x0C,
|
||||
0xDE, 0xC5, 0xAC, 0x93, 0x7A,
|
||||
0x61, 0x48, 0x2F, 0x16, 0xE8,
|
||||
0xCF, 0xB6, 0x9D, 0x84, 0x6B,
|
||||
0x52, 0x39, 0x20, 0x07, 0xD9,
|
||||
0xC0, 0xA7, 0x8E, 0x75, 0x5C,
|
||||
0x43, 0x2A, 0x11, 0xE3, 0xCA,
|
||||
0xB1, 0x98, 0x7F, 0x66, 0x4D,
|
||||
0x34, 0x1B, 0x00, 0x1D, 0x03
|
||||
};
|
||||
|
||||
#include "iface_cc2500.h"
|
||||
static uint8_t __attribute__((unused)) hop(uint8_t byte)
|
||||
{
|
||||
return pgm_read_byte_near(&hop_data[byte]);
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) set_start(uint8_t ch )
|
||||
{
|
||||
cc2500_strobe(CC2500_SIDLE);
|
||||
cc2500_writeReg(CC2500_23_FSCAL3, calData[ch][0]);
|
||||
cc2500_writeReg(CC2500_24_FSCAL2, calData[ch][1]);
|
||||
cc2500_writeReg(CC2500_25_FSCAL1, calData[ch][2]);
|
||||
cc2500_writeReg(CC2500_0A_CHANNR, ch==47?0:pgm_read_word(&hop_data[ch]));
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) frskyX_init()
|
||||
{
|
||||
CC2500_Reset();
|
||||
|
||||
for(uint8_t i=0;i<36;i++)
|
||||
{
|
||||
uint8_t reg=pgm_read_byte_near(&cc2500_conf[i][0]);
|
||||
uint8_t val=pgm_read_byte_near(&cc2500_conf[i][1]);
|
||||
|
||||
if(reg==CC2500_06_PKTLEN)
|
||||
val=0x1E;
|
||||
else
|
||||
if(reg==CC2500_08_PKTCTRL0)
|
||||
val=0x01;
|
||||
else
|
||||
if(reg==CC2500_0B_FSCTRL1)
|
||||
val=0x0A;
|
||||
else
|
||||
if(reg==CC2500_10_MDMCFG4)
|
||||
val=0x7B;
|
||||
else
|
||||
if(reg==CC2500_11_MDMCFG3)
|
||||
val=0x61;
|
||||
else
|
||||
if(reg==CC2500_12_MDMCFG2)
|
||||
val=0x13;
|
||||
else
|
||||
if(reg==CC2500_15_DEVIATN)
|
||||
val=0x51;
|
||||
|
||||
cc2500_writeReg(reg,val);
|
||||
}
|
||||
|
||||
#endif
|
||||
cc2500_writeReg(CC2500_07_PKTCTRL1, 0x04);
|
||||
cc2500_writeReg(CC2500_0C_FSCTRL0, option);
|
||||
cc2500_strobe(CC2500_SIDLE);
|
||||
//
|
||||
for(uint8_t c=0;c < 47;c++){//calibrate hop channels
|
||||
cc2500_strobe(CC2500_SIDLE);
|
||||
cc2500_writeReg(CC2500_0A_CHANNR,pgm_read_word(&hop_data[c]));
|
||||
cc2500_strobe(CC2500_SCAL);
|
||||
delayMicroseconds(900);//
|
||||
calData[c][0] = cc2500_readReg(CC2500_23_FSCAL3);
|
||||
calData[c][1] = cc2500_readReg(CC2500_24_FSCAL2);
|
||||
calData[c][2] = cc2500_readReg(CC2500_25_FSCAL1);
|
||||
}
|
||||
cc2500_strobe(CC2500_SIDLE);
|
||||
cc2500_writeReg(CC2500_0A_CHANNR,0x00);
|
||||
cc2500_strobe(CC2500_SCAL);
|
||||
delayMicroseconds(900);
|
||||
calData[47][0] = cc2500_readReg(CC2500_23_FSCAL3);
|
||||
calData[47][1] = cc2500_readReg(CC2500_24_FSCAL2);
|
||||
calData[47][2] = cc2500_readReg(CC2500_25_FSCAL1);
|
||||
//#######END INIT########
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) initialize_data(uint8_t adr)
|
||||
{
|
||||
cc2500_writeReg(CC2500_0C_FSCTRL0,option); // Frequency offset hack
|
||||
cc2500_writeReg(CC2500_18_MCSM0, 0x8);
|
||||
cc2500_writeReg(CC2500_09_ADDR, adr ? 0x03 : rx_tx_addr[3]);
|
||||
cc2500_writeReg(CC2500_07_PKTCTRL1,0x05);
|
||||
}
|
||||
|
||||
static uint8_t __attribute__((unused)) crc_Byte( uint8_t byte )
|
||||
{
|
||||
crc = (crc<<8) ^ pgm_read_word(&CRCTable[((uint8_t)(crc>>8) ^ byte) & 0xFF]);
|
||||
return byte;
|
||||
}
|
||||
|
||||
static uint16_t __attribute__((unused)) scaleForPXX( uint8_t i )
|
||||
{ //mapped 860,2140(125%) range to 64,1984(PXX values);
|
||||
return (uint16_t)(((Servo_data[i]-PPM_MIN)*3)>>1)+64;
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) frskyX_build_bind_packet()
|
||||
{
|
||||
crc=0;
|
||||
packet[0] = 0x1D;
|
||||
packet[1] = 0x03;
|
||||
packet[2] = 0x01;
|
||||
//
|
||||
packet[3] = crc_Byte(rx_tx_addr[3]);
|
||||
packet[4] = crc_Byte(rx_tx_addr[2]);
|
||||
int idx = ((state -FRSKY_BIND) % 10) * 5;
|
||||
packet[5] = crc_Byte(idx);
|
||||
packet[6] = crc_Byte(pgm_read_word(&hop_data[idx++]));
|
||||
packet[7] = crc_Byte(pgm_read_word(&hop_data[idx++]));
|
||||
packet[8] = crc_Byte(pgm_read_word(&hop_data[idx++]));
|
||||
packet[9] = crc_Byte(pgm_read_word(&hop_data[idx++]));
|
||||
packet[10] = crc_Byte(pgm_read_word(&hop_data[idx++]));
|
||||
packet[11] = crc_Byte(0x02);
|
||||
packet[12] = crc_Byte(RX_num);
|
||||
//
|
||||
for(uint8_t i=13;i<28;i++)
|
||||
packet[i]=crc_Byte(0);
|
||||
//
|
||||
packet[28]=highByte(crc);
|
||||
packet[29]=lowByte(crc);
|
||||
//
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) frskyX_data_frame()
|
||||
{
|
||||
//0x1D 0xB3 0xFD 0x02 0x56 0x07 0x15 0x00 0x00 0x00 0x04 0x40 0x00 0x04 0x40 0x00 0x04 0x40 0x00 0x04 0x40 0x08 0x00 0x00 0x00 0x00 0x00 0x00 0x96 0x12
|
||||
//
|
||||
uint8_t lpass = pass_ ;
|
||||
uint16_t chan_0 ;
|
||||
uint16_t chan_1 ;
|
||||
uint8_t flag2 = 0;
|
||||
uint8_t startChan = 0;
|
||||
crc = 0;
|
||||
//static uint8_t p = 0;
|
||||
//
|
||||
packet[0] = 0x1D;
|
||||
packet[1] = rx_tx_addr[3];
|
||||
packet[2] = rx_tx_addr[2];
|
||||
packet[3] = crc_Byte(0x02);
|
||||
//
|
||||
packet[4] = crc_Byte((ctr<<6)+channr); //*64
|
||||
packet[5] = crc_Byte(counter_rst);
|
||||
packet[6] = crc_Byte(RX_num);
|
||||
// FLAGS 00 - standard packet
|
||||
//10, 12, 14, 16, 18, 1A, 1C, 1E - failsafe packet
|
||||
//20 - range check packet
|
||||
packet[7] = crc_Byte(FS_flag);
|
||||
packet[8] = crc_Byte(flag2);
|
||||
//
|
||||
if ( lpass & 1 )
|
||||
startChan += 8 ;
|
||||
|
||||
for(uint8_t i = 0; i <12 ; i+=3)
|
||||
{//12 bytes
|
||||
chan_0 = scaleForPXX(startChan);
|
||||
if(lpass & 1 )
|
||||
chan_0+=2048;
|
||||
|
||||
packet[9+i] = crc_Byte(lowByte(chan_0));//3 bytes*4
|
||||
startChan++;
|
||||
chan_1 = scaleForPXX(startChan);
|
||||
if(lpass & 1 )
|
||||
chan_1+= 2048;
|
||||
|
||||
startChan++;
|
||||
packet[9+i+1]=crc_Byte((((chan_0>>8) & 0x0F)|(chan_1 << 4)));
|
||||
packet[9+i+2]=crc_Byte(chan_1>>4);
|
||||
}
|
||||
//packet[21]=crc_Byte(0x08);//first
|
||||
packet[21]=crc_Byte(0x80);//??? when received first telemetry frame is changed to 0x80
|
||||
//packet[21]=crc_Byte(ptr[p]);//???
|
||||
//p=(p+1)%4;//repeating 4 bytes sequence pattern every 4th frame.
|
||||
|
||||
pass_=lpass+1;
|
||||
|
||||
for (uint8_t i=22;i<28;i++)
|
||||
packet[i]=crc_Byte(0);
|
||||
|
||||
packet[28]=highByte(crc);
|
||||
packet[29]=lowByte(crc);
|
||||
}
|
||||
|
||||
uint16_t ReadFrSkyX()
|
||||
{
|
||||
switch(state)
|
||||
{
|
||||
default:
|
||||
set_start(47);
|
||||
CC2500_SetPower();
|
||||
cc2500_strobe(CC2500_SFRX);
|
||||
//
|
||||
frskyX_build_bind_packet();
|
||||
cc2500_strobe(CC2500_SIDLE);
|
||||
cc2500_writeFifo(packet, packet[0]+1);
|
||||
state++;
|
||||
return 9000;
|
||||
case FRSKY_BIND_DONE:
|
||||
initialize_data(0);
|
||||
channr=0;
|
||||
BIND_DONE;
|
||||
state++;
|
||||
break;
|
||||
case FRSKY_DATA1:
|
||||
LED_ON;
|
||||
CC2500_SetTxRxMode(TX_EN);
|
||||
set_start(channr);
|
||||
CC2500_SetPower();
|
||||
cc2500_strobe(CC2500_SFRX);
|
||||
channr = (channr+chanskip)%47;
|
||||
cc2500_strobe(CC2500_SIDLE);
|
||||
cc2500_writeFifo(packet, packet[0]+1);
|
||||
//
|
||||
frskyX_data_frame();
|
||||
state++;
|
||||
return 5500;
|
||||
case FRSKY_DATA2:
|
||||
CC2500_SetTxRxMode(RX_EN);
|
||||
cc2500_strobe(CC2500_SIDLE);
|
||||
state++;
|
||||
return 200;
|
||||
case FRSKY_DATA3:
|
||||
cc2500_strobe(CC2500_SRX);
|
||||
state++;
|
||||
return 3000;
|
||||
case FRSKY_DATA4:
|
||||
len = cc2500_readReg(CC2500_3B_RXBYTES | CC2500_READ_BURST) & 0x7F;
|
||||
if (len &&(len<MAX_PKT))
|
||||
{
|
||||
cc2500_readFifo(pkt, len);
|
||||
#if defined TELEMETRY
|
||||
frsky_check_telemetry(pkt,len); //check if valid telemetry packets
|
||||
//parse telemetry packets here
|
||||
//The same telemetry function used by FrSky(D8).
|
||||
#endif
|
||||
}
|
||||
state = FRSKY_DATA1;
|
||||
return 300;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint16_t initFrSkyX()
|
||||
{
|
||||
while(!chanskip)
|
||||
{
|
||||
randomSeed((uint32_t)analogRead(A6) << 10 | analogRead(A7));
|
||||
chanskip=random(0xfefefefe)%47;
|
||||
}
|
||||
while((chanskip-ctr)%4)
|
||||
ctr=(ctr+1)%4;
|
||||
|
||||
counter_rst=(chanskip-ctr)>>2;
|
||||
//for test***************
|
||||
//rx_tx_addr[3]=0xB3;
|
||||
//rx_tx_addr[2]=0xFD;
|
||||
//************************
|
||||
frskyX_init();
|
||||
//
|
||||
if(IS_AUTOBIND_FLAG_on)
|
||||
{
|
||||
state = FRSKY_BIND;
|
||||
initialize_data(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
state = FRSKY_DATA1;
|
||||
initialize_data(0);
|
||||
}
|
||||
return 10000;
|
||||
}
|
||||
#endif
|
||||
@@ -18,9 +18,10 @@
|
||||
#include "iface_cc2500.h"
|
||||
|
||||
//##########Variables########
|
||||
uint32_t state;
|
||||
uint8_t len;
|
||||
//uint32_t state;
|
||||
//uint8_t len;
|
||||
|
||||
/*
|
||||
enum {
|
||||
FRSKY_BIND = 0,
|
||||
FRSKY_BIND_DONE = 1000,
|
||||
@@ -30,6 +31,112 @@ enum {
|
||||
FRSKY_DATA4,
|
||||
FRSKY_DATA5
|
||||
};
|
||||
*/
|
||||
|
||||
static void __attribute__((unused)) frsky2way_init(uint8_t bind)
|
||||
{
|
||||
// Configure cc2500 for tx mode
|
||||
CC2500_Reset();
|
||||
//
|
||||
for(uint8_t i=0;i<36;i++)
|
||||
{
|
||||
uint8_t reg=pgm_read_byte_near(&cc2500_conf[i][0]);
|
||||
uint8_t val=pgm_read_byte_near(&cc2500_conf[i][1]);
|
||||
|
||||
if(reg==CC2500_0C_FSCTRL0)
|
||||
val=option;
|
||||
else
|
||||
if(reg==CC2500_1B_AGCCTRL2)
|
||||
val=bind ? 0x43 : 0x03;
|
||||
cc2500_writeReg(reg,val);
|
||||
}
|
||||
|
||||
CC2500_SetTxRxMode(TX_EN);
|
||||
CC2500_SetPower();
|
||||
|
||||
cc2500_strobe(CC2500_SIDLE);
|
||||
|
||||
cc2500_writeReg(CC2500_09_ADDR, bind ? 0x03 : rx_tx_addr[3]);
|
||||
cc2500_writeReg(CC2500_07_PKTCTRL1, 0x05);
|
||||
cc2500_strobe(CC2500_SIDLE); // Go to idle...
|
||||
//
|
||||
cc2500_writeReg(CC2500_0A_CHANNR, 0x00);
|
||||
cc2500_writeReg(CC2500_23_FSCAL3, 0x89);
|
||||
cc2500_strobe(CC2500_SFRX);
|
||||
//#######END INIT########
|
||||
}
|
||||
|
||||
static uint8_t __attribute__((unused)) get_chan_num(uint16_t idx)
|
||||
{
|
||||
uint8_t ret = (idx * 0x1e) % 0xeb;
|
||||
if(idx == 3 || idx == 23 || idx == 47)
|
||||
ret++;
|
||||
if(idx > 47)
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) frsky2way_build_bind_packet()
|
||||
{
|
||||
//11 03 01 d7 2d 00 00 1e 3c 5b 78 00 00 00 00 00 00 01
|
||||
//11 03 01 19 3e 00 02 8e 2f bb 5c 00 00 00 00 00 00 01
|
||||
packet[0] = 0x11;
|
||||
packet[1] = 0x03;
|
||||
packet[2] = 0x01;
|
||||
packet[3] = rx_tx_addr[3];
|
||||
packet[4] = rx_tx_addr[2];
|
||||
uint16_t idx = ((state -FRSKY_BIND) % 10) * 5;
|
||||
packet[5] = idx;
|
||||
packet[6] = get_chan_num(idx++);
|
||||
packet[7] = get_chan_num(idx++);
|
||||
packet[8] = get_chan_num(idx++);
|
||||
packet[9] = get_chan_num(idx++);
|
||||
packet[10] = get_chan_num(idx++);
|
||||
packet[11] = 0x00;
|
||||
packet[12] = 0x00;
|
||||
packet[13] = 0x00;
|
||||
packet[14] = 0x00;
|
||||
packet[15] = 0x00;
|
||||
packet[16] = 0x00;
|
||||
packet[17] = 0x01;
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) frsky2way_data_frame()
|
||||
{//pachet[4] is telemetry user frame counter(hub)
|
||||
//11 d7 2d 22 00 01 c9 c9 ca ca 88 88 ca ca c9 ca 88 88
|
||||
//11 57 12 00 00 01 f2 f2 f2 f2 06 06 ca ca ca ca 18 18
|
||||
packet[0] = 0x11; //Length
|
||||
packet[1] = rx_tx_addr[3];
|
||||
packet[2] = rx_tx_addr[2];
|
||||
packet[3] = counter;//
|
||||
#if defined TELEMETRY
|
||||
packet[4] = telemetry_counter;
|
||||
#else
|
||||
packet[4] = 0x00;
|
||||
#endif
|
||||
|
||||
packet[5] = 0x01;
|
||||
//
|
||||
packet[10] = 0;
|
||||
packet[11] = 0;
|
||||
packet[16] = 0;
|
||||
packet[17] = 0;
|
||||
for(uint8_t i = 0; i < 8; i++)
|
||||
{
|
||||
uint16_t value;
|
||||
value = convert_channel_frsky(i);
|
||||
if(i < 4)
|
||||
{
|
||||
packet[6+i] = value & 0xff;
|
||||
packet[10+(i>>1)] |= ((value >> 8) & 0x0f) << (4 *(i & 0x01));
|
||||
}
|
||||
else
|
||||
{
|
||||
packet[8+i] = value & 0xff;
|
||||
packet[16+((i-4)>>1)] |= ((value >> 8) & 0x0f) << (4 * ((i-4) & 0x01));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t initFrSky_2way()
|
||||
{
|
||||
@@ -88,12 +195,12 @@ uint16_t ReadFrSky_2way()
|
||||
if (state == FRSKY_DATA1)
|
||||
{
|
||||
len = cc2500_readReg(CC2500_3B_RXBYTES | CC2500_READ_BURST) & 0x7F;
|
||||
if (len)//20 bytes
|
||||
if (len<=MAX_PKT)//27 bytes
|
||||
{
|
||||
cc2500_readFifo(pkt, len); //received telemetry packets
|
||||
#if defined(TELEMETRY)
|
||||
//parse telemetry packet here
|
||||
check_telemetry(pkt,len); //check if valid telemetry packets and buffer them.
|
||||
frsky_check_telemetry(pkt,len); //check if valid telemetry packets and buffer them.
|
||||
#endif
|
||||
}
|
||||
CC2500_SetTxRxMode(TX_EN);
|
||||
@@ -109,161 +216,4 @@ uint16_t ReadFrSky_2way()
|
||||
}
|
||||
return state == FRSKY_DATA4 ? 7500 : 9000;
|
||||
}
|
||||
|
||||
#if defined(TELEMETRY)
|
||||
void check_telemetry(uint8_t *pkt,uint8_t len)
|
||||
{
|
||||
if(pkt[1] != rx_tx_addr[3] || pkt[2] != rx_tx_addr[2] || len != pkt[0] + 3)
|
||||
{//only packets with the required id and packet length
|
||||
for(uint8_t i=3;i<6;i++)
|
||||
pktt[i]=0;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (uint8_t i=3;i<len;i++)
|
||||
pktt[i]=pkt[i];
|
||||
telemetry_link=1;
|
||||
}
|
||||
}
|
||||
|
||||
void compute_RSSIdbm(){
|
||||
if(pktt[len-2] >=128){
|
||||
RSSI_dBm =(((uint16_t)(pktt[len-2])*18)>>5)- 82;
|
||||
}
|
||||
else{
|
||||
RSSI_dBm = (((uint16_t)(pktt[len-2])*18)>>5)+65;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void frsky2way_init(uint8_t bind)
|
||||
{
|
||||
// Configure cc2500 for tx mode
|
||||
CC2500_Reset();
|
||||
//
|
||||
cc2500_writeReg(CC2500_02_IOCFG0, 0x06);
|
||||
cc2500_writeReg(CC2500_00_IOCFG2, 0x06);
|
||||
cc2500_writeReg(CC2500_17_MCSM1, 0x0c);
|
||||
cc2500_writeReg(CC2500_18_MCSM0, 0x18);
|
||||
cc2500_writeReg(CC2500_06_PKTLEN, 0x19);
|
||||
cc2500_writeReg(CC2500_07_PKTCTRL1, 0x04);
|
||||
cc2500_writeReg(CC2500_08_PKTCTRL0, 0x05);
|
||||
cc2500_writeReg(CC2500_3E_PATABLE, 0xff);
|
||||
cc2500_writeReg(CC2500_0B_FSCTRL1, 0x08);
|
||||
cc2500_writeReg(CC2500_0C_FSCTRL0, fine);
|
||||
//base freq FREQ = 0x5C7627 (F = 2404MHz)
|
||||
cc2500_writeReg(CC2500_0D_FREQ2, 0x5c);
|
||||
cc2500_writeReg(CC2500_0E_FREQ1, 0x76);
|
||||
cc2500_writeReg(CC2500_0F_FREQ0, 0x27);
|
||||
//
|
||||
cc2500_writeReg(CC2500_10_MDMCFG4, 0xAA);
|
||||
cc2500_writeReg(CC2500_11_MDMCFG3, 0x39);
|
||||
cc2500_writeReg(CC2500_12_MDMCFG2, 0x11);
|
||||
cc2500_writeReg(CC2500_13_MDMCFG1, 0x23);
|
||||
cc2500_writeReg(CC2500_14_MDMCFG0, 0x7a);
|
||||
cc2500_writeReg(CC2500_15_DEVIATN, 0x42);
|
||||
cc2500_writeReg(CC2500_19_FOCCFG, 0x16);
|
||||
cc2500_writeReg(CC2500_1A_BSCFG, 0x6c);
|
||||
cc2500_writeReg(CC2500_1B_AGCCTRL2, bind ? 0x43 : 0x03);
|
||||
cc2500_writeReg(CC2500_1C_AGCCTRL1,0x40);
|
||||
cc2500_writeReg(CC2500_1D_AGCCTRL0,0x91);
|
||||
cc2500_writeReg(CC2500_21_FREND1, 0x56);
|
||||
cc2500_writeReg(CC2500_22_FREND0, 0x10);
|
||||
cc2500_writeReg(CC2500_23_FSCAL3, 0xa9);
|
||||
cc2500_writeReg(CC2500_24_FSCAL2, 0x0A);
|
||||
cc2500_writeReg(CC2500_25_FSCAL1, 0x00);
|
||||
cc2500_writeReg(CC2500_26_FSCAL0, 0x11);
|
||||
cc2500_writeReg(CC2500_29_FSTEST, 0x59);
|
||||
cc2500_writeReg(CC2500_2C_TEST2, 0x88);
|
||||
cc2500_writeReg(CC2500_2D_TEST1, 0x31);
|
||||
cc2500_writeReg(CC2500_2E_TEST0, 0x0B);
|
||||
cc2500_writeReg(CC2500_03_FIFOTHR, 0x07);
|
||||
cc2500_writeReg(CC2500_09_ADDR, 0x00);
|
||||
//
|
||||
CC2500_SetTxRxMode(TX_EN);
|
||||
CC2500_SetPower();
|
||||
|
||||
cc2500_strobe(CC2500_SIDLE);
|
||||
|
||||
cc2500_writeReg(CC2500_09_ADDR, bind ? 0x03 : rx_tx_addr[3]);
|
||||
cc2500_writeReg(CC2500_07_PKTCTRL1, 0x05);
|
||||
cc2500_strobe(CC2500_SIDLE); // Go to idle...
|
||||
//
|
||||
cc2500_writeReg(CC2500_0A_CHANNR, 0x00);
|
||||
cc2500_writeReg(CC2500_23_FSCAL3, 0x89);
|
||||
cc2500_strobe(CC2500_SFRX);
|
||||
//#######END INIT########
|
||||
}
|
||||
|
||||
uint8_t get_chan_num(uint16_t idx)
|
||||
{
|
||||
uint8_t ret = (idx * 0x1e) % 0xeb;
|
||||
if(idx == 3 || idx == 23 || idx == 47)
|
||||
ret++;
|
||||
if(idx > 47)
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void frsky2way_build_bind_packet()
|
||||
{
|
||||
//11 03 01 d7 2d 00 00 1e 3c 5b 78 00 00 00 00 00 00 01
|
||||
//11 03 01 19 3e 00 02 8e 2f bb 5c 00 00 00 00 00 00 01
|
||||
packet[0] = 0x11;
|
||||
packet[1] = 0x03;
|
||||
packet[2] = 0x01;
|
||||
packet[3] = rx_tx_addr[3];
|
||||
packet[4] = rx_tx_addr[2];
|
||||
uint16_t idx = ((state -FRSKY_BIND) % 10) * 5;
|
||||
packet[5] = idx;
|
||||
packet[6] = get_chan_num(idx++);
|
||||
packet[7] = get_chan_num(idx++);
|
||||
packet[8] = get_chan_num(idx++);
|
||||
packet[9] = get_chan_num(idx++);
|
||||
packet[10] = get_chan_num(idx++);
|
||||
packet[11] = 0x00;
|
||||
packet[12] = 0x00;
|
||||
packet[13] = 0x00;
|
||||
packet[14] = 0x00;
|
||||
packet[15] = 0x00;
|
||||
packet[16] = 0x00;
|
||||
packet[17] = 0x01;
|
||||
}
|
||||
|
||||
uint8_t telemetry_counter=0;
|
||||
|
||||
void frsky2way_data_frame()
|
||||
{//pachet[4] is telemetry user frame counter(hub)
|
||||
//11 d7 2d 22 00 01 c9 c9 ca ca 88 88 ca ca c9 ca 88 88
|
||||
//11 57 12 00 00 01 f2 f2 f2 f2 06 06 ca ca ca ca 18 18
|
||||
packet[0] = 0x11; //Length
|
||||
packet[1] = rx_tx_addr[3];
|
||||
packet[2] = rx_tx_addr[2];
|
||||
packet[3] = counter;//
|
||||
packet[4] = pkt[6]?(telemetry_counter++)%32:0;
|
||||
packet[5] = 0x01;
|
||||
//
|
||||
packet[10] = 0;
|
||||
packet[11] = 0;
|
||||
packet[16] = 0;
|
||||
packet[17] = 0;
|
||||
for(uint8_t i = 0; i < 8; i++)
|
||||
{
|
||||
uint16_t value;
|
||||
value = convert_channel_frsky(i);
|
||||
if(i < 4)
|
||||
{
|
||||
packet[6+i] = value & 0xff;
|
||||
packet[10+(i>>1)] |= ((value >> 8) & 0x0f) << (4 *(i & 0x01));
|
||||
}
|
||||
else
|
||||
{
|
||||
packet[8+i] = value & 0xff;
|
||||
packet[16+((i-4)>>1)] |= ((value >> 8) & 0x0f) << (4 * ((i-4) & 0x01));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,26 +12,27 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// Last sync with hexfet new_protocols/hisky_nrf24l01.c dated 2015-03-27
|
||||
|
||||
#if defined(HISKY_NRF24L01_INO)
|
||||
|
||||
#include "iface_nrf24l01.h"
|
||||
|
||||
#define BIND_COUNT 1000
|
||||
#define TXID_SIZE 5
|
||||
#define FREQUENCE_NUM 20
|
||||
#define HISKY_BIND_COUNT 1000
|
||||
#define HISKY_TXID_SIZE 5
|
||||
#define HISKY_FREQUENCE_NUM 20
|
||||
//
|
||||
uint8_t bind_buf_arry[4][10];
|
||||
|
||||
// HiSky protocol uses TX id as an address for nRF24L01, and uses frequency hopping sequence
|
||||
// which does not depend on this id and is passed explicitly in binding sequence. So we are free
|
||||
// to generate this sequence as we wish. It should be in the range [02..77]
|
||||
void calc_fh_channels(uint32_t seed)
|
||||
static void __attribute__((unused)) calc_fh_channels()
|
||||
{
|
||||
uint8_t idx = 0;
|
||||
uint32_t rnd = seed;
|
||||
uint32_t rnd = MProtocol_id;
|
||||
|
||||
while (idx < FREQUENCE_NUM)
|
||||
while (idx < HISKY_FREQUENCE_NUM)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t count_2_26 = 0, count_27_50 = 0, count_51_74 = 0;
|
||||
@@ -40,7 +41,7 @@ void calc_fh_channels(uint32_t seed)
|
||||
// Use least-significant byte. 73 is prime, so channels 76..77 are unused
|
||||
uint8_t next_ch = ((rnd >> 8) % 73) + 2;
|
||||
// Keep the distance 2 between the channels - either odd or even
|
||||
if (((next_ch ^ (uint8_t)seed) & 0x01 )== 0)
|
||||
if (((next_ch ^ (uint8_t)rx_tx_addr[3]) & 0x01 )== 0)
|
||||
continue;
|
||||
// Check that it's not duplicated and spread uniformly
|
||||
for (i = 0; i < idx; i++) {
|
||||
@@ -60,7 +61,7 @@ void calc_fh_channels(uint32_t seed)
|
||||
}
|
||||
}
|
||||
|
||||
void build_binding_packet(void)
|
||||
static void __attribute__((unused)) build_binding_packet(void)
|
||||
{
|
||||
uint8_t i;
|
||||
uint16_t sum=0;
|
||||
@@ -94,7 +95,7 @@ void build_binding_packet(void)
|
||||
}
|
||||
}
|
||||
|
||||
void hisky_init()
|
||||
static void __attribute__((unused)) hisky_init()
|
||||
{
|
||||
NRF24L01_Initialize();
|
||||
|
||||
@@ -115,11 +116,11 @@ void hisky_init()
|
||||
|
||||
// HiSky channel sequence: AILE ELEV THRO RUDD GEAR PITCH, channel data value is from 0 to 1000
|
||||
// Channel 7 - Gyro mode, 0 - 6 axis, 3 - 3 axis
|
||||
void build_ch_data()
|
||||
static void __attribute__((unused)) build_ch_data()
|
||||
{
|
||||
uint16_t temp;
|
||||
uint8_t i,j;
|
||||
uint8_t ch[]={AILERON, ELEVATOR, THROTTLE, RUDDER, AUX1, AUX2, AUX3, AUX4};
|
||||
const uint8_t ch[]={AILERON, ELEVATOR, THROTTLE, RUDDER, AUX1, AUX2, AUX3, AUX4};
|
||||
for (i = 0; i< 8; i++) {
|
||||
j=ch[i];
|
||||
temp=map(limit_channel_100(j),PPM_MIN_100,PPM_MAX_100,0,1000);
|
||||
@@ -143,10 +144,14 @@ uint16_t hisky_cb()
|
||||
NRF24L01_SetPower();
|
||||
phase=2;
|
||||
break;
|
||||
case 3:
|
||||
if (! bind_counter)
|
||||
NRF24L01_WritePayload(packet,10); // 2 packets per 5ms
|
||||
break;
|
||||
case 4:
|
||||
phase=6;
|
||||
break;
|
||||
case 7: // build packet and send failsafe every 100ms
|
||||
case 7: // build packet with failsafe every 100ms
|
||||
convert_channel_HK310(hopping_frequency_no!=0?RUDDER:AUX2,&packet[0],&packet[1]);
|
||||
convert_channel_HK310(hopping_frequency_no!=0?THROTTLE:AUX3,&packet[2],&packet[3]);
|
||||
convert_channel_HK310(hopping_frequency_no!=0?AUX1:AUX4,&packet[4],&packet[5]);
|
||||
@@ -194,7 +199,7 @@ uint16_t hisky_cb()
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, rx_tx_addr, 5);
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, hopping_frequency[hopping_frequency_no]);
|
||||
hopping_frequency_no++;
|
||||
if (hopping_frequency_no >= FREQUENCE_NUM)
|
||||
if (hopping_frequency_no >= HISKY_FREQUENCE_NUM)
|
||||
hopping_frequency_no = 0;
|
||||
break;
|
||||
case 7:
|
||||
@@ -212,15 +217,19 @@ uint16_t hisky_cb()
|
||||
return 1000; // send 1 binding packet and 1 data packet per 9ms
|
||||
}
|
||||
|
||||
// Generate internal id from TX id and manufacturer id (STM32 unique id)
|
||||
void initialize_tx_id()
|
||||
static void __attribute__((unused)) initialize_tx_id()
|
||||
{
|
||||
//Generate frequency hopping table
|
||||
if(sub_protocol==HK310)
|
||||
for(uint8_t i=0;i<FREQUENCE_NUM;i++)
|
||||
hopping_frequency[i]=i; // Sequential order hop channels...
|
||||
{
|
||||
// for HiSky surface protocol, the transmitter always generates hop channels in sequential order.
|
||||
// The transmitter only generates the first hop channel between 0 and 49. So the channel range is from 0 to 69.
|
||||
hopping_frequency_no=rx_tx_addr[0]%50;
|
||||
for(uint8_t i=0;i<HISKY_FREQUENCE_NUM;i++)
|
||||
hopping_frequency[i]=hopping_frequency_no++; // Sequential order hop channels...
|
||||
}
|
||||
else
|
||||
calc_fh_channels(MProtocol_id);
|
||||
calc_fh_channels();
|
||||
}
|
||||
|
||||
uint16_t initHiSky()
|
||||
@@ -233,7 +242,7 @@ uint16_t initHiSky()
|
||||
binding_idx = 0;
|
||||
|
||||
if(IS_AUTOBIND_FLAG_on)
|
||||
bind_counter = BIND_COUNT;
|
||||
bind_counter = HISKY_BIND_COUNT;
|
||||
else
|
||||
bind_counter = 0;
|
||||
return 1000;
|
||||
|
||||
@@ -12,19 +12,32 @@
|
||||
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 Hubsan H102D, H107/L/C/D and H107P/C+/D+
|
||||
// Last sync with hexfet new_protocols/hubsan_a7105.c dated 2015-12-11
|
||||
|
||||
#if defined(HUBSAN_A7105_INO)
|
||||
|
||||
#include "iface_a7105.h"
|
||||
|
||||
enum{
|
||||
HUBSAN_FLAG_VIDEO = 0x01, // record video
|
||||
HUBSAN_FLAG_FLIP = 0x08,
|
||||
HUBSAN_FLAG_LIGHT = 0x04
|
||||
// flags going to packet[9] (Normal)
|
||||
HUBSAN_FLAG_VIDEO= 0x01, // record video
|
||||
HUBSAN_FLAG_FLIP = 0x08, // enable flips
|
||||
HUBSAN_FLAG_LED = 0x04 // enable LEDs
|
||||
};
|
||||
|
||||
uint32_t sessionid;
|
||||
const uint32_t txid = 0xdb042679;
|
||||
enum{
|
||||
// flags going to packet[9] (Plus series)
|
||||
HUBSAN_FLAG_HEADLESS = 0x08, // headless mode
|
||||
};
|
||||
|
||||
enum{
|
||||
// flags going to packet[13] (Plus series)
|
||||
HUBSAN_FLAG_SNAPSHOT = 0x01,
|
||||
HUBSAN_FLAG_FLIP_PLUS = 0x80,
|
||||
};
|
||||
|
||||
uint32_t sessionid,id_data;
|
||||
|
||||
enum {
|
||||
BIND_1,
|
||||
@@ -43,7 +56,7 @@ enum {
|
||||
};
|
||||
#define WAIT_WRITE 0x80
|
||||
|
||||
void update_crc()
|
||||
static void __attribute__((unused)) hubsan_update_crc()
|
||||
{
|
||||
uint8_t sum = 0;
|
||||
for(uint8_t i = 0; i < 15; i++)
|
||||
@@ -51,93 +64,156 @@ void update_crc()
|
||||
packet[15] = (256 - (sum % 256)) & 0xFF;
|
||||
}
|
||||
|
||||
void hubsan_build_bind_packet(uint8_t state)
|
||||
static void __attribute__((unused)) hubsan_build_bind_packet(uint8_t bind_state)
|
||||
{
|
||||
packet[0] = state;
|
||||
static uint8_t handshake_counter;
|
||||
if(phase < BIND_7)
|
||||
handshake_counter = 0;
|
||||
memset(packet, 0, 16);
|
||||
packet[0] = bind_state;
|
||||
packet[1] = channel;
|
||||
packet[2] = (sessionid >> 24) & 0xFF;
|
||||
packet[3] = (sessionid >> 16) & 0xFF;
|
||||
packet[4] = (sessionid >> 8) & 0xFF;
|
||||
packet[5] = (sessionid >> 0) & 0xFF;
|
||||
packet[6] = 0x08;
|
||||
packet[7] = 0xe4;
|
||||
packet[8] = 0xea;
|
||||
packet[9] = 0x9e;
|
||||
packet[10] = 0x50;
|
||||
packet[11] = (txid >> 24) & 0xFF;
|
||||
packet[12] = (txid >> 16) & 0xFF;
|
||||
packet[13] = (txid >> 8) & 0xFF;
|
||||
packet[14] = (txid >> 0) & 0xFF;
|
||||
update_crc();
|
||||
if(id_data == ID_NORMAL)
|
||||
{
|
||||
packet[6] = 0x08;
|
||||
packet[7] = 0xe4;
|
||||
packet[8] = 0xea;
|
||||
packet[9] = 0x9e;
|
||||
packet[10] = 0x50;
|
||||
//const uint32_t txid = 0xdb042679;
|
||||
packet[11] = 0xDB;
|
||||
packet[12] = 0x04;
|
||||
packet[13] = 0x26;
|
||||
packet[14] = 0x79;
|
||||
}
|
||||
else
|
||||
{ //ID_PLUS
|
||||
if(phase >= BIND_3)
|
||||
{
|
||||
packet[7] = 0x62;
|
||||
packet[8] = 0x16;
|
||||
}
|
||||
if(phase == BIND_7)
|
||||
packet[2] = handshake_counter++;
|
||||
}
|
||||
hubsan_update_crc();
|
||||
}
|
||||
|
||||
//cc : throttle observed range: 0x00 - 0xFF (smaller is down)
|
||||
//ee : rudder observed range: 0x34 - 0xcc (smaller is right)52-204-60%
|
||||
//gg : elevator observed range: 0x3e - 0xbc (smaller is up)62-188 -50%
|
||||
//ii : aileron observed range: 0x45 - 0xc3 (smaller is right)69-195-50%
|
||||
void hubsan_build_packet()
|
||||
static void __attribute__((unused)) hubsan_build_packet()
|
||||
{
|
||||
static uint8_t vtx_freq = 0;
|
||||
memset(packet, 0, 16);
|
||||
if(vtx_freq != option || packet_count==100) // set vTX frequency (H107D)
|
||||
{
|
||||
vtx_freq = option;
|
||||
packet[0] = 0x40;
|
||||
packet[1] = (option>0xF2)?0x17:0x16;
|
||||
packet[2] = option+0x0D; // 5645 - 5900 MHz
|
||||
packet[0] = 0x40; // vtx data packet
|
||||
packet[1] = (vtx_freq>0xF2)?0x17:0x16;
|
||||
packet[2] = vtx_freq+0x0D; // 5645 - 5900 MHz
|
||||
packet[3] = 0x82;
|
||||
packet_count++;
|
||||
}
|
||||
else //20 00 00 00 80 00 7d 00 84 02 64 db 04 26 79 7b
|
||||
{
|
||||
packet[0] = 0x20;
|
||||
packet[2] = convert_channel_8b(THROTTLE);//throtle
|
||||
packet[0] = 0x20; // normal data packet
|
||||
packet[2] = convert_channel_8b(THROTTLE); //Throtle
|
||||
}
|
||||
packet[4] = 0xFF - convert_channel_8b(RUDDER);//Rudder is reversed
|
||||
packet[6] = 0xFF - convert_channel_8b(ELEVATOR); //Elevator is reversed
|
||||
packet[8] = convert_channel_8b(AILERON);//aileron
|
||||
if( packet_count < 100) {
|
||||
packet[9] = 0x02 | HUBSAN_FLAG_LIGHT | HUBSAN_FLAG_FLIP;
|
||||
packet_count++;
|
||||
packet[4] = 0xFF - convert_channel_8b(RUDDER); //Rudder is reversed
|
||||
packet[6] = 0xFF - convert_channel_8b(ELEVATOR); //Elevator is reversed
|
||||
packet[8] = convert_channel_8b(AILERON); //Aileron
|
||||
if(id_data == ID_NORMAL)
|
||||
{
|
||||
if( packet_count < 100)
|
||||
{
|
||||
packet[9] = 0x02 | HUBSAN_FLAG_LED | HUBSAN_FLAG_FLIP; // sends default value for the 100 first packets
|
||||
packet_count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
packet[9] = 0x02;
|
||||
// Channel 5
|
||||
if(Servo_AUX1) packet[9] |= HUBSAN_FLAG_FLIP;
|
||||
// Channel 6
|
||||
if(Servo_AUX2) packet[9] |= HUBSAN_FLAG_LED;
|
||||
// Channel 8
|
||||
if(Servo_AUX4) packet[9] |= HUBSAN_FLAG_VIDEO; // H102D
|
||||
}
|
||||
packet[10] = 0x64;
|
||||
//const uint32_t txid = 0xdb042679;
|
||||
packet[11] = 0xDB;
|
||||
packet[12] = 0x04;
|
||||
packet[13] = 0x26;
|
||||
packet[14] = 0x79;
|
||||
}
|
||||
else
|
||||
{
|
||||
packet[9] = 0x02;
|
||||
// Channel 5
|
||||
if( Servo_data[AUX1] >= PPM_SWITCH)
|
||||
packet[9] |= HUBSAN_FLAG_FLIP;
|
||||
// Channel 6
|
||||
if( Servo_data[AUX2] >= PPM_SWITCH)
|
||||
packet[9] |= HUBSAN_FLAG_LIGHT;
|
||||
// Channel 8
|
||||
if( Servo_data[AUX4] > PPM_SWITCH)
|
||||
packet[9] |= HUBSAN_FLAG_VIDEO;
|
||||
{ //ID_PLUS
|
||||
packet[3] = 0x64;
|
||||
packet[5] = 0x64;
|
||||
packet[7] = 0x64;
|
||||
packet[9] = 0x06;
|
||||
//FLIP|LIGHT|PICTURE|VIDEO|HEADLESS
|
||||
if(Servo_AUX4) packet[9] |= HUBSAN_FLAG_VIDEO;
|
||||
if(Servo_AUX5) packet[9] |= HUBSAN_FLAG_HEADLESS;
|
||||
packet[10]= 0x19;
|
||||
packet[12]= 0x5C; // ghost channel ?
|
||||
packet[13] = 0;
|
||||
if(Servo_AUX3) packet[13] = HUBSAN_FLAG_SNAPSHOT;
|
||||
if(Servo_AUX1) packet[13] |= HUBSAN_FLAG_FLIP_PLUS;
|
||||
packet[14]= 0x49; // ghost channel ?
|
||||
if(packet_count < 100)
|
||||
{ // set channels to neutral for first 100 packets
|
||||
packet[2] = 0x80; // throttle neutral is at mid stick on plus series
|
||||
packet[4] = 0x80;
|
||||
packet[6] = 0x80;
|
||||
packet[8] = 0x80;
|
||||
packet[9] = 0x06;
|
||||
packet[13]= 0x00;
|
||||
packet_count++;
|
||||
}
|
||||
}
|
||||
packet[10] = 0x64;
|
||||
packet[11] = (txid >> 24) & 0xFF;
|
||||
packet[12] = (txid >> 16) & 0xFF;
|
||||
packet[13] = (txid >> 8) & 0xFF;
|
||||
packet[14] = (txid >> 0) & 0xFF;
|
||||
update_crc();
|
||||
hubsan_update_crc();
|
||||
}
|
||||
|
||||
uint8_t hubsan_check_integrity()
|
||||
#if defined(TELEMETRY)
|
||||
static uint8_t __attribute__((unused)) hubsan_check_integrity()
|
||||
{
|
||||
uint8_t sum = 0;
|
||||
for(int i = 0; i < 15; i++)
|
||||
if( (packet[0]&0xFE) != 0xE0 )
|
||||
return 0;
|
||||
uint8_t sum = 0;
|
||||
for(uint8_t i = 0; i < 15; i++)
|
||||
sum += packet[i];
|
||||
return packet[15] == ((256 - (sum % 256)) & 0xFF);
|
||||
return ( packet[15] == (uint8_t)(-sum) );
|
||||
}
|
||||
#endif
|
||||
|
||||
uint16_t ReadHubsan()
|
||||
{
|
||||
static uint8_t txState=0;
|
||||
#if defined(TELEMETRY)
|
||||
static uint8_t rfMode=0;
|
||||
#endif
|
||||
static uint8_t txState=0;
|
||||
static uint8_t bind_count=0;
|
||||
uint16_t delay;
|
||||
uint8_t i;
|
||||
|
||||
switch(phase) {
|
||||
case BIND_1:
|
||||
bind_count++;
|
||||
if(bind_count >= 20)
|
||||
{
|
||||
if(id_data == ID_NORMAL)
|
||||
id_data = ID_PLUS;
|
||||
else
|
||||
id_data = ID_NORMAL;
|
||||
A7105_WriteID(id_data);
|
||||
bind_count = 0;
|
||||
}
|
||||
case BIND_3:
|
||||
case BIND_5:
|
||||
case BIND_7:
|
||||
@@ -151,13 +227,22 @@ uint16_t ReadHubsan()
|
||||
case BIND_5 | WAIT_WRITE:
|
||||
case BIND_7 | WAIT_WRITE:
|
||||
//wait for completion
|
||||
for(i = 0; i< 20; i++) {
|
||||
for(i = 0; i< 20; i++)
|
||||
if(! (A7105_ReadReg(A7105_00_MODE) & 0x01))
|
||||
break;
|
||||
}
|
||||
A7105_SetTxRxMode(RX_EN);
|
||||
A7105_Strobe(A7105_RX);
|
||||
phase &= ~WAIT_WRITE;
|
||||
if(id_data == ID_PLUS)
|
||||
{
|
||||
if(state == BIND_7 && packet[2] == 9)
|
||||
{
|
||||
state = DATA_1;
|
||||
A7105_WriteReg(A7105_1F_CODE_I, 0x0F);
|
||||
BIND_DONE;
|
||||
return 4500;
|
||||
}
|
||||
}
|
||||
phase++;
|
||||
return 4500; //7.5msec elapsed since last write
|
||||
case BIND_2:
|
||||
@@ -180,7 +265,7 @@ uint16_t ReadHubsan()
|
||||
return 15000; //22.5msec elapsed since last write
|
||||
}
|
||||
A7105_ReadData();
|
||||
if(packet[1] == 9) {
|
||||
if(packet[1] == 9 && id_data == ID_NORMAL) {
|
||||
phase = DATA_1;
|
||||
A7105_WriteReg(A7105_1F_CODE_I, 0x0F);
|
||||
BIND_DONE;
|
||||
@@ -195,12 +280,14 @@ uint16_t ReadHubsan()
|
||||
case DATA_4:
|
||||
case DATA_5:
|
||||
if( txState == 0) { // send packet
|
||||
#if defined(TELEMETRY)
|
||||
rfMode = A7105_TX;
|
||||
#endif
|
||||
if( phase == DATA_1)
|
||||
A7105_SetPower(); //Keep transmit power in sync
|
||||
hubsan_build_packet();
|
||||
A7105_Strobe(A7105_STANDBY);
|
||||
A7105_WriteData(16, phase == DATA_5 ? channel + 0x23 : channel);
|
||||
A7105_WriteData(16, phase == DATA_5 && id_data == ID_NORMAL ? channel + 0x23 : channel);
|
||||
if (phase == DATA_5)
|
||||
phase = DATA_1;
|
||||
else
|
||||
@@ -209,7 +296,8 @@ uint16_t ReadHubsan()
|
||||
}
|
||||
else {
|
||||
#if defined(TELEMETRY)
|
||||
if( rfMode == A7105_TX) {// switch to rx mode 3ms after packet sent
|
||||
if( rfMode == A7105_TX)
|
||||
{// switch to rx mode 3ms after packet sent
|
||||
for( i=0; i<10; i++)
|
||||
{
|
||||
if( !(A7105_ReadReg(A7105_00_MODE) & 0x01)) {// wait for tx completion
|
||||
@@ -220,15 +308,23 @@ uint16_t ReadHubsan()
|
||||
}
|
||||
}
|
||||
}
|
||||
if( rfMode == A7105_RX) { // check for telemetry frame
|
||||
for( i=0; i<10; i++) {
|
||||
if( !(A7105_ReadReg(A7105_00_MODE) & 0x01)) { // data received
|
||||
if( rfMode == A7105_RX)
|
||||
{ // check for telemetry frame
|
||||
for( i=0; i<10; i++)
|
||||
{
|
||||
if( !(A7105_ReadReg(A7105_00_MODE) & 0x01))
|
||||
{ // data received
|
||||
A7105_ReadData();
|
||||
if( !(A7105_ReadReg(A7105_00_MODE) & 0x01)){ // data received
|
||||
v_lipo=packet[13];// hubsan lipo voltage 8bits the real value is h_lipo/10(0x2A=42-4.2V)
|
||||
if( hubsan_check_integrity() )
|
||||
{
|
||||
v_lipo=packet[13];// hubsan lipo voltage 8bits the real value is h_lipo/10(0x2A=42 -> 4.2V)
|
||||
telemetry_link=1;
|
||||
}
|
||||
A7105_Strobe(A7105_RX);
|
||||
// Read TX RSSI
|
||||
RSSI_dBm=256-(A7105_ReadReg(A7105_1D_RSSI_THOLD)*8)/5; // value from A7105 is between 8 for maximum signal strength to 160 or less
|
||||
if(RSSI_dBm<0) RSSI_dBm=0;
|
||||
else if(RSSI_dBm>255) RSSI_dBm=255;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -249,13 +345,17 @@ uint16_t initHubsan() {
|
||||
const uint8_t allowed_ch[] = {0x14, 0x1e, 0x28, 0x32, 0x3c, 0x46, 0x50, 0x5a, 0x64, 0x6e, 0x78, 0x82};
|
||||
A7105_Init(INIT_HUBSAN); //hubsan_init();
|
||||
|
||||
randomSeed((uint32_t)analogRead(A0) << 10 | analogRead(A4));
|
||||
randomSeed((uint32_t)analogRead(A6) << 10 | analogRead(A7));
|
||||
sessionid = random(0xfefefefe) + ((uint32_t)random(0xfefefefe) << 16);
|
||||
channel = allowed_ch[random(0xfefefefe) % sizeof(allowed_ch)];
|
||||
|
||||
BIND_IN_PROGRESS; // autobind protocol
|
||||
phase = BIND_1;
|
||||
packet_count=0;
|
||||
id_data=ID_NORMAL;
|
||||
#if defined(TELEMETRY)
|
||||
telemetry_link=0;
|
||||
#endif
|
||||
return 10000;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,53 +12,241 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// Last sync with hexfet new_protocols/KN_nrf24l01.c dated 2015-11-09
|
||||
|
||||
#if defined(KN_NRF24L01_INO)
|
||||
|
||||
#include "iface_nrf24l01.h"
|
||||
|
||||
#define KN_BIND_COUNT 1000 // for KN 2sec every 2ms - 1000 packets
|
||||
// Timeout for callback in uSec, 2ms=2000us for KN
|
||||
#define KN_PACKET_PERIOD 2000
|
||||
#define KN_PACKET_CHKTIME 100 // Time to wait for packet to be sent (no ACK, so very short)
|
||||
// Wait for RX chip stable - 10ms
|
||||
#define KN_INIT_WAIT_MS 10000
|
||||
|
||||
//#define PAYLOADSIZE 16
|
||||
#define NFREQCHANNELS 4
|
||||
#define KN_TXID_SIZE 4
|
||||
//Payload(16 bytes) plus overhead(10 bytes) is 208 bits, takes about 0.4ms or 0.2ms
|
||||
//to send for the rate of 500kb/s and 1Mb/s respectively.
|
||||
|
||||
// Callback timeout period for sending bind packets, minimum 250
|
||||
#define KN_BINDING_PACKET_PERIOD 1000
|
||||
|
||||
// Timeout for sending data packets, in uSec, KN protocol requires 2ms
|
||||
#define KN_WL_SENDING_PACKET_PERIOD 2000
|
||||
// Timeout for sending data packets, in uSec, KNFX protocol requires 1.2 ms
|
||||
#define KN_FX_SENDING_PACKET_PERIOD 1200
|
||||
|
||||
// packets to be sent during binding, last 0.5 seconds in WL Toys and 0.2 seconds in Feilun
|
||||
#define KN_WL_BIND_COUNT 500
|
||||
#define KN_FX_BIND_COUNT 200
|
||||
|
||||
#define KN_PAYLOADSIZE 16
|
||||
|
||||
//24L01 has 126 RF channels, can we use all of them?
|
||||
#define KN_MAX_RF_CHANNEL 73
|
||||
|
||||
//KN protocol for WL Toys changes RF frequency every 10 ms, repeats with only 4 channels.
|
||||
//Feilun variant uses only 2 channels, so we will just repeat the hopping channels later
|
||||
#define KN_RF_CH_COUNT 4
|
||||
|
||||
//KN protocol for WL Toys sends 4 data packets every 2ms per frequency, plus a 2ms gap.
|
||||
#define KN_WL_PACKET_SEND_COUNT 5
|
||||
//KN protocol for Feilun sends 8 data packets every 1.2ms per frequency, plus a 0.3ms gap.
|
||||
#define KN_FX_PACKET_SEND_COUNT 8
|
||||
|
||||
#define KN_TX_ADDRESS_SIZE 5
|
||||
|
||||
enum {
|
||||
KN_FLAG_DR = 0x01, // Dual Rate
|
||||
KN_FLAG_TH = 0x02, // Throttle Hold
|
||||
KN_FLAG_IDLEUP = 0x04, // Idle up
|
||||
KN_PHASE_PRE_BIND,
|
||||
KN_PHASE_BINDING,
|
||||
KN_PHASE_PRE_SEND,
|
||||
KN_PHASE_SENDING,
|
||||
};
|
||||
|
||||
enum {
|
||||
KN_FLAG_DR = 0x01, // Dual Rate: 1 - full range
|
||||
KN_FLAG_TH = 0x02, // Throttle Hold: 1 - hold
|
||||
KN_FLAG_IDLEUP = 0x04, // Idle up: 1 - 3D
|
||||
KN_FLAG_RES1 = 0x08,
|
||||
KN_FLAG_RES2 = 0x10,
|
||||
KN_FLAG_RES3 = 0x20,
|
||||
KN_FLAG_GYRO3 = 0x40, // 00 - 6G mode, 01 - 3G mode
|
||||
KN_FLAG_GYRO3 = 0x40, // 0 - 6G mode, 1 - 3G mode
|
||||
KN_FLAG_GYROR = 0x80 // Always 0 so far
|
||||
};
|
||||
|
||||
//
|
||||
enum {
|
||||
KN_INIT2 = 0,
|
||||
KN_INIT2_NO_BIND,
|
||||
KN_BIND,
|
||||
KN_DATA
|
||||
};
|
||||
|
||||
/*enum {
|
||||
USE1MBPS_NO = 0,
|
||||
USE1MBPS_YES = 1,
|
||||
};*/
|
||||
|
||||
// 2-bytes CRC
|
||||
#define CRC_CONFIG (BV(NRF24L01_00_EN_CRC) | BV(NRF24L01_00_CRCO))
|
||||
|
||||
void kn_init()
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// This function init 24L01 regs and packet data for binding
|
||||
// Send tx address, hopping table (for Wl Toys), and data rate to the KN receiver during binding.
|
||||
// It seems that KN can remember these parameters, no binding needed after power up.
|
||||
// Bind uses fixed TX address "KNDZK", 1 Mbps data rate and channel 83
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
static void __attribute__((unused)) kn_bind_init()
|
||||
{
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, (uint8_t*)"KNDZK", 5);
|
||||
packet[0] = 'K';
|
||||
packet[1] = 'N';
|
||||
packet[2] = 'D';
|
||||
packet[3] = 'Z';
|
||||
//Use first four bytes of tx_addr
|
||||
packet[4] = rx_tx_addr[0];
|
||||
packet[5] = rx_tx_addr[1];
|
||||
packet[6] = rx_tx_addr[2];
|
||||
packet[7] = rx_tx_addr[3];
|
||||
|
||||
if(sub_protocol==WLTOYS)
|
||||
{
|
||||
packet[8] = hopping_frequency[0];
|
||||
packet[9] = hopping_frequency[1];
|
||||
packet[10] = hopping_frequency[2];
|
||||
packet[11] = hopping_frequency[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
packet[8] = 0x00;
|
||||
packet[9] = 0x00;
|
||||
packet[10] = 0x00;
|
||||
packet[11] = 0x00;
|
||||
}
|
||||
packet[12] = 0x00;
|
||||
packet[13] = 0x00;
|
||||
packet[14] = 0x00;
|
||||
packet[15] = 0x01; //(USE1MBPS_YES) ? 0x01 : 0x00;
|
||||
|
||||
//Set RF channel
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, 83);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Update control data to be sent
|
||||
// Do it once per frequency, so the same values will be sent 4 times
|
||||
// KN uses 4 10-bit data channels plus a 8-bit switch channel
|
||||
//
|
||||
// The packet[0] is used for pitch/throttle, the relation is hard coded, not changeable.
|
||||
// We can change the throttle/pitch range though.
|
||||
//
|
||||
// How to use trim? V977 stock controller can trim 6-axis mode to eliminate the drift.
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
static void __attribute__((unused)) kn_update_packet_control_data()
|
||||
{
|
||||
uint16_t value;
|
||||
value = convert_channel_10b(THROTTLE);
|
||||
packet[0] = (value >> 8) & 0xFF;
|
||||
packet[1] = value & 0xFF;
|
||||
value = convert_channel_10b(AILERON);
|
||||
packet[2] = (value >> 8) & 0xFF;
|
||||
packet[3] = value & 0xFF;
|
||||
value = convert_channel_10b(ELEVATOR);
|
||||
packet[4] = (value >> 8) & 0xFF;
|
||||
packet[5] = value & 0xFF;
|
||||
value = convert_channel_10b(RUDDER);
|
||||
packet[6] = (value >> 8) & 0xFF;
|
||||
packet[7] = value & 0xFF;
|
||||
// Trims, middle is 0x64 (100) range 0-200
|
||||
packet[8] = convert_channel_8b_scale(AUX5,0,200); // 0x64; // T
|
||||
packet[9] = convert_channel_8b_scale(AUX6,0,200); // 0x64; // A
|
||||
packet[10] = convert_channel_8b_scale(AUX7,0,200); // 0x64; // E
|
||||
packet[11] = 0x64; // R
|
||||
|
||||
flags=0;
|
||||
if (Servo_AUX1)
|
||||
flags = KN_FLAG_DR;
|
||||
if (Servo_AUX2)
|
||||
flags |= KN_FLAG_TH;
|
||||
if (Servo_AUX3)
|
||||
flags |= KN_FLAG_IDLEUP;
|
||||
if (Servo_AUX4)
|
||||
flags |= KN_FLAG_GYRO3;
|
||||
|
||||
packet[12] = flags;
|
||||
|
||||
packet[13] = 0x00;
|
||||
if(sub_protocol==WLTOYS)
|
||||
packet[13] = (packet_sent << 5) | (hopping_frequency_no << 2);
|
||||
|
||||
packet[14] = 0x00;
|
||||
packet[15] = 0x00;
|
||||
|
||||
NRF24L01_SetPower();
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// This function generate RF TX packet address
|
||||
// V977 can remember the binding parameters; we do not need rebind when power up.
|
||||
// This requires the address must be repeatable for a specific RF ID at power up.
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
static void __attribute__((unused)) kn_calculate_tx_addr()
|
||||
{
|
||||
if(sub_protocol==FEILUN)
|
||||
{
|
||||
uint8_t addr2;
|
||||
// Generate TXID with sum of minimum 256 and maximum 256+MAX_RF_CHANNEL-32
|
||||
rx_tx_addr[1] = 1 + rx_tx_addr[0] % (KN_MAX_RF_CHANNEL-33);
|
||||
addr2 = 1 + rx_tx_addr[2] % (KN_MAX_RF_CHANNEL-33);
|
||||
if ((uint16_t)(rx_tx_addr[0] + rx_tx_addr[1]) < 256)
|
||||
rx_tx_addr[2] = addr2;
|
||||
else
|
||||
rx_tx_addr[2] = 0x00;
|
||||
rx_tx_addr[3] = 0x00;
|
||||
while((uint16_t)(rx_tx_addr[0] + rx_tx_addr[1] + rx_tx_addr[2] + rx_tx_addr[3]) < 257)
|
||||
rx_tx_addr[3] += addr2;
|
||||
}
|
||||
//The 5th byte is a constant, must be 'K'
|
||||
rx_tx_addr[4] = 'K';
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// This function generates "random" RF hopping frequency channel numbers.
|
||||
// These numbers must be repeatable for a specific seed
|
||||
// The generated number range is from 0 to MAX_RF_CHANNEL. No repeat or adjacent numbers
|
||||
//
|
||||
// For Feilun variant, the channels are calculated from TXID, and since only 2 channels are used
|
||||
// we copy them to fill up to MAX_RF_CHANNEL
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
static void __attribute__((unused)) kn_calculate_freqency_hopping_channels()
|
||||
{
|
||||
if(sub_protocol==WLTOYS)
|
||||
{
|
||||
uint8_t idx = 0;
|
||||
uint32_t rnd = MProtocol_id;
|
||||
while (idx < KN_RF_CH_COUNT)
|
||||
{
|
||||
uint8_t i;
|
||||
rnd = rnd * 0x0019660D + 0x3C6EF35F; // Randomization
|
||||
|
||||
// Use least-significant byte. 73 is prime, so channels 76..77 are unused
|
||||
uint8_t next_ch = ((rnd >> 8) % KN_MAX_RF_CHANNEL) + 2;
|
||||
// Keep the distance 2 between the channels - either odd or even
|
||||
if (((next_ch ^ MProtocol_id) & 0x01 )== 0)
|
||||
continue;
|
||||
// Check that it's not duplicate and spread uniformly
|
||||
for (i = 0; i < idx; i++)
|
||||
if(hopping_frequency[i] == next_ch)
|
||||
break;
|
||||
if (i != idx)
|
||||
continue;
|
||||
hopping_frequency[idx++] = next_ch;
|
||||
}
|
||||
}
|
||||
else
|
||||
{//FEILUN
|
||||
hopping_frequency[0] = rx_tx_addr[0] + rx_tx_addr[1] + rx_tx_addr[2] + rx_tx_addr[3]; // - 256; ???
|
||||
hopping_frequency[1] = hopping_frequency[0] + 32;
|
||||
hopping_frequency[2] = hopping_frequency[0];
|
||||
hopping_frequency[3] = hopping_frequency[1];
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// This function setup 24L01
|
||||
// V977 uses one way communication, receiving only. 24L01 RX is never enabled.
|
||||
// V977 needs payload length in the packet. We should configure 24L01 to enable Packet Control Field(PCF)
|
||||
// Some RX reg settings are actually for enable PCF
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
static void __attribute__((unused)) kn_init()
|
||||
{
|
||||
kn_calculate_tx_addr();
|
||||
kn_calculate_freqency_hopping_channels();
|
||||
|
||||
NRF24L01_Initialize();
|
||||
|
||||
NRF24L01_WriteReg(NRF24L01_00_CONFIG, CRC_CONFIG);
|
||||
NRF24L01_WriteReg(NRF24L01_00_CONFIG, BV(NRF24L01_00_EN_CRC) | BV(NRF24L01_00_CRCO));
|
||||
NRF24L01_WriteReg(NRF24L01_01_EN_AA, 0x00); // No Auto Acknoledgement
|
||||
NRF24L01_WriteReg(NRF24L01_02_EN_RXADDR, 0x01); // Enable data pipe 0
|
||||
NRF24L01_WriteReg(NRF24L01_03_SETUP_AW, 0x03); // 5-byte RX/TX address
|
||||
@@ -68,207 +256,92 @@ void kn_init()
|
||||
NRF24L01_WriteReg(NRF24L01_11_RX_PW_P0, 0x20); // bytes of data payload for pipe 0
|
||||
|
||||
|
||||
NRF24L01_Activate(0x73); // Activate feature register
|
||||
NRF24L01_Activate(0x73);
|
||||
NRF24L01_WriteReg(NRF24L01_1C_DYNPD, 1); // Dynamic payload for data pipe 0
|
||||
// Enable: Dynamic Payload Length, Payload with ACK , W_TX_PAYLOAD_NOACK
|
||||
NRF24L01_WriteReg(NRF24L01_1D_FEATURE, BV(NRF2401_1D_EN_DPL) | BV(NRF2401_1D_EN_ACK_PAY) | BV(NRF2401_1D_EN_DYN_ACK));
|
||||
NRF24L01_Activate(0x73);
|
||||
}
|
||||
// Enable: Dynamic Payload Length to enable PCF
|
||||
NRF24L01_WriteReg(NRF24L01_1D_FEATURE, BV(NRF2401_1D_EN_DPL));
|
||||
|
||||
NRF24L01_SetPower();
|
||||
|
||||
uint16_t kn_init2()
|
||||
{
|
||||
NRF24L01_FlushTx();
|
||||
NRF24L01_FlushRx();
|
||||
packet_sent = 0;
|
||||
packet_count = 0;
|
||||
hopping_frequency_no = 0;
|
||||
|
||||
// Turn radio power on
|
||||
NRF24L01_SetTxRxMode(TX_EN);
|
||||
NRF24L01_WriteReg(NRF24L01_00_CONFIG, CRC_CONFIG | BV(NRF24L01_00_PWR_UP));
|
||||
return 150;
|
||||
NRF24L01_SetTxRxMode(TX_EN);
|
||||
NRF24L01_SetBitrate(NRF24L01_BR_1M); //USE1MBPS_YES ? NRF24L01_BR_1M : NRF24L01_BR_250K;
|
||||
}
|
||||
|
||||
void set_tx_for_bind()
|
||||
|
||||
//================================================================================================
|
||||
// Private Functions
|
||||
//================================================================================================
|
||||
uint16_t initKN()
|
||||
{
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, 83);
|
||||
NRF24L01_SetBitrate(NRF24L01_BR_1M); // 1Mbps for binding
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, (uint8_t *) "KNDZK", 5);
|
||||
}
|
||||
|
||||
void set_tx_for_data()
|
||||
{
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, rx_tx_addr, 5);
|
||||
}
|
||||
|
||||
void kn_calc_fh_channels(uint32_t seed)
|
||||
{
|
||||
uint8_t idx = 0;
|
||||
uint32_t rnd = seed;
|
||||
while (idx < NFREQCHANNELS) {
|
||||
uint8_t i;
|
||||
rnd = rnd * 0x0019660D + 0x3C6EF35F; // Randomization
|
||||
|
||||
// Use least-significant byte. 73 is prime, so channels 76..77 are unused
|
||||
uint8_t next_ch = ((rnd >> 8) % 73) + 2;
|
||||
// Keep the distance 2 between the channels - either odd or even
|
||||
if (((next_ch ^ seed) & 0x01 )== 0)
|
||||
continue;
|
||||
// Check that it's not duplicate and spread uniformly
|
||||
for (i = 0; i < idx; i++) {
|
||||
if(hopping_frequency[i] == next_ch)
|
||||
break;
|
||||
}
|
||||
if (i != idx)
|
||||
continue;
|
||||
hopping_frequency[idx++] = next_ch;
|
||||
if(sub_protocol==WLTOYS)
|
||||
{
|
||||
packet_period = KN_WL_SENDING_PACKET_PERIOD;
|
||||
bind_counter = KN_WL_BIND_COUNT;
|
||||
packet_count = KN_WL_PACKET_SEND_COUNT;
|
||||
}
|
||||
}
|
||||
|
||||
void kn_initialize_tx_id()
|
||||
{
|
||||
rx_tx_addr[4] = 'K';
|
||||
kn_calc_fh_channels(MProtocol_id);
|
||||
}
|
||||
|
||||
#define PACKET_COUNT_SHIFT 5
|
||||
#define RF_CHANNEL_SHIFT 2
|
||||
void kn_send_packet(uint8_t bind)
|
||||
{
|
||||
uint8_t rf_ch;
|
||||
if (bind) {
|
||||
rf_ch = 83;
|
||||
packet[0] = 'K';
|
||||
packet[1] = 'N';
|
||||
packet[2] = 'D';
|
||||
packet[3] = 'Z';
|
||||
packet[4] = rx_tx_addr[0];
|
||||
packet[5] = rx_tx_addr[1];
|
||||
packet[6] = rx_tx_addr[2];
|
||||
packet[7] = rx_tx_addr[3];
|
||||
packet[8] = hopping_frequency[0];
|
||||
packet[9] = hopping_frequency[1];
|
||||
packet[10] = hopping_frequency[2];
|
||||
packet[11] = hopping_frequency[3];
|
||||
packet[12] = 0x00;
|
||||
packet[13] = 0x00;
|
||||
packet[14] = 0x00;
|
||||
packet[15] = 0x01; //mode_bitrate == USE1MBPS_YES ? 0x01 : 0x00;
|
||||
} else {
|
||||
rf_ch = hopping_frequency[hopping_frequency_no];
|
||||
|
||||
// Each packet is repeated 4 times on the same channel
|
||||
// We're not strictly repeating them, rather we
|
||||
// send new packet on the same frequency, so the
|
||||
// receiver gets the freshest command. As receiver
|
||||
// hops to a new frequency as soon as valid packet
|
||||
// received it does not matter that the packet is
|
||||
// not the same one repeated twice - nobody checks this
|
||||
|
||||
// NB! packet_count overflow is handled and used in
|
||||
// callback.
|
||||
if (++packet_count == 4)
|
||||
hopping_frequency_no = (hopping_frequency_no + 1) & 0x03;
|
||||
|
||||
uint16_t kn_throttle, kn_rudder, kn_elevator, kn_aileron;
|
||||
kn_throttle = convert_channel_10b(THROTTLE);
|
||||
kn_aileron = convert_channel_10b(AILERON);
|
||||
kn_elevator = convert_channel_10b(ELEVATOR);
|
||||
kn_rudder = convert_channel_10b(RUDDER);
|
||||
packet[0] = (kn_throttle >> 8) & 0xFF;
|
||||
packet[1] = kn_throttle & 0xFF;
|
||||
packet[2] = (kn_aileron >> 8) & 0xFF;
|
||||
packet[3] = kn_aileron & 0xFF;
|
||||
packet[4] = (kn_elevator >> 8) & 0xFF;
|
||||
packet[5] = kn_elevator & 0xFF;
|
||||
packet[6] = (kn_rudder >> 8) & 0xFF;
|
||||
packet[7] = kn_rudder & 0xFF;
|
||||
// Trims, middle is 0x64 (100) 0-200
|
||||
packet[8] = 0x64; // T
|
||||
packet[9] = 0x64; // A
|
||||
packet[10] = 0x64; // E
|
||||
packet[11] = 0x64; // R
|
||||
|
||||
if (Servo_data[AUX1] > PPM_SWITCH)
|
||||
flags |= KN_FLAG_DR;
|
||||
else
|
||||
flags=0;
|
||||
if (Servo_data[AUX2] > PPM_SWITCH)
|
||||
flags |= KN_FLAG_TH;
|
||||
if (Servo_data[AUX3] > PPM_SWITCH)
|
||||
flags |= KN_FLAG_IDLEUP;
|
||||
if (Servo_data[AUX4] > PPM_SWITCH)
|
||||
flags |= KN_FLAG_GYRO3;
|
||||
|
||||
packet[12] = flags;
|
||||
|
||||
packet[13] = (packet_count << PACKET_COUNT_SHIFT) | (hopping_frequency_no << RF_CHANNEL_SHIFT);
|
||||
|
||||
packet[14] = 0x00;
|
||||
packet[15] = 0x00;
|
||||
else
|
||||
{
|
||||
packet_period = KN_FX_SENDING_PACKET_PERIOD;
|
||||
bind_counter = KN_FX_BIND_COUNT;
|
||||
packet_count = KN_FX_PACKET_SEND_COUNT;
|
||||
}
|
||||
kn_init();
|
||||
phase = IS_AUTOBIND_FLAG_on ? KN_PHASE_PRE_BIND : KN_PHASE_PRE_SEND;
|
||||
|
||||
packet_sent = 0;
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, rf_ch);
|
||||
NRF24L01_FlushTx();
|
||||
NRF24L01_WritePayload(packet, 16);
|
||||
//++total_packets;
|
||||
packet_sent = 1;
|
||||
|
||||
if (! hopping_frequency_no) {
|
||||
//Keep transmit power updated
|
||||
NRF24L01_SetPower();
|
||||
}
|
||||
return KN_INIT_WAIT_MS;
|
||||
}
|
||||
|
||||
uint16_t kn_callback()
|
||||
{
|
||||
uint16_t timeout = KN_PACKET_PERIOD;
|
||||
switch (phase)
|
||||
{
|
||||
case KN_INIT2:
|
||||
bind_counter = KN_BIND_COUNT;
|
||||
timeout = kn_init2();
|
||||
phase = KN_BIND;
|
||||
set_tx_for_bind();
|
||||
break;
|
||||
case KN_INIT2_NO_BIND:
|
||||
timeout = kn_init2();
|
||||
phase = KN_DATA;
|
||||
set_tx_for_data();
|
||||
break;
|
||||
case KN_BIND:
|
||||
if (packet_sent && NRF24L01_packet_ack() != PKT_ACKED)
|
||||
return KN_PACKET_CHKTIME;
|
||||
kn_send_packet(1);
|
||||
if (--bind_counter == 0) {
|
||||
phase = KN_DATA;
|
||||
set_tx_for_data();
|
||||
BIND_DONE;
|
||||
case KN_PHASE_PRE_BIND:
|
||||
kn_bind_init();
|
||||
phase=KN_PHASE_BINDING;
|
||||
//Do once, no break needed
|
||||
case KN_PHASE_BINDING:
|
||||
if(bind_counter>0)
|
||||
{
|
||||
bind_counter--;
|
||||
NRF24L01_WritePayload(packet, KN_PAYLOADSIZE);
|
||||
return KN_BINDING_PACKET_PERIOD;
|
||||
}
|
||||
break;
|
||||
case KN_DATA:
|
||||
if (packet_count == 4)
|
||||
packet_count = 0;
|
||||
else {
|
||||
if (packet_sent && NRF24L01_packet_ack() != PKT_ACKED)
|
||||
return KN_PACKET_CHKTIME;
|
||||
kn_send_packet(0);
|
||||
BIND_DONE;
|
||||
//Continue
|
||||
case KN_PHASE_PRE_SEND:
|
||||
packet_sent = 0;
|
||||
hopping_frequency_no = 0;
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, rx_tx_addr, KN_TX_ADDRESS_SIZE);
|
||||
phase = KN_PHASE_SENDING;
|
||||
//Do once, no break needed
|
||||
case KN_PHASE_SENDING:
|
||||
if(packet_sent >= packet_count)
|
||||
{
|
||||
packet_sent = 0;
|
||||
hopping_frequency_no++;
|
||||
if(hopping_frequency_no >= KN_RF_CH_COUNT) hopping_frequency_no = 0;
|
||||
kn_update_packet_control_data();
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, hopping_frequency[hopping_frequency_no]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return timeout;
|
||||
}
|
||||
|
||||
uint16_t initKN(){
|
||||
//total_packets = 0;
|
||||
//mode_bitrate=USE1MBPS_YES;
|
||||
kn_init();
|
||||
phase = IS_AUTOBIND_FLAG_on ? KN_INIT2 : KN_INIT2_NO_BIND;
|
||||
kn_initialize_tx_id();
|
||||
|
||||
// Call callback in 50ms
|
||||
return 50000;
|
||||
else
|
||||
{
|
||||
// Update sending count and RF channel index.
|
||||
// The protocol sends 4 data packets every 2ms per frequency, plus a 2ms gap.
|
||||
// Each data packet need a packet number and RF channel index
|
||||
packet[13] = 0x00;
|
||||
if(sub_protocol==WLTOYS)
|
||||
packet[13] = (packet_sent << 5) | (hopping_frequency_no << 2);
|
||||
}
|
||||
NRF24L01_WritePayload(packet, KN_PAYLOADSIZE);
|
||||
packet_sent++;
|
||||
return packet_period;
|
||||
} //switch
|
||||
|
||||
//Bad things happened, reset
|
||||
packet_sent = 0;
|
||||
phase = KN_PHASE_PRE_SEND;
|
||||
return packet_period;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
247
Multiprotocol/MJXQ_nrf24l01.ino
Normal file
247
Multiprotocol/MJXQ_nrf24l01.ino
Normal file
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
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 MJX WLH08, X600, X800, H26D
|
||||
// Last sync with hexfet new_protocols/mjxq_nrf24l01.c dated 2016-01-17
|
||||
|
||||
#if defined(MJXQ_NRF24L01_INO)
|
||||
|
||||
#include "iface_nrf24l01.h"
|
||||
|
||||
#define MJXQ_BIND_COUNT 150
|
||||
#define MJXQ_PACKET_PERIOD 4000 // Timeout for callback in uSec
|
||||
#define MJXQ_INITIAL_WAIT 500
|
||||
#define MJXQ_PACKET_SIZE 16
|
||||
#define MJXQ_RF_NUM_CHANNELS 4
|
||||
#define MJXQ_ADDRESS_LENGTH 5
|
||||
|
||||
#define MJXQ_PAN_TILT_COUNT 16 // for H26D - match stock tx timing
|
||||
#define MJXQ_PAN_DOWN 0x08
|
||||
#define MJXQ_PAN_UP 0x04
|
||||
#define MJXQ_TILT_DOWN 0x20
|
||||
#define MJXQ_TILT_UP 0x10
|
||||
static uint8_t __attribute__((unused)) MJXQ_pan_tilt_value()
|
||||
{
|
||||
// Servo_AUX8 PAN // H26D
|
||||
// Servo_AUX9 TILT
|
||||
uint8_t pan = 0;
|
||||
packet_count++;
|
||||
if(packet_count & MJXQ_PAN_TILT_COUNT)
|
||||
{
|
||||
if(Servo_AUX8)
|
||||
pan=MJXQ_PAN_UP;
|
||||
if(Servo_data[AUX8]<PPM_MIN_COMMAND)
|
||||
pan=MJXQ_PAN_DOWN;
|
||||
if(Servo_data[AUX9]>PPM_MIN_COMMAND)
|
||||
pan=MJXQ_TILT_UP;
|
||||
if(Servo_data[AUX9]<PPM_MIN_COMMAND)
|
||||
pan=MJXQ_TILT_DOWN;
|
||||
}
|
||||
return pan;
|
||||
}
|
||||
|
||||
#define MJXQ_CHAN2TRIM(X) (((X) & 0x80 ? (X) : 0x7f - (X)) >> 1)
|
||||
static void __attribute__((unused)) MJXQ_send_packet(uint8_t bind)
|
||||
{
|
||||
packet[0] = convert_channel_8b(THROTTLE);
|
||||
packet[1] = convert_channel_s8b(RUDDER);
|
||||
packet[4] = 0x40; // rudder does not work well with dyntrim
|
||||
packet[2] = convert_channel_s8b(ELEVATOR);
|
||||
packet[5] = MJXQ_CHAN2TRIM(packet[2]); // trim elevator
|
||||
packet[3] = convert_channel_s8b(AILERON);
|
||||
packet[6] = MJXQ_CHAN2TRIM(packet[3]); // trim aileron
|
||||
packet[7] = rx_tx_addr[0];
|
||||
packet[8] = rx_tx_addr[1];
|
||||
packet[9] = rx_tx_addr[2];
|
||||
|
||||
packet[10] = 0x00; // overwritten below for feature bits
|
||||
packet[11] = 0x00; // overwritten below for X600
|
||||
packet[12] = 0x00;
|
||||
packet[13] = 0x00;
|
||||
|
||||
packet[14] = 0xC0; // bind value
|
||||
|
||||
// Servo_AUX1 FLIP
|
||||
// Servo_AUX2 LED
|
||||
// Servo_AUX3 PICTURE
|
||||
// Servo_AUX4 VIDEO
|
||||
// Servo_AUX5 HEADLESS
|
||||
// Servo_AUX6 RTH
|
||||
// Servo_AUX7 AUTOFLIP // X800, X600
|
||||
switch(sub_protocol)
|
||||
{
|
||||
case H26D:
|
||||
packet[10]=MJXQ_pan_tilt_value();
|
||||
// fall through on purpose - no break
|
||||
case WLH08:
|
||||
packet[10] += GET_FLAG(Servo_AUX6, 0x02) //RTH
|
||||
| GET_FLAG(Servo_AUX5, 0x01); //HEADLESS
|
||||
if (!bind)
|
||||
{
|
||||
packet[14] = 0x04
|
||||
| GET_FLAG(Servo_AUX1, 0x01) //FLIP
|
||||
| GET_FLAG(Servo_AUX3, 0x08) //PICTURE
|
||||
| GET_FLAG(Servo_AUX4, 0x10) //VIDEO
|
||||
| GET_FLAG(!Servo_AUX2, 0x20); // air/ground mode
|
||||
}
|
||||
break;
|
||||
case X600:
|
||||
if(Servo_AUX5) //HEADLESS
|
||||
{ // driven trims cause issues when headless is enabled
|
||||
packet[5] = 0x40;
|
||||
packet[6] = 0x40;
|
||||
}
|
||||
packet[10] = GET_FLAG(!Servo_AUX2, 0x02); //LED
|
||||
packet[11] = GET_FLAG(Servo_AUX6, 0x01); //RTH
|
||||
if (!bind)
|
||||
{
|
||||
packet[14] = 0x02 // always high rates by bit2 = 1
|
||||
| GET_FLAG(Servo_AUX1, 0x04) //FLIP
|
||||
| GET_FLAG(Servo_AUX7, 0x10) //AUTOFLIP
|
||||
| GET_FLAG(Servo_AUX5, 0x20); //HEADLESS
|
||||
}
|
||||
break;
|
||||
case X800:
|
||||
default:
|
||||
packet[10] = 0x10
|
||||
| GET_FLAG(!Servo_AUX2, 0x02) //LED
|
||||
| GET_FLAG(Servo_AUX7, 0x01); //AUTOFLIP
|
||||
if (!bind)
|
||||
{
|
||||
packet[14] = 0x02 // always high rates by bit2 = 1
|
||||
| GET_FLAG(Servo_AUX1, 0x04) //FLIP
|
||||
| GET_FLAG(Servo_AUX3, 0x08) //PICTURE
|
||||
| GET_FLAG(Servo_AUX4, 0x10); //VIDEO
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
uint8_t sum = packet[0];
|
||||
for (uint8_t i=1; i < MJXQ_PACKET_SIZE-1; i++) sum += packet[i];
|
||||
packet[15] = sum;
|
||||
|
||||
// Power on, TX mode, 2byte CRC
|
||||
if (sub_protocol == H26D)
|
||||
NRF24L01_SetTxRxMode(TX_EN);
|
||||
else
|
||||
XN297_Configure(BV(NRF24L01_00_EN_CRC) | BV(NRF24L01_00_CRCO) | BV(NRF24L01_00_PWR_UP));
|
||||
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, hopping_frequency[hopping_frequency_no++ / 2]);
|
||||
hopping_frequency_no %= 2 * MJXQ_RF_NUM_CHANNELS; // channels repeated
|
||||
|
||||
NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70);
|
||||
NRF24L01_FlushTx();
|
||||
|
||||
if (sub_protocol == H26D)
|
||||
NRF24L01_WritePayload(packet, MJXQ_PACKET_SIZE);
|
||||
else
|
||||
XN297_WritePayload(packet, MJXQ_PACKET_SIZE);
|
||||
|
||||
NRF24L01_SetPower();
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) MJXQ_init()
|
||||
{
|
||||
uint8_t addr[MJXQ_ADDRESS_LENGTH];
|
||||
memcpy(addr, "\x6d\x6a\x77\x77\x77", MJXQ_ADDRESS_LENGTH);
|
||||
if (sub_protocol == WLH08)
|
||||
memcpy(hopping_frequency, "\x12\x22\x32\x42", MJXQ_RF_NUM_CHANNELS);
|
||||
else
|
||||
if (sub_protocol == H26D)
|
||||
memcpy(hopping_frequency, "\x36\x3e\x46\x2e", MJXQ_RF_NUM_CHANNELS);
|
||||
else
|
||||
{
|
||||
memcpy(hopping_frequency, "\x0a\x35\x42\x3d", MJXQ_RF_NUM_CHANNELS);
|
||||
memcpy(addr, "\x6d\x6a\x73\x73\x73", MJXQ_RF_NUM_CHANNELS);
|
||||
}
|
||||
|
||||
|
||||
NRF24L01_Initialize();
|
||||
NRF24L01_SetTxRxMode(TX_EN);
|
||||
|
||||
if (sub_protocol == H26D)
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, addr, MJXQ_ADDRESS_LENGTH);
|
||||
else
|
||||
XN297_SetTXAddr(addr, MJXQ_ADDRESS_LENGTH);
|
||||
|
||||
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 Acknowledgment on all data pipes
|
||||
NRF24L01_WriteReg(NRF24L01_02_EN_RXADDR, 0x01); // Enable data pipe 0 only
|
||||
NRF24L01_WriteReg(NRF24L01_04_SETUP_RETR, 0x00); // no retransmits
|
||||
NRF24L01_WriteReg(NRF24L01_11_RX_PW_P0, MJXQ_PACKET_SIZE); // rx pipe 0 (used only for blue board)
|
||||
NRF24L01_SetBitrate(NRF24L01_BR_1M); // 1Mbps
|
||||
NRF24L01_SetPower();
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) MJXQ_init2()
|
||||
{
|
||||
// haven't figured out txid<-->rf channel mapping for MJX models
|
||||
static const uint8_t rf_map[][4] = {
|
||||
{0x0A, 0x46, 0x3A, 0x42},
|
||||
{0x0A, 0x3C, 0x36, 0x3F},
|
||||
{0x0A, 0x43, 0x36, 0x3F} };
|
||||
if (sub_protocol == H26D)
|
||||
memcpy(hopping_frequency, "\x32\x3e\x42\x4e", MJXQ_RF_NUM_CHANNELS);
|
||||
else
|
||||
if (sub_protocol == WLH08)
|
||||
memcpy(hopping_frequency, rf_map[rx_tx_addr[0]%3], MJXQ_RF_NUM_CHANNELS);
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) MJXQ_initialize_txid()
|
||||
{
|
||||
// haven't figured out txid<-->rf channel mapping for MJX models
|
||||
static const uint8_t tx_map[][3]={
|
||||
{0xF8, 0x4F, 0x1C},
|
||||
{0xC8, 0x6E, 0x02},
|
||||
{0x48, 0x6A, 0x40} };
|
||||
if (sub_protocol == WLH08)
|
||||
rx_tx_addr[0]&=0xF8; // txid must be multiple of 8
|
||||
else
|
||||
memcpy(rx_tx_addr,tx_map[rx_tx_addr[0]%3],3);
|
||||
}
|
||||
|
||||
uint16_t MJXQ_callback()
|
||||
{
|
||||
if(IS_BIND_DONE_on)
|
||||
MJXQ_send_packet(0);
|
||||
else
|
||||
{
|
||||
if (bind_counter == 0)
|
||||
{
|
||||
MJXQ_init2();
|
||||
BIND_DONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
bind_counter--;
|
||||
MJXQ_send_packet(1);
|
||||
}
|
||||
}
|
||||
|
||||
return MJXQ_PACKET_PERIOD;
|
||||
}
|
||||
|
||||
uint16_t initMJXQ(void)
|
||||
{
|
||||
BIND_IN_PROGRESS; // autobind protocol
|
||||
bind_counter = MJXQ_BIND_COUNT;
|
||||
MJXQ_initialize_txid();
|
||||
MJXQ_init();
|
||||
packet_count=0;
|
||||
return MJXQ_INITIAL_WAIT+MJXQ_PACKET_PERIOD;
|
||||
}
|
||||
|
||||
#endif
|
||||
218
Multiprotocol/MT99xx_nrf24l01.ino
Normal file
218
Multiprotocol/MT99xx_nrf24l01.ino
Normal file
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
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 MT99xx, Eachine H7, Yi Zhan i6S
|
||||
// Last sync with Goebish mt99xx_nrf24l01.c dated 2016-01-29
|
||||
|
||||
#if defined(MT99XX_NRF24L01_INO)
|
||||
|
||||
#include "iface_nrf24l01.h"
|
||||
|
||||
#define MT99XX_BIND_COUNT 928
|
||||
#define MT99XX_PACKET_PERIOD_MT 2625
|
||||
#define MT99XX_PACKET_PERIOD_YZ 3125
|
||||
#define MT99XX_INITIAL_WAIT 500
|
||||
#define MT99XX_PACKET_SIZE 9
|
||||
|
||||
#define checksum_offset rf_ch_num
|
||||
#define channel_offset phase
|
||||
|
||||
enum{
|
||||
// flags going to packet[6] (MT99xx, H7)
|
||||
FLAG_MT_RATE1 = 0x01, // (H7 high rate)
|
||||
FLAG_MT_RATE2 = 0x02, // (MT9916 only)
|
||||
FLAG_MT_VIDEO = 0x10,
|
||||
FLAG_MT_SNAPSHOT= 0x20,
|
||||
FLAG_MT_FLIP = 0x80,
|
||||
};
|
||||
|
||||
enum {
|
||||
MT99XX_INIT = 0,
|
||||
MT99XX_BIND,
|
||||
MT99XX_DATA
|
||||
};
|
||||
|
||||
static void __attribute__((unused)) MT99XX_send_packet()
|
||||
{
|
||||
const uint8_t yz_p4_seq[] = {0xa0, 0x20, 0x60};
|
||||
const uint8_t mys_byte[] = {
|
||||
0x01, 0x11, 0x02, 0x12, 0x03, 0x13, 0x04, 0x14,
|
||||
0x05, 0x15, 0x06, 0x16, 0x07, 0x17, 0x00, 0x10
|
||||
};
|
||||
static uint8_t yz_seq_num=0;
|
||||
|
||||
if(sub_protocol != YZ)
|
||||
{ // MT99XX & H7
|
||||
packet[0] = convert_channel_8b_scale(THROTTLE,0x00,0xE1); // throttle
|
||||
packet[1] = convert_channel_8b_scale(RUDDER ,0x00,0xE1); // rudder
|
||||
packet[2] = convert_channel_8b_scale(AILERON ,0x00,0xE1); // aileron
|
||||
packet[3] = convert_channel_8b_scale(ELEVATOR,0x00,0xE1); // elevator
|
||||
packet[4] = 0x20; // pitch trim (0x3f-0x20-0x00)
|
||||
packet[5] = 0x20; // roll trim (0x00-0x20-0x3f)
|
||||
packet[6] = GET_FLAG( Servo_AUX1, FLAG_MT_FLIP )
|
||||
| GET_FLAG( Servo_AUX3, FLAG_MT_SNAPSHOT )
|
||||
| GET_FLAG( Servo_AUX4, FLAG_MT_VIDEO );
|
||||
if(sub_protocol==MT99)
|
||||
packet[6] |= 0x40 | FLAG_MT_RATE2;
|
||||
else
|
||||
packet[6] |= FLAG_MT_RATE1; // max rate on H7
|
||||
// todo: mys_byte = next channel index ?
|
||||
// low nibble: index in chan list ?
|
||||
// high nibble: 0->start from start of list, 1->start from end of list ?
|
||||
packet[7] = mys_byte[hopping_frequency_no];
|
||||
uint8_t result=checksum_offset;
|
||||
for(uint8_t i=0; i<8; i++)
|
||||
result += packet[i];
|
||||
packet[8] = result;
|
||||
}
|
||||
else
|
||||
{ // YZ
|
||||
packet[0] = convert_channel_8b_scale(THROTTLE,0x00,0x64); // throttle
|
||||
packet[1] = convert_channel_8b_scale(RUDDER ,0x00,0x64); // rudder
|
||||
packet[2] = convert_channel_8b_scale(ELEVATOR,0x00,0x64); // elevator
|
||||
packet[3] = convert_channel_8b_scale(AILERON ,0x00,0x64); // aileron
|
||||
if(packet_count++ >= 23)
|
||||
{
|
||||
yz_seq_num ++;
|
||||
if(yz_seq_num > 2)
|
||||
yz_seq_num = 0;
|
||||
packet_count=0;
|
||||
}
|
||||
packet[4] = yz_p4_seq[yz_seq_num];
|
||||
packet[5] = 0x02 // expert ? (0=unarmed, 1=normal)
|
||||
| GET_FLAG(Servo_AUX4, 0x10) //VIDEO
|
||||
| GET_FLAG(Servo_AUX1, 0x80) //FLIP
|
||||
| GET_FLAG(Servo_AUX5, 0x04) //HEADLESS
|
||||
| GET_FLAG(Servo_AUX3, 0x20); //SNAPSHOT
|
||||
packet[6] = GET_FLAG(Servo_AUX2, 0x80); //LED
|
||||
packet[7] = packet[0];
|
||||
for(uint8_t idx = 1; idx < MT99XX_PACKET_SIZE-2; idx++)
|
||||
packet[7] += packet[idx];
|
||||
packet[8] = 0xff;
|
||||
}
|
||||
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, hopping_frequency[hopping_frequency_no] + channel_offset);
|
||||
NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70);
|
||||
NRF24L01_FlushTx();
|
||||
XN297_WritePayload(packet, MT99XX_PACKET_SIZE);
|
||||
|
||||
hopping_frequency_no++;
|
||||
if(sub_protocol == YZ)
|
||||
hopping_frequency_no++; // skip every other channel
|
||||
|
||||
if(hopping_frequency_no > 15)
|
||||
hopping_frequency_no = 0;
|
||||
|
||||
NRF24L01_SetPower();
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) MT99XX_init()
|
||||
{
|
||||
NRF24L01_Initialize();
|
||||
NRF24L01_SetTxRxMode(TX_EN);
|
||||
NRF24L01_FlushTx();
|
||||
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_WriteReg(NRF24L01_03_SETUP_AW, 0x03); // 5 bytes address
|
||||
NRF24L01_WriteReg(NRF24L01_04_SETUP_RETR, 0x00); // no auto retransmit
|
||||
if(sub_protocol == YZ)
|
||||
NRF24L01_SetBitrate(NRF24L01_BR_250K); // 250Kbps (nRF24L01+ only)
|
||||
else
|
||||
NRF24L01_SetBitrate(NRF24L01_BR_1M); // 1Mbps
|
||||
NRF24L01_SetPower();
|
||||
|
||||
XN297_Configure(BV(NRF24L01_00_EN_CRC) | BV(NRF24L01_00_CRCO) | BV(NRF24L01_00_PWR_UP) | (sub_protocol == YZ ? BV(XN297_UNSCRAMBLED):0) );
|
||||
|
||||
XN297_SetTXAddr((uint8_t *)"\xCC\xCC\xCC\xCC\xCC", 5);
|
||||
}
|
||||
|
||||
static void __attribute__((unused)) MT99XX_initialize_txid()
|
||||
{
|
||||
if(sub_protocol == YZ)
|
||||
{
|
||||
rx_tx_addr[0] = 0x53; // test (SB id)
|
||||
rx_tx_addr[1] = 0x00;
|
||||
}
|
||||
checksum_offset = (rx_tx_addr[0] + rx_tx_addr[1]) & 0xff;
|
||||
channel_offset = (((checksum_offset & 0xf0)>>4) + (checksum_offset & 0x0f)) % 8;
|
||||
}
|
||||
|
||||
uint16_t MT99XX_callback()
|
||||
{
|
||||
if(IS_BIND_DONE_on)
|
||||
MT99XX_send_packet();
|
||||
else
|
||||
{
|
||||
if (bind_counter == 0)
|
||||
{
|
||||
rx_tx_addr[2] = 0x00;
|
||||
rx_tx_addr[3] = 0xCC;
|
||||
rx_tx_addr[4] = 0xCC;
|
||||
// set tx address for data packets
|
||||
XN297_SetTXAddr(rx_tx_addr, 5);
|
||||
BIND_DONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, hopping_frequency[hopping_frequency_no]);
|
||||
NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70);
|
||||
NRF24L01_FlushTx();
|
||||
XN297_WritePayload(packet, MT99XX_PACKET_SIZE); // bind packet
|
||||
hopping_frequency_no++;
|
||||
if(sub_protocol == YZ)
|
||||
hopping_frequency_no++; // skip every other channel
|
||||
if(hopping_frequency_no > 15)
|
||||
hopping_frequency_no = 0;
|
||||
bind_counter--;
|
||||
}
|
||||
}
|
||||
|
||||
return packet_period;
|
||||
}
|
||||
|
||||
uint16_t initMT99XX(void)
|
||||
{
|
||||
BIND_IN_PROGRESS; // autobind protocol
|
||||
bind_counter = MT99XX_BIND_COUNT;
|
||||
|
||||
memcpy(hopping_frequency,"\x02\x48\x0C\x3e\x16\x34\x20\x2A\x2A\x20\x34\x16\x3e\x0c\x48\x02",16);
|
||||
|
||||
MT99XX_initialize_txid();
|
||||
MT99XX_init();
|
||||
|
||||
packet[0] = 0x20;
|
||||
if(sub_protocol!=YZ)
|
||||
{ // MT99 & H7
|
||||
packet_period = MT99XX_PACKET_PERIOD_MT;
|
||||
packet[1] = 0x14;
|
||||
packet[2] = 0x03;
|
||||
packet[3] = 0x25;
|
||||
}
|
||||
else
|
||||
{ // YZ
|
||||
packet_period = MT99XX_PACKET_PERIOD_YZ;
|
||||
packet[1] = 0x15;
|
||||
packet[2] = 0x05;
|
||||
packet[3] = 0x06;
|
||||
}
|
||||
packet[4] = rx_tx_addr[0]; // 1st byte for data state tx address
|
||||
packet[5] = rx_tx_addr[1]; // 2nd byte for data state tx address (always 0x00 on Yi Zhan ?)
|
||||
packet[6] = 0x00; // 3rd byte for data state tx address (always 0x00 ?)
|
||||
packet[7] = checksum_offset; // checksum offset
|
||||
packet[8] = 0xAA; // fixed
|
||||
packet_count=0;
|
||||
return MT99XX_INITIAL_WAIT+MT99XX_PACKET_PERIOD_MT;
|
||||
}
|
||||
#endif
|
||||
@@ -13,26 +13,41 @@
|
||||
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Check selected board type
|
||||
#if not defined(ARDUINO_AVR_PRO) && not defined(ARDUINO_AVR_MINI)
|
||||
#error You must select the board type "Arduino Pro or Pro Mini" or "Arduino Mini"
|
||||
#endif
|
||||
#if F_CPU != 16000000L || not defined(__AVR_ATmega328P__)
|
||||
#error You must select the processor type "ATmega328(5V, 16MHz)"
|
||||
#endif
|
||||
|
||||
//******************
|
||||
// Protocols
|
||||
//******************
|
||||
enum PROTOCOLS
|
||||
{
|
||||
MODE_SERIAL = 0, // Serial commands
|
||||
MODE_FLYSKY = 1, // =>A7105 / FLYSKY protocol
|
||||
MODE_HUBSAN = 2, // =>A7105 / HUBSAN protocol
|
||||
MODE_FRSKY = 3, // =>CC2500 / FRSKY protocol
|
||||
MODE_HISKY = 4, // =>NRF24L01 / HISKY protocol
|
||||
MODE_V2X2 = 5, // =>NRF24L01 / V2x2 protocol
|
||||
MODE_DSM2 = 6, // =>CYRF6936 / DSM2 protocol
|
||||
MODE_DEVO =7, // =>CYRF6936 / DEVO protocol
|
||||
MODE_YD717 = 8, // =>NRF24L01 / YD717 protocol (CX10 red pcb)
|
||||
MODE_KN = 9, // =>NRF24L01 / KN protocol
|
||||
MODE_SYMAX = 10, // =>NRF24L01 / SYMAX protocol (SYMAX4 working)
|
||||
MODE_SLT = 11, // =>NRF24L01 / SLT protocol
|
||||
MODE_CX10 = 12, // =>NRF24L01 / CX-10 protocol
|
||||
MODE_CG023 = 13, // =>NRF24L01 / CG023 protocol
|
||||
MODE_BAYANG = 14, // =>NRF24L01 / BAYANG protocol
|
||||
MODE_FRSKYX = 15, // =>CC2500 / FRSKYX protocol
|
||||
MODE_FLYSKY = 1, // =>A7105
|
||||
MODE_HUBSAN = 2, // =>A7105
|
||||
MODE_FRSKY = 3, // =>CC2500
|
||||
MODE_HISKY = 4, // =>NRF24L01
|
||||
MODE_V2X2 = 5, // =>NRF24L01
|
||||
MODE_DSM2 = 6, // =>CYRF6936
|
||||
MODE_DEVO =7, // =>CYRF6936
|
||||
MODE_YD717 = 8, // =>NRF24L01
|
||||
MODE_KN = 9, // =>NRF24L01
|
||||
MODE_SYMAX = 10, // =>NRF24L01
|
||||
MODE_SLT = 11, // =>NRF24L01
|
||||
MODE_CX10 = 12, // =>NRF24L01
|
||||
MODE_CG023 = 13, // =>NRF24L01
|
||||
MODE_BAYANG = 14, // =>NRF24L01
|
||||
MODE_FRSKYX = 15, // =>CC2500
|
||||
MODE_ESKY = 16, // =>NRF24L01
|
||||
MODE_MT99XX=17, // =>NRF24L01
|
||||
MODE_MJXQ=18, // =>NRF24L01
|
||||
MODE_SHENQI=19 // =>NRF24L01
|
||||
};
|
||||
|
||||
enum Flysky
|
||||
{
|
||||
Flysky=0,
|
||||
@@ -53,31 +68,66 @@ enum YD717
|
||||
{
|
||||
YD717=0,
|
||||
SKYWLKR=1,
|
||||
SYMAX2=2,
|
||||
SYMAX4=2,
|
||||
XINXUN=3,
|
||||
NIHUI=4
|
||||
};
|
||||
enum KN
|
||||
{
|
||||
WLTOYS=0,
|
||||
FEILUN=1
|
||||
};
|
||||
enum SYMAX
|
||||
{
|
||||
SYMAX=0,
|
||||
SYMAX5C=1,
|
||||
SYMAX5C=1
|
||||
};
|
||||
|
||||
enum CX10 {
|
||||
enum CX10
|
||||
{
|
||||
CX10_GREEN = 0,
|
||||
CX10_BLUE, // also compatible with CX10-A, CX12
|
||||
DM007
|
||||
CX10_BLUE=1, // also compatible with CX10-A, CX12
|
||||
DM007=2,
|
||||
Q282=3,
|
||||
JC3015_1=4,
|
||||
JC3015_2=5,
|
||||
MK33041=6,
|
||||
Q242=7
|
||||
};
|
||||
|
||||
enum CG023 {
|
||||
enum CG023
|
||||
{
|
||||
CG023 = 0,
|
||||
YD829 = 1,
|
||||
H8_3D = 2
|
||||
};
|
||||
enum MT99XX
|
||||
{
|
||||
MT99 = 0,
|
||||
H7 = 1,
|
||||
YZ = 2
|
||||
};
|
||||
enum MJXQ
|
||||
{
|
||||
WLH08 = 0,
|
||||
X600 = 1,
|
||||
X800 = 2,
|
||||
H26D = 3
|
||||
};
|
||||
|
||||
#define PPM_MIN_COMMAND 1250
|
||||
#define PPM_SWITCH 1550
|
||||
#define PPM_MAX_COMMAND 1750
|
||||
#define NONE 0
|
||||
#define P_HIGH 1
|
||||
#define P_LOW 0
|
||||
#define AUTOBIND 1
|
||||
#define NO_AUTOBIND 0
|
||||
|
||||
struct PPM_Parameters
|
||||
{
|
||||
uint8_t protocol : 5;
|
||||
uint8_t sub_proto : 3;
|
||||
uint8_t rx_num : 4;
|
||||
uint8_t power : 1;
|
||||
uint8_t autobind : 1;
|
||||
uint8_t option;
|
||||
};
|
||||
|
||||
//*******************
|
||||
//*** Pinouts ***
|
||||
@@ -143,6 +193,7 @@ enum CG023 {
|
||||
#define LED_OFF PORTB &= ~_BV(5)
|
||||
#define LED_TOGGLE PORTB ^= _BV(5)
|
||||
#define LED_SET_OUTPUT DDRB |= _BV(5)
|
||||
#define IS_LED_on ( (PORTB & _BV(5)) != 0x00 )
|
||||
|
||||
// Macros
|
||||
#define NOP() __asm__ __volatile__("nop")
|
||||
@@ -183,8 +234,26 @@ enum CG023 {
|
||||
#define BIND_DONE protocol_flags |= _BV(7)
|
||||
#define IS_BIND_DONE_on ( ( protocol_flags & _BV(7) ) !=0 )
|
||||
|
||||
#define BAD_PROTO_off protocol_flags2 &= ~_BV(0)
|
||||
#define BAD_PROTO_on protocol_flags2 |= _BV(0)
|
||||
#define IS_BAD_PROTO_on ( ( protocol_flags2 & _BV(0) ) !=0 )
|
||||
|
||||
#define BLINK_BIND_TIME 100
|
||||
#define BLINK_SERIAL_TIME 500
|
||||
#define BLINK_BAD_PROTO_TIME_LOW 1000
|
||||
#define BLINK_BAD_PROTO_TIME_HIGH 50
|
||||
|
||||
//AUX flags definition
|
||||
#define Servo_AUX1 Servo_AUX & _BV(0)
|
||||
#define Servo_AUX2 Servo_AUX & _BV(1)
|
||||
#define Servo_AUX3 Servo_AUX & _BV(2)
|
||||
#define Servo_AUX4 Servo_AUX & _BV(3)
|
||||
#define Servo_AUX5 Servo_AUX & _BV(4)
|
||||
#define Servo_AUX6 Servo_AUX & _BV(5)
|
||||
#define Servo_AUX7 Servo_AUX & _BV(6)
|
||||
#define Servo_AUX8 Servo_AUX & _BV(7)
|
||||
|
||||
#define GET_FLAG(ch, mask) ( ch ? mask : 0)
|
||||
|
||||
//************************
|
||||
//*** Power settings ***
|
||||
@@ -285,41 +354,40 @@ enum {
|
||||
//*******************
|
||||
const uint16_t PROGMEM CRCTable[]=
|
||||
{
|
||||
0x0000,0x1189,0x2312,0x329b,0x4624,0x57ad,0x6536,0x74bf,
|
||||
0x8c48,0x9dc1,0xaf5a,0xbed3,0xca6c,0xdbe5,0xe97e,0xf8f7,
|
||||
0x1081,0x0108,0x3393,0x221a,0x56a5,0x472c,0x75b7,0x643e,
|
||||
0x9cc9,0x8d40,0xbfdb,0xae52,0xdaed,0xcb64,0xf9ff,0xe876,
|
||||
0x2102,0x308b,0x0210,0x1399,0x6726,0x76af,0x4434,0x55bd,
|
||||
0xad4a,0xbcc3,0x8e58,0x9fd1,0xeb6e,0xfae7,0xc87c,0xd9f5,
|
||||
0x3183,0x200a,0x1291,0x0318,0x77a7,0x662e,0x54b5,0x453c,
|
||||
0xbdcb,0xac42,0x9ed9,0x8f50,0xfbef,0xea66,0xd8fd,0xc974,
|
||||
0x4204,0x538d,0x6116,0x709f,0x0420,0x15a9,0x2732,0x36bb,
|
||||
0xce4c,0xdfc5,0xed5e,0xfcd7,0x8868,0x99e1,0xab7a,0xbaf3,
|
||||
0x5285,0x430c,0x7197,0x601e,0x14a1,0x0528,0x37b3,0x263a,
|
||||
0xdecd,0xcf44,0xfddf,0xec56,0x98e9,0x8960,0xbbfb,0xaa72,
|
||||
0x6306,0x728f,0x4014,0x519d,0x2522,0x34ab,0x0630,0x17b9,
|
||||
0xef4e,0xfec7,0xcc5c,0xddd5,0xa96a,0xb8e3,0x8a78,0x9bf1,
|
||||
0x7387,0x620e,0x5095,0x411c,0x35a3,0x242a,0x16b1,0x0738,
|
||||
0xffcf,0xee46,0xdcdd,0xcd54,0xb9eb,0xa862,0x9af9,0x8b70,
|
||||
0x8408,0x9581,0xa71a,0xb693,0xc22c,0xd3a5,0xe13e,0xf0b7,
|
||||
0x0840,0x19c9,0x2b52,0x3adb,0x4e64,0x5fed,0x6d76,0x7cff,
|
||||
0x9489,0x8500,0xb79b,0xa612,0xd2ad,0xc324,0xf1bf,0xe036,
|
||||
0x18c1,0x0948,0x3bd3,0x2a5a,0x5ee5,0x4f6c,0x7df7,0x6c7e,
|
||||
0xa50a,0xb483,0x8618,0x9791,0xe32e,0xf2a7,0xc03c,0xd1b5,
|
||||
0x2942,0x38cb,0x0a50,0x1bd9,0x6f66,0x7eef,0x4c74,0x5dfd,
|
||||
0xb58b,0xa402,0x9699,0x8710,0xf3af,0xe226,0xd0bd,0xc134,
|
||||
0x39c3,0x284a,0x1ad1,0x0b58,0x7fe7,0x6e6e,0x5cf5,0x4d7c,
|
||||
0xc60c,0xd785,0xe51e,0xf497,0x8028,0x91a1,0xa33a,0xb2b3,
|
||||
0x4a44,0x5bcd,0x6956,0x78df,0x0c60,0x1de9,0x2f72,0x3efb,
|
||||
0xd68d,0xc704,0xf59f,0xe416,0x90a9,0x8120,0xb3bb,0xa232,
|
||||
0x5ac5,0x4b4c,0x79d7,0x685e,0x1ce1,0x0d68,0x3ff3,0x2e7a,
|
||||
0xe70e,0xf687,0xc41c,0xd595,0xa12a,0xb0a3,0x8238,0x93b1,
|
||||
0x6b46,0x7acf,0x4854,0x59dd,0x2d62,0x3ceb,0x0e70,0x1ff9,
|
||||
0xf78f,0xe606,0xd49d,0xc514,0xb1ab,0xa022,0x92b9,0x8330,
|
||||
0x7bc7,0x6a4e,0x58d5,0x495c,0x3de3,0x2c6a,0x1ef1,0x0f78
|
||||
0x0000,0x1189,0x2312,0x329b,0x4624,0x57ad,0x6536,0x74bf,
|
||||
0x8c48,0x9dc1,0xaf5a,0xbed3,0xca6c,0xdbe5,0xe97e,0xf8f7,
|
||||
0x1081,0x0108,0x3393,0x221a,0x56a5,0x472c,0x75b7,0x643e,
|
||||
0x9cc9,0x8d40,0xbfdb,0xae52,0xdaed,0xcb64,0xf9ff,0xe876,
|
||||
0x2102,0x308b,0x0210,0x1399,0x6726,0x76af,0x4434,0x55bd,
|
||||
0xad4a,0xbcc3,0x8e58,0x9fd1,0xeb6e,0xfae7,0xc87c,0xd9f5,
|
||||
0x3183,0x200a,0x1291,0x0318,0x77a7,0x662e,0x54b5,0x453c,
|
||||
0xbdcb,0xac42,0x9ed9,0x8f50,0xfbef,0xea66,0xd8fd,0xc974,
|
||||
0x4204,0x538d,0x6116,0x709f,0x0420,0x15a9,0x2732,0x36bb,
|
||||
0xce4c,0xdfc5,0xed5e,0xfcd7,0x8868,0x99e1,0xab7a,0xbaf3,
|
||||
0x5285,0x430c,0x7197,0x601e,0x14a1,0x0528,0x37b3,0x263a,
|
||||
0xdecd,0xcf44,0xfddf,0xec56,0x98e9,0x8960,0xbbfb,0xaa72,
|
||||
0x6306,0x728f,0x4014,0x519d,0x2522,0x34ab,0x0630,0x17b9,
|
||||
0xef4e,0xfec7,0xcc5c,0xddd5,0xa96a,0xb8e3,0x8a78,0x9bf1,
|
||||
0x7387,0x620e,0x5095,0x411c,0x35a3,0x242a,0x16b1,0x0738,
|
||||
0xffcf,0xee46,0xdcdd,0xcd54,0xb9eb,0xa862,0x9af9,0x8b70,
|
||||
0x8408,0x9581,0xa71a,0xb693,0xc22c,0xd3a5,0xe13e,0xf0b7,
|
||||
0x0840,0x19c9,0x2b52,0x3adb,0x4e64,0x5fed,0x6d76,0x7cff,
|
||||
0x9489,0x8500,0xb79b,0xa612,0xd2ad,0xc324,0xf1bf,0xe036,
|
||||
0x18c1,0x0948,0x3bd3,0x2a5a,0x5ee5,0x4f6c,0x7df7,0x6c7e,
|
||||
0xa50a,0xb483,0x8618,0x9791,0xe32e,0xf2a7,0xc03c,0xd1b5,
|
||||
0x2942,0x38cb,0x0a50,0x1bd9,0x6f66,0x7eef,0x4c74,0x5dfd,
|
||||
0xb58b,0xa402,0x9699,0x8710,0xf3af,0xe226,0xd0bd,0xc134,
|
||||
0x39c3,0x284a,0x1ad1,0x0b58,0x7fe7,0x6e6e,0x5cf5,0x4d7c,
|
||||
0xc60c,0xd785,0xe51e,0xf497,0x8028,0x91a1,0xa33a,0xb2b3,
|
||||
0x4a44,0x5bcd,0x6956,0x78df,0x0c60,0x1de9,0x2f72,0x3efb,
|
||||
0xd68d,0xc704,0xf59f,0xe416,0x90a9,0x8120,0xb3bb,0xa232,
|
||||
0x5ac5,0x4b4c,0x79d7,0x685e,0x1ce1,0x0d68,0x3ff3,0x2e7a,
|
||||
0xe70e,0xf687,0xc41c,0xd595,0xa12a,0xb0a3,0x8238,0x93b1,
|
||||
0x6b46,0x7acf,0x4854,0x59dd,0x2d62,0x3ceb,0x0e70,0x1ff9,
|
||||
0xf78f,0xe606,0xd49d,0xc514,0xb1ab,0xa022,0x92b9,0x8330,
|
||||
0x7bc7,0x6a4e,0x58d5,0x495c,0x3de3,0x2c6a,0x1ef1,0x0f78
|
||||
};
|
||||
|
||||
|
||||
//****************************************
|
||||
//*** MULTI protocol serial definition ***
|
||||
//****************************************
|
||||
@@ -349,6 +417,10 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
|
||||
CG023 13
|
||||
Bayang 14
|
||||
FrskyX 15
|
||||
ESky 16
|
||||
MT99XX 17
|
||||
MJXQ 18
|
||||
SHENQI 19
|
||||
BindBit=> 0x80 1=Bind/0=No
|
||||
AutoBindBit=> 0x40 1=Yes /0=No
|
||||
RangeCheck=> 0x20 1=Yes /0=No
|
||||
@@ -369,9 +441,12 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
|
||||
sub_protocol==YD717
|
||||
YD717 0
|
||||
SKYWLKR 1
|
||||
SYMAX2 2
|
||||
SYMAX4 2
|
||||
XINXUN 3
|
||||
NIHUI 4
|
||||
sub_protocol==KN
|
||||
WLTOYS 0
|
||||
FEILUN 1
|
||||
sub_protocol==SYMAX
|
||||
SYMAX 0
|
||||
SYMAX5C 1
|
||||
@@ -379,10 +454,24 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
|
||||
CX10_GREEN 0
|
||||
CX10_BLUE 1 // also compatible with CX10-A, CX12
|
||||
DM007 2
|
||||
Q282 3
|
||||
JC3015_1 4
|
||||
JC3015_2 5
|
||||
MK33041 6
|
||||
Q242 7
|
||||
sub_protocol==CG023
|
||||
CG023 0
|
||||
YD829 1
|
||||
H8_3D 2
|
||||
sub_protocol==MT99XX
|
||||
MT99 0
|
||||
H7 1
|
||||
YZ 2
|
||||
sub_protocol==MJXQ
|
||||
WLH08 0
|
||||
X600 1
|
||||
X800 2
|
||||
H26D 3
|
||||
Power value => 0x80 0=High/1=Low
|
||||
Stream[3] = option_protocol;
|
||||
option_protocol value is -127..127
|
||||
@@ -394,78 +483,5 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
|
||||
1843 +100%
|
||||
2047 +125%
|
||||
Channels bits are concatenated to fit in 22 bytes like in SBUS protocol
|
||||
|
||||
|
||||
**************************
|
||||
8 channels serial protocol
|
||||
**************************
|
||||
Serial: 125000 Baud 8n1 _ xxxx xxxx - ---
|
||||
Channels:
|
||||
Nbr=8
|
||||
10bits=0..1023
|
||||
0 -125%
|
||||
96 -100%
|
||||
512 0%
|
||||
928 +100%
|
||||
1023 +125%
|
||||
Stream[0] = sub_protocol|BindBit|RangeCheckBit|AutoBindBit;
|
||||
sub_protocol is 0..31 (bits 0..4)
|
||||
=> Reserved 0
|
||||
Flysky 1
|
||||
Hubsan 2
|
||||
Frsky 3
|
||||
Hisky 4
|
||||
V2x2 5
|
||||
DSM2 6
|
||||
Devo 7
|
||||
YD717 8
|
||||
KN 9
|
||||
SymaX 10
|
||||
SLT 11
|
||||
CX10 12
|
||||
CG023 13
|
||||
Bayang 14
|
||||
FrskyX 15
|
||||
BindBit=> 0x80 1=Bind/0=No
|
||||
AutoBindBit=> 0x40 1=Yes /0=No
|
||||
RangeCheck=> 0x20 1=Yes /0=No
|
||||
Stream[1] = RxNum | Power | Type;
|
||||
RxNum value is 0..15 (bits 0..3)
|
||||
Type is 0..7 <<4 (bit 4..6)
|
||||
sub_protocol==Flysky
|
||||
Flysky 0
|
||||
V9x9 1
|
||||
V6x6 2
|
||||
V912 3
|
||||
sub_protocol==Hisky
|
||||
Hisky 0
|
||||
HK310 1
|
||||
sub_protocol==DSM2
|
||||
DSM2 0
|
||||
DSMX 1
|
||||
sub_protocol==YD717
|
||||
YD717 0
|
||||
SKYWLKR 1
|
||||
SYMAX2 2
|
||||
XINXUN 3
|
||||
NIHUI 4
|
||||
sub_protocol==SYMAX
|
||||
SYMAX 0
|
||||
SYMAX5C 1
|
||||
sub_protocol==CX10
|
||||
CX10_GREEN 0
|
||||
CX10_BLUE 1 // also compatible with CX10-A, CX12
|
||||
DM007 2
|
||||
sub_protocol==CG023
|
||||
CG023 0
|
||||
YD829 1
|
||||
H8_3D 2
|
||||
Power value => 0x80 0=High/1=Low
|
||||
Stream[2] = option_protocol;
|
||||
option_protocol value is -127..127
|
||||
Stream[i+3] = lowByte(channel[i]) // with i[0..7]
|
||||
Stream[11] = highByte(channel[0])<<6 | highByte(channel[1])<<4 | highByte(channel[2])<<2 | highByte(channel[3])
|
||||
Stream[12] = highByte(channel[4])<<6 | highByte(channel[5])<<4 | highByte(channel[6])<<2 | highByte(channel[7])
|
||||
Stream[13] = lowByte(CRC16(Stream[0..12])
|
||||
*/
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
http://www.rcgroups.com/forums/showthread.php?t=2165676
|
||||
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/edit/master/README.md
|
||||
|
||||
Thanks to PhracturedBlue
|
||||
Thanks to PhracturedBlue, Hexfet, Goebish and all protocol developers
|
||||
Ported from deviation firmware
|
||||
|
||||
This project is free software: you can redistribute it and/or modify
|
||||
@@ -23,162 +23,60 @@
|
||||
#include <avr/eeprom.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <util/delay.h>
|
||||
#include "Multiprotocol.h"
|
||||
|
||||
#include "multiprotocol.h"
|
||||
|
||||
//******************************************************
|
||||
// Multiprotocol module configuration starts here
|
||||
|
||||
//Uncomment the TX type
|
||||
#define ER9X
|
||||
//#define DEVO7
|
||||
|
||||
//Uncomment to enable 8 channels serial protocol, 16 otherwise
|
||||
//#define NUM_SERIAL_CH_8
|
||||
|
||||
//Uncomment to enable telemetry
|
||||
#define TELEMETRY
|
||||
|
||||
//Protocols to include in compilation, comment to exclude
|
||||
#define BAYANG_NRF24L01_INO
|
||||
#define CG023_NRF24L01_INO
|
||||
#define CX10_NRF24L01_INO
|
||||
#define DEVO_CYRF6936_INO
|
||||
#define DSM2_CYRF6936_INO
|
||||
#define FLYSKY_A7105_INO
|
||||
#define FRSKY_CC2500_INO
|
||||
#define HISKY_NRF24L01_INO
|
||||
#define HUBSAN_A7105_INO
|
||||
#define KN_NRF24L01_INO
|
||||
#define SLT_NRF24L01_INO
|
||||
#define SYMAX_NRF24L01_INO
|
||||
#define V2X2_NRF24L01_INO
|
||||
#define YD717_NRF24L01_INO
|
||||
//#define FRSKYX_CC2500_INO
|
||||
|
||||
//Update this table to set which protocol/sub_protocol is called for the corresponding dial number
|
||||
static const uint8_t PPM_prot[15][2]= { {MODE_FLYSKY , Flysky }, //Dial=1
|
||||
{MODE_HUBSAN , 0 }, //Dial=2
|
||||
{MODE_FRSKY , 0 }, //Dial=3
|
||||
{MODE_HISKY , Hisky }, //Dial=4
|
||||
{MODE_V2X2 , 0 }, //Dial=5
|
||||
{MODE_DSM2 , DSM2 }, //Dial=6
|
||||
{MODE_DEVO , 0 }, //Dial=7
|
||||
{MODE_YD717 , YD717 }, //Dial=8
|
||||
{MODE_KN , 0 }, //Dial=9
|
||||
{MODE_SYMAX , SYMAX }, //Dial=10
|
||||
{MODE_SLT , 0 }, //Dial=11
|
||||
{MODE_CX10 , CX10_BLUE }, //Dial=12
|
||||
{MODE_CG023 , CG023 }, //Dial=13
|
||||
{MODE_BAYANG , 0 }, //Dial=14
|
||||
{MODE_SYMAX , SYMAX5C } //Dial=15
|
||||
};
|
||||
|
||||
//
|
||||
//TX definitions with timing endpoints and channels order
|
||||
//
|
||||
|
||||
// Turnigy PPM and channels
|
||||
#if defined(ER9X)
|
||||
#define PPM_MAX 2140
|
||||
#define PPM_MIN 860
|
||||
#define PPM_MAX_100 2012
|
||||
#define PPM_MIN_100 988
|
||||
enum chan_order{
|
||||
AILERON =0,
|
||||
ELEVATOR,
|
||||
THROTTLE,
|
||||
RUDDER,
|
||||
AUX1,
|
||||
AUX2,
|
||||
AUX3,
|
||||
AUX4,
|
||||
AUX5,
|
||||
AUX6,
|
||||
AUX7,
|
||||
AUX8
|
||||
};
|
||||
#endif
|
||||
|
||||
// Devo PPM and channels
|
||||
#if defined(DEVO7)
|
||||
#define PPM_MAX 2100
|
||||
#define PPM_MIN 900
|
||||
#define PPM_MAX_100 1920
|
||||
#define PPM_MIN_100 1120
|
||||
enum chan_order{
|
||||
ELEVATOR=0,
|
||||
AILERON,
|
||||
THROTTLE,
|
||||
RUDDER,
|
||||
AUX1,
|
||||
AUX2,
|
||||
AUX3,
|
||||
AUX4,
|
||||
AUX5,
|
||||
AUX6,
|
||||
AUX7,
|
||||
AUX8
|
||||
};
|
||||
#endif
|
||||
|
||||
//CC2500 RF module frequency adjustment, use in case you cannot bind with Frsky RX
|
||||
//Note: this is set via Option when serial protocol is used
|
||||
//values from 0-127 offset increase frequency, values from 255 to 127 decrease base frequency
|
||||
//uint8_t fine = 0x00;
|
||||
uint8_t fine = 0xd7; //* 215=-41 *
|
||||
|
||||
// Multiprotocol module configuration ends here
|
||||
//******************************************************
|
||||
|
||||
//Multiprotocol module configuration file
|
||||
#include "_Config.h"
|
||||
|
||||
//Global constants/variables
|
||||
|
||||
uint32_t MProtocol_id;//tx id,
|
||||
uint32_t MProtocol_id_master;
|
||||
uint32_t Model_fixed_id=0;
|
||||
uint32_t fixed_id;
|
||||
uint8_t cyrfmfg_id[6];//for dsm2 and devo
|
||||
uint8_t cyrfmfg_id[6];//for dsm2 and devo
|
||||
uint32_t blink=0;
|
||||
//
|
||||
uint16_t counter;
|
||||
uint8_t channel;
|
||||
uint8_t packet[40];
|
||||
uint8_t channel;
|
||||
uint8_t packet[40];
|
||||
|
||||
#define NUM_CHN 16
|
||||
// Servo data
|
||||
uint16_t Servo_data[NUM_CHN];
|
||||
// PPM variable
|
||||
volatile uint16_t PPM_data[NUM_CHN];
|
||||
uint8_t Servo_AUX;
|
||||
|
||||
// NRF variables
|
||||
uint8_t rx_tx_addr[5];
|
||||
uint8_t phase;
|
||||
// Protocol variables
|
||||
uint8_t rx_tx_addr[5];
|
||||
uint8_t phase;
|
||||
uint16_t bind_counter;
|
||||
uint8_t bind_phase;
|
||||
uint8_t binding_idx;
|
||||
uint8_t bind_phase;
|
||||
uint8_t binding_idx;
|
||||
uint32_t packet_counter;
|
||||
uint16_t packet_period;
|
||||
uint8_t packet_count;
|
||||
uint8_t packet_sent;
|
||||
uint8_t packet_length;
|
||||
uint8_t hopping_frequency[23];
|
||||
uint8_t *hopping_frequency_ptr;
|
||||
uint8_t hopping_frequency_no=0;
|
||||
uint8_t rf_ch_num;
|
||||
uint8_t throttle, rudder, elevator, aileron;
|
||||
uint8_t flags;
|
||||
uint8_t packet_count;
|
||||
uint8_t packet_sent;
|
||||
uint8_t packet_length;
|
||||
uint8_t hopping_frequency[23];
|
||||
uint8_t *hopping_frequency_ptr;
|
||||
uint8_t hopping_frequency_no=0;
|
||||
uint8_t rf_ch_num;
|
||||
uint8_t throttle, rudder, elevator, aileron;
|
||||
uint8_t flags;
|
||||
uint16_t crc;
|
||||
//
|
||||
uint32_t state;
|
||||
uint8_t len;
|
||||
uint8_t RX_num;
|
||||
|
||||
// Mode_select variables
|
||||
uint8_t mode_select;
|
||||
uint8_t protocol_flags;
|
||||
uint8_t protocol_flags=0,protocol_flags2=0;
|
||||
|
||||
// PPM variable
|
||||
volatile uint16_t PPM_data[NUM_CHN];
|
||||
|
||||
// Serial variables
|
||||
#if defined(NUM_SERIAL_CH_8) //8 channels serial protocol
|
||||
#define RXBUFFER_SIZE 14
|
||||
#else //16 channels serial protocol
|
||||
#define RXBUFFER_SIZE 25
|
||||
#endif
|
||||
#define TXBUFFER_SIZE 12
|
||||
volatile uint8_t rx_buff[RXBUFFER_SIZE];
|
||||
volatile uint8_t rx_ok_buff[RXBUFFER_SIZE];
|
||||
@@ -192,22 +90,23 @@ uint8_t cur_protocol[2];
|
||||
uint8_t prev_protocol=0;
|
||||
|
||||
// Telemetry
|
||||
#define MAX_PKT 27
|
||||
uint8_t pkt[MAX_PKT];//telemetry receiving packets
|
||||
#if defined(TELEMETRY)
|
||||
uint8_t pkt[27];//telemetry receiving packets
|
||||
uint8_t pktt[27];//telemetry receiving packets
|
||||
volatile uint8_t tx_head;
|
||||
volatile uint8_t tx_tail;
|
||||
uint8_t v_lipo;
|
||||
int16_t RSSI_dBm;
|
||||
//const uint8_t RSSI_offset=72;//69 71.72 values db
|
||||
uint8_t telemetry_link=0;
|
||||
#include "telemetry.h"
|
||||
uint8_t pktt[MAX_PKT];//telemetry receiving packets
|
||||
volatile uint8_t tx_head;
|
||||
volatile uint8_t tx_tail;
|
||||
uint8_t v_lipo;
|
||||
int16_t RSSI_dBm;
|
||||
//const uint8_t RSSI_offset=72;//69 71.72 values db
|
||||
uint8_t telemetry_link=0;
|
||||
uint8_t telemetry_counter=0;
|
||||
#endif
|
||||
|
||||
// Callback
|
||||
typedef uint16_t (*void_function_t) (void);//pointer to a function with no parameters which return an uint16_t integer
|
||||
void_function_t remote_callback = 0;
|
||||
void CheckTimer(uint16_t (*cb)(void));
|
||||
static void CheckTimer(uint16_t (*cb)(void));
|
||||
|
||||
// Init
|
||||
void setup()
|
||||
@@ -239,6 +138,9 @@ void setup()
|
||||
Servo_data[THROTTLE]=PPM_MIN_100;
|
||||
memcpy((void *)PPM_data,Servo_data, sizeof(Servo_data));
|
||||
|
||||
//Wait for every component to start
|
||||
delay(100);
|
||||
|
||||
// Read status of bind button
|
||||
if( (PINB & _BV(5)) == 0x00 )
|
||||
BIND_BUTTON_FLAG_on; // If bind button pressed save the status for protocol id reset under hubsan
|
||||
@@ -247,30 +149,42 @@ void setup()
|
||||
// after this mode_select will be one of {0000, 0001, ..., 1111}
|
||||
mode_select=0x0F - ( ( (PINB>>2)&0x07 ) | ( (PINC<<3)&0x08) );//encoder dip switches 1,2,4,8=>B2,B3,B4,C0
|
||||
//**********************************
|
||||
//mode_select=14; // here to test PPM
|
||||
//mode_select=1; // here to test PPM
|
||||
//**********************************
|
||||
|
||||
// Update LED
|
||||
LED_OFF;
|
||||
LED_OFF;
|
||||
LED_SET_OUTPUT;
|
||||
|
||||
// Read or create protocol id
|
||||
MProtocol_id=random_id(10,false);
|
||||
MProtocol_id_master=MProtocol_id;
|
||||
|
||||
//Set power transmission flags
|
||||
POWER_FLAG_on; //By default high power for everything
|
||||
MProtocol_id_master=random_id(10,false);
|
||||
|
||||
//Init RF modules
|
||||
#ifdef CC2500_INSTALLED
|
||||
CC2500_Reset();
|
||||
#endif
|
||||
|
||||
//Protocol and interrupts initialization
|
||||
if(mode_select != MODE_SERIAL)
|
||||
{ // PPM
|
||||
cur_protocol[0]= PPM_prot[mode_select-1][0];
|
||||
sub_protocol = PPM_prot[mode_select-1][1];
|
||||
protocol_init(cur_protocol[0]);
|
||||
mode_select--;
|
||||
cur_protocol[0] = PPM_prot[mode_select].protocol;
|
||||
sub_protocol = PPM_prot[mode_select].sub_proto;
|
||||
RX_num = PPM_prot[mode_select].rx_num;
|
||||
MProtocol_id = RX_num + MProtocol_id_master;
|
||||
option = PPM_prot[mode_select].option;
|
||||
if(PPM_prot[mode_select].power) POWER_FLAG_on;
|
||||
if(PPM_prot[mode_select].autobind) AUTOBIND_FLAG_on;
|
||||
mode_select++;
|
||||
|
||||
protocol_init();
|
||||
|
||||
//Configure PPM interrupt
|
||||
EICRA |=(1<<ISC11); // The rising edge of INT1 pin D3 generates an interrupt request
|
||||
EIMSK |= (1<<INT1); // INT1 interrupt enable
|
||||
#if defined(TELEMETRY)
|
||||
PPM_Telemetry_serial_init(); // Configure serial for telemetry
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{ // Serial
|
||||
@@ -287,11 +201,12 @@ void loop()
|
||||
if(mode_select==MODE_SERIAL && IS_RX_FLAG_on) // Serial mode and something has been received
|
||||
{
|
||||
update_serial_data(); // Update protocol and data
|
||||
update_aux_flags();
|
||||
if(IS_CHANGE_PROTOCOL_FLAG_on)
|
||||
{ // Protocol needs to be changed
|
||||
LED_OFF; //led off during protocol init
|
||||
module_reset(); //reset previous module
|
||||
protocol_init(cur_protocol[0]&0x1F); //init new protocol
|
||||
protocol_init(); //init new protocol
|
||||
CHANGE_PROTOCOL_FLAG_off; //done
|
||||
}
|
||||
}
|
||||
@@ -303,44 +218,53 @@ void loop()
|
||||
Servo_data[i]=PPM_data[i];
|
||||
sei(); // enable global int
|
||||
}
|
||||
update_aux_flags();
|
||||
PPM_FLAG_off; // wait for next frame before update
|
||||
}
|
||||
update_led_status();
|
||||
#if defined(TELEMETRY)
|
||||
if(((cur_protocol[0]&0x1F)==MODE_FRSKY)||((cur_protocol[0]&0x1F)==MODE_HUBSAN))
|
||||
if( ((cur_protocol[0]&0x1F)==MODE_FRSKY) || ((cur_protocol[0]&0x1F)==MODE_HUBSAN) || ((cur_protocol[0]&0x1F)==MODE_FRSKYX) )
|
||||
frskyUpdate();
|
||||
#endif
|
||||
if (remote_callback != 0)
|
||||
CheckTimer(remote_callback);
|
||||
}
|
||||
|
||||
// Update led status based on binding and serial
|
||||
void update_led_status(void)
|
||||
// Update Servo_AUX flags based on servo AUX positions
|
||||
static void update_aux_flags(void)
|
||||
{
|
||||
if(cur_protocol[0]==0)
|
||||
{ // serial without valid protocol
|
||||
if(blink<millis())
|
||||
{
|
||||
LED_TOGGLE;
|
||||
Servo_AUX=0;
|
||||
for(uint8_t i=0;i<8;i++)
|
||||
if(Servo_data[AUX1+i]>PPM_SWITCH)
|
||||
Servo_AUX|=1<<i;
|
||||
}
|
||||
|
||||
// Update led status based on binding and serial
|
||||
static void update_led_status(void)
|
||||
{
|
||||
if(blink<millis())
|
||||
{
|
||||
if(cur_protocol[0]==0) // No valid serial received at least once
|
||||
blink+=BLINK_SERIAL_TIME; //blink slowly while waiting a valid serial input
|
||||
}
|
||||
}
|
||||
else
|
||||
if(remote_callback == 0)
|
||||
LED_OFF;
|
||||
else
|
||||
if(IS_BIND_DONE_on)
|
||||
LED_ON; //bind completed -> led on
|
||||
if(remote_callback == 0)
|
||||
{ // Invalid protocol
|
||||
if(IS_LED_on) //flash to indicate invalid protocol
|
||||
blink+=BLINK_BAD_PROTO_TIME_LOW;
|
||||
else
|
||||
blink+=BLINK_BAD_PROTO_TIME_HIGH;
|
||||
}
|
||||
else
|
||||
if(blink<millis())
|
||||
{
|
||||
LED_TOGGLE;
|
||||
blink+=BLINK_BIND_TIME; //blink fastly during binding
|
||||
}
|
||||
if(IS_BIND_DONE_on)
|
||||
LED_OFF; //bind completed -> led on
|
||||
else
|
||||
blink+=BLINK_BIND_TIME; //blink fastly during binding
|
||||
LED_TOGGLE;
|
||||
}
|
||||
}
|
||||
|
||||
// Protocol scheduler
|
||||
void CheckTimer(uint16_t (*cb)(void))
|
||||
static void CheckTimer(uint16_t (*cb)(void))
|
||||
{
|
||||
uint16_t next_callback;
|
||||
uint32_t prev;
|
||||
@@ -373,13 +297,14 @@ void CheckTimer(uint16_t (*cb)(void))
|
||||
}
|
||||
}
|
||||
|
||||
void protocol_init(uint8_t protocol)
|
||||
// Protocol start
|
||||
static void protocol_init()
|
||||
{
|
||||
uint16_t next_callback=100; // Default is immediate call back
|
||||
uint16_t next_callback=0; // Default is immediate call back
|
||||
remote_callback = 0;
|
||||
|
||||
set_rx_tx_addr(MProtocol_id);
|
||||
blink=millis()+BLINK_BIND_TIME;
|
||||
blink=millis();
|
||||
if(IS_BIND_BUTTON_FLAG_on)
|
||||
AUTOBIND_FLAG_on;
|
||||
if(IS_AUTOBIND_FLAG_on)
|
||||
@@ -387,10 +312,10 @@ void protocol_init(uint8_t protocol)
|
||||
else
|
||||
BIND_DONE;
|
||||
|
||||
CTRL1_on; //antenna RF3 by default
|
||||
CTRL2_off; //antenna RF3 by default
|
||||
CTRL1_on; //NRF24L01 antenna RF3 by default
|
||||
CTRL2_off; //NRF24L01 antenna RF3 by default
|
||||
|
||||
switch(protocol) // Init the requested protocol
|
||||
switch(cur_protocol[0]&0x1F) // Init the requested protocol
|
||||
{
|
||||
#if defined(FLYSKY_A7105_INO)
|
||||
case MODE_FLYSKY:
|
||||
@@ -491,6 +416,30 @@ void protocol_init(uint8_t protocol)
|
||||
next_callback=initBAYANG();
|
||||
remote_callback = BAYANG_callback;
|
||||
break;
|
||||
#endif
|
||||
#if defined(ESKY_NRF24L01_INO)
|
||||
case MODE_ESKY:
|
||||
next_callback=initESKY();
|
||||
remote_callback = ESKY_callback;
|
||||
break;
|
||||
#endif
|
||||
#if defined(MT99XX_NRF24L01_INO)
|
||||
case MODE_MT99XX:
|
||||
next_callback=initMT99XX();
|
||||
remote_callback = MT99XX_callback;
|
||||
break;
|
||||
#endif
|
||||
#if defined(MJXQ_NRF24L01_INO)
|
||||
case MODE_MJXQ:
|
||||
next_callback=initMJXQ();
|
||||
remote_callback = MJXQ_callback;
|
||||
break;
|
||||
#endif
|
||||
#if defined(SHENQI_NRF24L01_INO)
|
||||
case MODE_SHENQI:
|
||||
next_callback=initSHENQI();
|
||||
remote_callback = SHENQI_callback;
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -506,7 +455,7 @@ void protocol_init(uint8_t protocol)
|
||||
BIND_BUTTON_FLAG_off; // do not bind/reset id anymore even if protocol change
|
||||
}
|
||||
|
||||
void update_serial_data()
|
||||
static void update_serial_data()
|
||||
{
|
||||
if(rx_ok_buff[0]&0x20) //check range
|
||||
RANGE_FLAG_on;
|
||||
@@ -522,7 +471,6 @@ void update_serial_data()
|
||||
POWER_FLAG_on; //power high
|
||||
|
||||
option=rx_ok_buff[2];
|
||||
fine=option; // Update FrSky fine tuning
|
||||
|
||||
if( ((rx_ok_buff[0]&0x5F) != (cur_protocol[0]&0x5F)) || ( (rx_ok_buff[1]&0x7F) != cur_protocol[1] ) )
|
||||
{ // New model has been selected
|
||||
@@ -530,26 +478,15 @@ void update_serial_data()
|
||||
cur_protocol[1] = rx_ok_buff[1]&0x7F; //store current protocol
|
||||
CHANGE_PROTOCOL_FLAG_on; //change protocol
|
||||
sub_protocol=(rx_ok_buff[1]>>4)& 0x07; //subprotocol no (0-7) bits 4-6
|
||||
MProtocol_id=MProtocol_id_master+(rx_ok_buff[1]& 0x0F); //personalized RX bind + rx num // rx_num bits 0---3
|
||||
RX_num=rx_ok_buff[1]& 0x0F;
|
||||
MProtocol_id=MProtocol_id_master+RX_num; //personalized RX bind + rx num // rx_num bits 0---3
|
||||
}
|
||||
else
|
||||
if( ((rx_ok_buff[0]&0x80)!=0) && ((cur_protocol[0]&0x80)==0) ) // Bind flag has been set
|
||||
CHANGE_PROTOCOL_FLAG_on; //restart protocol with bind
|
||||
cur_protocol[0] = rx_ok_buff[0]; //store current protocol
|
||||
|
||||
// decode channel values
|
||||
#if defined(NUM_SERIAL_CH_8) //8 channels serial protocol
|
||||
Servo_data[0]=rx_ok_buff[3]+((rx_ok_buff[11]&0xC0)<<2);
|
||||
Servo_data[1]=rx_ok_buff[4]+((rx_ok_buff[11]&0x30)<<4);
|
||||
Servo_data[2]=rx_ok_buff[5]+((rx_ok_buff[11]&0x0C)<<6);
|
||||
Servo_data[3]=rx_ok_buff[6]+((rx_ok_buff[11]&0x03)<<8);
|
||||
Servo_data[4]=rx_ok_buff[7]+((rx_ok_buff[12]&0xC0)<<2);
|
||||
Servo_data[5]=rx_ok_buff[8]+((rx_ok_buff[12]&0x30)<<4);
|
||||
Servo_data[6]=rx_ok_buff[9]+((rx_ok_buff[12]&0x0C)<<6);
|
||||
Servo_data[7]=rx_ok_buff[10]+((rx_ok_buff[12]&0x03)<<8);
|
||||
for(uint8_t i=0;i<8;i++)
|
||||
Servo_data[i]=((Servo_data[i]*5)>>2)+860; //range 860-2140;
|
||||
#else //16 channels serial protocol
|
||||
// decode channel values
|
||||
volatile uint8_t *p=rx_ok_buff+2;
|
||||
uint8_t dec=-3;
|
||||
for(uint8_t i=0;i<NUM_CHN;i++)
|
||||
@@ -563,36 +500,32 @@ void update_serial_data()
|
||||
p++;
|
||||
Servo_data[i]=((((*((uint32_t *)p))>>dec)&0x7FF)*5)/8+860; //value range 860<->2140 -125%<->+125%
|
||||
}
|
||||
#endif
|
||||
RX_FLAG_off; //data has been processed
|
||||
}
|
||||
|
||||
void module_reset()
|
||||
static void module_reset()
|
||||
{
|
||||
remote_callback = 0;
|
||||
switch(prev_protocol)
|
||||
{
|
||||
case MODE_FLYSKY:
|
||||
case MODE_HUBSAN:
|
||||
A7105_Reset();
|
||||
break;
|
||||
case MODE_FRSKY:
|
||||
case MODE_FRSKYX:
|
||||
CC2500_Reset();
|
||||
break;
|
||||
case MODE_HISKY:
|
||||
case MODE_V2X2:
|
||||
case MODE_YD717:
|
||||
case MODE_KN:
|
||||
case MODE_SYMAX:
|
||||
case MODE_SLT:
|
||||
case MODE_CX10:
|
||||
NRF24L01_Reset();
|
||||
break;
|
||||
case MODE_DSM2:
|
||||
case MODE_DEVO:
|
||||
CYRF_Reset();
|
||||
break;
|
||||
if(remote_callback)
|
||||
{ // previous protocol loaded
|
||||
remote_callback = 0;
|
||||
switch(prev_protocol)
|
||||
{
|
||||
case MODE_FLYSKY:
|
||||
case MODE_HUBSAN:
|
||||
A7105_Reset();
|
||||
break;
|
||||
case MODE_FRSKY:
|
||||
case MODE_FRSKYX:
|
||||
CC2500_Reset();
|
||||
break;
|
||||
case MODE_DSM2:
|
||||
case MODE_DEVO:
|
||||
CYRF_Reset();
|
||||
break;
|
||||
default: // MODE_HISKY, MODE_V2X2, MODE_YD717, MODE_KN, MODE_SYMAX, MODE_SLT, MODE_CX10, MODE_CG023, MODE_BAYANG, MODE_ESKY, MODE_MT99XX, MODE_MJXQ, MODE_SHENQI
|
||||
NRF24L01_Reset();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -647,8 +580,48 @@ uint16_t limit_channel_100(uint8_t ch)
|
||||
return Servo_data[ch];
|
||||
}
|
||||
|
||||
#if defined(TELEMETRY)
|
||||
void Serial_write(uint8_t data)
|
||||
{
|
||||
cli(); // disable global int
|
||||
if(++tx_head>=TXBUFFER_SIZE)
|
||||
tx_head=0;
|
||||
tx_buff[tx_head]=data;
|
||||
sei(); // enable global int
|
||||
UCSR0B |= (1<<UDRIE0);//enable UDRE interrupt
|
||||
}
|
||||
#endif
|
||||
|
||||
static void Mprotocol_serial_init()
|
||||
{
|
||||
#include <util/setbaud.h>
|
||||
UBRR0H = UBRRH_VALUE;
|
||||
UBRR0L = UBRRL_VALUE;
|
||||
UCSR0A = 0 ; // Clear X2 bit
|
||||
//Set frame format to 8 data bits, even parity, 2 stop bits
|
||||
UCSR0C = (1<<UPM01)|(1<<USBS0)|(1<<UCSZ01)|(1<<UCSZ00);
|
||||
while ( UCSR0A & (1 << RXC0) )//flush receive buffer
|
||||
UDR0;
|
||||
//enable reception and RC complete interrupt
|
||||
UCSR0B = (1<<RXEN0)|(1<<RXCIE0);//rx enable and interrupt
|
||||
UCSR0B |= (1<<TXEN0);//tx enable
|
||||
}
|
||||
|
||||
#if defined(TELEMETRY)
|
||||
static void PPM_Telemetry_serial_init()
|
||||
{
|
||||
//9600 bauds
|
||||
UBRR0H = 0x00;
|
||||
UBRR0L = 0x67;
|
||||
UCSR0A = 0 ; // Clear X2 bit
|
||||
//Set frame format to 8 data bits, none, 1 stop bit
|
||||
UCSR0C = (1<<UCSZ01)|(1<<UCSZ00);
|
||||
UCSR0B = (1<<TXEN0);//tx enable
|
||||
}
|
||||
#endif
|
||||
|
||||
// Convert 32b id to rx_tx_addr
|
||||
void set_rx_tx_addr(uint32_t id)
|
||||
static void set_rx_tx_addr(uint32_t id)
|
||||
{ // Used by almost all protocols
|
||||
rx_tx_addr[0] = (id >> 24) & 0xFF;
|
||||
rx_tx_addr[1] = (id >> 16) & 0xFF;
|
||||
@@ -657,42 +630,6 @@ void set_rx_tx_addr(uint32_t id)
|
||||
rx_tx_addr[4] = 0xC1; // for YD717: always uses first data port
|
||||
}
|
||||
|
||||
#if defined(TELEMETRY)
|
||||
void Serial_write(uint8_t data)
|
||||
{
|
||||
uint8_t t=tx_head;
|
||||
if(++t>=TXBUFFER_SIZE)
|
||||
t=0;
|
||||
tx_buff[t]=data;
|
||||
tx_head=t;
|
||||
UCSR0B |= (1<<UDRIE0);//enable UDRE interrupt
|
||||
}
|
||||
#endif
|
||||
|
||||
void Mprotocol_serial_init()
|
||||
{
|
||||
#if defined(NUM_SERIAL_CH_8) //8 channels serial protocol
|
||||
#define BAUD 125000
|
||||
#include <util/setbaud.h>
|
||||
UBRR0H = UBRRH_VALUE;
|
||||
UBRR0L = UBRRL_VALUE;
|
||||
//Set frame format to 8 data bits, no parity, 1 stop bit
|
||||
UCSR0C |= (1<<UCSZ01)|(1<<UCSZ00);
|
||||
#else //16 channels serial protocol
|
||||
#define BAUD 100000
|
||||
#include <util/setbaud.h>
|
||||
UBRR0H = UBRRH_VALUE;
|
||||
UBRR0L = UBRRL_VALUE;
|
||||
//Set frame format to 8 data bits, even parity, 2 stop bits
|
||||
UCSR0C |= (1<<UPM01)|(1<<USBS0)|(1<<UCSZ01)|(1<<UCSZ00);
|
||||
#endif
|
||||
while ( UCSR0A & (1 << RXC0) )//flush receive buffer
|
||||
UDR0;
|
||||
//enable reception and RC complete interrupt
|
||||
UCSR0B |= (1<<RXEN0)|(1<<RXCIE0);//rx enable and interrupt
|
||||
UCSR0B |= (1<<TXEN0);//tx enable
|
||||
}
|
||||
|
||||
static uint32_t random_id(uint16_t adress, uint8_t create_new)
|
||||
{
|
||||
uint32_t id;
|
||||
@@ -724,6 +661,7 @@ static uint32_t random_id(uint16_t adress, uint8_t create_new)
|
||||
/**************************/
|
||||
/**************************/
|
||||
|
||||
//PPM
|
||||
ISR(INT1_vect)
|
||||
{ // Interrupt on PPM pin
|
||||
static int8_t chan=-1;
|
||||
@@ -742,62 +680,17 @@ ISR(INT1_vect)
|
||||
else
|
||||
if(chan!=-1) // need to wait for start of frame
|
||||
{ //servo values between 500us and 2420us will end up here
|
||||
PPM_data[chan] = Cur_TCNT1/2;
|
||||
if(PPM_data[chan]<PPM_MIN) PPM_data[chan]=PPM_MIN;
|
||||
else if(PPM_data[chan]>PPM_MAX) PPM_data[chan]=PPM_MAX;
|
||||
uint16_t a = Cur_TCNT1>>1;
|
||||
if(a<PPM_MIN) a=PPM_MIN;
|
||||
else if(a>PPM_MAX) a=PPM_MAX;
|
||||
PPM_data[chan]=a;
|
||||
if(chan++>=NUM_CHN)
|
||||
chan=-1; // don't accept any new channels
|
||||
}
|
||||
Prev_TCNT1+=Cur_TCNT1;
|
||||
}
|
||||
|
||||
#if defined(TELEMETRY)
|
||||
ISR(USART_UDRE_vect)
|
||||
{ // Transmit interrupt
|
||||
uint8_t t = tx_tail;
|
||||
if(tx_head!=t)
|
||||
{
|
||||
if(++t>=TXBUFFER_SIZE)//head
|
||||
t=0;
|
||||
UDR0=tx_buff[t];
|
||||
tx_tail=t;
|
||||
}
|
||||
if (t == tx_head)
|
||||
UCSR0B &= ~(1<<UDRIE0); // Check if all data is transmitted . if yes disable transmitter UDRE interrupt
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(NUM_SERIAL_CH_8) //8 channels serial protocol
|
||||
ISR(USART_RX_vect)
|
||||
{ // RX interrupt
|
||||
static uint16_t crc = 0;
|
||||
|
||||
if(idx==0)
|
||||
{ // Let's try to sync at this point
|
||||
OCR1B=TCNT1+5000L; // timer for 2500us
|
||||
TIFR1=(1<<OCF1B); // clear OCR1B match flag
|
||||
TIMSK1 |=(1<<OCIE1B); // enable interrupt on compare B match
|
||||
crc=0;
|
||||
}
|
||||
if(idx<RXBUFFER_SIZE-1)
|
||||
{ // Store bytes in buffer and calculate crc as we go
|
||||
rx_buff[idx]=UDR0;
|
||||
crc = (crc<<8) ^ pgm_read_word(&CRCTable[((uint8_t)(crc>>8) ^ rx_buff[idx++]) & 0xFF]);
|
||||
}
|
||||
else
|
||||
{ // A frame has been received and needs to be checked before giving it to main
|
||||
TIMSK1 &=~(1<<OCIE1B); // disable interrupt on compare B match
|
||||
if(UDR0==(uint8_t)(crc & 0xFF) && !IS_RX_FLAG_on)
|
||||
{ //Good frame received and main has finished with previous buffer
|
||||
for(idx=0;idx<RXBUFFER_SIZE;idx++)
|
||||
rx_ok_buff[idx]=rx_buff[idx]; // Duplicate the buffer
|
||||
RX_FLAG_on; //flag for main to process servo data
|
||||
LED_ON;
|
||||
}
|
||||
idx=0;
|
||||
}
|
||||
}
|
||||
#else //16 channels serial protocol
|
||||
//Serial RX
|
||||
ISR(USART_RX_vect)
|
||||
{ // RX interrupt
|
||||
if((UCSR0A&0x1C)==0) // Check frame error, data overrun and parity error
|
||||
@@ -834,9 +727,26 @@ ISR(USART_RX_vect)
|
||||
idx=0; // Error encountered discard full frame...
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//Serial timer
|
||||
ISR(TIMER1_COMPB_vect)
|
||||
{ // Timer1 compare B interrupt
|
||||
idx=0;
|
||||
}
|
||||
|
||||
#if defined(TELEMETRY)
|
||||
//Serial TX
|
||||
ISR(USART_UDRE_vect)
|
||||
{ // Transmit interrupt
|
||||
uint8_t t = tx_tail;
|
||||
if(tx_head!=t)
|
||||
{
|
||||
if(++t>=TXBUFFER_SIZE)//head
|
||||
t=0;
|
||||
UDR0=tx_buff[t];
|
||||
tx_tail=t;
|
||||
}
|
||||
if (t == tx_head)
|
||||
UCSR0B &= ~(1<<UDRIE0); // Check if all data is transmitted . if yes disable transmitter UDRE interrupt
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
//---------------------------
|
||||
#include "iface_nrf24l01.h"
|
||||
|
||||
void nrf_spi_write(uint8_t command)
|
||||
static void nrf_spi_write(uint8_t command)
|
||||
{
|
||||
uint8_t n=8;
|
||||
|
||||
@@ -39,7 +39,7 @@ void nrf_spi_write(uint8_t command)
|
||||
}
|
||||
|
||||
//VARIANT 2
|
||||
uint8_t nrf_spi_read(void)
|
||||
static uint8_t nrf_spi_read(void)
|
||||
{
|
||||
uint8_t result;
|
||||
uint8_t i;
|
||||
@@ -106,7 +106,7 @@ uint8_t NRF24L01_ReadReg(uint8_t reg)
|
||||
return data;
|
||||
}
|
||||
|
||||
void NRF24L01_ReadRegisterMulti(uint8_t reg, uint8_t * data, uint8_t length)
|
||||
/*static void NRF24L01_ReadRegisterMulti(uint8_t reg, uint8_t * data, uint8_t length)
|
||||
{
|
||||
NRF_CSN_off;
|
||||
nrf_spi_write(R_REGISTER | (REGISTER_MASK & reg));
|
||||
@@ -114,8 +114,8 @@ void NRF24L01_ReadRegisterMulti(uint8_t reg, uint8_t * data, uint8_t length)
|
||||
data[i] = nrf_spi_read();
|
||||
NRF_CSN_on;
|
||||
}
|
||||
|
||||
void NRF24L01_ReadPayload(uint8_t * data, uint8_t length)
|
||||
*/
|
||||
static void NRF24L01_ReadPayload(uint8_t * data, uint8_t length)
|
||||
{
|
||||
NRF_CSN_off;
|
||||
nrf_spi_write(R_RX_PAYLOAD);
|
||||
@@ -124,7 +124,7 @@ void NRF24L01_ReadPayload(uint8_t * data, uint8_t length)
|
||||
NRF_CSN_on;
|
||||
}
|
||||
|
||||
void NRF24L01_Strobe(uint8_t state)
|
||||
static void NRF24L01_Strobe(uint8_t state)
|
||||
{
|
||||
NRF_CSN_off;
|
||||
nrf_spi_write(state);
|
||||
@@ -154,14 +154,15 @@ void NRF24L01_SetBitrate(uint8_t bitrate)
|
||||
// Note that bitrate 250kbps (and bit RF_DR_LOW) is valid only
|
||||
// for nRF24L01+. There is no way to programmatically tell it from
|
||||
// older version, nRF24L01, but the older is practically phased out
|
||||
// by Nordic, so we assume that we deal with with modern version.
|
||||
// by Nordic, so we assume that we deal with modern version.
|
||||
|
||||
// Bit 0 goes to RF_DR_HIGH, bit 1 - to RF_DR_LOW
|
||||
rf_setup = (rf_setup & 0xD7) | ((bitrate & 0x02) << 4) | ((bitrate & 0x01) << 3);
|
||||
NRF24L01_WriteReg(NRF24L01_06_RF_SETUP, rf_setup);
|
||||
}
|
||||
|
||||
void NRF24L01_SetPower_Value(uint8_t power)
|
||||
/*
|
||||
static void NRF24L01_SetPower_Value(uint8_t power)
|
||||
{
|
||||
uint8_t nrf_power = 0;
|
||||
switch(power) {
|
||||
@@ -179,7 +180,7 @@ void NRF24L01_SetPower_Value(uint8_t power)
|
||||
rf_setup = (rf_setup & 0xF9) | ((nrf_power & 0x03) << 1);
|
||||
NRF24L01_WriteReg(NRF24L01_06_RF_SETUP, rf_setup);
|
||||
}
|
||||
|
||||
*/
|
||||
void NRF24L01_SetPower()
|
||||
{
|
||||
uint8_t power=NRF_BIND_POWER;
|
||||
@@ -254,44 +255,9 @@ uint8_t NRF24L01_packet_ack()
|
||||
return PKT_PENDING;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//---------------------------
|
||||
/*
|
||||
void NRF24L01_spi_test(void)
|
||||
{
|
||||
unsigned long errors = 0;
|
||||
unsigned long test = 0;
|
||||
unsigned long time;
|
||||
uint8_t test_data_r[5];
|
||||
uint8_t test_data_w[5] = {0x01,0x02,0x03,0x04,0x05};
|
||||
|
||||
time = micros();
|
||||
Serial.println("Testing SPI");
|
||||
for(test=0; test < 2775600 ; test++) // should run for X mins.
|
||||
{
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_0B_RX_ADDR_P1, test_data_w, 5);
|
||||
NRF24L01_ReadRegisterMulti(NRF24L01_0B_RX_ADDR_P1, test_data_r, 5);
|
||||
if(0 != memcmp(test_data_r, test_data_w, sizeof(test_data_r))) errors++;
|
||||
test_data_w[0] ++;
|
||||
test_data_w[1] ++;
|
||||
test_data_w[2] ++;
|
||||
test_data_w[3] ++;
|
||||
test_data_w[4] ++;
|
||||
}
|
||||
Serial.print("test "); Serial.print(test, HEX); Serial.print("\n");
|
||||
Serial.print("errors "); Serial.print(errors, HEX); Serial.print("\n");
|
||||
Serial.print("time "); Serial.print(micros()- time, DEC); Serial.print("\n");
|
||||
|
||||
// 124211960
|
||||
// 90899216
|
||||
}
|
||||
*/
|
||||
//---------------------------
|
||||
|
||||
|
||||
///////////////
|
||||
// XN297 emulation layer
|
||||
uint8_t xn297_scramble_enabled;
|
||||
uint8_t xn297_addr_len;
|
||||
uint8_t xn297_tx_addr[5];
|
||||
uint8_t xn297_rx_addr[5];
|
||||
@@ -304,14 +270,21 @@ static const uint8_t xn297_scramble[] = {
|
||||
0x1b, 0x5d, 0x19, 0x10, 0x24, 0xd3, 0xdc, 0x3f,
|
||||
0x8e, 0xc5, 0x2f};
|
||||
|
||||
static const uint16_t xn297_crc_xorout[] = {
|
||||
0x0000, 0x3448, 0x9BA7, 0x8BBB, 0x85E1, 0x3E8C, // 1st entry is missing, probably never needed
|
||||
0x451E, 0x18E6, 0x6B24, 0xE7AB, 0x3828, 0x8148, // it's used for 3-byte address w/ 0 byte payload only
|
||||
const uint16_t PROGMEM xn297_crc_xorout[] = {
|
||||
0x0000, 0x3d5f, 0xa6f1, 0x3a23, 0xaa16, 0x1caf,
|
||||
0x62b2, 0xe0eb, 0x0821, 0xbe07, 0x5f1a, 0xaf15,
|
||||
0x4f0a, 0xad24, 0x5e48, 0xed34, 0x068c, 0xf2c9,
|
||||
0x1852, 0xdf36, 0x129d, 0xb17c, 0xd5f5, 0x70d7,
|
||||
0xb798, 0x5133, 0x67db, 0xd94e};
|
||||
|
||||
const uint16_t PROGMEM xn297_crc_xorout_scrambled[] = {
|
||||
0x0000, 0x3448, 0x9BA7, 0x8BBB, 0x85E1, 0x3E8C,
|
||||
0x451E, 0x18E6, 0x6B24, 0xE7AB, 0x3828, 0x814B,
|
||||
0xD461, 0xF494, 0x2503, 0x691D, 0xFE8B, 0x9BA7,
|
||||
0x8B17, 0x2920, 0x8B5F, 0x61B1, 0xD391, 0x7401,
|
||||
0x2138, 0x129F, 0xB3A0, 0x2988};
|
||||
|
||||
uint8_t bit_reverse(uint8_t b_in)
|
||||
static uint8_t bit_reverse(uint8_t b_in)
|
||||
{
|
||||
uint8_t b_out = 0;
|
||||
for (uint8_t i = 0; i < 8; ++i)
|
||||
@@ -322,7 +295,7 @@ uint8_t bit_reverse(uint8_t b_in)
|
||||
return b_out;
|
||||
}
|
||||
|
||||
uint16_t crc16_update(uint16_t crc, uint8_t a)
|
||||
static uint16_t crc16_update(uint16_t crc, uint8_t a)
|
||||
{
|
||||
static const uint16_t polynomial = 0x1021;
|
||||
|
||||
@@ -362,16 +335,21 @@ void XN297_SetRXAddr(const uint8_t* addr, uint8_t len)
|
||||
memcpy(buf, addr, len);
|
||||
memcpy(xn297_rx_addr, addr, len);
|
||||
for (uint8_t i = 0; i < xn297_addr_len; ++i)
|
||||
buf[i] = xn297_rx_addr[i] ^ xn297_scramble[xn297_addr_len-i-1];
|
||||
{
|
||||
buf[i] = xn297_rx_addr[i];
|
||||
if(xn297_scramble_enabled)
|
||||
buf[i] ^= xn297_scramble[xn297_addr_len-i-1];
|
||||
}
|
||||
NRF24L01_WriteReg(NRF24L01_03_SETUP_AW, len-2);
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_0A_RX_ADDR_P0, buf, 5);
|
||||
}
|
||||
|
||||
void XN297_Configure(uint8_t flags)
|
||||
void XN297_Configure(uint16_t flags)
|
||||
{
|
||||
xn297_scramble_enabled = !(flags & BV(XN297_UNSCRAMBLED));
|
||||
xn297_crc = !!(flags & BV(NRF24L01_00_EN_CRC));
|
||||
flags &= ~(BV(NRF24L01_00_EN_CRC) | BV(NRF24L01_00_CRCO));
|
||||
NRF24L01_WriteReg(NRF24L01_00_CONFIG, flags);
|
||||
NRF24L01_WriteReg(NRF24L01_00_CONFIG, flags & 0xFF);
|
||||
}
|
||||
|
||||
void XN297_WritePayload(uint8_t* msg, uint8_t len)
|
||||
@@ -387,12 +365,20 @@ void XN297_WritePayload(uint8_t* msg, uint8_t len)
|
||||
buf[last++] = 0x55;
|
||||
}
|
||||
for (uint8_t i = 0; i < xn297_addr_len; ++i)
|
||||
buf[last++] = xn297_tx_addr[xn297_addr_len-i-1] ^ xn297_scramble[i];
|
||||
|
||||
for (uint8_t i = 0; i < len; ++i) {
|
||||
{
|
||||
buf[last] = xn297_tx_addr[xn297_addr_len-i-1];
|
||||
if(xn297_scramble_enabled)
|
||||
buf[last] ^= xn297_scramble[i];
|
||||
last++;
|
||||
}
|
||||
for (uint8_t i = 0; i < len; ++i)
|
||||
{
|
||||
// bit-reverse bytes in packet
|
||||
uint8_t b_out = bit_reverse(msg[i]);
|
||||
buf[last++] = b_out ^ xn297_scramble[xn297_addr_len+i];
|
||||
buf[last] = b_out;
|
||||
if(xn297_scramble_enabled)
|
||||
buf[last] ^= xn297_scramble[xn297_addr_len+i];
|
||||
last++;
|
||||
}
|
||||
if (xn297_crc)
|
||||
{
|
||||
@@ -400,7 +386,10 @@ void XN297_WritePayload(uint8_t* msg, uint8_t len)
|
||||
uint16_t crc = 0xb5d2;
|
||||
for (uint8_t i = offset; i < last; ++i)
|
||||
crc = crc16_update(crc, buf[i]);
|
||||
crc ^= xn297_crc_xorout[xn297_addr_len - 3 + len];
|
||||
if(xn297_scramble_enabled)
|
||||
crc ^= pgm_read_word(&xn297_crc_xorout_scrambled[xn297_addr_len - 3 + len]);
|
||||
else
|
||||
crc ^= pgm_read_word(&xn297_crc_xorout[xn297_addr_len - 3 + len]);
|
||||
buf[last++] = crc >> 8;
|
||||
buf[last++] = crc & 0xff;
|
||||
}
|
||||
@@ -409,9 +398,207 @@ void XN297_WritePayload(uint8_t* msg, uint8_t len)
|
||||
|
||||
void XN297_ReadPayload(uint8_t* msg, uint8_t len)
|
||||
{
|
||||
// TODO: if xn297_crc==1, check CRC before filling *msg
|
||||
NRF24L01_ReadPayload(msg, len);
|
||||
for(uint8_t i=0; i<len; i++)
|
||||
msg[i] = bit_reverse(msg[i]) ^ bit_reverse(xn297_scramble[i+xn297_addr_len]);
|
||||
{
|
||||
msg[i] = bit_reverse(msg[i]);
|
||||
if(xn297_scramble_enabled)
|
||||
msg[i] ^= bit_reverse(xn297_scramble[i+xn297_addr_len]);
|
||||
}
|
||||
}
|
||||
|
||||
// End of XN297 emulation
|
||||
|
||||
///////////////
|
||||
// LT8910 emulation layer
|
||||
uint8_t LT8910_buffer[64];
|
||||
uint8_t LT8910_buffer_start;
|
||||
uint16_t LT8910_buffer_overhead_bits;
|
||||
uint8_t LT8910_addr[8];
|
||||
uint8_t LT8910_addr_size;
|
||||
uint8_t LT8910_Preamble_Len;
|
||||
uint8_t LT8910_Tailer_Len;
|
||||
uint8_t LT8910_CRC_Initial_Data;
|
||||
uint8_t LT8910_Flags;
|
||||
#define LT8910_CRC_ON 6
|
||||
#define LT8910_SCRAMBLE_ON 5
|
||||
#define LT8910_PACKET_LENGTH_EN 4
|
||||
#define LT8910_DATA_PACKET_TYPE_1 3
|
||||
#define LT8910_DATA_PACKET_TYPE_0 2
|
||||
#define LT8910_FEC_TYPE_1 1
|
||||
#define LT8910_FEC_TYPE_0 0
|
||||
|
||||
void LT8910_Config(uint8_t preamble_len, uint8_t trailer_len, uint8_t flags, uint8_t crc_init)
|
||||
{
|
||||
//Preamble 1 to 8 bytes
|
||||
LT8910_Preamble_Len=preamble_len;
|
||||
//Trailer 4 to 18 bits
|
||||
LT8910_Tailer_Len=trailer_len;
|
||||
//Flags
|
||||
// CRC_ON: 1 on, 0 off
|
||||
// SCRAMBLE_ON: 1 on, 0 off
|
||||
// PACKET_LENGTH_EN: 1 1st byte of payload is payload size
|
||||
// DATA_PACKET_TYPE: 00 NRZ, 01 Manchester, 10 8bit/10bit line code, 11 interleave data type
|
||||
// FEC_TYPE: 00 No FEC, 01 FEC13, 10 FEC23, 11 reserved
|
||||
LT8910_Flags=flags;
|
||||
//CRC init constant
|
||||
LT8910_CRC_Initial_Data=crc_init;
|
||||
}
|
||||
|
||||
void LT8910_SetChannel(uint8_t channel)
|
||||
{
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, channel +2); //NRF24L01 is 2400+channel but LT8900 is 2402+channel
|
||||
}
|
||||
|
||||
void LT8910_SetTxRxMode(enum TXRX_State mode)
|
||||
{
|
||||
if(mode == TX_EN)
|
||||
{
|
||||
//Switch to TX
|
||||
NRF24L01_SetTxRxMode(TXRX_OFF);
|
||||
NRF24L01_SetTxRxMode(TX_EN);
|
||||
//Disable CRC
|
||||
NRF24L01_WriteReg(NRF24L01_00_CONFIG, (1 << NRF24L01_00_PWR_UP));
|
||||
}
|
||||
else
|
||||
if (mode == RX_EN)
|
||||
{
|
||||
NRF24L01_WriteReg(NRF24L01_02_EN_RXADDR, 0x01); // Enable data pipe 0 only
|
||||
NRF24L01_WriteReg(NRF24L01_11_RX_PW_P0, 32);
|
||||
//Switch to RX
|
||||
NRF24L01_SetTxRxMode(TXRX_OFF);
|
||||
NRF24L01_FlushRx();
|
||||
NRF24L01_SetTxRxMode(RX_EN);
|
||||
// Disable CRC
|
||||
NRF24L01_WriteReg(NRF24L01_00_CONFIG, (1 << NRF24L01_00_PWR_UP) | (1 << NRF24L01_00_PRIM_RX) );
|
||||
}
|
||||
else
|
||||
NRF24L01_SetTxRxMode(TXRX_OFF);
|
||||
}
|
||||
|
||||
void LT8910_BuildOverhead()
|
||||
{
|
||||
uint8_t pos;
|
||||
|
||||
//Build overhead
|
||||
//preamble
|
||||
memset(LT8910_buffer,LT8910_addr[0]&0x01?0xAA:0x55,LT8910_Preamble_Len-1);
|
||||
pos=LT8910_Preamble_Len-1;
|
||||
//address
|
||||
for(uint8_t i=0;i<LT8910_addr_size;i++)
|
||||
{
|
||||
LT8910_buffer[pos]=bit_reverse(LT8910_addr[i]);
|
||||
pos++;
|
||||
}
|
||||
//trailer
|
||||
memset(LT8910_buffer+pos,(LT8910_buffer[pos-1]&0x01)==0?0xAA:0x55,3);
|
||||
LT8910_buffer_overhead_bits=pos*8+LT8910_Tailer_Len;
|
||||
//nrf address length max is 5
|
||||
pos+=LT8910_Tailer_Len/8;
|
||||
LT8910_buffer_start=pos>5?5:pos;
|
||||
}
|
||||
|
||||
void LT8910_SetAddress(uint8_t *address,uint8_t addr_size)
|
||||
{
|
||||
uint8_t addr[5];
|
||||
|
||||
//Address size (SyncWord) 2 to 8 bytes, 16/32/48/64 bits
|
||||
LT8910_addr_size=addr_size;
|
||||
memcpy(LT8910_addr,address,LT8910_addr_size);
|
||||
|
||||
//Build overhead
|
||||
LT8910_BuildOverhead();
|
||||
|
||||
//Set NRF RX&TX address based on overhead content
|
||||
NRF24L01_WriteReg(NRF24L01_03_SETUP_AW, LT8910_buffer_start-2);
|
||||
for(uint8_t i=0;i<LT8910_buffer_start;i++) // reverse bytes order
|
||||
addr[i]=LT8910_buffer[LT8910_buffer_start-i-1];
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_0A_RX_ADDR_P0, addr,LT8910_buffer_start);
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, addr,LT8910_buffer_start);
|
||||
}
|
||||
|
||||
uint8_t LT8910_ReadPayload(uint8_t* msg, uint8_t len)
|
||||
{
|
||||
uint8_t i,pos=0,shift,end,buffer[32];
|
||||
unsigned int crc=LT8910_CRC_Initial_Data,a;
|
||||
pos=LT8910_buffer_overhead_bits/8-LT8910_buffer_start;
|
||||
end=pos+len+(LT8910_Flags&_BV(LT8910_PACKET_LENGTH_EN)?1:0)+(LT8910_Flags&_BV(LT8910_CRC_ON)?2:0);
|
||||
//Read payload
|
||||
NRF24L01_ReadPayload(buffer,end+1);
|
||||
//Check address + trail
|
||||
for(i=0;i<pos;i++)
|
||||
if(LT8910_buffer[LT8910_buffer_start+i]!=buffer[i])
|
||||
return 0; // wrong address...
|
||||
//Shift buffer to remove trail bits
|
||||
shift=LT8910_buffer_overhead_bits&0x7;
|
||||
for(i=pos;i<end;i++)
|
||||
{
|
||||
a=(buffer[i]<<8)+buffer[i+1];
|
||||
a<<=shift;
|
||||
buffer[i]=(a>>8)&0xFF;
|
||||
}
|
||||
//Check len
|
||||
if(LT8910_Flags&_BV(LT8910_PACKET_LENGTH_EN))
|
||||
{
|
||||
crc=crc16_update(crc,buffer[pos]);
|
||||
if(bit_reverse(len)!=buffer[pos++])
|
||||
return 0; // wrong len...
|
||||
}
|
||||
//Decode message
|
||||
for(i=0;i<len;i++)
|
||||
{
|
||||
crc=crc16_update(crc,buffer[pos]);
|
||||
msg[i]=bit_reverse(buffer[pos++]);
|
||||
}
|
||||
//Check CRC
|
||||
if(LT8910_Flags&_BV(LT8910_CRC_ON))
|
||||
{
|
||||
if(buffer[pos++]!=((crc>>8)&0xFF)) return 0; // wrong CRC...
|
||||
if(buffer[pos]!=(crc&0xFF)) return 0; // wrong CRC...
|
||||
}
|
||||
//Everything ok
|
||||
return 1;
|
||||
}
|
||||
|
||||
void LT8910_WritePayload(uint8_t* msg, uint8_t len)
|
||||
{
|
||||
unsigned int crc=LT8910_CRC_Initial_Data,a,mask;
|
||||
uint8_t i, pos=0,tmp, buffer[64], pos_final,shift;
|
||||
//Add packet len
|
||||
if(LT8910_Flags&_BV(LT8910_PACKET_LENGTH_EN))
|
||||
{
|
||||
tmp=bit_reverse(len);
|
||||
buffer[pos++]=tmp;
|
||||
crc=crc16_update(crc,tmp);
|
||||
}
|
||||
//Add payload
|
||||
for(i=0;i<len;i++)
|
||||
{
|
||||
tmp=bit_reverse(msg[i]);
|
||||
buffer[pos++]=tmp;
|
||||
crc=crc16_update(crc,tmp);
|
||||
}
|
||||
//Add CRC
|
||||
if(LT8910_Flags&_BV(LT8910_CRC_ON))
|
||||
{
|
||||
buffer[pos++]=crc>>8;
|
||||
buffer[pos++]=crc;
|
||||
}
|
||||
//Shift everything to fit behind the trailer (4 to 18 bits)
|
||||
shift=LT8910_buffer_overhead_bits&0x7;
|
||||
pos_final=LT8910_buffer_overhead_bits/8;
|
||||
mask=~(0xFF<<(8-shift));
|
||||
LT8910_buffer[pos_final+pos]=0xFF;
|
||||
for(i=pos-1;i!=0xFF;i--)
|
||||
{
|
||||
a=buffer[i]<<(8-shift);
|
||||
LT8910_buffer[pos_final+i]=(LT8910_buffer[pos_final+i]&mask>>8)|a>>8;
|
||||
LT8910_buffer[pos_final+i+1]=(LT8910_buffer[pos_final+i+1]&mask)|a;
|
||||
}
|
||||
if(shift)
|
||||
pos++;
|
||||
//Send everything
|
||||
NRF24L01_WritePayload(LT8910_buffer+LT8910_buffer_start,pos_final+pos-LT8910_buffer_start);
|
||||
}
|
||||
// End of LT8910 emulation
|
||||
|
||||
108
Multiprotocol/SHENQI_nrf24l01.ino
Normal file
108
Multiprotocol/SHENQI_nrf24l01.ino
Normal file
@@ -0,0 +1,108 @@
|
||||
#if defined(SHENQI_NRF24L01_INO)
|
||||
|
||||
#include "iface_nrf24l01.h"
|
||||
|
||||
const uint8_t PROGMEM SHENQI_Freq[] = {
|
||||
50,50,20,60,30,40,
|
||||
10,30,40,20,60,10,
|
||||
50,20,50,40,10,60,
|
||||
30,30,60,10,40,50,
|
||||
20,10,60,20,50,30,
|
||||
40,40,30,50,20,60,
|
||||
10,10,20,30,40,50,
|
||||
60,60,50,40,30,20,
|
||||
10,60,10,50,30,40,
|
||||
20,10,40,30,60,20 };
|
||||
|
||||
void SHENQI_init()
|
||||
{
|
||||
NRF24L01_Initialize();
|
||||
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_SetBitrate(NRF24L01_BR_1M); // 1Mbps
|
||||
NRF24L01_SetPower();
|
||||
|
||||
NRF24L01_WriteReg(NRF24L01_03_SETUP_AW, 0x03); // 5 bytes rx/tx address
|
||||
|
||||
LT8910_Config(4, 8, _BV(LT8910_CRC_ON)|_BV(LT8910_PACKET_LENGTH_EN), 0xAA);
|
||||
LT8910_SetChannel(2);
|
||||
LT8910_SetAddress((uint8_t *)"\x9A\x9A\x9A\x9A",4);
|
||||
LT8910_SetTxRxMode(RX_EN);
|
||||
}
|
||||
|
||||
void SHENQI_send_packet()
|
||||
{
|
||||
packet[0]=0x00;
|
||||
if(packet_count==0)
|
||||
{
|
||||
uint8_t bind_addr[4];
|
||||
bind_addr[0]=0x9A;
|
||||
bind_addr[1]=0x9A;
|
||||
bind_addr[2]=rx_tx_addr[2];
|
||||
bind_addr[3]=rx_tx_addr[3];
|
||||
LT8910_SetAddress(bind_addr,4);
|
||||
LT8910_SetChannel(2);
|
||||
packet[1]=rx_tx_addr[1];
|
||||
packet[2]=rx_tx_addr[0];
|
||||
packet_period=2508;
|
||||
}
|
||||
else
|
||||
{
|
||||
LT8910_SetAddress(rx_tx_addr,4);
|
||||
packet[1]=255-convert_channel_8b(RUDDER);
|
||||
packet[2]=255-convert_channel_8b_scale(THROTTLE,0x60,0xA0);
|
||||
uint8_t freq=pgm_read_byte_near(&SHENQI_Freq[hopping_frequency_no])+(rx_tx_addr[1]&0x0F);
|
||||
LT8910_SetChannel(freq);
|
||||
hopping_frequency_no++;
|
||||
if(hopping_frequency_no==60)
|
||||
hopping_frequency_no=0;
|
||||
packet_period=1750;
|
||||
}
|
||||
// Send packet + 1 retransmit - not sure why but needed (not present on original TX...)
|
||||
LT8910_WritePayload(packet,3);
|
||||
while(NRF24L01_packet_ack()!=PKT_ACKED);
|
||||
LT8910_WritePayload(packet,3);
|
||||
|
||||
packet_count++;
|
||||
if(packet_count==7)
|
||||
{
|
||||
packet_count=0;
|
||||
packet_period=3000;
|
||||
}
|
||||
// Set power
|
||||
NRF24L01_SetPower();
|
||||
}
|
||||
|
||||
uint16_t SHENQI_callback()
|
||||
{
|
||||
if(IS_BIND_DONE_on)
|
||||
SHENQI_send_packet();
|
||||
else
|
||||
{
|
||||
if( NRF24L01_ReadReg(NRF24L01_07_STATUS) & BV(NRF24L01_07_RX_DR))
|
||||
{
|
||||
if(LT8910_ReadPayload(packet, 3))
|
||||
{
|
||||
BIND_DONE;
|
||||
rx_tx_addr[3]=packet[1];
|
||||
rx_tx_addr[2]=packet[2];
|
||||
LT8910_SetTxRxMode(TX_EN);
|
||||
packet_period=14000;
|
||||
}
|
||||
NRF24L01_FlushRx();
|
||||
}
|
||||
}
|
||||
return packet_period;
|
||||
}
|
||||
|
||||
uint16_t initSHENQI()
|
||||
{
|
||||
BIND_IN_PROGRESS; // autobind protocol
|
||||
SHENQI_init();
|
||||
hopping_frequency_no = 0;
|
||||
packet_count=0;
|
||||
packet_period=100;
|
||||
return 1000;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -12,6 +12,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// Last sync with hexfet new_protocols/slt_nrf24l01.c dated 2015-02-13
|
||||
|
||||
#if defined(SLT_NRF24L01_INO)
|
||||
|
||||
@@ -30,7 +31,7 @@ enum {
|
||||
SLT_DATA3
|
||||
};
|
||||
|
||||
void SLT_init()
|
||||
static void __attribute__((unused)) SLT_init()
|
||||
{
|
||||
NRF24L01_Initialize();
|
||||
NRF24L01_WriteReg(NRF24L01_00_CONFIG, BV(NRF24L01_00_EN_CRC) | BV(NRF24L01_00_CRCO)); // 2-bytes CRC, radio off
|
||||
@@ -46,7 +47,7 @@ void SLT_init()
|
||||
NRF24L01_FlushRx();
|
||||
}
|
||||
|
||||
static void SLT_init2()
|
||||
static void __attribute__((unused)) SLT_init2()
|
||||
{
|
||||
NRF24L01_FlushTx();
|
||||
packet_sent = 0;
|
||||
@@ -56,7 +57,7 @@ static void SLT_init2()
|
||||
NRF24L01_SetTxRxMode(TX_EN);
|
||||
}
|
||||
|
||||
void SLT_set_tx_id(void)
|
||||
static void __attribute__((unused)) SLT_set_tx_id(void)
|
||||
{
|
||||
// Frequency hopping sequence generation
|
||||
for (uint8_t i = 0; i < 4; ++i)
|
||||
@@ -67,7 +68,7 @@ void SLT_set_tx_id(void)
|
||||
hopping_frequency[i*4 + 1] = (rx_tx_addr[i] >> 2) + base;
|
||||
hopping_frequency[i*4 + 2] = (rx_tx_addr[i] >> 4) + (rx_tx_addr[next_i] & 0x03)*0x10 + base;
|
||||
if (i*4 + 3 < SLT_NFREQCHANNELS) // guard for 16 channel
|
||||
hopping_frequency[i*4 + 3] = (rx_tx_addr[i] >> 6) + (rx_tx_addr[next_i] & 0x0f)*0x04 + base;
|
||||
hopping_frequency[i*4 + 3] = (rx_tx_addr[i] >> 6) + (rx_tx_addr[next_i] & 0x0f)*0x04 + base;
|
||||
}
|
||||
|
||||
// unique
|
||||
@@ -89,16 +90,16 @@ void SLT_set_tx_id(void)
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, rx_tx_addr, 4);
|
||||
}
|
||||
|
||||
void wait_radio()
|
||||
static void __attribute__((unused)) SLT_wait_radio()
|
||||
{
|
||||
if (packet_sent)
|
||||
while (!(NRF24L01_ReadReg(NRF24L01_07_STATUS) & BV(NRF24L01_07_TX_DS))) ;
|
||||
packet_sent = 0;
|
||||
}
|
||||
|
||||
void send_data(uint8_t *data, uint8_t len)
|
||||
static void __attribute__((unused)) SLT_send_data(uint8_t *data, uint8_t len)
|
||||
{
|
||||
wait_radio();
|
||||
SLT_wait_radio();
|
||||
NRF24L01_FlushTx();
|
||||
NRF24L01_WriteReg(NRF24L01_07_STATUS, BV(NRF24L01_07_TX_DS) | BV(NRF24L01_07_RX_DR) | BV(NRF24L01_07_MAX_RT));
|
||||
NRF24L01_WritePayload(data, len);
|
||||
@@ -106,11 +107,11 @@ void send_data(uint8_t *data, uint8_t len)
|
||||
packet_sent = 1;
|
||||
}
|
||||
|
||||
void SLT_build_packet()
|
||||
static void __attribute__((unused)) SLT_build_packet()
|
||||
{
|
||||
// aileron, elevator, throttle, rudder, gear, pitch
|
||||
uint8_t e = 0; // byte where extension 2 bits for every 10-bit channel are packed
|
||||
uint8_t ch[]={AILERON, ELEVATOR, THROTTLE, RUDDER};
|
||||
const uint8_t ch[]={AILERON, ELEVATOR, THROTTLE, RUDDER};
|
||||
for (uint8_t i = 0; i < 4; ++i) {
|
||||
uint16_t v = convert_channel_10b(ch[i]);
|
||||
packet[i] = v;
|
||||
@@ -128,19 +129,20 @@ void SLT_build_packet()
|
||||
hopping_frequency_no = 0;
|
||||
}
|
||||
|
||||
static void send_bind_packet()
|
||||
static void __attribute__((unused)) SLT_send_bind_packet()
|
||||
{
|
||||
wait_radio();
|
||||
|
||||
SLT_wait_radio();
|
||||
BIND_IN_PROGRESS; // autobind protocol
|
||||
NRF24L01_SetPower();
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, (uint8_t *)"\x7E\xB8\x63\xA9", 4);
|
||||
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, 0x50);
|
||||
send_data(rx_tx_addr, 4);
|
||||
SLT_send_data(rx_tx_addr, 4);
|
||||
|
||||
// NB: we should wait until the packet's sent before changing TX address!
|
||||
wait_radio();
|
||||
SLT_wait_radio();
|
||||
|
||||
BIND_DONE;
|
||||
NRF24L01_SetPower();
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, rx_tx_addr, 4);
|
||||
}
|
||||
@@ -156,24 +158,23 @@ uint16_t SLT_callback()
|
||||
delay_us = 150;
|
||||
break;
|
||||
case SLT_BIND:
|
||||
send_bind_packet();
|
||||
SLT_send_bind_packet();
|
||||
phase = SLT_DATA1;
|
||||
delay_us = 19000;
|
||||
BIND_DONE;
|
||||
break;
|
||||
case SLT_DATA1:
|
||||
SLT_build_packet();
|
||||
send_data(packet, 7);
|
||||
SLT_send_data(packet, 7);
|
||||
phase = SLT_DATA2;
|
||||
delay_us = 1000;
|
||||
break;
|
||||
case SLT_DATA2:
|
||||
send_data(packet, 7);
|
||||
SLT_send_data(packet, 7);
|
||||
phase = SLT_DATA3;
|
||||
delay_us = 1000;
|
||||
break;
|
||||
case SLT_DATA3:
|
||||
send_data(packet, 7);
|
||||
SLT_send_data(packet, 7);
|
||||
if (++counter >= 100)
|
||||
{
|
||||
counter = 0;
|
||||
@@ -196,7 +197,6 @@ uint16_t initSLT()
|
||||
SLT_init();
|
||||
phase = SLT_INIT2;
|
||||
SLT_set_tx_id();
|
||||
BIND_IN_PROGRESS; // autobind protocol
|
||||
return 50000;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,16 +12,13 @@
|
||||
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 Syma X5C-1, X11, X11C, X12 and for sub protocol X5C Syma X5C (original), X2
|
||||
// Last sync with hexfet new_protocols/cx10_nrf24l01.c dated 2015-09-28
|
||||
|
||||
#if defined(SYMAX_NRF24L01_INO)
|
||||
|
||||
#include "iface_nrf24l01.h"
|
||||
|
||||
/***
|
||||
Main protocol compatible with Syma X5C-1, X11, X11C, X12.
|
||||
SymaX5C protocol option compatible with Syma X5C (original) and X2.
|
||||
***/
|
||||
|
||||
#define SYMAX_BIND_COUNT 345 // 1.5 seconds
|
||||
#define SYMAX_FIRST_PACKET_DELAY 12000
|
||||
#define SYMAX_PACKET_PERIOD 4000 // Timeout for callback in uSec
|
||||
@@ -44,16 +41,7 @@ enum {
|
||||
SYMAX_DATA
|
||||
};
|
||||
|
||||
/*
|
||||
http://www.deviationtx.com/forum/protocol-development/3768-syma-x5c-1-x11-x12?start=140
|
||||
TX address Channel Sequence
|
||||
S1 3B B6 00 00 A2 15 35 1D 3D
|
||||
D1 9A E9 02 00 A2 14 34 1C 3C
|
||||
|
||||
D2 46 18 00 00 A2 11 21 31 41
|
||||
*/
|
||||
|
||||
uint8_t SYMAX_checksum(uint8_t *data)
|
||||
static uint8_t __attribute__((unused)) SYMAX_checksum(uint8_t *data)
|
||||
{
|
||||
uint8_t sum = data[0];
|
||||
|
||||
@@ -66,7 +54,7 @@ uint8_t SYMAX_checksum(uint8_t *data)
|
||||
return sum + ( sub_protocol==SYMAX5C ? 0 : 0x55 );
|
||||
}
|
||||
|
||||
void SYMAX_read_controls()
|
||||
static void __attribute__((unused)) SYMAX_read_controls()
|
||||
{
|
||||
// Protocol is registered AETRF, that is
|
||||
// Aileron is channel 1, Elevator - 2, Throttle - 3, Rudder - 4, Flip control - 5
|
||||
@@ -75,25 +63,24 @@ void SYMAX_read_controls()
|
||||
throttle = convert_channel_8b(THROTTLE);
|
||||
rudder = convert_channel_s8b(RUDDER);
|
||||
|
||||
flags=0;
|
||||
// Channel 5
|
||||
if (Servo_data[AUX1] > PPM_SWITCH)
|
||||
if (Servo_AUX1)
|
||||
flags = SYMAX_FLAG_FLIP;
|
||||
else
|
||||
flags=0;
|
||||
// Channel 7
|
||||
if (Servo_data[AUX3] > PPM_SWITCH)
|
||||
if (Servo_AUX3)
|
||||
flags |= SYMAX_FLAG_PICTURE;
|
||||
// Channel 8
|
||||
if (Servo_data[AUX4] > PPM_SWITCH)
|
||||
if (Servo_AUX4)
|
||||
flags |= SYMAX_FLAG_VIDEO;
|
||||
// Channel 9
|
||||
if (Servo_data[AUX5] > PPM_SWITCH)
|
||||
if (Servo_AUX5)
|
||||
flags |= SYMAX_FLAG_HEADLESS;
|
||||
}
|
||||
|
||||
#define X5C_CHAN2TRIM(X) ((((X) & 0x80 ? 0xff - (X) : 0x80 + (X)) >> 2) + 0x20)
|
||||
|
||||
void SYMAX_build_packet_x5c(uint8_t bind)
|
||||
static void __attribute__((unused)) SYMAX_build_packet_x5c(uint8_t bind)
|
||||
{
|
||||
if (bind)
|
||||
{
|
||||
@@ -124,12 +111,12 @@ void SYMAX_build_packet_x5c(uint8_t bind)
|
||||
packet[14] = (flags & SYMAX_FLAG_VIDEO ? 0x10 : 0x00)
|
||||
| (flags & SYMAX_FLAG_PICTURE ? 0x08 : 0x00)
|
||||
| (flags & SYMAX_FLAG_FLIP ? 0x01 : 0x00)
|
||||
| 0x04;// (flags & SYMAX_FLAG_RATES ? 0x04 : 0x00);
|
||||
| 0x04;// always high rates (bit 3 is rate control)
|
||||
packet[15] = SYMAX_checksum(packet);
|
||||
}
|
||||
}
|
||||
|
||||
void SYMAX_build_packet(uint8_t bind)
|
||||
static void __attribute__((unused)) SYMAX_build_packet(uint8_t bind)
|
||||
{
|
||||
if (bind)
|
||||
{
|
||||
@@ -151,7 +138,7 @@ void SYMAX_build_packet(uint8_t bind)
|
||||
packet[2] = rudder;
|
||||
packet[3] = aileron;
|
||||
packet[4] = (flags & SYMAX_FLAG_VIDEO ? 0x80 : 0x00) | (flags & SYMAX_FLAG_PICTURE ? 0x40 : 0x00);
|
||||
packet[5] = (elevator >> 2) | 0xc0; //always high rates (bit 7 is rate control) (flags & SYMAX_FLAG_RATES ? 0x80 : 0x00) | 0x40; // use trims to extend controls
|
||||
packet[5] = (elevator >> 2) | 0xc0; //always high rates (bit 7 is rate control)
|
||||
packet[6] = (rudder >> 2) | (flags & SYMAX_FLAG_FLIP ? 0x40 : 0x00);
|
||||
packet[7] = (aileron >> 2) | (flags & SYMAX_FLAG_HEADLESS ? 0x80 : 0x00);
|
||||
packet[8] = 0x00;
|
||||
@@ -159,7 +146,7 @@ void SYMAX_build_packet(uint8_t bind)
|
||||
packet[9] = SYMAX_checksum(packet);
|
||||
}
|
||||
|
||||
void SYMAX_send_packet(uint8_t bind)
|
||||
static void __attribute__((unused)) SYMAX_send_packet(uint8_t bind)
|
||||
{
|
||||
if (sub_protocol==SYMAX5C)
|
||||
SYMAX_build_packet_x5c(bind);
|
||||
@@ -180,7 +167,7 @@ void SYMAX_send_packet(uint8_t bind)
|
||||
NRF24L01_SetPower(); // Set tx_power
|
||||
}
|
||||
|
||||
static void symax_init()
|
||||
static void __attribute__((unused)) symax_init()
|
||||
{
|
||||
NRF24L01_Initialize();
|
||||
//
|
||||
@@ -232,7 +219,7 @@ static void symax_init()
|
||||
NRF24L01_WriteReg(NRF24L01_00_CONFIG, 0x0e); // power on
|
||||
}
|
||||
|
||||
void symax_init1()
|
||||
static void __attribute__((unused)) symax_init1()
|
||||
{
|
||||
// duplicate stock tx sending strange packet (effect unknown)
|
||||
uint8_t first_packet[] = {0xf9, 0x96, 0x82, 0x1b, 0x20, 0x08, 0x08, 0xf2, 0x7d, 0xef, 0xff, 0x00, 0x00, 0x00, 0x00};
|
||||
@@ -240,13 +227,6 @@ void symax_init1()
|
||||
uint8_t chans_bind_x5c[] = {0x27, 0x1b, 0x39, 0x28, 0x24, 0x22, 0x2e, 0x36,
|
||||
0x19, 0x21, 0x29, 0x14, 0x1e, 0x12, 0x2d, 0x18};
|
||||
|
||||
//uint8_t data_rx_tx_addr[] = {0x3b,0xb6,0x00,0x00,0xa2};
|
||||
//uint8_t data_rx_tx_addr[] = {0x9A,0xe9,0x03,0x00,0xa2};//<<---- is ok
|
||||
//uint8_t data_rx_tx_addr[] = {0x3b,0xb6,0x00,0x00,0xa2};//<<--- is ok
|
||||
//uint8_t data_rx_tx_addr[] = {0x9A,0xe9,0x00,0x00,0xa2};
|
||||
//uint8_t data_rx_tx_addr[] = {0x9A,0xe9,0x03,0x00,0xa2};//<<---- is ok
|
||||
//uint8_t data_rx_tx_addr[] = {0x46,0x18,0x00,0x00,0xa2};
|
||||
|
||||
NRF24L01_FlushTx();
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, 0x08);
|
||||
NRF24L01_WritePayload(first_packet, 15);
|
||||
@@ -267,14 +247,12 @@ void symax_init1()
|
||||
}
|
||||
|
||||
// channels determined by last byte of tx address
|
||||
void symax_set_channels(uint8_t address)
|
||||
static void __attribute__((unused)) symax_set_channels(uint8_t address)
|
||||
{
|
||||
static const uint8_t start_chans_1[] = {0x0a, 0x1a, 0x2a, 0x3a};
|
||||
static const uint8_t start_chans_2[] = {0x2a, 0x0a, 0x42, 0x22};
|
||||
static const uint8_t start_chans_3[] = {0x1a, 0x3a, 0x12, 0x32};
|
||||
//static const uint8_t start_chans_4[] = {0x15, 0x35, 0x1d, 0x3d};
|
||||
//static const uint8_t start_chans_5[] = {0x14, 0x34, 0x1c, 0x3c};
|
||||
//static const uint8_t start_chans_6[] = {0x11, 0x21, 0x31, 0x41};
|
||||
|
||||
uint8_t laddress = address & 0x1f;
|
||||
uint8_t i;
|
||||
uint32_t *pchans = (uint32_t *)hopping_frequency; // avoid compiler warning
|
||||
@@ -312,7 +290,7 @@ void symax_set_channels(uint8_t address)
|
||||
*pchans = 0x39194121;
|
||||
}
|
||||
|
||||
void symax_init2()
|
||||
static void __attribute__((unused)) symax_init2()
|
||||
{
|
||||
uint8_t chans_data_x5c[] = {0x1d, 0x2f, 0x26, 0x3d, 0x15, 0x2b, 0x25, 0x24,
|
||||
0x27, 0x2c, 0x1c, 0x3e, 0x39, 0x2d, 0x22};
|
||||
|
||||
337
Multiprotocol/Telemetry.ino
Normal file
337
Multiprotocol/Telemetry.ino
Normal file
@@ -0,0 +1,337 @@
|
||||
//*************************************
|
||||
// FrSky Telemetry serial code *
|
||||
// By Midelic on RCGroups *
|
||||
//*************************************
|
||||
|
||||
#if defined TELEMETRY
|
||||
#if defined FRSKYX_CC2500_INO
|
||||
#define SPORT_TELEMETRY
|
||||
#endif
|
||||
#if defined FRSKY_CC2500_INO
|
||||
#define HUB_TELEMETRY
|
||||
#endif
|
||||
#if defined SPORT_TELEMETRY
|
||||
#define SPORT_TELEMETRY
|
||||
#define SPORT_TIME 12000
|
||||
uint32_t last=0;
|
||||
uint8_t sport_counter=0;
|
||||
uint8_t RxBt=0;
|
||||
uint8_t rssi;
|
||||
uint8_t ADC2;
|
||||
#endif
|
||||
#if defined HUB_TELEMETRY
|
||||
#define MAX_PKTX 10
|
||||
uint8_t pktx[MAX_PKTX];
|
||||
uint8_t index;
|
||||
uint8_t prev_index;
|
||||
uint8_t pass = 0;
|
||||
#endif
|
||||
#define USER_MAX_BYTES 6
|
||||
uint8_t frame[18];
|
||||
|
||||
void frskySendStuffed()
|
||||
{
|
||||
Serial_write(0x7E);
|
||||
for (uint8_t i = 0; i < 9; i++)
|
||||
{
|
||||
if ((frame[i] == 0x7e) || (frame[i] == 0x7d))
|
||||
{
|
||||
Serial_write(0x7D);
|
||||
frame[i] ^= 0x20;
|
||||
}
|
||||
Serial_write(frame[i]);
|
||||
}
|
||||
Serial_write(0x7E);
|
||||
}
|
||||
|
||||
void compute_RSSIdbm(){
|
||||
|
||||
RSSI_dBm = (((uint16_t)(pktt[len-2])*18)>>5);
|
||||
if(pktt[len-2] >=128)
|
||||
RSSI_dBm -= 82;
|
||||
else
|
||||
RSSI_dBm += 65;
|
||||
}
|
||||
|
||||
void frsky_check_telemetry(uint8_t *pkt,uint8_t len)
|
||||
{
|
||||
if(pkt[1] != rx_tx_addr[3] || pkt[2] != rx_tx_addr[2] || len != pkt[0] + 3)
|
||||
{//only packets with the required id and packet length
|
||||
for(uint8_t i=3;i<6;i++)
|
||||
pktt[i]=0;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (uint8_t i=3;i<len;i++)
|
||||
pktt[i]=pkt[i];
|
||||
telemetry_link=1;
|
||||
if(pktt[6]>0)
|
||||
telemetry_counter=(telemetry_counter+1)%32;
|
||||
}
|
||||
}
|
||||
|
||||
void frsky_link_frame()
|
||||
{
|
||||
frame[0] = 0xFE;
|
||||
if ((cur_protocol[0]&0x1F)==MODE_FRSKY)
|
||||
{
|
||||
compute_RSSIdbm();
|
||||
frame[1] = pktt[3];
|
||||
frame[2] = pktt[4];
|
||||
frame[3] = (uint8_t)RSSI_dBm;
|
||||
frame[4] = pktt[5]*2;
|
||||
}
|
||||
else
|
||||
if ((cur_protocol[0]&0x1F)==MODE_HUBSAN)
|
||||
{
|
||||
frame[1] = v_lipo*2; //v_lipo; common 0x2A=42/10=4.2V
|
||||
frame[2] = frame[1];
|
||||
frame[3] = 0x00;
|
||||
frame[4] = (uint8_t)RSSI_dBm;
|
||||
}
|
||||
frame[5] = frame[6] = frame[7] = frame[8] = 0;
|
||||
frskySendStuffed();
|
||||
}
|
||||
|
||||
#if defined HUB_TELEMETRY
|
||||
void frsky_user_frame()
|
||||
{
|
||||
uint8_t indexx = 0, c=0, j=8, n=0, i;
|
||||
|
||||
if(pktt[6]>0 && pktt[6]<=MAX_PKTX)
|
||||
{//only valid hub frames
|
||||
frame[0] = 0xFD;
|
||||
frame[1] = 0;
|
||||
frame[2] = pktt[7];
|
||||
|
||||
switch(pass)
|
||||
{
|
||||
case 0:
|
||||
indexx=pktt[6];
|
||||
for(i=0;i<indexx;i++)
|
||||
{
|
||||
if(pktt[j]==0x5E)
|
||||
{
|
||||
if(c++)
|
||||
{
|
||||
c=0;
|
||||
n++;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
pktx[i]=pktt[j++];
|
||||
}
|
||||
indexx = indexx-n;
|
||||
pass=1;
|
||||
|
||||
case 1:
|
||||
index=indexx;
|
||||
prev_index = indexx;
|
||||
if(index<USER_MAX_BYTES)
|
||||
{
|
||||
for(i=0;i<index;i++)
|
||||
frame[i+3]=pktx[i];
|
||||
pktt[6]=0;
|
||||
pass=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
index = USER_MAX_BYTES;
|
||||
for(i=0;i<index;i++)
|
||||
frame[i+3]=pktx[i];
|
||||
pass=2;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
index = prev_index - index;
|
||||
prev_index=0;
|
||||
if(index<MAX_PKTX-USER_MAX_BYTES) //10-6=4
|
||||
for(i=0;i<index;i++)
|
||||
frame[i+3]=pktx[USER_MAX_BYTES+i];
|
||||
pass=0;
|
||||
pktt[6]=0;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(!index)
|
||||
return;
|
||||
frame[1] = index;
|
||||
frskySendStuffed();
|
||||
}
|
||||
else
|
||||
pass=0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined SPORT_TELEMETRY
|
||||
|
||||
/* SPORT details serial
|
||||
100K 8E2 normal-multiprotocol
|
||||
-every 12ms-
|
||||
1 2 3 4 5 6 7 8 9 CRC DESCR
|
||||
7E 98 10 05 F1 20 23 0F 00 A6 SWR_ID
|
||||
7E 98 10 01 F1 33 00 00 00 C9 RSSI_ID
|
||||
7E 98 10 04 F1 58 00 00 00 A1 BATT_ID
|
||||
7E BA 10 03 F1 E2 00 00 00 18 ADC2_ID
|
||||
7E BA 10 03 F1 E2 00 00 00 18 ADC2_ID
|
||||
7E BA 10 03 F1 E2 00 00 00 18 ADC2_ID
|
||||
7E BA 10 03 F1 E2 00 00 00 18 ADC2_ID
|
||||
7E BA 10 03 F1 E2 00 00 00 18 ADC2_ID
|
||||
7E BA 10 03 F1 E2 00 00 00 18 ADC2_ID
|
||||
|
||||
|
||||
Telemetry frames(RF) SPORT info 15 bytes
|
||||
SPORT frame 6+3 bytes
|
||||
[00] PKLEN 0E 0E 0E 0E
|
||||
[01] TXID1 DD DD DD DD
|
||||
[02] TXID2 6D 6D 6D 6D
|
||||
[03] CONST 02 02 02 02
|
||||
[04] RS/RB 2C D0 2C CE //D0;CE=2*RSSI;....2C = RX battery voltage(5V from Bec)
|
||||
[05] ????? 03 10 21 32 //TX/RX telemetry hand-shake bytes
|
||||
[06] NO.BT 00 00 06 03 //No.of valid SPORT frame bytes in the frame
|
||||
[07] STRM1 00 00 7E 00
|
||||
[08] STRM2 00 00 1A 00
|
||||
[09] STRM3 00 00 10 00
|
||||
[10] STRM4 03 03 03 03
|
||||
[11] STRM5 F1 F1 F1 F1
|
||||
[12] STRM6 D1 D1 D0 D0
|
||||
[13] CHKSUM1
|
||||
[14] CHKSUM2
|
||||
*/
|
||||
|
||||
|
||||
void sportSend(uint8_t *p)
|
||||
{
|
||||
uint16_t crc_s = 0;
|
||||
Serial_write(0x7e);//+9
|
||||
for (uint8_t i = 0; i < 9; i++)
|
||||
{
|
||||
if (i == 8)
|
||||
p[i] = 0xff - crc_s;
|
||||
if ((p[i] == 0x7e) || (p[i] == 0x7d))
|
||||
{
|
||||
Serial_write(0x7d);
|
||||
Serial_write(0x20 ^ p[i]);
|
||||
}
|
||||
else
|
||||
Serial_write(p[i]);
|
||||
if (i>0)
|
||||
{
|
||||
crc_s += p[i]; //0-1FF
|
||||
crc_s += crc_s >> 8; //0-100
|
||||
crc_s &= 0x00ff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sportIdle()
|
||||
{
|
||||
Serial_write(0x7e);
|
||||
}
|
||||
|
||||
void sportSendFrame()
|
||||
{
|
||||
//at the moment only SWR RSSI,RxBt and A2.
|
||||
sport_counter = (sport_counter + 1) %9;
|
||||
|
||||
for (uint8_t i=5;i<8;i++)
|
||||
frame[i]=0;
|
||||
|
||||
switch (sport_counter)
|
||||
{
|
||||
case 0: // SWR
|
||||
frame[0] = 0x98;
|
||||
frame[1] = 0x10;
|
||||
frame[2] = 0x05;
|
||||
frame[3] = 0xf1;
|
||||
frame[4] = 0x20;//dummy values if swr 20230f00
|
||||
frame[5] = 0x23;
|
||||
frame[6] = 0x0F;
|
||||
frame[7] = 0x00;
|
||||
break;
|
||||
case 1: // RSSI
|
||||
frame[0] = 0x98;
|
||||
frame[1] = 0x10;
|
||||
frame[2] = 0x01;
|
||||
frame[3] = 0xf1;
|
||||
frame[4] = rssi;
|
||||
break;
|
||||
case 2: //BATT
|
||||
frame[0] = 0x98;
|
||||
frame[1] = 0x10;
|
||||
frame[2] = 0x04;
|
||||
frame[3] = 0xf1;
|
||||
frame[4] = RxBt;//a1;
|
||||
break;
|
||||
case 3: //ADC2(A2)
|
||||
frame[0] = 0x1A;
|
||||
frame[1] = 0x10;
|
||||
frame[2] = 0x03;
|
||||
frame[3] = 0xf1;
|
||||
frame[4] = ADC2;//a2;;
|
||||
break;
|
||||
default:
|
||||
sportIdle();
|
||||
return;
|
||||
}
|
||||
sportSend(frame);
|
||||
}
|
||||
|
||||
void process_sport_data()//only for ADC2
|
||||
{
|
||||
uint8_t j=7;
|
||||
if(pktt[6]>0 && pktt[6]<=USER_MAX_BYTES)
|
||||
{
|
||||
for(uint8_t i=0;i<6;i++)
|
||||
if(pktt[j++]==0x03)
|
||||
if(pktt[j]==0xF1)
|
||||
{
|
||||
ADC2=pktt[j+1];
|
||||
break;
|
||||
}
|
||||
pktt[6]=0;//new frame
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void frskyUpdate()
|
||||
{
|
||||
if(telemetry_link && (cur_protocol[0]&0x1F) != MODE_FRSKYX )
|
||||
{
|
||||
frsky_link_frame();
|
||||
telemetry_link=0;
|
||||
return;
|
||||
}
|
||||
#if defined HUB_TELEMETRY
|
||||
if(!telemetry_link && (cur_protocol[0]&0x1F) != MODE_HUBSAN && (cur_protocol[0]&0x1F) != MODE_FRSKYX)
|
||||
{
|
||||
frsky_user_frame();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if defined SPORT_TELEMETRY
|
||||
if ((cur_protocol[0]&0x1F)==MODE_FRSKYX)
|
||||
{
|
||||
if(telemetry_link)
|
||||
{
|
||||
process_sport_data();
|
||||
if(pktt[4]>0x36)
|
||||
rssi=pktt[4]/2;
|
||||
else
|
||||
RxBt=pktt[4];
|
||||
telemetry_link=0;
|
||||
}
|
||||
uint32_t now = micros();
|
||||
if ((now - last) > SPORT_TIME)
|
||||
{
|
||||
sportSendFrame();
|
||||
last = now;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -12,10 +12,11 @@
|
||||
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 WLToys V2x2, JXD JD38x, JD39x, JJRC H6C, Yizhan Tarantula X6 ...
|
||||
// Last sync with hexfet new_protocols/v202_nrf24l01.c dated 2015-03-15
|
||||
|
||||
#if defined(V2X2_NRF24L01_INO)
|
||||
|
||||
// compatible with WLToys V2x2, JXD JD38x, JD39x, JJRC H6C, Yizhan Tarantula X6 ...
|
||||
|
||||
#include "iface_nrf24l01.h"
|
||||
|
||||
@@ -73,9 +74,8 @@ static const uint8_t freq_hopping[][16] = {
|
||||
{ 0x22, 0x27, 0x17, 0x39, 0x34, 0x28, 0x2B, 0x1D,
|
||||
0x18, 0x2A, 0x21, 0x38, 0x10, 0x26, 0x20, 0x1F } // 03
|
||||
};
|
||||
//static uint8_t hopping_frequency[16];
|
||||
|
||||
void v202_init()
|
||||
static void __attribute__((unused)) v202_init()
|
||||
{
|
||||
NRF24L01_Initialize();
|
||||
|
||||
@@ -103,14 +103,12 @@ void v202_init()
|
||||
NRF24L01_WriteReg(NRF24L01_15_RX_PW_P4, V2X2_PAYLOADSIZE);
|
||||
NRF24L01_WriteReg(NRF24L01_16_RX_PW_P5, V2X2_PAYLOADSIZE);
|
||||
NRF24L01_WriteReg(NRF24L01_17_FIFO_STATUS, 0x00); // Just in case, no real bits to write here
|
||||
uint8_t v2x2_rx_tx_addr[] = {0x66, 0x88, 0x68, 0x68, 0x68};
|
||||
uint8_t rx_p1_addr[] = {0x88, 0x66, 0x86, 0x86, 0x86};
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_0A_RX_ADDR_P0, v2x2_rx_tx_addr, 5);
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_0B_RX_ADDR_P1, rx_p1_addr, 5);
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, v2x2_rx_tx_addr, 5);
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_0A_RX_ADDR_P0, (uint8_t *)"\x66\x88\x68\x68\x68", 5);
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_0B_RX_ADDR_P1, (uint8_t *)"\x88\x66\x86\x86\x86", 5);
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, (uint8_t *)"\x66\x88\x68\x68\x68", 5);
|
||||
}
|
||||
|
||||
void V202_init2()
|
||||
static void __attribute__((unused)) V202_init2()
|
||||
{
|
||||
NRF24L01_FlushTx();
|
||||
packet_sent = 0;
|
||||
@@ -121,7 +119,7 @@ void V202_init2()
|
||||
//Done by TX_EN??? => NRF24L01_WriteReg(NRF24L01_00_CONFIG, BV(NRF24L01_00_EN_CRC) | BV(NRF24L01_00_CRCO) | BV(NRF24L01_00_PWR_UP));
|
||||
}
|
||||
|
||||
void set_tx_id(void)
|
||||
static void __attribute__((unused)) V2X2_set_tx_id(void)
|
||||
{
|
||||
uint8_t sum;
|
||||
sum = rx_tx_addr[1] + rx_tx_addr[2] + rx_tx_addr[3];
|
||||
@@ -136,7 +134,7 @@ void set_tx_id(void)
|
||||
}
|
||||
}
|
||||
|
||||
void add_pkt_checksum()
|
||||
static void __attribute__((unused)) V2X2_add_pkt_checksum()
|
||||
{
|
||||
uint8_t sum = 0;
|
||||
for (uint8_t i = 0; i < 15; ++i)
|
||||
@@ -144,7 +142,7 @@ void add_pkt_checksum()
|
||||
packet[15] = sum;
|
||||
}
|
||||
|
||||
void send_packet(uint8_t bind)
|
||||
static void __attribute__((unused)) V2X2_send_packet(uint8_t bind)
|
||||
{
|
||||
uint8_t flags2=0;
|
||||
if (bind)
|
||||
@@ -170,28 +168,25 @@ void send_packet(uint8_t bind)
|
||||
packet[6] = 0x40; // roll
|
||||
|
||||
//Flags
|
||||
flags=0;
|
||||
// Channel 5
|
||||
if (Servo_data[AUX1] > PPM_SWITCH)
|
||||
flags |= V2X2_FLAG_FLIP;
|
||||
if (Servo_AUX1) flags = V2X2_FLAG_FLIP;
|
||||
// Channel 6
|
||||
if (Servo_data[AUX2] > PPM_SWITCH)
|
||||
flags |= V2X2_FLAG_LIGHT;
|
||||
if (Servo_AUX2) flags |= V2X2_FLAG_LIGHT;
|
||||
// Channel 7
|
||||
if (Servo_data[AUX3] > PPM_SWITCH)
|
||||
flags |= V2X2_FLAG_CAMERA;
|
||||
if (Servo_AUX3) flags |= V2X2_FLAG_CAMERA;
|
||||
// Channel 8
|
||||
if (Servo_data[AUX4] > PPM_SWITCH)
|
||||
flags |= V2X2_FLAG_VIDEO;
|
||||
if (Servo_AUX4) flags |= V2X2_FLAG_VIDEO;
|
||||
|
||||
//Flags2
|
||||
// Channel 9
|
||||
if (Servo_data[AUX5] > PPM_SWITCH)
|
||||
if (Servo_AUX5)
|
||||
flags2 = V2X2_FLAG_HEADLESS;
|
||||
// Channel 10
|
||||
if (Servo_data[AUX6] > PPM_SWITCH)
|
||||
if (Servo_AUX6)
|
||||
flags2 |= V2X2_FLAG_MAG_CAL_X;
|
||||
// Channel 11
|
||||
if (Servo_data[AUX7] > PPM_SWITCH)
|
||||
if (Servo_AUX7)
|
||||
flags2 |= V2X2_FLAG_MAG_CAL_Y;
|
||||
}
|
||||
// TX id
|
||||
@@ -205,7 +200,7 @@ void send_packet(uint8_t bind)
|
||||
packet[13] = 0x00;
|
||||
//
|
||||
packet[14] = flags;
|
||||
add_pkt_checksum();
|
||||
V2X2_add_pkt_checksum();
|
||||
|
||||
packet_sent = 0;
|
||||
uint8_t rf_ch = hopping_frequency[hopping_frequency_no >> 1];
|
||||
@@ -213,7 +208,6 @@ void send_packet(uint8_t bind)
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, rf_ch);
|
||||
NRF24L01_FlushTx();
|
||||
NRF24L01_WritePayload(packet, V2X2_PAYLOADSIZE);
|
||||
++packet_counter;
|
||||
packet_sent = 1;
|
||||
|
||||
if (! hopping_frequency_no)
|
||||
@@ -237,7 +231,7 @@ uint16_t ReadV2x2()
|
||||
if (packet_sent && NRF24L01_packet_ack() != PKT_ACKED) {
|
||||
return PACKET_CHKTIME;
|
||||
}
|
||||
send_packet(1);
|
||||
V2X2_send_packet(1);
|
||||
if (--counter == 0) {
|
||||
phase = V202_DATA;
|
||||
BIND_DONE;
|
||||
@@ -247,7 +241,7 @@ uint16_t ReadV2x2()
|
||||
if (packet_sent && NRF24L01_packet_ack() != PKT_ACKED) {
|
||||
return PACKET_CHKTIME;
|
||||
}
|
||||
send_packet(0);
|
||||
V2X2_send_packet(0);
|
||||
break;
|
||||
}
|
||||
// Packet every 4ms
|
||||
@@ -256,8 +250,6 @@ uint16_t ReadV2x2()
|
||||
|
||||
uint16_t initV2x2()
|
||||
{
|
||||
flags=0;
|
||||
packet_counter = 0;
|
||||
v202_init();
|
||||
//
|
||||
if (IS_AUTOBIND_FLAG_on)
|
||||
@@ -267,7 +259,7 @@ uint16_t initV2x2()
|
||||
}
|
||||
else
|
||||
phase = V202_INIT2_NO_BIND;
|
||||
set_tx_id();
|
||||
V2X2_set_tx_id();
|
||||
return 50000;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
// Last sync with hexfet new_protocols/yd717_nrf24l01.c dated 2015-09-28
|
||||
|
||||
#if defined(YD717_NRF24L01_INO)
|
||||
|
||||
@@ -23,7 +24,7 @@
|
||||
#define YD717_PACKET_CHKTIME 500 // Time to wait if packet not yet acknowledged or timed out
|
||||
|
||||
// Stock tx fixed frequency is 0x3C. Receiver only binds on this freq.
|
||||
#define RF_CHANNEL 0x3C
|
||||
#define YD717_RF_CHANNEL 0x3C
|
||||
|
||||
#define YD717_FLAG_FLIP 0x0F
|
||||
#define YD717_FLAG_LIGHT 0x80
|
||||
@@ -32,7 +33,6 @@
|
||||
#define YD717_FLAG_HEADLESS 0x10
|
||||
|
||||
#define YD717_PAYLOADSIZE 8 // receive data pipes set to this size, but unused
|
||||
//#define YD717_MAX_PACKET_SIZE 9 // YD717 packets have 8-byte payload, Syma X4 is 9
|
||||
|
||||
enum {
|
||||
YD717_INIT1 = 0,
|
||||
@@ -41,7 +41,7 @@ enum {
|
||||
YD717_DATA
|
||||
};
|
||||
|
||||
void yd717_send_packet(uint8_t bind)
|
||||
static void __attribute__((unused)) yd717_send_packet(uint8_t bind)
|
||||
{
|
||||
uint8_t rudder_trim, elevator_trim, aileron_trim;
|
||||
if (bind)
|
||||
@@ -93,23 +93,17 @@ void yd717_send_packet(uint8_t bind)
|
||||
packet[6] = aileron_trim;
|
||||
}
|
||||
// Flags
|
||||
flags=0;
|
||||
// Channel 5
|
||||
if (Servo_data[AUX1] > PPM_SWITCH)
|
||||
flags = YD717_FLAG_FLIP;
|
||||
else
|
||||
flags=0;
|
||||
if (Servo_AUX1) flags = YD717_FLAG_FLIP;
|
||||
// Channel 6
|
||||
if (Servo_data[AUX2] > PPM_SWITCH)
|
||||
flags |= YD717_FLAG_LIGHT;
|
||||
if (Servo_AUX2) flags |= YD717_FLAG_LIGHT;
|
||||
// Channel 7
|
||||
if (Servo_data[AUX3] > PPM_SWITCH)
|
||||
flags |= YD717_FLAG_PICTURE;
|
||||
if (Servo_AUX3) flags |= YD717_FLAG_PICTURE;
|
||||
// Channel 8
|
||||
if (Servo_data[AUX4] > PPM_SWITCH)
|
||||
flags |= YD717_FLAG_VIDEO;
|
||||
if (Servo_AUX4) flags |= YD717_FLAG_VIDEO;
|
||||
// Channel 9
|
||||
if (Servo_data[AUX5] > PPM_SWITCH)
|
||||
flags |= YD717_FLAG_HEADLESS;
|
||||
if (Servo_AUX5) flags |= YD717_FLAG_HEADLESS;
|
||||
packet[7] = flags;
|
||||
}
|
||||
|
||||
@@ -123,7 +117,7 @@ void yd717_send_packet(uint8_t bind)
|
||||
{
|
||||
packet[8] = packet[0]; // checksum
|
||||
for(uint8_t i=1; i < 8; i++)
|
||||
packet[8] += packet[i];
|
||||
packet[8] += packet[i];
|
||||
packet[8] = ~packet[8];
|
||||
NRF24L01_WritePayload(packet, 9);
|
||||
}
|
||||
@@ -131,7 +125,7 @@ void yd717_send_packet(uint8_t bind)
|
||||
NRF24L01_SetPower(); // Set tx_power
|
||||
}
|
||||
|
||||
void yd717_init()
|
||||
static void __attribute__((unused)) yd717_init()
|
||||
{
|
||||
NRF24L01_Initialize();
|
||||
|
||||
@@ -142,7 +136,7 @@ void yd717_init()
|
||||
NRF24L01_WriteReg(NRF24L01_02_EN_RXADDR, 0x3F); // Enable all data pipes
|
||||
NRF24L01_WriteReg(NRF24L01_03_SETUP_AW, 0x03); // 5-byte RX/TX address
|
||||
NRF24L01_WriteReg(NRF24L01_04_SETUP_RETR, 0x1A); // 500uS retransmit t/o, 10 tries
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, RF_CHANNEL); // Channel 3C
|
||||
NRF24L01_WriteReg(NRF24L01_05_RF_CH, YD717_RF_CHANNEL); // Channel 3C
|
||||
NRF24L01_SetBitrate(NRF24L01_BR_1M); // 1Mbps
|
||||
NRF24L01_SetPower();
|
||||
NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70); // Clear data ready, data sent, and retransmit
|
||||
@@ -168,23 +162,24 @@ void yd717_init()
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, rx_tx_addr, 5);
|
||||
}
|
||||
|
||||
void YD717_init1()
|
||||
static void __attribute__((unused)) YD717_init1()
|
||||
{
|
||||
// for bind packets set address to prearranged value known to receiver
|
||||
uint8_t bind_rx_tx_addr[] = {0x65, 0x65, 0x65, 0x65, 0x65};
|
||||
if( sub_protocol==SYMAX2 )
|
||||
for(uint8_t i=0; i < 5; i++)
|
||||
uint8_t i;
|
||||
if( sub_protocol==SYMAX4 )
|
||||
for(i=0; i < 5; i++)
|
||||
bind_rx_tx_addr[i] = 0x60;
|
||||
else
|
||||
if( sub_protocol==NIHUI )
|
||||
for(uint8_t i=0; i < 5; i++)
|
||||
for(i=0; i < 5; i++)
|
||||
bind_rx_tx_addr[i] = 0x64;
|
||||
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_0A_RX_ADDR_P0, bind_rx_tx_addr, 5);
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_10_TX_ADDR, bind_rx_tx_addr, 5);
|
||||
}
|
||||
|
||||
void YD717_init2()
|
||||
static void __attribute__((unused)) YD717_init2()
|
||||
{
|
||||
// set rx/tx address for data phase
|
||||
NRF24L01_WriteRegisterMulti(NRF24L01_0A_RX_ADDR_P0, rx_tx_addr, 5);
|
||||
@@ -244,7 +239,6 @@ uint16_t yd717_callback()
|
||||
uint16_t initYD717()
|
||||
{
|
||||
rx_tx_addr[4] = 0xC1; // always uses first data port
|
||||
flags = 0;
|
||||
yd717_init();
|
||||
phase = YD717_INIT1;
|
||||
BIND_IN_PROGRESS; // autobind protocol
|
||||
|
||||
256
Multiprotocol/_Config.h
Normal file
256
Multiprotocol/_Config.h
Normal file
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
/** Multiprotocol module configuration file ***/
|
||||
|
||||
//Uncomment your TX type
|
||||
#define TX_ER9X //ER9X AETR (988<->2012µs)
|
||||
//#define TX_DEVO7 //DEVO7 EATR (1120<->1920µs)
|
||||
//#define TX_SPEKTRUM //Spektrum TAER (1100<->1900µs)
|
||||
//#define TX_HISKY //HISKY AETR (1100<->1900µs)
|
||||
|
||||
//Uncomment to enable telemetry
|
||||
#define TELEMETRY
|
||||
|
||||
//Comment if a module is not installed
|
||||
#define A7105_INSTALLED
|
||||
#define CYRF6936_INSTALLED
|
||||
#define CC2500_INSTALLED
|
||||
#define NFR24L01_INSTALLED
|
||||
|
||||
//Comment a protocol to exclude it from compilation
|
||||
#ifdef A7105_INSTALLED
|
||||
#define FLYSKY_A7105_INO
|
||||
#define HUBSAN_A7105_INO
|
||||
#endif
|
||||
#ifdef CYRF6936_INSTALLED
|
||||
#define DEVO_CYRF6936_INO
|
||||
#define DSM2_CYRF6936_INO
|
||||
#endif
|
||||
#ifdef CC2500_INSTALLED
|
||||
#define FRSKY_CC2500_INO
|
||||
#define FRSKYX_CC2500_INO
|
||||
#endif
|
||||
#ifdef NFR24L01_INSTALLED
|
||||
#define BAYANG_NRF24L01_INO
|
||||
#define CG023_NRF24L01_INO
|
||||
#define CX10_NRF24L01_INO
|
||||
#define ESKY_NRF24L01_INO
|
||||
#define HISKY_NRF24L01_INO
|
||||
#define KN_NRF24L01_INO
|
||||
#define SLT_NRF24L01_INO
|
||||
#define SYMAX_NRF24L01_INO
|
||||
#define V2X2_NRF24L01_INO
|
||||
#define YD717_NRF24L01_INO
|
||||
#define MT99XX_NRF24L01_INO
|
||||
#define MJXQ_NRF24L01_INO
|
||||
#define SHENQI_NRF24L01_INO
|
||||
#endif
|
||||
|
||||
//Update this table to set which protocol and all associated settings are called for the corresponding dial number
|
||||
const PPM_Parameters PPM_prot[15]= {
|
||||
// Dial Protocol Sub protocol RX_Num Power Auto Bind Option
|
||||
/* 1 */ {MODE_FLYSKY, Flysky , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 2 */ {MODE_HUBSAN, 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 3 */ {MODE_FRSKY , 0 , 0 , P_HIGH , NO_AUTOBIND , 0xD7 }, // D7 fine tuning
|
||||
/* 4 */ {MODE_HISKY , Hisky , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 5 */ {MODE_V2X2 , 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 6 */ {MODE_DSM2 , DSM2 , 0 , P_HIGH , NO_AUTOBIND , 6 }, // 6 channels @ 11ms
|
||||
/* 7 */ {MODE_DEVO , 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 8 */ {MODE_YD717 , YD717 , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 9 */ {MODE_KN , WLTOYS , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 10 */ {MODE_SYMAX , SYMAX , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 11 */ {MODE_SLT , 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 12 */ {MODE_CX10 , CX10_BLUE , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 13 */ {MODE_CG023 , CG023 , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 14 */ {MODE_BAYANG, 0 , 0 , P_HIGH , NO_AUTOBIND , 0 },
|
||||
/* 15 */ {MODE_SYMAX , SYMAX5C , 0 , P_HIGH , NO_AUTOBIND , 0 }
|
||||
};
|
||||
/* Available protocols and associated sub protocols:
|
||||
MODE_FLYSKY
|
||||
Flysky
|
||||
V9X9
|
||||
V6X6
|
||||
V912
|
||||
MODE_HUBSAN
|
||||
NONE
|
||||
MODE_FRSKY
|
||||
NONE
|
||||
MODE_HISKY
|
||||
Hisky
|
||||
HK310
|
||||
MODE_V2X2
|
||||
NONE
|
||||
MODE_DSM2
|
||||
DSM2
|
||||
DSMX
|
||||
MODE_DEVO
|
||||
NONE
|
||||
MODE_YD717
|
||||
YD717
|
||||
SKYWLKR
|
||||
SYMAX4
|
||||
XINXUN
|
||||
NIHUI
|
||||
MODE_KN
|
||||
WLTOYS
|
||||
FEILUN
|
||||
MODE_SYMAX
|
||||
SYMAX
|
||||
SYMAX5C
|
||||
MODE_SLT
|
||||
NONE
|
||||
MODE_CX10
|
||||
CX10_GREEN
|
||||
CX10_BLUE
|
||||
DM007
|
||||
Q282
|
||||
JC3015_1
|
||||
JC3015_2
|
||||
MK33041
|
||||
Q242
|
||||
MODE_CG023
|
||||
CG023
|
||||
YD829
|
||||
H8_3D
|
||||
MODE_BAYANG
|
||||
NONE
|
||||
MODE_FRSKYX
|
||||
NONE
|
||||
MODE_ESKY
|
||||
NONE
|
||||
MODE_MT99XX
|
||||
MT99
|
||||
H7
|
||||
YZ
|
||||
MODE_MJXQ
|
||||
WLH08
|
||||
X600
|
||||
X800
|
||||
H26D
|
||||
MODE_SHENQI
|
||||
NONE
|
||||
|
||||
RX_Num value between 0 and 15
|
||||
|
||||
Power P_HIGH or P_LOW
|
||||
|
||||
Auto Bind AUTOBIND or NO_AUTOBIND
|
||||
|
||||
Option value between 0 and 255. 0xD7 or 0x00 for Frsky fine tuning.
|
||||
*/
|
||||
|
||||
//******************
|
||||
//TX definitions with timing endpoints and channels order
|
||||
|
||||
// Turnigy PPM and channels
|
||||
#if defined(TX_ER9X)
|
||||
#define PPM_MAX 2140 // 125%
|
||||
#define PPM_MIN 860 // 125%
|
||||
#define PPM_MAX_100 2012 // 100%
|
||||
#define PPM_MIN_100 988 // 100%
|
||||
enum chan_order{
|
||||
AILERON =0,
|
||||
ELEVATOR,
|
||||
THROTTLE,
|
||||
RUDDER,
|
||||
AUX1,
|
||||
AUX2,
|
||||
AUX3,
|
||||
AUX4,
|
||||
AUX5,
|
||||
AUX6,
|
||||
AUX7,
|
||||
AUX8,
|
||||
AUX9
|
||||
};
|
||||
#endif
|
||||
|
||||
// Devo PPM and channels
|
||||
#if defined(TX_DEVO7)
|
||||
#define PPM_MAX 2100 // 125%
|
||||
#define PPM_MIN 900 // 125%
|
||||
#define PPM_MAX_100 1920 // 100%
|
||||
#define PPM_MIN_100 1120 // 100%
|
||||
enum chan_order{
|
||||
ELEVATOR=0,
|
||||
AILERON,
|
||||
THROTTLE,
|
||||
RUDDER,
|
||||
AUX1,
|
||||
AUX2,
|
||||
AUX3,
|
||||
AUX4,
|
||||
AUX5,
|
||||
AUX6,
|
||||
AUX7,
|
||||
AUX8,
|
||||
AUX9
|
||||
};
|
||||
#endif
|
||||
|
||||
// SPEKTRUM PPM and channels
|
||||
#if defined(TX_SPEKTRUM)
|
||||
#define PPM_MAX 2000 // 125%
|
||||
#define PPM_MIN 1000 // 125%
|
||||
#define PPM_MAX_100 1900 // 100%
|
||||
#define PPM_MIN_100 1100 // 100%
|
||||
enum chan_order{
|
||||
THROTTLE=0,
|
||||
AILERON,
|
||||
ELEVATOR,
|
||||
RUDDER,
|
||||
AUX1,
|
||||
AUX2,
|
||||
AUX3,
|
||||
AUX4,
|
||||
AUX5,
|
||||
AUX6,
|
||||
AUX7,
|
||||
AUX8,
|
||||
AUX9
|
||||
};
|
||||
#endif
|
||||
|
||||
// HISKY
|
||||
#if defined(TX_HISKY)
|
||||
#define PPM_MAX 2000 // 125%
|
||||
#define PPM_MIN 1000 // 125%
|
||||
#define PPM_MAX_100 1900 // 100%
|
||||
#define PPM_MIN_100 1100 // 100%
|
||||
enum chan_order{
|
||||
AILERON =0,
|
||||
ELEVATOR,
|
||||
THROTTLE,
|
||||
RUDDER,
|
||||
AUX1,
|
||||
AUX2,
|
||||
AUX3,
|
||||
AUX4,
|
||||
AUX5,
|
||||
AUX6,
|
||||
AUX7,
|
||||
AUX8,
|
||||
AUX9
|
||||
};
|
||||
#endif
|
||||
|
||||
#define PPM_MIN_COMMAND 1250
|
||||
#define PPM_SWITCH 1550
|
||||
#define PPM_MAX_COMMAND 1750
|
||||
|
||||
//Uncoment the desired serial speed
|
||||
#define BAUD 100000
|
||||
//#define BAUD 125000
|
||||
@@ -16,6 +16,16 @@
|
||||
#ifndef _IFACE_CC2500_H_
|
||||
#define _IFACE_CC2500_H_
|
||||
|
||||
enum {
|
||||
FRSKY_BIND = 0,
|
||||
FRSKY_BIND_DONE = 1000,
|
||||
FRSKY_DATA1,
|
||||
FRSKY_DATA2,
|
||||
FRSKY_DATA3,
|
||||
FRSKY_DATA4,
|
||||
FRSKY_DATA5
|
||||
};
|
||||
|
||||
enum {
|
||||
CC2500_00_IOCFG2 = 0x00, // GDO2 output pin configuration
|
||||
CC2500_01_IOCFG1 = 0x01, // GDO1 output pin configuration
|
||||
@@ -146,4 +156,43 @@ enum {
|
||||
//void CC2500_WriteData(u8 *packet, u8 length);
|
||||
//void CC2500_ReadData(u8 *dpbuffer, int len);
|
||||
//void CC2500_SetTxRxMode(enum TXRX_State);
|
||||
|
||||
const PROGMEM uint8_t cc2500_conf[][2]={
|
||||
{ CC2500_02_IOCFG0, 0x06 },
|
||||
{ CC2500_00_IOCFG2, 0x06 },
|
||||
{ CC2500_17_MCSM1, 0x0c },
|
||||
{ CC2500_18_MCSM0, 0x18 },
|
||||
{ CC2500_06_PKTLEN, 0x19 },
|
||||
{ CC2500_07_PKTCTRL1, 0x04 },
|
||||
{ CC2500_08_PKTCTRL0, 0x05 },
|
||||
{ CC2500_3E_PATABLE, 0xff },
|
||||
{ CC2500_0B_FSCTRL1, 0x08 },
|
||||
{ CC2500_0C_FSCTRL0, 0x00 }, // option
|
||||
{ CC2500_0D_FREQ2, 0x5c },
|
||||
{ CC2500_0E_FREQ1, 0x76 },
|
||||
{ CC2500_0F_FREQ0, 0x27 },
|
||||
{ CC2500_10_MDMCFG4, 0xAA },
|
||||
{ CC2500_11_MDMCFG3, 0x39 },
|
||||
{ CC2500_12_MDMCFG2, 0x11 },
|
||||
{ CC2500_13_MDMCFG1, 0x23 },
|
||||
{ CC2500_14_MDMCFG0, 0x7a },
|
||||
{ CC2500_15_DEVIATN, 0x42 },
|
||||
{ CC2500_19_FOCCFG, 0x16 },
|
||||
{ CC2500_1A_BSCFG, 0x6c },
|
||||
{ CC2500_1B_AGCCTRL2, 0x43 }, // bind ? 0x43 : 0x03
|
||||
{ CC2500_1C_AGCCTRL1,0x40 },
|
||||
{ CC2500_1D_AGCCTRL0,0x91 },
|
||||
{ CC2500_21_FREND1, 0x56 },
|
||||
{ CC2500_22_FREND0, 0x10 },
|
||||
{ CC2500_23_FSCAL3, 0xa9 },
|
||||
{ CC2500_24_FSCAL2, 0x0A },
|
||||
{ CC2500_25_FSCAL1, 0x00 },
|
||||
{ CC2500_26_FSCAL0, 0x11 },
|
||||
{ CC2500_29_FSTEST, 0x59 },
|
||||
{ CC2500_2C_TEST2, 0x88 },
|
||||
{ CC2500_2D_TEST1, 0x31 },
|
||||
{ CC2500_2E_TEST0, 0x0B },
|
||||
{ CC2500_03_FIFOTHR, 0x07 },
|
||||
{ CC2500_09_ADDR, 0x00 }
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -83,13 +83,13 @@ void CYRF_SetTxRxMode(enum TXRX_State);
|
||||
void CYRF_ConfigRFChannel(u8 ch);
|
||||
void CYRF_SetPower(u8 power);
|
||||
void CYRF_ConfigCRCSeed(u16 crc);
|
||||
void CYRF_StartReceive();
|
||||
static void CYRF_StartReceive();
|
||||
void CYRF_ConfigSOPCode(const u8 *sopcodes);
|
||||
void CYRF_ConfigDataCode(const u8 *datacodes, u8 len);
|
||||
u8 CYRF_ReadRSSI(u32 dodummyread);
|
||||
void CYRF_ReadDataPacket(u8 dpbuffer[]);
|
||||
static u8 CYRF_ReadRSSI(u32 dodummyread);
|
||||
static void CYRF_ReadDataPacket(u8 dpbuffer[]);
|
||||
void CYRF_WriteDataPacket(const u8 dpbuffer[]);
|
||||
void CYRF_WriteDataPacketLen(const u8 dpbuffer[], u8 len);
|
||||
static void CYRF_WriteDataPacketLen(const u8 dpbuffer[], u8 len);
|
||||
void CYRF_WriteRegister(u8 address, u8 data);
|
||||
u8 CYRF_ReadRegister(u8 address);
|
||||
void CYRF_WritePreamble(u32 preamble);
|
||||
|
||||
@@ -102,18 +102,7 @@ enum {
|
||||
#define REUSE_TX_PL 0xE3
|
||||
//#define NOP 0xFF
|
||||
|
||||
/*
|
||||
void NRF24L01_Initialize();
|
||||
byte NRF24L01_WriteReg(byte reg, byte data);
|
||||
byte NRF24L01_WriteRegisterMulti(byte reg, byte data[], byte length);
|
||||
byte NRF24L01_WritePayload(byte *data, byte len);
|
||||
byte NRF24L01_ReadReg(byte reg);
|
||||
byte NRF24L01_ReadRegisterMulti(byte reg, byte data[], byte length);
|
||||
byte NRF24L01_ReadPayload(byte *data, byte len);
|
||||
// XN297 emulation layer
|
||||
#define XN297_UNSCRAMBLED 8
|
||||
|
||||
byte NRF24L01_FlushTx();
|
||||
byte NRF24L01_FlushRx();
|
||||
byte NRF24L01_Activate(byte code);
|
||||
|
||||
*/
|
||||
#endif
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
|
||||
void frskySendStuffed(uint8_t frame[])
|
||||
{
|
||||
|
||||
Serial_write(0x7E);
|
||||
for (uint8_t i = 0; i < 9; i++) {
|
||||
if ((frame[i] == 0x7e) || (frame[i] == 0x7d)) {
|
||||
Serial_write(0x7D);
|
||||
frame[i] ^= 0x20;
|
||||
}
|
||||
Serial_write(frame[i]);
|
||||
}
|
||||
Serial_write(0x7E);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void frskySendFrame()
|
||||
{
|
||||
uint8_t frame[9];
|
||||
|
||||
frame[0] = 0xfe;
|
||||
if ((cur_protocol[0]&0x1F)==MODE_FRSKY)
|
||||
{
|
||||
compute_RSSIdbm();
|
||||
frame[1] = pktt[3];
|
||||
frame[2] = pktt[4];
|
||||
frame[3] = (uint8_t)RSSI_dBm;
|
||||
frame[4] = pktt[5]*2;//txrssi
|
||||
frame[5] = frame[6] = frame[7] = frame[8] = 0;
|
||||
}
|
||||
else
|
||||
if ((cur_protocol[0]&0x1F)==MODE_HUBSAN)
|
||||
{
|
||||
frame[1] = v_lipo*2;
|
||||
frame[2] = 0;
|
||||
frame[3] = 0x5A;//dummy value
|
||||
frame[4] = 2 * 0x5A;//dummy value
|
||||
frame[5] = frame[6] = frame[7] = frame[8] = 0;
|
||||
}
|
||||
frskySendStuffed(frame);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void frskyUpdate()
|
||||
{
|
||||
if(telemetry_link){
|
||||
frskySendFrame();
|
||||
telemetry_link=0;
|
||||
|
||||
}
|
||||
}
|
||||
412
PCB v2.3d/Multipro-txV2-3d-cache.lib
Normal file
412
PCB v2.3d/Multipro-txV2-3d-cache.lib
Normal file
@@ -0,0 +1,412 @@
|
||||
EESchema-LIBRARY Version 2.3 Date: 05/02/2016 16:56:43
|
||||
#encoding utf-8
|
||||
#
|
||||
# +5V
|
||||
#
|
||||
DEF +5V #PWR 0 40 Y Y 1 F P
|
||||
F0 "#PWR" 0 90 20 H I C CNN
|
||||
F1 "+5V" 0 90 30 H V C CNN
|
||||
F2 "~" 0 0 60 H V C CNN
|
||||
F3 "~" 0 0 60 H V C CNN
|
||||
DRAW
|
||||
X +5V 1 0 0 0 U 20 20 0 0 W N
|
||||
C 0 50 20 0 1 0 N
|
||||
P 4 0 1 0 0 0 0 30 0 30 0 30 N
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# +BATT
|
||||
#
|
||||
DEF +BATT #PWR 0 0 Y Y 1 F P
|
||||
F0 "#PWR" 0 -50 20 H I C CNN
|
||||
F1 "+BATT" 0 100 30 H V C CNN
|
||||
F2 "~" 0 0 60 H V C CNN
|
||||
F3 "~" 0 0 60 H V C CNN
|
||||
DRAW
|
||||
X +BATT 1 0 0 0 U 20 20 0 0 w N
|
||||
C 0 60 20 0 1 0 N
|
||||
P 3 0 1 0 0 0 0 40 0 40 N
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# 3V3
|
||||
#
|
||||
DEF 3V3 #PWR 0 0 Y Y 1 F P
|
||||
F0 "#PWR" 0 100 40 H I C CNN
|
||||
F1 "3V3" 0 125 40 H V C CNN
|
||||
F2 "~" 0 0 60 H V C CNN
|
||||
F3 "~" 0 0 60 H V C CNN
|
||||
DRAW
|
||||
X 3V3 1 0 0 0 U 30 30 0 0 W N
|
||||
P 2 0 1 0 0 60 0 0 N
|
||||
P 6 0 1 0 0 60 20 40 0 90 -20 40 0 60 0 60 N
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# A7105
|
||||
#
|
||||
DEF A7105 U 0 40 Y Y 1 F N
|
||||
F0 "U" 500 650 60 H V C CNN
|
||||
F1 "A7105" 0 800 60 H V C CNN
|
||||
F2 "~" 0 -400 60 H V C CNN
|
||||
F3 "~" 0 -400 60 H V C CNN
|
||||
DRAW
|
||||
S 400 -800 -350 700 0 1 0 N
|
||||
X 3V3 1 -650 550 300 R 70 70 1 1 I
|
||||
X SCS 2 -650 400 300 R 70 70 1 1 I
|
||||
X GND 3 -650 250 300 R 70 70 1 1 I
|
||||
X SCK 4 -650 100 300 R 70 70 1 1 I
|
||||
X SDIO 5 -650 -50 300 R 70 70 1 1 I
|
||||
X GIO1 6 -650 -200 300 R 70 70 1 1 I
|
||||
X GIO2 7 -650 -350 300 R 70 70 1 1 O
|
||||
X RXEN 8 -650 -500 300 R 70 70 1 1 I
|
||||
X TXEN 9 -650 -650 300 R 70 70 1 1 O
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# ATMEGA168A-A
|
||||
#
|
||||
DEF ATMEGA168A-A IC 0 40 Y Y 1 F N
|
||||
F0 "IC" -750 1250 40 H V L BNN
|
||||
F1 "ATMEGA168A-A" 400 -1400 40 H V L BNN
|
||||
F2 "TQFP32" 0 0 30 H V C CIN
|
||||
F3 "~" 0 0 60 H V C CNN
|
||||
ALIAS ATMEGA48A-A ATMEGA48PA-A ATMEGA88A-A ATMEGA88PA-A ATMEGA168PA-A ATMEGA328-A ATMEGA328P-A
|
||||
DRAW
|
||||
S -750 1200 850 -1300 0 1 10 f
|
||||
X (PCINT19/OC2B/INT1)PD3 1 1000 -800 150 L 40 40 1 1 B
|
||||
X (PCINT20/XCK/T0)PD4 2 1000 -900 150 L 40 40 1 1 B
|
||||
X GND 3 -900 -1200 150 R 40 40 1 1 W
|
||||
X VCC 4 -900 1100 150 R 40 40 1 1 W
|
||||
X GND 5 -900 -1100 150 R 40 40 1 1 W
|
||||
X VCC 6 -900 1000 150 R 40 40 1 1 W
|
||||
X (PCINT6/XTAL1/TOSC1)PB6 7 1000 500 150 L 40 40 1 1 B
|
||||
X (PCINT7/XTAL2/TOSC2)PB7 8 1000 400 150 L 40 40 1 1 B
|
||||
X (PCINT21/OC0B/T1)PD5 9 1000 -1000 150 L 40 40 1 1 B
|
||||
X (PCINT22/OC0A/AIN0)PD6 10 1000 -1100 150 L 40 40 1 1 B
|
||||
X AREF 20 -900 500 150 R 40 40 1 1 B
|
||||
X (PCINT16/RXD)PD0 30 1000 -500 150 L 40 40 1 1 B
|
||||
X (PCINT23/AIN1)PD7 11 1000 -1200 150 L 40 40 1 1 B
|
||||
X GND 21 -900 -1000 150 R 40 40 1 1 W
|
||||
X (PCINT17/TXD)PD1 31 1000 -600 150 L 40 40 1 1 B
|
||||
X (PCINT0/CLKO/ICP1)PB0 12 1000 1100 150 L 40 40 1 1 B
|
||||
X ADC7 22 -900 -350 150 R 40 40 1 1 N
|
||||
X (PCINT18/INT0)PD2 32 1000 -700 150 L 40 40 1 1 B
|
||||
X (PCINT1/OC1A)PB1 13 1000 1000 150 L 40 40 1 1 B
|
||||
X (PCINT8/ADC0)PC0 23 1000 250 150 L 40 40 1 1 B
|
||||
X (PCINT2/OC1B/~SS~)PB2 14 1000 900 150 L 40 40 1 1 B
|
||||
X (PCINT9/ADC1)PC1 24 1000 150 150 L 40 40 1 1 B
|
||||
X (PCINT3/OC2A/MOSI)PB3 15 1000 800 150 L 40 40 1 1 B
|
||||
X (PCINT10/ADC2)PC2 25 1000 50 150 L 40 40 1 1 B
|
||||
X (PCINT4/MISO)PB4 16 1000 700 150 L 40 40 1 1 B
|
||||
X (PCINT11/ADC3)PC3 26 1000 -50 150 L 40 40 1 1 B
|
||||
X (PCINT5/SCK)PB5 17 1000 600 150 L 40 40 1 1 B
|
||||
X (PCINT12/SDA/ADC4)PC4 27 1000 -150 150 L 40 40 1 1 B
|
||||
X AVCC 18 -900 800 150 R 40 40 1 1 W
|
||||
X (PCINT14/SCL/ADC5)PC5 28 1000 -250 150 L 40 40 1 1 B
|
||||
X ADC6 19 -900 -250 150 R 40 40 1 1 N
|
||||
X (PCINT14/~RESET~)PC6 29 1000 -350 150 L 40 40 1 1 B
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# C
|
||||
#
|
||||
DEF C C 0 10 N Y 1 F N
|
||||
F0 "C" 0 100 40 H V L CNN
|
||||
F1 "C" 6 -85 40 H V L CNN
|
||||
F2 "~" 38 -150 30 H V C CNN
|
||||
F3 "~" 0 0 60 H V C CNN
|
||||
$FPLIST
|
||||
SM*
|
||||
C?
|
||||
C1-1
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
P 2 0 1 20 -80 -30 80 -30 N
|
||||
P 2 0 1 20 -80 30 80 30 N
|
||||
X ~ 1 0 200 170 D 40 40 1 1 P
|
||||
X ~ 2 0 -200 170 U 40 40 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# CC2500
|
||||
#
|
||||
DEF CC2500 U 0 40 Y Y 1 F N
|
||||
F0 "U" 500 600 60 H V C CNN
|
||||
F1 "CC2500" 0 700 60 H V C CNN
|
||||
F2 "~" 0 -400 60 H V C CNN
|
||||
F3 "~" 0 -400 60 H V C CNN
|
||||
DRAW
|
||||
S 400 -900 -350 650 0 1 0 N
|
||||
X 3V3 1 -650 550 300 R 70 70 1 1 I
|
||||
X SI 2 -650 400 300 R 70 70 1 1 I
|
||||
X SCLK 3 -650 250 300 R 70 70 1 1 I
|
||||
X SO 4 -650 100 300 R 70 70 1 1 I
|
||||
X GDO2 5 -650 -50 300 R 70 70 1 1 I
|
||||
X GND 6 -650 -200 300 R 70 70 1 1 I
|
||||
X GDOo 7 -650 -350 300 R 70 70 1 1 I
|
||||
X CSn 8 -650 -500 300 R 70 70 1 1 I
|
||||
X PA_EN 9 -650 -650 300 R 70 70 1 1 I
|
||||
X LNA_EN 10 -650 -800 300 R 70 70 1 1 I
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# CONN_2
|
||||
#
|
||||
DEF CONN_2 P 0 40 Y N 1 F N
|
||||
F0 "P" -50 0 40 V V C CNN
|
||||
F1 "CONN_2" 50 0 40 V V C CNN
|
||||
F2 "~" 0 0 60 H V C CNN
|
||||
F3 "~" 0 0 60 H V C CNN
|
||||
DRAW
|
||||
S -100 150 100 -150 0 1 0 N
|
||||
X P1 1 -350 100 250 R 60 60 1 1 P I
|
||||
X PM 2 -350 -100 250 R 60 60 1 1 P I
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# CONN_3X2
|
||||
#
|
||||
DEF CONN_3X2 P 0 40 Y N 1 F N
|
||||
F0 "P" 0 250 50 H V C CNN
|
||||
F1 "CONN_3X2" 0 50 40 V V C CNN
|
||||
F2 "~" 0 0 60 H V C CNN
|
||||
F3 "~" 0 0 60 H V C CNN
|
||||
DRAW
|
||||
S -100 200 100 -100 0 1 0 N
|
||||
X 1 1 -400 150 300 R 60 60 1 1 P I
|
||||
X 2 2 400 150 300 L 60 60 1 1 P I
|
||||
X 3 3 -400 50 300 R 60 60 1 1 P I
|
||||
X 4 4 400 50 300 L 60 60 1 1 P I
|
||||
X 5 5 -400 -50 300 R 60 60 1 1 P I
|
||||
X 6 6 400 -50 300 L 60 60 1 1 P I
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# CONN_5
|
||||
#
|
||||
DEF CONN_5 P 0 40 Y Y 1 F N
|
||||
F0 "P" -50 0 50 V V C CNN
|
||||
F1 "CONN_5" 50 0 50 V V C CNN
|
||||
F2 "~" 0 0 60 H V C CNN
|
||||
F3 "~" 0 0 60 H V C CNN
|
||||
DRAW
|
||||
S -100 250 100 -250 0 1 0 f
|
||||
X ~ 1 -400 200 300 R 60 60 1 1 P I
|
||||
X ~ 2 -400 100 300 R 60 60 1 1 P I
|
||||
X ~ 3 -400 0 300 R 60 60 1 1 P I
|
||||
X ~ 4 -400 -100 300 R 60 60 1 1 P I
|
||||
X ~ 5 -400 -200 300 R 60 60 1 1 P I
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# CP1
|
||||
#
|
||||
DEF CP1 C 0 10 N N 1 F N
|
||||
F0 "C" 50 100 50 H V L CNN
|
||||
F1 "CP1" 50 -100 50 H V L CNN
|
||||
F2 "~" 0 0 60 H V C CNN
|
||||
F3 "~" 0 0 60 H V C CNN
|
||||
$FPLIST
|
||||
CP*
|
||||
SM*
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
T 0 -50 100 80 0 0 0 + Normal 0 C C
|
||||
A 0 -200 180 563 1236 0 1 15 N 100 -50 -100 -50
|
||||
P 4 0 1 15 -100 50 100 50 50 50 50 50 N
|
||||
X ~ 1 0 200 150 D 40 40 1 1 P
|
||||
X ~ 2 0 -200 180 U 40 40 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# CRYSTAL
|
||||
#
|
||||
DEF CRYSTAL X 0 40 N N 1 F N
|
||||
F0 "X" 0 150 60 H V C CNN
|
||||
F1 "CRYSTAL" 0 -150 60 H V C CNN
|
||||
F2 "~" 0 0 60 H V C CNN
|
||||
F3 "~" 0 0 60 H V C CNN
|
||||
DRAW
|
||||
P 2 0 1 16 -100 100 -100 -100 N
|
||||
P 2 0 1 16 100 100 100 -100 N
|
||||
P 5 0 1 12 -50 50 50 50 50 -50 -50 -50 -50 50 f
|
||||
X 1 1 -300 -50 200 R 40 40 1 1 P
|
||||
X 2 2 -300 50 200 R 40 40 1 1 P
|
||||
X 3 3 300 50 200 L 40 40 1 1 P
|
||||
X 4 4 300 -50 200 L 40 40 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# CYRF6936
|
||||
#
|
||||
DEF CYRF6936 U 0 40 Y Y 1 F N
|
||||
F0 "U" 0 1000 60 H V C CNN
|
||||
F1 "CYRF6936" 0 800 60 H V C CNN
|
||||
F2 "~" 0 -400 60 H V C CNN
|
||||
F3 "~" 0 -400 60 H V C CNN
|
||||
DRAW
|
||||
S 400 -800 -350 700 0 1 0 N
|
||||
X 5.0V 1 -650 500 300 R 70 70 1 1 I
|
||||
X NCS 2 -650 350 300 R 70 70 1 1 I
|
||||
X SCK 4 -650 200 300 R 70 70 1 1 I
|
||||
X GND 5 -650 50 300 R 70 70 1 1 I
|
||||
X GND 6 -650 -100 300 R 70 70 1 1 I
|
||||
X MOSI 8 -650 -250 300 R 70 70 1 1 I
|
||||
X RST 9 -650 -400 300 R 70 70 1 1 I
|
||||
X MISO 10 -650 -600 300 R 70 70 1 1 I
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# GND
|
||||
#
|
||||
DEF ~GND #PWR 0 0 Y Y 1 F P
|
||||
F0 "#PWR" 0 0 30 H I C CNN
|
||||
F1 "GND" 0 -70 30 H I C CNN
|
||||
F2 "~" 0 0 60 H V C CNN
|
||||
F3 "~" 0 0 60 H V C CNN
|
||||
DRAW
|
||||
P 4 0 1 0 -50 0 0 -50 50 0 -50 0 N
|
||||
X GND 1 0 0 0 U 30 30 1 1 W N
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# HEX_DIP
|
||||
#
|
||||
DEF HEX_DIP SW 0 40 Y Y 1 F N
|
||||
F0 "SW" 0 -350 60 H V C CNN
|
||||
F1 "HEX_DIP" 0 350 60 H V C CNN
|
||||
F2 "~" 0 0 60 H V C CNN
|
||||
F3 "~" 0 0 60 H V C CNN
|
||||
DRAW
|
||||
S -200 250 200 -250 0 1 0 N
|
||||
P 4 0 1 0 50 50 -50 0 50 -100 50 50 F
|
||||
X 1 1 500 -150 300 L 50 50 1 1 O
|
||||
X C 2 500 0 300 L 50 50 1 1 P
|
||||
X 4 3 500 150 300 L 50 50 1 1 O
|
||||
X 2 4 -500 150 300 R 50 50 1 1 O
|
||||
X C 5 -500 0 300 R 50 50 1 1 P
|
||||
X 8 6 -500 -150 300 R 50 50 1 1 O
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# JUMPER
|
||||
#
|
||||
DEF JUMPER JP 0 30 Y N 1 F N
|
||||
F0 "JP" 0 150 60 H V C CNN
|
||||
F1 "JUMPER" 0 -80 40 H V C CNN
|
||||
F2 "~" 0 0 60 H V C CNN
|
||||
F3 "~" 0 0 60 H V C CNN
|
||||
DRAW
|
||||
A 0 -26 125 1426 373 0 1 0 N -98 50 99 50
|
||||
C -100 0 35 0 1 0 N
|
||||
C 100 0 35 0 1 0 N
|
||||
X 1 1 -300 0 165 R 60 60 0 1 P
|
||||
X 2 2 300 0 165 L 60 60 0 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# LED
|
||||
#
|
||||
DEF LED D 0 40 Y N 1 F N
|
||||
F0 "D" 0 100 50 H V C CNN
|
||||
F1 "LED" 0 -100 50 H V C CNN
|
||||
F2 "~" 0 0 60 H V C CNN
|
||||
F3 "~" 0 0 60 H V C CNN
|
||||
$FPLIST
|
||||
LED-3MM
|
||||
LED-5MM
|
||||
LED-10MM
|
||||
LED-0603
|
||||
LED-0805
|
||||
LED-1206
|
||||
LEDV
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
P 2 0 1 0 50 50 50 -50 N
|
||||
P 3 0 1 0 -50 50 50 0 -50 -50 F
|
||||
P 3 0 1 0 65 -40 110 -80 105 -55 N
|
||||
P 3 0 1 0 80 -25 125 -65 120 -40 N
|
||||
X A 1 -200 0 150 R 40 40 1 1 P
|
||||
X K 2 200 0 150 L 40 40 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# NCP1117ST50T3G
|
||||
#
|
||||
DEF NCP1117ST50T3G U 0 30 Y Y 1 F N
|
||||
F0 "U" 150 -196 40 H V C CNN
|
||||
F1 "NCP1117ST50T3G" 0 200 40 H V C CNN
|
||||
F2 "~" 0 0 60 H V C CNN
|
||||
F3 "~" 0 0 60 H V C CNN
|
||||
ALIAS NCP1117ST12T3G NCP1117ST15T3G NCP1117ST18T3G NCP1117ST20T3G NCP1117ST25T3G NCP1117ST285T3G NCP1117ST33T3G
|
||||
$FPLIST
|
||||
SOT223
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
S -250 -150 250 150 0 1 10 f
|
||||
X GND 1 0 -250 100 U 40 40 1 1 W
|
||||
X VO 2 400 50 150 L 40 40 1 1 w
|
||||
X VI 3 -400 50 150 R 40 40 1 1 W
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# NRF24L01
|
||||
#
|
||||
DEF NRF24L01 U 0 40 Y Y 1 F N
|
||||
F0 "U" 500 650 60 H V C CNN
|
||||
F1 "NRF24L01" 0 800 60 H V C CNN
|
||||
F2 "~" 0 -400 60 H V C CNN
|
||||
F3 "~" 0 -400 60 H V C CNN
|
||||
DRAW
|
||||
S 400 -650 -350 700 0 1 0 N
|
||||
X GND 1 -650 550 300 R 70 70 1 1 I
|
||||
X 3V3 2 -650 400 300 R 70 70 1 1 I
|
||||
X CE 3 -650 250 300 R 70 70 1 1 I
|
||||
X CSN 4 -650 100 300 R 70 70 1 1 I
|
||||
X SCK 5 -650 -50 300 R 70 70 1 1 I
|
||||
X MOSI 6 -650 -200 300 R 70 70 1 1 I
|
||||
X MISO 7 -650 -350 300 R 70 70 1 1 I
|
||||
X IRQ 8 -650 -500 300 R 70 70 1 1 N
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# R
|
||||
#
|
||||
DEF R R 0 0 N Y 1 F N
|
||||
F0 "R" 80 0 40 V V C CNN
|
||||
F1 "R" 7 1 40 V V C CNN
|
||||
F2 "~" -70 0 30 V V C CNN
|
||||
F3 "~" 0 0 30 H V C CNN
|
||||
$FPLIST
|
||||
R?
|
||||
SM0603
|
||||
SM0805
|
||||
R?-*
|
||||
SM1206
|
||||
$ENDFPLIST
|
||||
DRAW
|
||||
S -40 150 40 -150 0 1 12 N
|
||||
X ~ 1 0 250 100 D 60 60 1 1 P
|
||||
X ~ 2 0 -250 100 U 60 60 1 1 P
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
# SW_PUSH_4_Pin
|
||||
#
|
||||
DEF SW_PUSH_4_Pin SW 0 40 N N 1 F N
|
||||
F0 "SW" 150 110 50 H V C CNN
|
||||
F1 "SW_PUSH_4_Pin" 0 -200 50 H V C CNN
|
||||
F2 "~" 0 0 60 H V C CNN
|
||||
F3 "~" 0 0 60 H V C CNN
|
||||
DRAW
|
||||
S -170 50 170 60 0 1 0 N
|
||||
P 4 0 1 0 -40 60 -30 90 30 90 40 60 N
|
||||
X 1 1 -300 0 200 R 60 60 0 1 P I
|
||||
X 3 3 300 0 200 L 60 60 0 1 P I
|
||||
X 2 2 -300 -100 200 R 50 50 1 1 I I
|
||||
X 4 4 300 -100 200 L 50 50 1 1 I I
|
||||
ENDDRAW
|
||||
ENDDEF
|
||||
#
|
||||
#End Library
|
||||
248
PCB v2.3d/Multipro-txV2-3d.cmp
Normal file
248
PCB v2.3d/Multipro-txV2-3d.cmp
Normal file
@@ -0,0 +1,248 @@
|
||||
Cmp-Mod V01 Created by CvPcb (2013-07-07 BZR 4022)-stable date = 05/02/2016 14:40:56
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53C2AE5B;
|
||||
Reference = C1;
|
||||
ValeurCmp = 22uF;
|
||||
IdModule = c_tant_B;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53BC5DA8;
|
||||
Reference = C2;
|
||||
ValeurCmp = 0.1uF;
|
||||
IdModule = SM0603_Capa;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53C2AE76;
|
||||
Reference = C3;
|
||||
ValeurCmp = 22uF;
|
||||
IdModule = c_tant_B;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53BC62F4;
|
||||
Reference = C4;
|
||||
ValeurCmp = 18pF;
|
||||
IdModule = SM0603_Capa;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53BC631E;
|
||||
Reference = C5;
|
||||
ValeurCmp = 18pF;
|
||||
IdModule = SM0603_Capa;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53C2B150;
|
||||
Reference = C6;
|
||||
ValeurCmp = 22uF;
|
||||
IdModule = c_tant_B;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /54845FE2;
|
||||
Reference = C7;
|
||||
ValeurCmp = 0.1uF;
|
||||
IdModule = SM0603_Capa;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53BC617C;
|
||||
Reference = D1;
|
||||
ValeurCmp = LED;
|
||||
IdModule = LED-0603;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53C2D9F8;
|
||||
Reference = D2;
|
||||
ValeurCmp = LED;
|
||||
IdModule = LED-0603;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53BC5C99;
|
||||
Reference = IC1;
|
||||
ValeurCmp = ATMEGA328-A;
|
||||
IdModule = TQFP32;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53FE5887;
|
||||
Reference = JP1;
|
||||
ValeurCmp = JUMPER;
|
||||
IdModule = c_0603;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53FE5896;
|
||||
Reference = JP2;
|
||||
ValeurCmp = JUMPER;
|
||||
IdModule = c_0603;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /56B4E4E1;
|
||||
Reference = JP3;
|
||||
ValeurCmp = JUMPER;
|
||||
IdModule = c_0603;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /56B4EFD5;
|
||||
Reference = JP4;
|
||||
ValeurCmp = JUMPER;
|
||||
IdModule = c_0603;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53C2DBCC;
|
||||
Reference = P1;
|
||||
ValeurCmp = ISP;
|
||||
IdModule = pin_array_3x2;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53FE5423;
|
||||
Reference = P2;
|
||||
ValeurCmp = CONN_5;
|
||||
IdModule = MOLEX_4455_N2X5;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /56B4E4CA;
|
||||
Reference = P3;
|
||||
ValeurCmp = CONN_2;
|
||||
IdModule = PIN_ARRAY_2X1;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53BC5FEA;
|
||||
Reference = R1;
|
||||
ValeurCmp = 10K;
|
||||
IdModule = SM0603_Resistor;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53C2B990;
|
||||
Reference = R2;
|
||||
ValeurCmp = 2K2;
|
||||
IdModule = SM0603_Resistor;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53C2B99F;
|
||||
Reference = R3;
|
||||
ValeurCmp = 1K;
|
||||
IdModule = SM0603_Resistor;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53BC6125;
|
||||
Reference = R4;
|
||||
ValeurCmp = 1K;
|
||||
IdModule = SM0603_Resistor;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53C2B787;
|
||||
Reference = R5;
|
||||
ValeurCmp = 2K2;
|
||||
IdModule = SM0603_Resistor;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53C2D8C4;
|
||||
Reference = R6;
|
||||
ValeurCmp = 1K;
|
||||
IdModule = SM0603_Resistor;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /54DCE006;
|
||||
Reference = R7;
|
||||
ValeurCmp = 2K2;
|
||||
IdModule = SM0603_Resistor;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /56B4E6D8;
|
||||
Reference = R8;
|
||||
ValeurCmp = 470;
|
||||
IdModule = SM0603_Resistor;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /54394777;
|
||||
Reference = SW1;
|
||||
ValeurCmp = HEX_DIP;
|
||||
IdModule = DIP-6__300;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /56B4EC6E;
|
||||
Reference = SW2;
|
||||
ValeurCmp = BIND;
|
||||
IdModule = SW_PUSH_6x4.5MM;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /56B4EC7B;
|
||||
Reference = SW3;
|
||||
ValeurCmp = RESET;
|
||||
IdModule = Switch_SMT5mm;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53C2ACE9;
|
||||
Reference = U1;
|
||||
ValeurCmp = NCP1117ST50T3G;
|
||||
IdModule = SOT223;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53C2AD08;
|
||||
Reference = U2;
|
||||
ValeurCmp = NCP1117ST33T3G;
|
||||
IdModule = SOT223;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53C2BF57;
|
||||
Reference = U3;
|
||||
ValeurCmp = CYRF6936;
|
||||
IdModule = CYRF6936;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53C2C184;
|
||||
Reference = U4;
|
||||
ValeurCmp = A7105;
|
||||
IdModule = XL7105-D03B;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53C2C24E;
|
||||
Reference = U5;
|
||||
ValeurCmp = NRF24L01;
|
||||
IdModule = NRF24L01;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53C2C3F4;
|
||||
Reference = U6;
|
||||
ValeurCmp = CC2500;
|
||||
IdModule = header_10_2mm;
|
||||
EndCmp
|
||||
|
||||
BeginCmp
|
||||
TimeStamp = /53BC62D3;
|
||||
Reference = X1;
|
||||
ValeurCmp = 16MHz;
|
||||
IdModule = crystal_FA238-TSX3225;
|
||||
EndCmp
|
||||
|
||||
EndListe
|
||||
3253
PCB v2.3d/Multipro-txV2-3d.kicad_pcb
Normal file
3253
PCB v2.3d/Multipro-txV2-3d.kicad_pcb
Normal file
File diff suppressed because it is too large
Load Diff
644
PCB v2.3d/Multipro-txV2-3d.net
Normal file
644
PCB v2.3d/Multipro-txV2-3d.net
Normal file
@@ -0,0 +1,644 @@
|
||||
(export (version D)
|
||||
(design
|
||||
(source "C:\\Documents and Settings\\Steve\\My Documents\\Multipro-tx\\MultiproV2.3d\\Multipro-txV2-3d.sch")
|
||||
(date "05/02/2016 16:35:59")
|
||||
(tool "eeschema (2013-07-07 BZR 4022)-stable"))
|
||||
(components
|
||||
(comp (ref IC1)
|
||||
(value ATMEGA328-A)
|
||||
(footprint TQFP32)
|
||||
(libsource (lib atmel) (part ATMEGA328-A))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53BC5C99))
|
||||
(comp (ref C2)
|
||||
(value 0.1uF)
|
||||
(libsource (lib device) (part C))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53BC5DA8))
|
||||
(comp (ref R1)
|
||||
(value 10K)
|
||||
(libsource (lib device) (part R))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53BC5FEA))
|
||||
(comp (ref R4)
|
||||
(value 1K)
|
||||
(libsource (lib device) (part R))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53BC6125))
|
||||
(comp (ref D1)
|
||||
(value LED)
|
||||
(libsource (lib device) (part LED))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53BC617C))
|
||||
(comp (ref X1)
|
||||
(value 16MHz)
|
||||
(libsource (lib device) (part CRYSTAL))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53BC62D3))
|
||||
(comp (ref C4)
|
||||
(value 18pF)
|
||||
(libsource (lib device) (part C))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53BC62F4))
|
||||
(comp (ref C5)
|
||||
(value 18pF)
|
||||
(libsource (lib device) (part C))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53BC631E))
|
||||
(comp (ref U1)
|
||||
(value NCP1117ST50T3G)
|
||||
(libsource (lib regul) (part NCP1117ST50T3G))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53C2ACE9))
|
||||
(comp (ref U2)
|
||||
(value NCP1117ST33T3G)
|
||||
(libsource (lib regul) (part NCP1117ST50T3G))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53C2AD08))
|
||||
(comp (ref C1)
|
||||
(value 22uF)
|
||||
(libsource (lib device) (part CP1))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53C2AE5B))
|
||||
(comp (ref C3)
|
||||
(value 22uF)
|
||||
(libsource (lib device) (part CP1))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53C2AE76))
|
||||
(comp (ref C6)
|
||||
(value 22uF)
|
||||
(libsource (lib device) (part CP1))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53C2B150))
|
||||
(comp (ref R5)
|
||||
(value 2K2)
|
||||
(libsource (lib device) (part R))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53C2B787))
|
||||
(comp (ref R2)
|
||||
(value 2K2)
|
||||
(libsource (lib device) (part R))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53C2B990))
|
||||
(comp (ref R3)
|
||||
(value 1K)
|
||||
(libsource (lib device) (part R))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53C2B99F))
|
||||
(comp (ref U3)
|
||||
(value CYRF6936)
|
||||
(libsource (lib device) (part CYRF6936))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53C2BF57))
|
||||
(comp (ref U4)
|
||||
(value A7105)
|
||||
(libsource (lib device) (part A7105))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53C2C184))
|
||||
(comp (ref U5)
|
||||
(value NRF24L01)
|
||||
(libsource (lib device) (part NRF24L01))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53C2C24E))
|
||||
(comp (ref U6)
|
||||
(value CC2500)
|
||||
(libsource (lib device) (part CC2500))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53C2C3F4))
|
||||
(comp (ref R6)
|
||||
(value 1K)
|
||||
(libsource (lib device) (part R))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53C2D8C4))
|
||||
(comp (ref D2)
|
||||
(value LED)
|
||||
(libsource (lib device) (part LED))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53C2D9F8))
|
||||
(comp (ref P1)
|
||||
(value ISP)
|
||||
(libsource (lib conn) (part CONN_3X2))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53C2DBCC))
|
||||
(comp (ref P2)
|
||||
(value CONN_5)
|
||||
(libsource (lib conn) (part CONN_5))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53FE5423))
|
||||
(comp (ref JP2)
|
||||
(value JUMPER)
|
||||
(libsource (lib device) (part JUMPER))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53FE5887))
|
||||
(comp (ref JP4)
|
||||
(value JUMPER)
|
||||
(libsource (lib device) (part JUMPER))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 53FE5896))
|
||||
(comp (ref SW1)
|
||||
(value HEX_DIP)
|
||||
(libsource (lib device) (part HEX_DIP))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 54394777))
|
||||
(comp (ref C7)
|
||||
(value 0.1uF)
|
||||
(libsource (lib device) (part C))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 54845FE2))
|
||||
(comp (ref R7)
|
||||
(value 2K2)
|
||||
(libsource (lib device) (part R))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 54DCE006))
|
||||
(comp (ref P3)
|
||||
(value CONN_2)
|
||||
(libsource (lib conn) (part CONN_2))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 56B4E4CA))
|
||||
(comp (ref JP3)
|
||||
(value JUMPER)
|
||||
(libsource (lib device) (part JUMPER))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 56B4E4E1))
|
||||
(comp (ref R8)
|
||||
(value 470)
|
||||
(libsource (lib device) (part R))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 56B4E6D8))
|
||||
(comp (ref SW2)
|
||||
(value BIND)
|
||||
(libsource (lib device) (part SW_PUSH_4_PIN))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 56B4EC6E))
|
||||
(comp (ref SW3)
|
||||
(value RESET)
|
||||
(libsource (lib device) (part SW_PUSH_4_PIN))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 56B4EC7B))
|
||||
(comp (ref JP1)
|
||||
(value JUMPER)
|
||||
(libsource (lib device) (part JUMPER))
|
||||
(sheetpath (names /) (tstamps /))
|
||||
(tstamp 56B4EFD5)))
|
||||
(libparts
|
||||
(libpart (lib device) (part A7105)
|
||||
(fields
|
||||
(field (name Reference) U)
|
||||
(field (name Value) A7105)
|
||||
(field (name Footprint) ~)
|
||||
(field (name Datasheet) ~))
|
||||
(pins
|
||||
(pin (num 1) (name 3V3) (type input))
|
||||
(pin (num 2) (name SCS) (type input))
|
||||
(pin (num 3) (name GND) (type input))
|
||||
(pin (num 4) (name SCK) (type input))
|
||||
(pin (num 5) (name SDIO) (type input))
|
||||
(pin (num 6) (name GIO1) (type input))
|
||||
(pin (num 7) (name GIO2) (type output))
|
||||
(pin (num 8) (name RXEN) (type input))
|
||||
(pin (num 9) (name TXEN) (type output))))
|
||||
(libpart (lib device) (part C)
|
||||
(description "Condensateur non polarise")
|
||||
(footprints
|
||||
(fp SM*)
|
||||
(fp C?)
|
||||
(fp C1-1))
|
||||
(fields
|
||||
(field (name Reference) C)
|
||||
(field (name Value) C)
|
||||
(field (name Footprint) ~)
|
||||
(field (name Datasheet) ~))
|
||||
(pins
|
||||
(pin (num 1) (name ~) (type passive))
|
||||
(pin (num 2) (name ~) (type passive))))
|
||||
(libpart (lib device) (part CC2500)
|
||||
(fields
|
||||
(field (name Reference) U)
|
||||
(field (name Value) CC2500)
|
||||
(field (name Footprint) ~)
|
||||
(field (name Datasheet) ~))
|
||||
(pins
|
||||
(pin (num 1) (name 3V3) (type input))
|
||||
(pin (num 2) (name SI) (type input))
|
||||
(pin (num 3) (name SCLK) (type input))
|
||||
(pin (num 4) (name SO) (type input))
|
||||
(pin (num 5) (name GDO2) (type input))
|
||||
(pin (num 6) (name GND) (type input))
|
||||
(pin (num 7) (name GDOo) (type input))
|
||||
(pin (num 8) (name CSn) (type input))
|
||||
(pin (num 9) (name PA_EN) (type input))
|
||||
(pin (num 10) (name LNA_EN) (type input))))
|
||||
(libpart (lib device) (part CP1)
|
||||
(description "Condensateur polarise")
|
||||
(footprints
|
||||
(fp CP*)
|
||||
(fp SM*))
|
||||
(fields
|
||||
(field (name Reference) C)
|
||||
(field (name Value) CP1)
|
||||
(field (name Footprint) ~)
|
||||
(field (name Datasheet) ~))
|
||||
(pins
|
||||
(pin (num 1) (name ~) (type passive))
|
||||
(pin (num 2) (name ~) (type passive))))
|
||||
(libpart (lib device) (part CRYSTAL)
|
||||
(fields
|
||||
(field (name Reference) X)
|
||||
(field (name Value) CRYSTAL)
|
||||
(field (name Footprint) ~)
|
||||
(field (name Datasheet) ~))
|
||||
(pins
|
||||
(pin (num 1) (name 1) (type passive))
|
||||
(pin (num 2) (name 2) (type passive))
|
||||
(pin (num 3) (name 3) (type passive))
|
||||
(pin (num 4) (name 4) (type passive))))
|
||||
(libpart (lib device) (part CYRF6936)
|
||||
(fields
|
||||
(field (name Reference) U)
|
||||
(field (name Value) CYRF6936)
|
||||
(field (name Footprint) ~)
|
||||
(field (name Datasheet) ~))
|
||||
(pins
|
||||
(pin (num 1) (name 5.0V) (type input))
|
||||
(pin (num 2) (name NCS) (type input))
|
||||
(pin (num 4) (name SCK) (type input))
|
||||
(pin (num 5) (name GND) (type input))
|
||||
(pin (num 6) (name GND) (type input))
|
||||
(pin (num 8) (name MOSI) (type input))
|
||||
(pin (num 9) (name RST) (type input))
|
||||
(pin (num 10) (name MISO) (type input))))
|
||||
(libpart (lib device) (part HEX_DIP)
|
||||
(fields
|
||||
(field (name Reference) SW)
|
||||
(field (name Value) HEX_DIP)
|
||||
(field (name Footprint) ~)
|
||||
(field (name Datasheet) ~))
|
||||
(pins
|
||||
(pin (num 1) (name 1) (type output))
|
||||
(pin (num 2) (name C) (type passive))
|
||||
(pin (num 3) (name 4) (type output))
|
||||
(pin (num 4) (name 2) (type output))
|
||||
(pin (num 5) (name C) (type passive))
|
||||
(pin (num 6) (name 8) (type output))))
|
||||
(libpart (lib device) (part JUMPER)
|
||||
(fields
|
||||
(field (name Reference) JP)
|
||||
(field (name Value) JUMPER)
|
||||
(field (name Footprint) ~)
|
||||
(field (name Datasheet) ~))
|
||||
(pins
|
||||
(pin (num 1) (name 1) (type passive))
|
||||
(pin (num 2) (name 2) (type passive))))
|
||||
(libpart (lib device) (part LED)
|
||||
(footprints
|
||||
(fp LED-3MM)
|
||||
(fp LED-5MM)
|
||||
(fp LED-10MM)
|
||||
(fp LED-0603)
|
||||
(fp LED-0805)
|
||||
(fp LED-1206)
|
||||
(fp LEDV))
|
||||
(fields
|
||||
(field (name Reference) D)
|
||||
(field (name Value) LED)
|
||||
(field (name Footprint) ~)
|
||||
(field (name Datasheet) ~))
|
||||
(pins
|
||||
(pin (num 1) (name A) (type passive))
|
||||
(pin (num 2) (name K) (type passive))))
|
||||
(libpart (lib device) (part NRF24L01)
|
||||
(fields
|
||||
(field (name Reference) U)
|
||||
(field (name Value) NRF24L01)
|
||||
(field (name Footprint) ~)
|
||||
(field (name Datasheet) ~))
|
||||
(pins
|
||||
(pin (num 1) (name GND) (type input))
|
||||
(pin (num 2) (name 3V3) (type input))
|
||||
(pin (num 3) (name CE) (type input))
|
||||
(pin (num 4) (name CSN) (type input))
|
||||
(pin (num 5) (name SCK) (type input))
|
||||
(pin (num 6) (name MOSI) (type input))
|
||||
(pin (num 7) (name MISO) (type input))
|
||||
(pin (num 8) (name IRQ) (type NotConnected))))
|
||||
(libpart (lib device) (part R)
|
||||
(description Resistance)
|
||||
(footprints
|
||||
(fp R?)
|
||||
(fp SM0603)
|
||||
(fp SM0805)
|
||||
(fp R?-*)
|
||||
(fp SM1206))
|
||||
(fields
|
||||
(field (name Reference) R)
|
||||
(field (name Value) R)
|
||||
(field (name Footprint) ~)
|
||||
(field (name Datasheet) ~))
|
||||
(pins
|
||||
(pin (num 1) (name ~) (type passive))
|
||||
(pin (num 2) (name ~) (type passive))))
|
||||
(libpart (lib device) (part SW_PUSH_4_Pin)
|
||||
(description "Push Button 4 Pin")
|
||||
(fields
|
||||
(field (name Reference) SW)
|
||||
(field (name Value) SW_PUSH_4_Pin)
|
||||
(field (name Footprint) ~)
|
||||
(field (name Datasheet) ~))
|
||||
(pins
|
||||
(pin (num 1) (name 1) (type passive))
|
||||
(pin (num 2) (name 2) (type input))
|
||||
(pin (num 3) (name 3) (type passive))
|
||||
(pin (num 4) (name 4) (type input))))
|
||||
(libpart (lib conn) (part CONN_2)
|
||||
(description "Symbole general de connecteur")
|
||||
(fields
|
||||
(field (name Reference) P)
|
||||
(field (name Value) CONN_2)
|
||||
(field (name Footprint) ~)
|
||||
(field (name Datasheet) ~))
|
||||
(pins
|
||||
(pin (num 1) (name P1) (type passive))
|
||||
(pin (num 2) (name PM) (type passive))))
|
||||
(libpart (lib conn) (part CONN_3X2)
|
||||
(description "Symbole general de connecteur")
|
||||
(fields
|
||||
(field (name Reference) P)
|
||||
(field (name Value) CONN_3X2)
|
||||
(field (name Footprint) ~)
|
||||
(field (name Datasheet) ~))
|
||||
(pins
|
||||
(pin (num 1) (name 1) (type passive))
|
||||
(pin (num 2) (name 2) (type passive))
|
||||
(pin (num 3) (name 3) (type passive))
|
||||
(pin (num 4) (name 4) (type passive))
|
||||
(pin (num 5) (name 5) (type passive))
|
||||
(pin (num 6) (name 6) (type passive))))
|
||||
(libpart (lib conn) (part CONN_5)
|
||||
(description "Symbole general de connecteur")
|
||||
(fields
|
||||
(field (name Reference) P)
|
||||
(field (name Value) CONN_5)
|
||||
(field (name Footprint) ~)
|
||||
(field (name Datasheet) ~))
|
||||
(pins
|
||||
(pin (num 1) (name ~) (type passive))
|
||||
(pin (num 2) (name ~) (type passive))
|
||||
(pin (num 3) (name ~) (type passive))
|
||||
(pin (num 4) (name ~) (type passive))
|
||||
(pin (num 5) (name ~) (type passive))))
|
||||
(libpart (lib regul) (part NCP1117ST50T3G)
|
||||
(description "NCP1117ST50T3G, 1A Low drop-out regulator, Fixed Output 5V, SOT223")
|
||||
(docs http://www.onsemi.com/pub_link/Collateral/NCP1117-D.PDF)
|
||||
(footprints
|
||||
(fp SOT223))
|
||||
(fields
|
||||
(field (name Reference) U)
|
||||
(field (name Value) NCP1117ST50T3G)
|
||||
(field (name Footprint) ~)
|
||||
(field (name Datasheet) ~))
|
||||
(pins
|
||||
(pin (num 1) (name GND) (type power_in))
|
||||
(pin (num 2) (name VO) (type power_out))
|
||||
(pin (num 3) (name VI) (type power_in))))
|
||||
(libpart (lib atmel) (part ATMEGA168A-A)
|
||||
(description "ATMEGA168A, TQFP32, 16k Flash, 1kB SRAM, 512B EEPROM")
|
||||
(docs http://www.atmel.com/dyn/resources/prod_documents/doc8271.pdf)
|
||||
(fields
|
||||
(field (name Reference) IC)
|
||||
(field (name Value) ATMEGA168A-A)
|
||||
(field (name Footprint) TQFP32)
|
||||
(field (name Datasheet) ~))
|
||||
(pins
|
||||
(pin (num 1) (name "(PCINT19/OC2B/INT1)PD3") (type BiDi))
|
||||
(pin (num 2) (name "(PCINT20/XCK/T0)PD4") (type BiDi))
|
||||
(pin (num 3) (name GND) (type power_in))
|
||||
(pin (num 4) (name VCC) (type power_in))
|
||||
(pin (num 5) (name GND) (type power_in))
|
||||
(pin (num 6) (name VCC) (type power_in))
|
||||
(pin (num 7) (name "(PCINT6/XTAL1/TOSC1)PB6") (type BiDi))
|
||||
(pin (num 8) (name "(PCINT7/XTAL2/TOSC2)PB7") (type BiDi))
|
||||
(pin (num 9) (name "(PCINT21/OC0B/T1)PD5") (type BiDi))
|
||||
(pin (num 10) (name "(PCINT22/OC0A/AIN0)PD6") (type BiDi))
|
||||
(pin (num 11) (name "(PCINT23/AIN1)PD7") (type BiDi))
|
||||
(pin (num 12) (name "(PCINT0/CLKO/ICP1)PB0") (type BiDi))
|
||||
(pin (num 13) (name "(PCINT1/OC1A)PB1") (type BiDi))
|
||||
(pin (num 14) (name "(PCINT2/OC1B/~SS~)PB2") (type BiDi))
|
||||
(pin (num 15) (name "(PCINT3/OC2A/MOSI)PB3") (type BiDi))
|
||||
(pin (num 16) (name "(PCINT4/MISO)PB4") (type BiDi))
|
||||
(pin (num 17) (name "(PCINT5/SCK)PB5") (type BiDi))
|
||||
(pin (num 18) (name AVCC) (type power_in))
|
||||
(pin (num 19) (name ADC6) (type NotConnected))
|
||||
(pin (num 20) (name AREF) (type BiDi))
|
||||
(pin (num 21) (name GND) (type power_in))
|
||||
(pin (num 22) (name ADC7) (type NotConnected))
|
||||
(pin (num 23) (name "(PCINT8/ADC0)PC0") (type BiDi))
|
||||
(pin (num 24) (name "(PCINT9/ADC1)PC1") (type BiDi))
|
||||
(pin (num 25) (name "(PCINT10/ADC2)PC2") (type BiDi))
|
||||
(pin (num 26) (name "(PCINT11/ADC3)PC3") (type BiDi))
|
||||
(pin (num 27) (name "(PCINT12/SDA/ADC4)PC4") (type BiDi))
|
||||
(pin (num 28) (name "(PCINT14/SCL/ADC5)PC5") (type BiDi))
|
||||
(pin (num 29) (name "(PCINT14/~RESET~)PC6") (type BiDi))
|
||||
(pin (num 30) (name "(PCINT16/RXD)PD0") (type BiDi))
|
||||
(pin (num 31) (name "(PCINT17/TXD)PD1") (type BiDi))
|
||||
(pin (num 32) (name "(PCINT18/INT0)PD2") (type BiDi)))))
|
||||
(libraries
|
||||
(library (logical device)
|
||||
(uri "C:\\Program Files\\KiCad\\share\\library\\device.lib"))
|
||||
(library (logical conn)
|
||||
(uri "C:\\Program Files\\KiCad\\share\\library\\conn.lib"))
|
||||
(library (logical regul)
|
||||
(uri "C:\\Program Files\\KiCad\\share\\library\\regul.lib"))
|
||||
(library (logical atmel)
|
||||
(uri "C:\\Program Files\\KiCad\\share\\library\\atmel.lib")))
|
||||
(nets
|
||||
(net (code 1) (name GND)
|
||||
(node (ref P2) (pin 4))
|
||||
(node (ref C7) (pin 2))
|
||||
(node (ref SW1) (pin 5))
|
||||
(node (ref SW1) (pin 2))
|
||||
(node (ref C5) (pin 2))
|
||||
(node (ref C4) (pin 1))
|
||||
(node (ref X1) (pin 4))
|
||||
(node (ref SW3) (pin 4))
|
||||
(node (ref SW3) (pin 3))
|
||||
(node (ref SW2) (pin 4))
|
||||
(node (ref SW2) (pin 3))
|
||||
(node (ref D1) (pin 2))
|
||||
(node (ref R3) (pin 2))
|
||||
(node (ref U6) (pin 6))
|
||||
(node (ref U5) (pin 1))
|
||||
(node (ref U4) (pin 3))
|
||||
(node (ref U3) (pin 6))
|
||||
(node (ref U3) (pin 5))
|
||||
(node (ref C3) (pin 2))
|
||||
(node (ref C1) (pin 2))
|
||||
(node (ref U2) (pin 1))
|
||||
(node (ref U1) (pin 1))
|
||||
(node (ref C6) (pin 2))
|
||||
(node (ref IC1) (pin 21))
|
||||
(node (ref IC1) (pin 5))
|
||||
(node (ref IC1) (pin 3))
|
||||
(node (ref X1) (pin 2))
|
||||
(node (ref C2) (pin 2))
|
||||
(node (ref D2) (pin 2))
|
||||
(node (ref P1) (pin 6)))
|
||||
(net (code 2) (name "")
|
||||
(node (ref D2) (pin 1))
|
||||
(node (ref R6) (pin 2)))
|
||||
(net (code 3) (name 3V3)
|
||||
(node (ref R5) (pin 2))
|
||||
(node (ref U6) (pin 1))
|
||||
(node (ref U5) (pin 2))
|
||||
(node (ref C7) (pin 1))
|
||||
(node (ref U4) (pin 1))
|
||||
(node (ref U2) (pin 2))
|
||||
(node (ref IC1) (pin 18))
|
||||
(node (ref IC1) (pin 6))
|
||||
(node (ref P1) (pin 2))
|
||||
(node (ref IC1) (pin 4))
|
||||
(node (ref R1) (pin 1))
|
||||
(node (ref C6) (pin 1)))
|
||||
(net (code 4) (name /CC25_CSN)
|
||||
(node (ref IC1) (pin 11))
|
||||
(node (ref U6) (pin 8)))
|
||||
(net (code 5) (name /MISO)
|
||||
(node (ref U3) (pin 10))
|
||||
(node (ref IC1) (pin 10))
|
||||
(node (ref U5) (pin 7))
|
||||
(node (ref U6) (pin 4)))
|
||||
(net (code 6) (name /SCK)
|
||||
(node (ref IC1) (pin 2))
|
||||
(node (ref U4) (pin 4))
|
||||
(node (ref U6) (pin 3))
|
||||
(node (ref U3) (pin 4))
|
||||
(node (ref U5) (pin 5)))
|
||||
(net (code 7) (name /MOSI)
|
||||
(node (ref U5) (pin 6))
|
||||
(node (ref IC1) (pin 9))
|
||||
(node (ref U6) (pin 2))
|
||||
(node (ref U4) (pin 5))
|
||||
(node (ref U3) (pin 8)))
|
||||
(net (code 8) (name +5V)
|
||||
(node (ref U2) (pin 3))
|
||||
(node (ref U1) (pin 2))
|
||||
(node (ref C3) (pin 1))
|
||||
(node (ref U3) (pin 1))
|
||||
(node (ref R6) (pin 1)))
|
||||
(net (code 9) (name /D11)
|
||||
(node (ref P1) (pin 4))
|
||||
(node (ref SW1) (pin 4))
|
||||
(node (ref IC1) (pin 15)))
|
||||
(net (code 10) (name /RESET)
|
||||
(node (ref IC1) (pin 29))
|
||||
(node (ref SW3) (pin 1))
|
||||
(node (ref P1) (pin 5))
|
||||
(node (ref R1) (pin 2))
|
||||
(node (ref SW3) (pin 2)))
|
||||
(net (code 11) (name /D12)
|
||||
(node (ref P1) (pin 1))
|
||||
(node (ref IC1) (pin 16))
|
||||
(node (ref SW1) (pin 3)))
|
||||
(net (code 12) (name "")
|
||||
(node (ref U4) (pin 7))
|
||||
(node (ref U4) (pin 8)))
|
||||
(net (code 13) (name "")
|
||||
(node (ref U4) (pin 6))
|
||||
(node (ref U4) (pin 9)))
|
||||
(net (code 14) (name /A7105_CSN)
|
||||
(node (ref IC1) (pin 32))
|
||||
(node (ref U4) (pin 2)))
|
||||
(net (code 15) (name /CC25_LANEN)
|
||||
(node (ref U6) (pin 5))
|
||||
(node (ref U6) (pin 10)))
|
||||
(net (code 16) (name /CC25_PAEN)
|
||||
(node (ref U6) (pin 9))
|
||||
(node (ref U6) (pin 7)))
|
||||
(net (code 17) (name /NRF_CE)
|
||||
(node (ref R5) (pin 1))
|
||||
(node (ref U5) (pin 3)))
|
||||
(net (code 18) (name /NRF_CSN)
|
||||
(node (ref U5) (pin 4))
|
||||
(node (ref IC1) (pin 12)))
|
||||
(net (code 19) (name "")
|
||||
(node (ref R8) (pin 1))
|
||||
(node (ref P3) (pin 2))
|
||||
(node (ref JP3) (pin 2)))
|
||||
(net (code 20) (name /PPM_IN)
|
||||
(node (ref JP2) (pin 1))
|
||||
(node (ref P2) (pin 1))
|
||||
(node (ref R2) (pin 2)))
|
||||
(net (code 21) (name "")
|
||||
(node (ref JP3) (pin 1))
|
||||
(node (ref P2) (pin 5)))
|
||||
(net (code 22) (name "")
|
||||
(node (ref JP4) (pin 2))
|
||||
(node (ref P3) (pin 1)))
|
||||
(net (code 23) (name "")
|
||||
(node (ref JP2) (pin 2))
|
||||
(node (ref R7) (pin 1)))
|
||||
(net (code 24) (name "")
|
||||
(node (ref R3) (pin 1))
|
||||
(node (ref JP1) (pin 2)))
|
||||
(net (code 25) (name /RX)
|
||||
(node (ref IC1) (pin 30))
|
||||
(node (ref R7) (pin 2)))
|
||||
(net (code 26) (name "")
|
||||
(node (ref P2) (pin 2))
|
||||
(node (ref JP4) (pin 1)))
|
||||
(net (code 27) (name /TX)
|
||||
(node (ref IC1) (pin 31))
|
||||
(node (ref R8) (pin 2)))
|
||||
(net (code 28) (name /CYRF_RST)
|
||||
(node (ref IC1) (pin 28))
|
||||
(node (ref U3) (pin 9)))
|
||||
(net (code 29) (name /CYRF_CSN)
|
||||
(node (ref U3) (pin 2))
|
||||
(node (ref IC1) (pin 13)))
|
||||
(net (code 30) (name /A0)
|
||||
(node (ref IC1) (pin 23))
|
||||
(node (ref SW1) (pin 6)))
|
||||
(net (code 31) (name /D10)
|
||||
(node (ref SW1) (pin 1))
|
||||
(node (ref IC1) (pin 14)))
|
||||
(net (code 32) (name /xtl2)
|
||||
(node (ref X1) (pin 1))
|
||||
(node (ref IC1) (pin 8))
|
||||
(node (ref C5) (pin 1)))
|
||||
(net (code 33) (name /xtl1)
|
||||
(node (ref IC1) (pin 7))
|
||||
(node (ref X1) (pin 3))
|
||||
(node (ref C4) (pin 2)))
|
||||
(net (code 34) (name "")
|
||||
(node (ref D1) (pin 1))
|
||||
(node (ref SW2) (pin 1))
|
||||
(node (ref SW2) (pin 2))
|
||||
(node (ref R4) (pin 2)))
|
||||
(net (code 35) (name /A3)
|
||||
(node (ref IC1) (pin 26)))
|
||||
(net (code 36) (name /D3)
|
||||
(node (ref IC1) (pin 1))
|
||||
(node (ref R2) (pin 1))
|
||||
(node (ref JP1) (pin 1)))
|
||||
(net (code 37) (name /A4)
|
||||
(node (ref IC1) (pin 27)))
|
||||
(net (code 38) (name /A2)
|
||||
(node (ref IC1) (pin 25)))
|
||||
(net (code 39) (name /A1)
|
||||
(node (ref IC1) (pin 24)))
|
||||
(net (code 40) (name /A6)
|
||||
(node (ref IC1) (pin 19)))
|
||||
(net (code 41) (name /A7)
|
||||
(node (ref IC1) (pin 22)))
|
||||
(net (code 42) (name /PB5)
|
||||
(node (ref P1) (pin 3))
|
||||
(node (ref IC1) (pin 17))
|
||||
(node (ref R4) (pin 1)))
|
||||
(net (code 43) (name "")
|
||||
(node (ref IC1) (pin 20))
|
||||
(node (ref C2) (pin 1)))
|
||||
(net (code 44) (name "")
|
||||
(node (ref U5) (pin 8)))
|
||||
(net (code 45) (name /BATT)
|
||||
(node (ref C1) (pin 1))
|
||||
(node (ref P2) (pin 3))
|
||||
(node (ref U1) (pin 3)))))
|
||||
41
PCB v2.3d/Multipro-txV2-3d.pro
Normal file
41
PCB v2.3d/Multipro-txV2-3d.pro
Normal file
@@ -0,0 +1,41 @@
|
||||
update=04/02/2016 18:14:57
|
||||
last_client=pcbnew
|
||||
[pcbnew]
|
||||
version=1
|
||||
LastNetListRead=Multipro-txV2-3d.net
|
||||
UseCmpFile=1
|
||||
PadDrill=0.750000000000
|
||||
PadDrillOvalY=0.750000000000
|
||||
PadSizeH=1.250000000000
|
||||
PadSizeV=1.250000000000
|
||||
PcbTextSizeV=1.500000000000
|
||||
PcbTextSizeH=1.500000000000
|
||||
PcbTextThickness=0.300000000000
|
||||
ModuleTextSizeV=1.000000000000
|
||||
ModuleTextSizeH=1.000000000000
|
||||
ModuleTextSizeThickness=0.150000000000
|
||||
SolderMaskClearance=0.000000000000
|
||||
SolderMaskMinWidth=0.000000000000
|
||||
DrawSegmentWidth=0.400000000000
|
||||
BoardOutlineThickness=0.100000000000
|
||||
ModuleOutlineThickness=0.150000000000
|
||||
[pcbnew/libraries]
|
||||
LibDir=../Multipro-txV2
|
||||
LibName1=sockets
|
||||
LibName2=connect
|
||||
LibName3=discret
|
||||
LibName4=pin_array
|
||||
LibName5=divers
|
||||
LibName6=smd_capacitors
|
||||
LibName7=smd_resistors
|
||||
LibName8=smd_crystal&oscillator
|
||||
LibName9=smd_dil
|
||||
LibName10=smd_transistors
|
||||
LibName11=libcms
|
||||
LibName12=display
|
||||
LibName13=led
|
||||
LibName14=dip_sockets
|
||||
LibName15=pga_sockets
|
||||
LibName16=valves
|
||||
LibName17=Logo
|
||||
LibName18=LogoBsilk
|
||||
1452
PCB v2.3d/Multipro-txV2-3d.sch
Normal file
1452
PCB v2.3d/Multipro-txV2-3d.sch
Normal file
File diff suppressed because it is too large
Load Diff
BIN
PCB v2.3d/PCB_v2.3d.jpg
Normal file
BIN
PCB v2.3d/PCB_v2.3d.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 172 KiB |
35
PCB v2.3d/Readme.txt
Normal file
35
PCB v2.3d/Readme.txt
Normal file
@@ -0,0 +1,35 @@
|
||||
These are KiCad files and you are free to do what you will with them. KiCad is a good, free, and fairly
|
||||
easy to learn. Build your own BOM and gerber files.
|
||||
|
||||
This is a variant of the Multipro V2.3c circuit design. It is basicly the same as the 2.3c board as far
|
||||
as component placement goes. What's changed is the added resistors for the serial protocol and also
|
||||
the addition of solder jumpers on the bottom of the board for the various options to connect the TX, RX, and PPM
|
||||
lines through them. See below for more detail.
|
||||
|
||||
The schematic has been updated to reflect the added components and jumper pads as well as cleaned
|
||||
up a little. As it sits now, the .net file loads without any complaints and DRC checks pass.
|
||||
|
||||
The jumpers, and how they are used:
|
||||
|
||||
|
||||
There are four solder type jumpers on the bottom side of the board near the lower left corner when the
|
||||
bottom of the board is facing towards you. The silkscreen shows which jumper is which. These four jumpers
|
||||
enable the board to be configured in several ways as explaned below.
|
||||
|
||||
(J-1) Use (PPM V/V) if the incoming PPM signal is at a higher voltage level, leave open if ~~5V.
|
||||
|
||||
(J-2) Use (Jumper 2) to connect the incomming PPM signal to the RX pin on the processor
|
||||
|
||||
(J-3) Short (TELEM) only if you have done a telemetry mod to your radio, leave open if not needed. When
|
||||
connected, pin 2 of the two pin header (P3) is also connected.
|
||||
|
||||
(J-4) Use (MOD) only to connect the transmitter pin 2 to pin 1 of the two pin header (P3).
|
||||
|
||||
The direction this project is going, it is most likely J-2 will be the only one needing to be shorted for
|
||||
the serial method of sending model protocols.
|
||||
|
||||
|
||||
These files are submitted without any guarentee of accureacy or suitability for any intended use. I am strictly
|
||||
an amature with time on his hands. Although I have done all I know to make it correct, things outside of my
|
||||
knowledge base are beyond my control. Do not use untested equipment around persons not familiar with the hazards
|
||||
of remote controlled vehicals.
|
||||
BIN
PCB v2.3d/Schematic_v2.3d.jpg
Normal file
BIN
PCB v2.3d/Schematic_v2.3d.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 224 KiB |
324
Protocols_Details.md
Normal file
324
Protocols_Details.md
Normal file
@@ -0,0 +1,324 @@
|
||||
#Protocols details
|
||||
**You'll find below a detailed description of every supported protocols sorted by RF modules.**
|
||||
|
||||
Legend:
|
||||
- Extended limits supported: -125%..+125% can be used and will be transmitted. Otherwise the default is -100%..+100% only.
|
||||
- Autobind protocol: you do not need to press the bind button at power up to bind, this is done automatically.
|
||||
|
||||
***
|
||||
#A7105 RF Module
|
||||
|
||||
##FLYSKY
|
||||
Extended limits supported
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8
|
||||
---|---|---|---|---|---|---|---
|
||||
A|E|T|R|CH5|CH6|CH7|CH8
|
||||
|
||||
###Sub_protocol V9X9
|
||||
CH5|CH6|CH7|CH8
|
||||
---|---|---|---
|
||||
FLIP|LIGHT|PICTURE|VIDEO
|
||||
|
||||
###Sub_protocol V6X6
|
||||
CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12
|
||||
---|---|---|---|---|---|---|---
|
||||
FLIP|LIGHT|PICTURE|VIDEO|HEADLESS|RTH|XCAL|YCAL
|
||||
|
||||
###Sub_protocol V912
|
||||
CH5|CH6
|
||||
---|---
|
||||
BTMBTN|TOPBTN
|
||||
|
||||
##HUBSAN
|
||||
Models: Hubsan H102D, H107/L/C/D and Hubsan H107P/C+/D+
|
||||
|
||||
Autobind protocol
|
||||
|
||||
Telemetry enabled for battery voltage and TX RSSI
|
||||
|
||||
Option=vTX frequency (H107D) 5645 - 5900 MHz
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9
|
||||
---|---|---|---|---|---|---|---|---
|
||||
A|E|T|R|FLIP|LIGHT|PICTURE|VIDEO|HEADLESS
|
||||
|
||||
***
|
||||
#CC2500 RF Module
|
||||
|
||||
##FRSKY
|
||||
Extended limits supported
|
||||
|
||||
Telemetry enabled for A0, A1, RSSI, TSSI and Hub
|
||||
|
||||
Option=fine frequency tuning, usually 0 or -41 based on the manufacturer boards
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8
|
||||
---|---|---|---|---|---|---|---
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8
|
||||
|
||||
##FRSKYX
|
||||
Models: FrSky receivers X4R, X6R and X8R.
|
||||
|
||||
Extended limits supported
|
||||
|
||||
Telemetry enabled for A1 (RxBatt), A2, RSSI
|
||||
|
||||
Option=fine frequency tuning, usually 0 or -41 based on the manufacturer boards
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
|
||||
---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
|
||||
|
||||
***
|
||||
#CYRF6936 RF Module
|
||||
|
||||
##DEVO
|
||||
Extended limits supported
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8
|
||||
---|---|---|---|---|---|---|---
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8
|
||||
|
||||
##DSM2
|
||||
Extended limits supported
|
||||
|
||||
option=number of channels and frame rate:
|
||||
- 0 : 4 channels @22ms
|
||||
- 1 : 5 channels @22ms
|
||||
- 2 : 6 channels @22ms
|
||||
- 3 : 7 channels @22ms
|
||||
|
||||
- 4 : 4 channels @11ms
|
||||
- 5 : 5 channels @11ms
|
||||
- 6 : 6 channels @11ms
|
||||
- 7 : 7 channels @11ms
|
||||
|
||||
- 8 : 8 channels @22ms
|
||||
- 9 : 9 channels @22ms
|
||||
- 10 : 10 channels @22ms
|
||||
- 11 : 11 channels @22ms
|
||||
- 12 : 12 channels @22ms
|
||||
|
||||
6 is usually giving the best results with most of the RX.
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12
|
||||
---|---|---|---|---|---|---|---|---|----|----|----
|
||||
A|E|T|R|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12
|
||||
|
||||
###Sub_protocol DSMX
|
||||
Same as above
|
||||
|
||||
***
|
||||
#NRF24L01 RF Module
|
||||
|
||||
##BAYANG
|
||||
Models: EAchine H8(C) mini, BayangToys X6/X7/X9, JJRC JJ850, Floureon H101 ...
|
||||
|
||||
Autobind protocol
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10
|
||||
---|---|---|---|---|---|---|---|---|----
|
||||
A|E|T|R|FLIP|RTH|PICTURE|VIDEO|HEADLESS|INVERTED
|
||||
|
||||
##CG023
|
||||
Models: EAchine CG023/CG031/3D X4
|
||||
|
||||
Autobind protocol
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9
|
||||
---|---|---|---|---|---|---|---|---
|
||||
A|E|T|R|FLIP|LIGHT|PICTURE|VIDEO|HEADLESS
|
||||
|
||||
###Sub_protocol YD829
|
||||
Models: Attop YD-822/YD-829/YD-829C ...
|
||||
|
||||
CH5|CH6|CH7|CH8|CH9
|
||||
---|---|---|---|---
|
||||
FLIP||PICTURE|VIDEO|HEADLESS
|
||||
|
||||
###Sub_protocol H8_3D
|
||||
Models: EAchine H8 mini 3D, JJRC H20/H22
|
||||
|
||||
CH5|CH6|CH7|CH8|CH9
|
||||
---|---|---|---|---
|
||||
FLIP|LIGTH|OPT1|OPT2|CAL
|
||||
|
||||
JJRC H20: OPT1=Headless, OPT2=RTH
|
||||
|
||||
JJRC H22: OPT1=RTH, OPT2=180/360° flip mode
|
||||
|
||||
H8 3D: OPT1=RTH + headless, OPT2=180/360° flip mode
|
||||
|
||||
CAL: calibrate accelerometers
|
||||
|
||||
##CX10
|
||||
Extended limits supported
|
||||
|
||||
Autobind protocol
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6
|
||||
---|---|---|---|---|---
|
||||
A|E|T|R|FLIP|RATE
|
||||
|
||||
Rate: -100%=rate 1, 0%=rate 2, +100%=rate 3
|
||||
|
||||
###Sub_protocol GREEN
|
||||
Models: Cheerson CX-10 green pcb
|
||||
|
||||
Same channels assignement as above.
|
||||
|
||||
###Sub_protocol BLUE
|
||||
Models: Cheerson CX-10 blue pcb & some newer red pcb, CX-10A, CX-10C, CX11, CX12, Floureon FX10, JJRC DHD D1
|
||||
|
||||
CH5|CH6|CH7|CH8
|
||||
---|---|---|---
|
||||
FLIP|RATE|PICTURE|VIDEO
|
||||
|
||||
Rate: -100%=rate 1, 0%=rate 2, +100%=rate 3 or headless for CX-10A
|
||||
|
||||
###Sub_protocol DM007
|
||||
|
||||
CH5|CH6|CH7|CH8|CH9
|
||||
---|---|---|---|---
|
||||
FLIP|MODE|PICTURE|VIDEO|HEADLESS
|
||||
|
||||
###Sub_protocol Q282 and Q242
|
||||
|
||||
CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12
|
||||
---|---|---|---|---|---|---|---
|
||||
FLIP|LED|PICTURE|VIDEO|HEADLESS|RTH|XCAL|YCAL
|
||||
|
||||
Model: JXD 509 is using Q282 with CH12=Start/Stop motors
|
||||
|
||||
###Sub_protocol JC3015_1
|
||||
|
||||
CH5|CH6|CH7|CH8
|
||||
---|---|---|---
|
||||
FLIP|MODE|PICTURE|VIDEO
|
||||
|
||||
###Sub_protocol JC3015_2
|
||||
|
||||
CH5|CH6|CH7|CH8
|
||||
---|---|---|---
|
||||
FLIP|MODE|LED|DFLIP
|
||||
|
||||
###Sub_protocol MK33041
|
||||
|
||||
CH5|CH6|CH7|CH8|CH9|CH10
|
||||
---|---|---|---|---|---
|
||||
FLIP|MODE|PICTURE|VIDEO|HEADLESS|RTH
|
||||
|
||||
##ESKY
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6
|
||||
---|---|---|---|---|---
|
||||
A|E|T|R|GYRO|PITCH
|
||||
|
||||
##HISKY
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8
|
||||
---|---|---|---|---|---|---|---
|
||||
A|E|T|R|GEAR|PITCH|GYRO|CH8
|
||||
|
||||
GYRO: -100%=6G, +100%=3G
|
||||
|
||||
###HK310
|
||||
Models: RX HK-3000, HK3100 and XY3000 (TX are HK-300, HK-310 and TL-3C)
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8
|
||||
---|---|---|---|---|---|---|---
|
||||
|||T|R|AUX|T_FSAFE|R_FSAFE|AUX_FSAFE
|
||||
|
||||
##KN
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11
|
||||
---|---|---|---|---|---|---|---|---|----|----
|
||||
A|E|T|R|DR|THOLD|IDLEUP|GYRO|Ttrim|Atrim|Etrim
|
||||
|
||||
Dual Rate: +100%=full range, Throttle Hold: +100%=hold, Idle Up: +100%=3D, GYRO: -100%=6G, +100%=3G
|
||||
|
||||
###Sub_protocol WLTOYS
|
||||
###Sub_protocol FEILUN
|
||||
Same channels assignement as above.
|
||||
|
||||
##MJXQ
|
||||
Autobind protocol
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13
|
||||
---|---|---|---|---|---|---|---|---|---|---|---|---
|
||||
A|E|T|R|FLIP|LED|PICTURE|VIDEO|HEADLESS|RTH|AUTOFLIP|PAN|TILT
|
||||
|
||||
###Sub_protocol WLH08
|
||||
###Sub_protocol X600
|
||||
###Sub_protocol X800
|
||||
###Sub_protocol H26D
|
||||
|
||||
##MT99XX
|
||||
Autobind protocol
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9
|
||||
---|---|---|---|---|---|---|---|---
|
||||
A|E|T|R|FLIP|LED|PICTURE|VIDEO|HEADLESS
|
||||
|
||||
###Sub_protocol MT
|
||||
Models: MT99xx
|
||||
###Sub_protocol H7
|
||||
Models: Eachine H7, Cheerson CX023
|
||||
###Sub_protocol YZ
|
||||
Model: Yi Zhan i6S
|
||||
Only one model can be flown at the same time since the ID is hardcoded.
|
||||
|
||||
##Shenqi
|
||||
Autobind protocol
|
||||
|
||||
Model: Shenqiwei 1/20 Mini Motorcycle
|
||||
|
||||
CH1|CH2|CH3|CH4
|
||||
---|---|---|---
|
||||
| |T|R
|
||||
|
||||
Throttle +100%=full forward,0%=stop,-100%=full backward.
|
||||
|
||||
##SLT
|
||||
Autobind protocol
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6
|
||||
---|---|---|---|---|---
|
||||
A|E|T|R|GEAR|PITCH
|
||||
|
||||
##Symax
|
||||
Autobind protocol
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9
|
||||
---|---|---|---|---|---|---|---|---
|
||||
A|E|T|R|FLIP||PICTURE|VIDEO|HEADLESS
|
||||
|
||||
###Sub_protocol SYMAX
|
||||
Models: Syma X5C-1/X11/X11C/X12
|
||||
|
||||
###Sub_protocol SYMAX5C
|
||||
Model: Syma X5C (original) and X2
|
||||
|
||||
##V2X2
|
||||
Models: WLToys V202/252/272, JXD 385/388, JJRC H6C, Yizhan Tarantula X6 ...
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11
|
||||
---|---|---|---|---|---|---|---|---|----|----
|
||||
A|E|T|R|FLIP|LIGHT|PICTURE|VIDEO|HEADLESS|MAG_CAL_X|MAG_CAL_Y
|
||||
|
||||
PICTURE: also automatic Missile Launcher and Hoist in one direction
|
||||
|
||||
VIDEO: also Sprayer, Bubbler, Missile Launcher(1), and Hoist in the other dir
|
||||
|
||||
##YD717
|
||||
Autobind protocol
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9
|
||||
---|---|---|---|---|---|---|---|---
|
||||
A|E|T|R|FLIP|LIGHT|PICTURE|VIDEO|HEADLESS
|
||||
|
||||
###Sub_protocol YD717
|
||||
###Sub_protocol SKYWLKR
|
||||
###Sub_protocol SYMAX4
|
||||
###Sub_protocol XINXUN
|
||||
###Sub_protocol NIHUI
|
||||
Same channels assignement as above.
|
||||
401
README.md
401
README.md
@@ -1,13 +1,13 @@
|
||||
# DIY-Multiprotocol-TX-Module
|
||||
Multiprotocol is a TX module which enables any TX to control lot of different models available on the market.
|
||||
Multiprotocol is a 2.4GHz transmitter which enables any TX to control lot of different models available on the market.
|
||||
|
||||
The source code is partly based on the Deviation TX project, thanks to all the developpers for their great job on protocols.
|
||||
|
||||
[Main thread on RCGROUPS for additional information](http://www.rcgroups.com/forums/showthread.php?t=2165676)
|
||||
[Forum link on RCGROUPS](http://www.rcgroups.com/forums/showthread.php?t=2165676) for additional information or requesting a new protocol integration.
|
||||
|
||||
 
|
||||
|
||||
**If you are looking at downloading the latest compiled version (hex file), it's under [Release](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/releases) on the top menu.**
|
||||
**To download the latest compiled version (hex file), click on [Release](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/releases) on the top menu.**
|
||||
|
||||
##Contents
|
||||
|
||||
@@ -17,7 +17,7 @@ The source code is partly based on the Deviation TX project, thanks to all the d
|
||||
|
||||
[Hardware](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module#hardware)
|
||||
|
||||
[Compilation and programmation](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module#compilation)
|
||||
[Compilation and programmation](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module#compilation-and-programmation)
|
||||
|
||||
[Troubleshooting](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module#troubleshooting)
|
||||
|
||||
@@ -26,12 +26,23 @@ The source code is partly based on the Deviation TX project, thanks to all the d
|
||||
###Using standard PPM output (trainer port)
|
||||
The multiprotocol TX module can be used on any TX with a trainer port.
|
||||
|
||||
Channels order is AETR by default but can be changed in the source code.
|
||||
Channels order is AETR by default but can be changed in the _Config.h.
|
||||
|
||||
The protocol selection is done via a dip switch or a rotary dip switch for access to up to 15 different protocols.
|
||||
The protocol selection is done via a dip switch, rotary dip switch or scsi ID selector.
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
You can access to up to 15 different protocols and associated settings.
|
||||
|
||||
Settings per selection are located in _Config.h:
|
||||
- Protocol and type: many main protocols have variants
|
||||
- RX Num: number your different RXs and make sure only one model will react to the commands
|
||||
- Power: High or low, enables to lower the power setting of your TX (indoor for example).
|
||||
- Option: -127..+127 allowing to set specific protocol options. Like for Hubsan to set the video frequency.
|
||||
- Autobind: Yes or No. At the model selection (or power applied to the TX) a bind sequence will be initiated
|
||||
|
||||
###Using a serial output
|
||||
The multiprotocol TX module takes full advantage of being used on a Turnigy 9X, 9XR, 9XR Pro, Taranis, 9Xtreme, AR9X, ... running [er9x or ersky9X](https://github.com/MikeBland/mbtx/tree/next). (A version for OpenTX is being looked at)
|
||||
|
||||
@@ -50,18 +61,33 @@ Options are:
|
||||
|
||||
Notes:
|
||||
- Using this solution does not need any modification of the TX since it uses the TX module slot PPM pin for serial transfer.
|
||||
- There are 2 versions of serial protocol either 8 or 16 channels. 16 channels is the latest version. Make sure to use the right version based on your version of er9x/ersky9x.
|
||||
- Channels order is AETR by default but can be changed in the source code.
|
||||
- There are 2 versions of serial protocol either 8 or 16 channels. 16 channels is the latest and only available version going forward. Make sure to use the right version based on your version of er9x/ersky9x.
|
||||
- Channels order is AETR by default but can be changed in _Config.h.
|
||||
|
||||
###Telemetry
|
||||
Telemetry is available for er9x and ersky9x TXs.
|
||||
There are only 2 protocols so far supporting telemetry: Hubsan and Frsky.
|
||||
|
||||
To enable telemetry on Turnigy 9X or 9XR you need to modify your TX following one of the Frsky mod like this [one](http://blog.oscarliang.net/turnigy-9x-advance-mod/).
|
||||
There are 3 protocols supporting telemetry: Hubsan, FrSky and FrSkyX.
|
||||
|
||||
Enabling telemetry on 9XR PRO and may be other TXs does not require any hardware modifications. The additional required serial pin is already available on the TX back module pins.
|
||||
Hubsan displays the battery voltage and TX RSSI.
|
||||
|
||||
Once the TX is telemetry enabled, it just needs to be configured on the model as usual.
|
||||
FrSky displays full telemetry (A0, A1, RX RSSI, TX RSSI and Hub).
|
||||
|
||||
FrSkyX displays basic telemetry (A1, A2 and RX RSSI).
|
||||
|
||||
### If used in PPM mode
|
||||
|
||||
Telemetry is available as a serial 9600 8 n 1 output on the TX pin of the Atmega328p using the FRSky hub format.
|
||||
|
||||
You can connect it to your TX if it is telemetry enabled or use a bluetooth adapter (HC05/HC06) along with an app on your phone/tablet ([app example](https://play.google.com/store/apps/details?id=biz.onomato.frskydash&hl=fr)) to display telemetry information and setup alerts.
|
||||
|
||||
### If used in Serial mode
|
||||
Telemetry is built in for er9x and ersky9x TXs.
|
||||
|
||||
To enable telemetry on a Turnigy 9X or 9XR you need to modify your TX following one of the Frsky mod like this [one](http://blog.oscarliang.net/turnigy-9x-advance-mod/).
|
||||
|
||||
Enabling telemetry on a 9XR PRO and may be other TXs does not require any hardware modifications. The additional required serial pin is already available on the TX back module pins.
|
||||
|
||||
Once the TX is telemetry enabled, it just needs to be configured on the model (see er9x/ersky9x documentation).
|
||||
|
||||
##Protocols
|
||||
|
||||
@@ -72,231 +98,125 @@ There are little chances to get a duplicated ID.
|
||||
It's possible to generate a new ID using bind button on the Hubsan protocol during power up.
|
||||
|
||||
###Bind
|
||||
To bind a model in:
|
||||
1. PPM Mode:
|
||||
- press the bind button, apply power and then release.
|
||||
2. Serial Mode:
|
||||
- use the GUI, access the model protocol page and long press on Bind.
|
||||
- press the bind button, apply power and then release will request a bind of the loaded model protocol. Note that the bind button is only effective at power up and not when the protocol is changed on the fly.
|
||||
To bind a model in PPM Mode press the physical bind button, apply power and then release.
|
||||
|
||||
In Serial Mode you have 2 options:
|
||||
- use the GUI, access the model protocol page and long press on Bind. This operation can be done at anytime.
|
||||
- press the physical bind button, apply power and then release. It will request a bind of the first loaded model protocol.
|
||||
|
||||
Notes:
|
||||
- the physical bind button is only effective at power up. Pressing the button later has no effects.
|
||||
- a bind in progress is indicated by the LED fast blinking. Make sure to bind during this period.
|
||||
|
||||
###Protocol selection
|
||||
|
||||
####Using the dial for PPM input
|
||||
PPM is only allowing access to a subset of existing protocols & sub_protocols.
|
||||
The default association dial position / protocol is listed below.
|
||||
PPM is only allowing access to a subset of existing protocols.
|
||||
The protocols, subprotocols and all other settings can be personalized by modifying the **_Config.h** file.
|
||||
|
||||
Dial|Protocol|Sub_protocol|RF Module
|
||||
----|--------|------------|---------
|
||||
0|Select serial||
|
||||
1|FLYSKY|Flysky|A7105
|
||||
2|HUBSAN|-|A7105
|
||||
3|FRSKY|-|CC2500
|
||||
4|HISKY|Hisky|NRF24L01
|
||||
5|V2X2|-|NRF24L01
|
||||
6|DSM2|DSM2|CYRF6936
|
||||
7|DEVO|-|CYRF6936
|
||||
8|YD717|YD717|NRF24L01
|
||||
9|KN|-|NRF24L01
|
||||
10|SYMAX|SYMAX|NRF24L01
|
||||
11|SLT|-|NRF24L01
|
||||
12|CX10|CX10_BLUE|NRF24L01
|
||||
13|CG023|CG023|NRF24L01
|
||||
14|BAYANG|-|NRF24L01
|
||||
15|SYMAX|SYMAX5C|NRF24L01
|
||||
The default association dial position / protocol in every release is listed below.
|
||||
|
||||
Notes:
|
||||
Dial|Protocol|Sub_protocol|RX Num|Power|Auto Bind|Option|RF Module
|
||||
----|--------|------------|------|-----|---------|------|---------
|
||||
0|Select serial||||||
|
||||
1|FLYSKY|Flysky|0|High|No|0|A7105
|
||||
2|HUBSAN|-|0|High|No|0|A7105
|
||||
3|FRSKY|-|0|High|No|-41|CC2500
|
||||
4|HISKY|Hisky|0|High|No|0|NRF24L01
|
||||
5|V2X2|-|0|High|No|0|NRF24L01
|
||||
6|DSM2|DSM2|0|High|No|6|CYRF6936
|
||||
7|DEVO|-|0|High|No|0|CYRF6936
|
||||
8|YD717|YD717|0|High|No|0|NRF24L01
|
||||
9|KN|WLTOYS|0|High|No|0|NRF24L01
|
||||
10|SYMAX|SYMAX|0|High|No|0|NRF24L01
|
||||
11|SLT|-|0|High|No|0|NRF24L01
|
||||
12|CX10|BLUE|0|High|No|0|NRF24L01
|
||||
13|CG023|CG023|0|High|No|0|NRF24L01
|
||||
14|BAYANG|-|0|High|No|0|NRF24L01
|
||||
15|SYMAX|SYMAX5C|0|High|No|0|NRF24L01
|
||||
|
||||
Note:
|
||||
- The dial selection must be done before the power is applied.
|
||||
- The protocols and subprotocols accessible by the dial can be personalized by modifying the source code.
|
||||
|
||||
####Using serial input with er9x/ersky9x
|
||||
Serial is allowing access to all existing protocols & sub_protocols listed below.
|
||||
|
||||
Protocol|Sub_protocol|RF Module
|
||||
--------|------------|---------
|
||||
Flysky||A7105
|
||||
#####A7105 RF module
|
||||
Protocol|Sub_protocol
|
||||
--------|------------
|
||||
Flysky|
|
||||
|Flysky
|
||||
|V9x9
|
||||
|V6x6
|
||||
|V912
|
||||
Hubsan||A7105
|
||||
Frsky||CC2500
|
||||
Hisky||NRF24L01
|
||||
|Hisky
|
||||
|HK310
|
||||
V2x2||NRF24L01
|
||||
DSM2||CYRF6936
|
||||
Hubsan|
|
||||
|
||||
#####CC2500 RF module
|
||||
Protocol|Sub_protocol
|
||||
--------|------------
|
||||
FrSky|
|
||||
FrSkyX|
|
||||
|
||||
#####CYRF6936 RF module
|
||||
Protocol|Sub_protocol
|
||||
--------|------------
|
||||
DSM2|
|
||||
|DSM2
|
||||
|DSMX
|
||||
Devo||CYRF6936
|
||||
YD717||NRF24L01
|
||||
Devo|
|
||||
|
||||
#####NRF24L01 RF module
|
||||
Protocol|Sub_protocol
|
||||
--------|------------
|
||||
Hisky|
|
||||
|Hisky
|
||||
|HK310
|
||||
V2x2|
|
||||
YD717|
|
||||
|YD717
|
||||
|SKYWLKR
|
||||
|SYMAX2
|
||||
|SYMAX4
|
||||
|XINXUN
|
||||
|NIHUI
|
||||
KN||NRF24L01
|
||||
SymaX||NRF24L01
|
||||
KN|
|
||||
|WLTOYS
|
||||
|FEILUN
|
||||
SymaX|
|
||||
|SYMAX
|
||||
|SYMAX5C
|
||||
SLT||NRF24L01
|
||||
CX10||NRF24L01
|
||||
|CX10_GREEN
|
||||
|CX10_BLUE
|
||||
SLT|
|
||||
CX10|
|
||||
|GREEN
|
||||
|BLUE
|
||||
|DM007
|
||||
CG023||NRF24L01
|
||||
|Q282
|
||||
|JC3015_1
|
||||
|JC3015_2
|
||||
|MK33041
|
||||
|Q242
|
||||
CG023|
|
||||
|CG023
|
||||
|YD829
|
||||
|H8_3D
|
||||
Bayang||NRF24L01
|
||||
Bayang|
|
||||
FrskyX||CC2500
|
||||
ESky|
|
||||
MT99XX|
|
||||
|MT
|
||||
|H7
|
||||
|YZ
|
||||
MJXQ|
|
||||
|WLH08
|
||||
|X600
|
||||
|X800
|
||||
|H26D
|
||||
Shenqi|
|
||||
|
||||
Note:
|
||||
- The dial should be set to 0 for serial. Which means all protocol selection pins should be left unconnected.
|
||||
|
||||
###Protocol details
|
||||
Extended limits supported: -125%..+125% can be used and will be transmitted. Otherwise the default is -100%..+100% only.
|
||||
|
||||
Autobind protocol: you do not need to press the bind button at power up to bind, this is done automatically.
|
||||
|
||||
####BAYANG
|
||||
Autobind protocol
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
|
||||
---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----
|
||||
A|E|T|R|FLIP|HEADLESS|RTH
|
||||
|
||||
####CG023
|
||||
Autobind protocol
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
|
||||
---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----
|
||||
A|E|T|R|FLIP|LIGHT|PICTURE|VIDEO|HEADLESS
|
||||
|
||||
#####Sub_protocol YD829
|
||||
CH5|CH6|CH7|CH8|CH9
|
||||
---|---|---|---|---
|
||||
FLIP||PICTURE|VIDEO|HEADLESS
|
||||
|
||||
#####Sub_protocol H8_3D
|
||||
CH5|CH6|CH7|CH8|CH9
|
||||
---|---|---|---|---
|
||||
FLIP|HEADLESS|RTH
|
||||
|
||||
RTH on H8_3D is 180/360 flip mode
|
||||
|
||||
Both sticks bottom left: calibrate accelerometers
|
||||
|
||||
####CX10
|
||||
Extended limits supported
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
|
||||
---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----
|
||||
A|E|T|R|FLIP|MODE|PICTURE|VIDEO|HEADLESS
|
||||
|
||||
MODE: +100%=mode3 or headless for CX-10A, -100%=mode1, 0%=mode2
|
||||
|
||||
####DEVO
|
||||
Extended limits supported
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
|
||||
---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8
|
||||
|
||||
####DSM2
|
||||
Extended limits supported
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
|
||||
---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----
|
||||
A|E|T|R|CH5|CH6|CH7|CH8
|
||||
|
||||
####FLYSKY
|
||||
Extended limits supported
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
|
||||
---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----
|
||||
A|E|T|R|CH5|CH6|CH7|CH8
|
||||
|
||||
#####Sub_protocol V9X9
|
||||
CH5|CH6|CH7|CH8
|
||||
---|---|---|---
|
||||
UNK|LIGHT|PICTURE|VIDEO
|
||||
|
||||
#####Sub_protocol V6X6
|
||||
CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12
|
||||
---|---|---|---|---|---|---|---
|
||||
FLIP|LIGHT|PICTURE|VIDEO|HEADLESS|RTH|XCAL|YCAL
|
||||
|
||||
#####Sub_protocol V912
|
||||
CH5|CH6
|
||||
---|---
|
||||
BTMBTN|TOPBTN
|
||||
|
||||
####FRSKY
|
||||
Extended limits supported
|
||||
|
||||
Telemetry enabled for A0, A1, RSSI
|
||||
|
||||
Option=fine frequency tuning, usually 0 or -41 based on the manufacturer boards
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
|
||||
---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8
|
||||
|
||||
####HISKY
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
|
||||
---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----
|
||||
A|E|T|R|GEAR|PITCH|GYRO|CH8
|
||||
|
||||
GYRO: -100%=6G, +100%=3G
|
||||
|
||||
####HK310
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
|
||||
---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----
|
||||
|||T|R|AUX|T_FSAFE|R_FSAFE|AUX_FSAFE
|
||||
|
||||
####HUBSAN
|
||||
Autobind protocol
|
||||
|
||||
Telemetry enabled for battery voltage only
|
||||
|
||||
Option=vTX frequency (H107D) 5645 - 5900 MHz
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
|
||||
---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----
|
||||
A|E|T|R|FLIP|LIGHT||VIDEO
|
||||
|
||||
####KN
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
|
||||
---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----
|
||||
A|E|T|R|DR|THOLD|IDLEUP|GYRO3
|
||||
|
||||
GYRO3: -100%=6G, +100%=3G
|
||||
|
||||
####SLT
|
||||
Autobind protocol
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
|
||||
---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----
|
||||
A|E|T|R|GEAR|PITCH
|
||||
|
||||
####Symax
|
||||
Autobind protocol
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
|
||||
---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----
|
||||
A|E|T|R|FLIP||PICTURE|VIDEO|HEADLESS
|
||||
|
||||
####V2X2
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
|
||||
---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----
|
||||
A|E|T|R|FLIP|LIGHT|PICTURE|VIDEO|HEADLESS|MAG_CAL_X|MAG_CAL_Y
|
||||
|
||||
####YD717
|
||||
Autobind protocol
|
||||
|
||||
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13|CH14|CH15|CH16
|
||||
---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----
|
||||
A|E|T|R|FLIP|LIGHT|PICTURE|VIDEO|HEADLESS
|
||||
###Protocols details
|
||||
**Check the [Protocols_Details.md](./Protocols_Details.md) file for a detailed description of every protocols with channels assignements.**
|
||||
|
||||
##Hardware
|
||||
|
||||
@@ -311,24 +231,39 @@ RF modules can be installed for protocols need only. Example: if you only need t
|
||||
|
||||
You also need some [antennas](http://www.banggood.com/2_4GHz-3dBi-RP-SMA-Connector-Booster-Wireless-Antenna-Modem-Router-p-979407.html) and [cables](http://www.banggood.com/10cm-PCI-UFL-IPX-to-RPSMA-Female-Jack-Pigtail-Cable-p-924933.html).
|
||||
|
||||
###Microcontroller
|
||||
The main program is running on an ATMEGA328 running @16MHz and 3.3V.
|
||||
An [Arduino pro mini](http://www.banggood.com/Wholesale-New-Ver-Pro-Mini-ATMEGA328-328p-5V-16MHz-Arduino-Compatible-Nano-Size-p-68534.html) can be used to build your own Multimodule.
|
||||
###Board
|
||||
The main program is running on an ATMEGA328p running @16MHz and 3.3V.
|
||||
An [Arduino pro mini 16Mhz/5V](http://www.banggood.com/Wholesale-New-Ver-Pro-Mini-ATMEGA328-328p-5V-16MHz-Arduino-Compatible-Nano-Size-p-68534.html) powered at 3.3V (yes it works) can be used to build your own Multimodule. An Arduino Mini based on Atmega328p can also be used.
|
||||
|
||||
Using stripboard:
|
||||
|
||||

|
||||

|
||||
|
||||
Using a [home made PCB](http://www.rcgroups.com/forums/showpost.php?p=32645328&postcount=1621):
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
or build your own board using SMD components and an associated PCB:
|
||||
or build your own board using [SMD components](http://www.rcgroups.com/forums/showpost.php?p=31064232&postcount=1020) and an [associated PCB v2.3c](https://oshpark.com/shared_projects/MaGYDg0y):
|
||||
|
||||

|
||||

|
||||
 
|
||||
|
||||
If you build this PCB v2.3c and want to enable serial mode for er9x/ersky9x, you have to do [this mod](http://static.rcgroups.net/forums/attachments/4/0/8/5/8/3/a8667856-242-multi.jpg).
|
||||
|
||||
**[New PCB v2.3d!](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/tree/master/PCB%20v2.3d) available**
|
||||
|
||||
Repository includes Kicad files of schematic and pcb. This is a variant of the Multipro V2.3c circuit design. It is basicly the same as the 2.3c board as far as component placement goes. What's changed is the added resistors for the serial protocol and also
|
||||
the addition of solder jumpers on the bottom of the board for the various options to connect the TX, RX, and PPM
|
||||
lines through them.
|
||||
|
||||

|
||||

|
||||
|
||||
[OSH Park link](https://oshpark.com/shared_projects/Ztus1ah8) if you want to order.
|
||||
|
||||
###Schematic
|
||||

|
||||
|
||||
@@ -345,24 +280,43 @@ You can 3D print your box (details [here](http://www.rcgroups.com/forums/showpos
|
||||
##Compilation and programmation
|
||||
|
||||
###Toolchain
|
||||
Arduino 1.6.5
|
||||
Multiprotocol source can be compiled using the Arduino IDE.
|
||||
|
||||
Compilation of the code posted here works. So if it doesn't for you this is a problem with your setup, please double check everything before asking.
|
||||
The currently supported Arduino version is [1.6.7](https://www.arduino.cc/download_handler.php?f=/arduino-1.6.7-windows.exe).
|
||||
|
||||
Multiprotocol.ino header can be modified to compile with/without some protocols, change protocols/sub_protocols associated with dial for PPM input, different channel orders, different channels timing, 8 or 16 channels serial protocol, Telemetry or not, ...
|
||||
Download the [zip file](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/archive/master.zip) of this repository, unzip it in a folder, navigate to the Multiprotocol directory and then click on Multiprotocol.ino. The Arduino environment will appear and the Multiprotocol project will be loaded.
|
||||
|
||||
[_Config.h file](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/blob/master/Multiprotocol/_Config.h) must be modified to select which protocols will be available, change protocols/sub_protocols/settings associated with dial for PPM input, different TX channel orders and timing, Telemetry or not, ...
|
||||
|
||||
Notes:
|
||||
- Make sure to select "Arduino Pro or Pro Mini, ATmega328 (5V,16MHz)" before compiling.
|
||||
- Compilation of the code posted here works. So if it doesn't for you this is a problem with your setup, please double check everything before asking.
|
||||
|
||||
###Upload the code using ISP (In System Programming)
|
||||
It is recommended to use an external programmer like [USBASP](http://www.banggood.com/USBASP-USBISP-3_3-5V-AVR-Downloader-Programmer-With-ATMEGA8-ATMEGA128-p-934425.html) to upload the code in the Atmega328. The programmer should be set to 3.3V or nothing to not supply any over voltage to the multimodule and avoid any damages.
|
||||
|
||||
The dial must be set to 0 before flashing!
|
||||
|
||||
From the Arduino environment, you can use this shortcut to compile and upload to the module: Skecth->Upload Using Programmer (Ctrl+Maj+U)
|
||||
|
||||
To flash the latest provided hex file under [Release](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/releases), you can use a tool like [AVR Burn-O-Mat](http://avr8-burn-o-mat.aaabbb.de/), set the microcontroller to m328p and flash it.
|
||||
|
||||
###Upload the code using FTDI (USB serial to TTL)
|
||||
Use this method only for Arduino Pro Mini boards with bootloader.
|
||||
|
||||
Use an external FTDI adapter like [this one](http://www.banggood.com/FT232RL-FTDI-USB-To-TTL-Serial-Converter-Adapter-Module-For-Arduino-p-917226.html).
|
||||
|
||||
The programmer should be set to 3.3V or nothing to not supply any over voltage to the multimodule and avoid any damages.
|
||||
|
||||
From the Arduino environment, you can use Upload button which will compile and upload to the module: Skecth->Upload (Ctrl+U)
|
||||
|
||||
To upload the latest provided hex file under [Release](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/releases), you can use a tool like [XLoader](http://russemotto.com/xloader/), set the microcontroller to Atmega328 and upload it.
|
||||
|
||||
###Set fuses
|
||||
Use a tool like [AVR Burn-O-Mat](http://avr8-burn-o-mat.aaabbb.de/) to set the fuses of the Atmega328 to:
|
||||
- Low Fuse 0xFF
|
||||
- High Fuse 0xD2
|
||||
- Extended Fuse 0x05
|
||||
- Extended Fuse 0x05 (or 0xFD which is the same)
|
||||
|
||||
This will make sure your ATMEGA328 is well configured and the global TX ID is not erased at each updates.
|
||||
|
||||
@@ -370,18 +324,25 @@ This will make sure your ATMEGA328 is well configured and the global TX ID is no
|
||||
|
||||
###LED status
|
||||
- off: program not running or a protocol selected with the associated module not installed.
|
||||
- flash: invalid protocol selected (excluded from compilation or invalid protocol number)
|
||||
- slow blink: serial has been selected but no valid signal has been seen on the RX pin.
|
||||
- fast blink: bind in progress.
|
||||
- on: normal operation.
|
||||
|
||||
###Protocol selection
|
||||
####Input Mode - PPM
|
||||
- The protocol/mode selection must be done before the power is applied.
|
||||
- Connect 1 to 4 of the selection protocol pins to GND.
|
||||
|
||||
####Input Mode - Serial
|
||||
- Make sure you have done the mods to the v2.3c PCB by adding the 2.2k and 470 ohm resistors as indicated in the [Board section] (https://github.com/pascallanger/DIY-Multiprotocol-TX-Module#board).
|
||||
- Leave all 4 selection pins unconnected.
|
||||
|
||||
###Bind
|
||||
Make sure to follow this procedure: press the bind button, apply power and then release it after 1sec. The LED should be blinking fast indicating a bind status and then fixed on. It's normal that the LED turns off when you press the bind button, this behavior is not controlled by the Atmega328.
|
||||
Make sure to follow this procedure: press the bind button, apply power and then release it after 1sec. The LED should be blinking fast indicating a bind status and then fixed on when the bind period is over. It's normal that the LED turns off when you press the bind button, this behavior is not controlled by the Atmega328.
|
||||
For serial, the preffered method is to bind via the GUI protocol page.
|
||||
|
||||
###Protocol selection
|
||||
For serial, leave all 4 selection pins unconnected.
|
||||
For PPM, connect 1 to 4 of the selection protocol pins to GND.
|
||||
The protocol/mode selection must be done before the power is applied.
|
||||
It migth happen that your module is always binding at power up. If this is the case, there is a big chance that you are using an Arduino Pro Mini with an external status LED. To work around this issue connect a 10K resistor between D13 and 3.3V.
|
||||
|
||||
###Report issues
|
||||
You can report your problem using the [GitHub issue](https://github.com/pascallanger/DIY-Multiprotocol-TX-Module/issues) system or go to the [Main thread on RCGROUPS](http://www.rcgroups.com/forums/showthread.php?t=2165676) to ask your question.
|
||||
|
||||
Reference in New Issue
Block a user