Merge remote-tracking branch 'refs/remotes/pascallanger/master' into benlye-multi-new

This commit is contained in:
Ben Lye 2017-11-30 13:07:38 +00:00
commit 3dd9df558e
12 changed files with 425 additions and 228 deletions

View File

@ -165,6 +165,33 @@ void A7105_Strobe(uint8_t address) {
SPI_Write(address);
A7105_CSN_on;
}
// Fine tune A7105 LO base frequency
// this is required for some A7105 modules and/or RXs with inaccurate crystal oscillator
// arg: offset in +/-kHz
void A7105_AdjustLOBaseFreq(int16_t offset)
{
// LO base frequency = 32e6*(bip+(bfp/(2^16)))
uint8_t bip; // LO base frequency integer part
uint32_t bfp; // LO base frequency fractional part
if(offset < 0)
{
bip = 0x4a; // 2368 MHz
bfp = 0xffff+((offset<<11)/1000)+1;
}
else
{
bip = 0x4b; // 2400 MHz (default)
bfp = (offset<<11)/1000;
}
if(offset == 0)
bfp = 0x0002; // as per datasheet, not sure why recommended, but that's a +1kHz drift only ...
A7105_WriteReg( A7105_11_PLL_III, bip);
A7105_WriteReg( A7105_12_PLL_IV, (bfp >> 8) & 0xff);
A7105_WriteReg( A7105_13_PLL_V, bfp & 0xff);
}
#ifdef HUBSAN_A7105_INO
const uint8_t PROGMEM HUBSAN_A7105_regs[] = {
0xFF, 0x63, 0xFF, 0x0F, 0xFF, 0xFF, 0xFF ,0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x05, 0x04, 0xFF,

View File

@ -13,9 +13,6 @@
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
// 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)
@ -27,9 +24,6 @@
#define CG023_RF_BIND_CHANNEL 0x2D
#define CG023_BIND_COUNT 500 // 4 seconds
#define YD829_PACKET_PERIOD 4100 // Timeout for callback in uSec
#define H8_3D_PACKET_PERIOD 1800 // Timeout for callback in uSec
#define H8_3D_PACKET_SIZE 20
#define H8_3D_RF_NUM_CHANNELS 4
enum CG023_FLAGS {
@ -55,26 +49,6 @@ enum YD829_FLAGS {
YD829_FLAG_STILL = 0x80,
};
enum H8_3D_FLAGS {
// flags going to packet[17]
H8_3D_FLAG_FLIP = 0x01,
H8_3D_FLAG_RATE_MID = 0x02,
H8_3D_FLAG_RATE_HIGH = 0x04,
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 {
// flags going to packet[18]
H8_3D_FLAG_VIDEO = 0x80,
H8_3D_FLAG_PICTURE = 0x40,
H8_3D_FLAG_CALIBRATE1 = 0x20, // H8 3D acc calibration, H20 headless calib
H8_3D_FLAG_CALIBRATE2 = 0x10, // H11D and H20 acc calibration
H8_3D_FLAG_CAM_DN = 0x08,
H8_3D_FLAG_CAM_UP = 0x04,
};
static void __attribute__((unused)) CG023_send_packet(uint8_t bind)
{
// throttle : 0x00 - 0xFF
@ -88,117 +62,59 @@ static void __attribute__((unused)) CG023_send_packet(uint8_t bind)
// aileron : 0x43 - 0x7F - 0xBB
aileron = convert_channel_8b_scale(AILERON, 0x43, 0xBB);
if (bind)
packet[0]= 0xaa;
else
packet[0]= 0x55;
// transmitter id
packet[1] = rx_tx_addr[0];
packet[2] = rx_tx_addr[1];
if(sub_protocol==H8_3D)
// unknown
packet[3] = 0x00;
packet[4] = 0x00;
packet[5] = throttle;
packet[6] = rudder;
packet[7] = elevator;
packet[8] = aileron;
// throttle trim : 0x30 - 0x20 - 0x10
packet[9] = 0x20; // neutral
// neutral trims
packet[10] = 0x20;
packet[11] = 0x40;
packet[12] = 0x40;
if(sub_protocol==CG023)
{
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]; // txid checksum
memset(&packet[9], 0, 10);
if (bind)
{
packet[5] = 0x00;
packet[6] = 0x00;
packet[7] = 0x01;
}
else
{
packet[5] = hopping_frequency_no;
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;
// neutral trims
packet[13] = 0x20;
packet[14] = 0x20;
packet[15] = 0x20;
packet[16] = 0x20;
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_AUX5,H8_3D_FLAG_HEADLESS)
| GET_FLAG(Servo_AUX6,H8_3D_FLAG_RTH); // 180/360 flip mode on H8 3D
packet[18] = GET_FLAG(Servo_AUX3,H8_3D_FLAG_PICTURE)
| GET_FLAG(Servo_AUX4,H8_3D_FLAG_VIDEO)
| GET_FLAG(Servo_AUX7,H8_3D_FLAG_CALIBRATE1)
| GET_FLAG(Servo_AUX8,H8_3D_FLAG_CALIBRATE2);
if(Servo_data[AUX9]<PPM_MIN_COMMAND)
packet[18] |= H8_3D_FLAG_CAM_DN;
if(Servo_data[AUX9]>PPM_MAX_COMMAND)
packet[18] |= H8_3D_FLAG_CAM_UP;
}
uint8_t sum = packet[9];
for (uint8_t i=10; i < H8_3D_PACKET_SIZE-1; i++)
sum += packet[i];
packet[19] = sum; // data checksum
// rate
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
{ // CG023 and YD829
if (bind)
packet[0]= 0xaa;
else
packet[0]= 0x55;
// transmitter id
// unknown
packet[3] = 0x00;
packet[4] = 0x00;
packet[5] = throttle;
packet[6] = rudder;
packet[7] = elevator;
packet[8] = aileron;
// throttle trim : 0x30 - 0x20 - 0x10
packet[9] = 0x20; // neutral
// neutral trims
packet[10] = 0x20;
packet[11] = 0x40;
packet[12] = 0x40;
if(sub_protocol==CG023)
{
// rate
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
| 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;
{// YD829
// rate
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;
// 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, sub_protocol==H8_3D?hopping_frequency[0]:CG023_RF_BIND_CHANNEL);
NRF24L01_WriteReg(NRF24L01_05_RF_CH, CG023_RF_BIND_CHANNEL);
else
{
if(sub_protocol==H8_3D)
{
NRF24L01_WriteReg(NRF24L01_05_RF_CH, hopping_frequency[hopping_frequency_no++]);
hopping_frequency_no %= H8_3D_RF_NUM_CHANNELS;
}
else // CG023 and YD829
NRF24L01_WriteReg(NRF24L01_05_RF_CH, hopping_frequency_no);
}
NRF24L01_WriteReg(NRF24L01_05_RF_CH, hopping_frequency_no);
// clear packet status bits and TX FIFO
NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70);
NRF24L01_FlushTx();
XN297_WritePayload(packet, sub_protocol==H8_3D ? H8_3D_PACKET_SIZE:CG023_PACKET_SIZE);
XN297_WritePayload(packet, CG023_PACKET_SIZE);
NRF24L01_SetPower(); // Set tx_power
}
@ -207,16 +123,14 @@ static void __attribute__((unused)) CG023_init()
{
NRF24L01_Initialize();
NRF24L01_SetTxRxMode(TX_EN);
if(sub_protocol==H8_3D)
XN297_SetTXAddr((uint8_t *)"\xC4\x57\x09\x65\x21", 5);
else // CG023 and YD829
XN297_SetTXAddr((uint8_t *)"\x26\xA8\x67\x35\xCC", 5);
XN297_SetTXAddr((uint8_t *)"\x26\xA8\x67\x35\xCC", 5);
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_04_SETUP_RETR, 0x00); // no retransmits
NRF24L01_SetBitrate(NRF24L01_BR_1M); // 1Mbps
NRF24L01_SetPower();
}
@ -240,25 +154,10 @@ uint16_t CG023_callback()
static void __attribute__((unused)) CG023_initialize_txid()
{
if(sub_protocol==H8_3D)
{
rx_tx_addr[0] = 0xa0 + (rx_tx_addr[0] % 0x10);
rx_tx_addr[1] = 0xb0 + (rx_tx_addr[1] % 0x20);
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]&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
rx_tx_addr[0]= 0x80 | (rx_tx_addr[0] % 0x40);
if( rx_tx_addr[0] == 0xAA) // avoid using same freq for bind and data channel
rx_tx_addr[0] ++;
hopping_frequency_no = rx_tx_addr[0] - 0x7D; // rf channel for data packets
}
rx_tx_addr[0]= 0x80 | (rx_tx_addr[0] % 0x40);
if( rx_tx_addr[0] == 0xAA) // avoid using same freq for bind and data channel
rx_tx_addr[0] ++;
hopping_frequency_no = rx_tx_addr[0] - 0x7D; // rf channel for data packets
}
uint16_t initCG023(void)
@ -269,11 +168,8 @@ uint16_t initCG023(void)
CG023_init();
if(sub_protocol==CG023)
packet_period=CG023_PACKET_PERIOD;
else
if(sub_protocol==YD829)
packet_period=YD829_PACKET_PERIOD;
else
packet_period=H8_3D_PACKET_PERIOD;
else // YD829
packet_period=YD829_PACKET_PERIOD;
return CG023_INITIAL_WAIT+YD829_PACKET_PERIOD;
}

View File

@ -84,7 +84,7 @@ static void __attribute__((unused)) flysky_apply_extension_flags()
packet[13] |= FLAG_V6X6_HLESS1;
packet[14] |= FLAG_V6X6_HLESS2;
}
if(Servo_AUX6) //use option to manipulate these bytes
if(Servo_AUX6)
packet[14] |= FLAG_V6X6_RTH;
if(Servo_AUX7)
packet[14] |= FLAG_V6X6_XCAL;

View File

@ -0,0 +1,258 @@
/*
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 EAchine 3D X4, CG023/CG031, Attop YD-822/YD-829/YD-829C and H8_3D/JJRC H20/H22
// Merged CG023 and H8_3D protocols
// 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(H8_3D_NRF24L01_INO)
#include "iface_nrf24l01.h"
#define H8_3D_PACKET_PERIOD 1800
#define H20H_PACKET_PERIOD 9340
#define H20MINI_PACKET_PERIOD 3100
#define H8_3D_INITIAL_WAIT 500
#define H8_3D_PACKET_SIZE 20
#define H8_3D_RF_NUM_CHANNELS 4
#define H20H_BIND_RF 0x49
#define H8_3D_BIND_COUNT 1000
enum H8_3D_FLAGS {
// flags going to packet[17]
H8_3D_FLAG_FLIP = 0x01,
H8_3D_FLAG_RATE_MID = 0x02,
H8_3D_FLAG_RATE_HIGH = 0x04,
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 {
// flags going to packet[18]
H8_3D_FLAG_VIDEO = 0x80,
H8_3D_FLAG_PICTURE = 0x40,
H8_3D_FLAG_CALIBRATE1 = 0x20, // H8 3D acc calibration, H20,H20H headless calib
H8_3D_FLAG_CALIBRATE2 = 0x10, // H11D, H20, H20H acc calibration
H8_3D_FLAG_CAM_DN = 0x08,
H8_3D_FLAG_CAM_UP = 0x04,
};
static void __attribute__((unused)) H8_3D_send_packet(uint8_t bind)
{
if(sub_protocol==H20H)
packet[0] = 0x14;
else // H8_3D, H20MINI, H30MINI
packet[0] = 0x13;
packet[1] = rx_tx_addr[0];
packet[2] = rx_tx_addr[1];
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]; // txid checksum
memset(&packet[9], 0, 10);
if (bind)
{
packet[5] = 0x00;
packet[6] = 0x00;
packet[7] = 0x01;
}
else
{
packet[5] = hopping_frequency_no;
packet[7] = 0x03;
rudder = convert_channel_8b_scale(RUDDER,0x44,0xBC); // yaw right : 0x80 (neutral) - 0xBC (right)
if(sub_protocol!=H20H)
{ // H8_3D, H20MINI, H30MINI
packet[6] = 0x08;
packet[9] = convert_channel_8b(THROTTLE); // throttle : 0x00 - 0xFF
packet[15] = 0x20; // trims
packet[16] = 0x20; // trims
if (rudder<=0x80)
rudder=0x80-rudder; // yaw left : 0x00 (neutral) - 0x3C (left)
if(rudder==0x01 || rudder==0x81)
rudder=0x00; // Small deadband
}
else
{ //H20H
packet[6] = hopping_frequency_no == 0 ? 8 - packet_count : 16 - packet_count;
packet[9] = convert_channel_8b_scale(THROTTLE, 0x43, 0xBB); // throttle : 0x43 - 0x7F - 0xBB
packet[15]= 0x40; // trims
packet[16]= 0x40; // trims
rudder--; // rudder : 0x43 - 0x7F - 0xBB
if (rudder>=0x7F-1 && rudder<=0x7F+1)
rudder=0x7F; // Small deadband
}
packet[10] = rudder;
packet[11] = convert_channel_8b_scale(ELEVATOR, 0x43, 0xBB); // elevator : 0x43 - 0x7F - 0xBB
packet[12] = convert_channel_8b_scale(AILERON, 0x43, 0xBB); // aileron : 0x43 - 0x7F - 0xBB
// neutral trims
packet[13] = 0x20;
packet[14] = 0x20;
// flags
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_AUX5,H8_3D_FLAG_HEADLESS)
| GET_FLAG(Servo_AUX6,H8_3D_FLAG_RTH); // 180/360 flip mode on H8 3D
packet[18] = GET_FLAG(Servo_AUX3,H8_3D_FLAG_PICTURE)
| GET_FLAG(Servo_AUX4,H8_3D_FLAG_VIDEO)
| GET_FLAG(Servo_AUX7,H8_3D_FLAG_CALIBRATE1)
| GET_FLAG(Servo_AUX8,H8_3D_FLAG_CALIBRATE2);
if(Servo_data[AUX9]<PPM_MIN_COMMAND)
packet[18] |= H8_3D_FLAG_CAM_DN;
if(Servo_data[AUX9]>PPM_MAX_COMMAND)
packet[18] |= H8_3D_FLAG_CAM_UP;
}
uint8_t sum = packet[9];
for (uint8_t i=10; i < H8_3D_PACKET_SIZE-1; i++)
sum += packet[i];
packet[19] = sum; // data checksum
// 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(sub_protocol!=H20H)
{ // H8_3D, H20MINI, H30MINI
NRF24L01_WriteReg(NRF24L01_05_RF_CH, bind ? hopping_frequency[0] : hopping_frequency[hopping_frequency_no++]);
hopping_frequency_no %= H8_3D_RF_NUM_CHANNELS;
}
else
{ //H20H
NRF24L01_WriteReg(NRF24L01_05_RF_CH, bind ? H20H_BIND_RF : hopping_frequency[packet_count>>3]);
if(!bind)
{
packet_count++;
if(packet_count>15)
{
packet_count = 0;
hopping_frequency_no = 0;
}
else
if(packet_count > 7)
hopping_frequency_no = 1;
}
}
// clear packet status bits and TX FIFO
NRF24L01_WriteReg(NRF24L01_07_STATUS, 0x70);
NRF24L01_FlushTx();
XN297_WritePayload(packet, H8_3D_PACKET_SIZE);
NRF24L01_SetPower(); // Set tx_power
}
static void __attribute__((unused)) H8_3D_init()
{
NRF24L01_Initialize();
NRF24L01_SetTxRxMode(TX_EN);
if(sub_protocol==H20H)
XN297_SetTXAddr((uint8_t *)"\xEE\xDD\xCC\xBB\x11", 5);
else // H8_3D, H20MINI, H30MINI
XN297_SetTXAddr((uint8_t *)"\xC4\x57\x09\x65\x21", 5);
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_04_SETUP_RETR, 0x00); // no retransmits
NRF24L01_SetBitrate(NRF24L01_BR_1M); // 1Mbps
NRF24L01_SetPower();
}
uint16_t H8_3D_callback()
{
if(IS_BIND_DONE_on)
H8_3D_send_packet(0);
else
{
if (bind_counter == 0)
{
BIND_DONE;
packet_count=0;
}
else
{
H8_3D_send_packet(1);
bind_counter--;
}
}
return packet_period;
}
// captured from H20H stock transmitters
const uint8_t PROGMEM h20h_tx_rf_map[3][6] = {{/*ID*/0x83, 0x3c, 0x60, 0x00, /*RF*/0x47, 0x3e},
{/*ID*/0x5c, 0x2b, 0x60, 0x00, /*RF*/0x4a, 0x3c},
{/*ID*/0x57, 0x07, 0x00, 0x00, /*RF*/0x41, 0x48} };
// captured from H20 Mini / H30 Mini stock transmitters
const uint8_t PROGMEM h20mini_tx_rf_map[4][8] = {{/*ID*/0xb4, 0xbb, 0x09, 0x00, /*RF*/0x3e, 0x45, 0x47, 0x4a},
{/*ID*/0x94, 0x9d, 0x0b, 0x00, /*RF*/0x3e, 0x43, 0x49, 0x4a},
{/*ID*/0xd1, 0xd0, 0x00, 0x00, /*RF*/0x3f, 0x42, 0x46, 0x4a},
{/*ID*/0xcb, 0xcd, 0x04, 0x00, /*RF*/0x41, 0x43, 0x46, 0x4a}};
static void __attribute__((unused)) H8_3D_initialize_txid()
{
uint8_t id_num=rx_tx_addr[4];
switch(sub_protocol)
{
case H8_3D:
for(uint8_t i=0; i<4; i++)
hopping_frequency[i] = 6 + (0x0f*i) + (((rx_tx_addr[i] >> 4) + (rx_tx_addr[i] & 0x0f)) % 0x0f);
break;
case H20H:
id_num%=3; // 3 different IDs
for(uint8_t i=0; i<4; i++)
{
rx_tx_addr[i] = pgm_read_byte_near(&h20h_tx_rf_map[id_num][i]);
if(i<2)
hopping_frequency[i] = pgm_read_byte_near(&h20h_tx_rf_map[id_num][i+4]);
}
break;
case H20MINI:
case H30MINI:
id_num%=4; // 4 different IDs
for(uint8_t i=0; i<4; i++)
{
rx_tx_addr[i] = pgm_read_byte_near(&h20mini_tx_rf_map[id_num][i]);
hopping_frequency[i] = pgm_read_byte_near(&h20mini_tx_rf_map[id_num][i+4]);
}
break;
}
}
uint16_t initH8_3D(void)
{
BIND_IN_PROGRESS; // autobind protocol
bind_counter = H8_3D_BIND_COUNT;
H8_3D_initialize_txid();
H8_3D_init();
switch(sub_protocol)
{
case H8_3D:
packet_period=H8_3D_PACKET_PERIOD;
break;
case H20H:
packet_period=H20H_PACKET_PERIOD;
break;
case H20MINI:
case H30MINI:
packet_period=H20MINI_PACKET_PERIOD;
break;
}
return H8_3D_INITIAL_WAIT;
}
#endif

View File

@ -10,7 +10,7 @@
10,SymaX,SYMAX,SYMAX5C
11,SLT,SLT,VISTA
12,CX10,GREEN,BLUE,DM007,---,J3015_1,J3015_2,MK33041
13,CG023,CG023,YD829,H8_3D
13,CG023,CG023,YD829
14,Bayang,Bayang,H8S3D,X16_AH,IRDRONE
15,FrskyX,CH_16,CH_8,EU_16,EU_8
16,ESky
@ -33,3 +33,4 @@
33,DM002
34,CABELL,CAB_V3,C_TELEM,-,-,-,-,F_SAFE,UNBIND
35,ESKY150
36,H8_3D,H8_3D,H20H,H20Mini,H30Mini

View File

@ -19,7 +19,7 @@
#define VERSION_MAJOR 1
#define VERSION_MINOR 1
#define VERSION_REVISION 6
#define VERSION_PATCH_LEVEL 33
#define VERSION_PATCH_LEVEL 35
//******************
// Protocols
//******************
@ -61,6 +61,7 @@ enum PROTOCOLS
MODE_DM002 = 33, // =>NRF24L01
MODE_CABELL = 34, // =>NRF24L01
MODE_ESKY150 = 35, // =>NRF24L01
MODE_H8_3D = 36, // =>NRF24L01
};
enum Flysky
@ -133,7 +134,6 @@ enum CG023
{
CG023 = 0,
YD829 = 1,
H8_3D = 2
};
enum BAYANG
{
@ -206,6 +206,13 @@ enum CABELL
CABELL_SET_FAIL_SAFE= 6,
CABELL_UNBIND = 7,
};
enum H8_3D
{
H8_3D = 0,
H20H = 1,
H20MINI = 2,
H30MINI = 3,
};
#define NONE 0
#define P_HIGH 1
@ -535,6 +542,7 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
DM002 33
CABELL 34
ESKY150 35
H8_3D 36
BindBit=> 0x80 1=Bind/0=No
AutoBindBit=> 0x40 1=Yes /0=No
RangeCheck=> 0x20 1=Yes /0=No
@ -586,7 +594,6 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
sub_protocol==CG023
CG023 0
YD829 1
H8_3D 2
sub_protocol==BAYANG
BAYANG 0
H8S3D 1
@ -643,6 +650,11 @@ Serial: 100000 Baud 8e2 _ xxxx xxxx p --
CABELL_V3_TELEMETRY 1
CABELL_SET_FAIL_SAFE 6
CABELL_UNBIND 7
sub_protocol==H8_3D
H8_3D 0
H20H 1
H20MINI 2
H30MINI 3
Power value => 0x80 0=High/1=Low
Stream[3] = option_protocol;

View File

@ -25,8 +25,6 @@
//#define DEBUG_TX
//#define SERIAL_DEBUG // Only for STM32_BOARD compiled with Upload method "Serial"->usart1, "STM32duino bootloader"->USB serial
#define USE_MY_CONFIG
#ifdef __arm__// Let's automatically select the board if arm is selected
#define STM32_BOARD
#endif
@ -40,7 +38,7 @@
#include "_Config.h"
//Personal config file
#if defined USE_MY_CONFIG
#if __has_include("_MyConfig.h")
#include "_MyConfig.h"
#endif
@ -1015,6 +1013,12 @@ static void protocol_init()
remote_callback = ESKY150_callback;
break;
#endif
#if defined(H8_3D_NRF24L01_INO)
case MODE_H8_3D:
next_callback=initH8_3D();
remote_callback = H8_3D_callback;
break;
#endif
#endif
}
}

View File

@ -141,12 +141,13 @@
#define DM002_NRF24L01_INO
#define CABELL_NRF24L01_INO
#define ESKY150_NRF24L01_INO
#define H8_3D_NRF24L01_INO
/**************************/
/*** FAILSAFE SETTINGS ***/
/**************************/
//SHFSS failsafe is by default set to all channels hold their positions except throttle forced to low (980µs)
//You can uncomment the setting below to use channels 9(1) to 16(8) instead
//You can uncomment the setting below to use channels 9(1) to 16(8) as failsafe instead
//#define SFHSS_FAILSAFE_CH9_16
#define AFHDS2A_FAILSAFE
@ -348,7 +349,6 @@ const PPM_Parameters PPM_prot[15]= {
MODE_CG023
CG023
YD829
H8_3D
MODE_BAYANG
BAYANG
H8S3D
@ -414,6 +414,11 @@ const PPM_Parameters PPM_prot[15]= {
CABELL_SET_FAIL_SAFE
CABELL_UNBIND
MODE_ESKY150
MODE_H8_3D
H8_3D
H20H
H20 Mini
H30 Mini
*/
// RX_Num is used for model match. Using RX_Num values different for each receiver will prevent starting a model with the false config loaded...

View File

@ -0,0 +1,27 @@
//#define FORCE_GLOBAL_ID 0x12345678
#if not defined STM32_BOARD
// Atmega328p board list of unwanted protocols to fit in flash
#undef AFHDS2A_A7105_INO
#undef DEVO_CYRF6936_INO
#undef J6PRO_CYRF6936_INO
#undef WK2x01_CYRF6936_INO
#undef FRSKYV_CC2500_INO
#undef FRSKYX_CC2500_INO
#undef KN_NRF24L01_INO
#undef SLT_NRF24L01_INO
#undef FY326_NRF24L01_INO
#undef FQ777_NRF24L01_INO
#undef ASSAN_NRF24L01_INO
#undef HONTAI_NRF24L01_INO
#undef Q303_NRF24L01_INO
#undef GW008_NRF24L01_INO
#undef DM002_NRF24L01_INO
#undef CABELL_NRF24L01_INO
#undef ESKY150_NRF24L01_INO
#undef H8_3D_NRF24L01_INO
#endif

View File

@ -425,22 +425,6 @@ CH5|CH6|CH7|CH8|CH9
---|---|---|---|---
FLIP||PICTURE|VIDEO|HEADLESS
### Sub_protocol H8_3D - *2*
Models: EAchine H8 mini 3D, JJRC H20/H22/H11D
CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13
---|---|---|---|---|---|---|---|---
FLIP|LIGTH|PICTURE|VIDEO|OPT1|OPT2|CAL1|CAL2|GIMBAL
JJRC H20: OPT1=Headless, OPT2=RTH
JJRC H22: OPT1=RTH, OPT2=180/360° flip mode
H8 3D: OPT1=RTH then press a direction to enter headless mode (like stock TX), OPT2=switch 180/360° flip mode
CAL1: H8 3D acc calib, H20 headless calib
CAL2: H11D/H20 acc calib
## CX10 - *12*
Autobind protocol
@ -536,6 +520,34 @@ CH1|CH2|CH3|CH4|CH5
---|---|---|---|---
A|E|T|R|FLIP
## H8_3D - *36*
Autobind protocol
### Sub_protocol H8_3D - *0*
Models: EAchine H8 mini 3D, JJRC H20/H22/H11D
CH5|CH6|CH7|CH8|CH9|CH10|CH11|CH12|CH13
---|---|---|---|---|---|---|---|---
FLIP|LIGTH|PICTURE|VIDEO|OPT1|OPT2|CAL1|CAL2|GIMBAL
JJRC H20: OPT1=Headless, OPT2=RTH
JJRC H22: OPT1=RTH, OPT2=180/360° flip mode
H8 3D: OPT1=RTH then press a direction to enter headless mode (like stock TX), OPT2=switch 180/360° flip mode
CAL1: H8 3D acc calib, H20/H20H headless calib
CAL2: H11D/H20/H20H acc calib
### Sub_protocol H20H - *1*
CH6=Motors on/off
### Sub_protocol H20 Mini - *2*
**Only 3 TX IDs available, change RX_Num value 0-1-2 to cycle through them**
### Sub_protocol H30 Mini - *3*
**Only 4 TX IDs available, change RX_Num value 0-1-2_3 to cycle through them**
## HISKY - *4*
### Sub_protocol Hisky - *0*
CH1|CH2|CH3|CH4|CH5|CH6|CH7|CH8

View File

@ -1,53 +1,8 @@
# Advanced Topics {This page is currently a proof of concept}
Warning: the topics on this page are not for the fainthearted. It is strongly recommended that you have some experience in getting up and runnning with your module before you dive in there. On the other hand what is described on this page are some very useful options that could greatly increase the value and the enjoyment of your Multiprotocol module.
# Serial uploader that works through the transmitter pins
This document describes how you can set up your ATmega-based Mulitprotocol module to allow you to update the firmware by connecting a USB to TTL serial (like a FTDI) adapter to the module's transmitter interface pins. It is great if you exclusively use the Serial interface with your transmitter because the Bind button is used as "bootloader" button. It requires a small custom bootloader to be uploaded and a simple interface cable to be soldered up. See the [Advanced ATmega Serial Uploader](Advanced_ATmega_Serial_Uploader.md) page for more details.
Created and supported by: Mike Blandford
RCGroups page: http://www.rcgroups.com/forums/showpost.php?p=35584619&postcount=4867
# Telemetry in PPM mode
It is possible to access the telemetry stream coming from the receiver through the MULTI-module. This document describes a simple bluetooth module to stream telemetry information to a mobile device like an Android smartphone or tablet. The method may be generalized to feed telemetry to the transmitter if the transmitter has the capabilities to process the information. This is very useful with modules used in the PPM mode with transmitters that do not support telemetry. See the [Advanced Bluetooth Telemetry](Advanced_Bluetooth_Telemetry.md) page for more details.
Created and supported by: Midelic
RCGroups page: None
# Manually setting fuses on ATmega328
This document describes a relatively simple process to set the fuses on ATmega328 using the flexibility of the command line. It does not require installation of AVRdude because it uses the AVRdude that is bundled with the Arduino IDE. See the [Advanced Manually Setting ATmega328 Fuses](Advanced_Manually_Setting_ATmega328_Fuses.md) page for more details.
Created and supported by: hpnuts
## Flashing Multi_STM32 module.
#### Flashing without Tx power
This is another method of Flshing Multi_STM32 which is riskier.This method is for skilled users who understand the task.
The key difference of this method is that the 3.3V FTDI cable must also provide power to the 5V circuitry during the flashing process. To do this, a jumper must be enabled connecting the 3.3V VCC to the 5V line. The risk is to forget 3.3V jumper in, after flashing and when TX restarted.
**If the module is powered through the transmitter and this jumper(3.3V) is enabled, then it will feed 5V throughout the 3.3V circuit and this will fry your RF modules. Do not plug the module into the transmitter before removing this jumper!**
**YOU HAVE BEEN WARNED!!!.**
1. Remove the module from the transmitter bay
1. Set BOOT0 jumper Skip this step if you made your own cable.
1. Set the 3.3V jumper.
1. Connect your 3.3V FTDI cable (USB - TTL serial) to Multiprotocol serial port (RX,TX,GND,5V).
Connect the pins as follows:
* Module RX pin to FTDI TX pin
* Module TX pin to FTDI Rx pin
* Module GND to FTDI GND
* Module 5V to FTDI 3.3V FTDI power supply
1. In arduino IDE under the **Tools** -> **Board:** check that you have selected the **Generic STM32F103C series** board
1. Under **Tools** -> **Upload Method:** select **Serial**.
1. Click "Upload" and the sketch will be uploaded normally.
1. Once the firmware has uploaded:
* Remove the 3.3V jumper!!!!
* Remove the BOOT0 jumper
* Check that you removed the 3.3V jumper
1. Insert the module into the transmitter bay
RCGroups page: No rcgroups page
This document describes a relatively simple process to set the fuses on ATmega328. See the [Advanced Manually Setting ATmega328 Fuses](Advanced_Manually_Setting_ATmega328_Fuses.md) page for more details.

View File

@ -16,7 +16,7 @@ Multiprotocol firmware is compiled using the Arduino IDE. The guide below will w
1. [Preparing to upload the firmware](#preparing-to-upload-the-firmware)
1. [Connect the programmer](#connect-the-programmer)
1. [Select an upload method](#select-an-upload-method)
1. [Burn bootloader](#burn-bootloader)
1. [Burn the bootloader](#burn-the-bootloader)
1. [Uploading the firmware](#uploading-the-firmware)
1. [Flash from TX](#flash-from-tx)
1. [Upload via USB](#upload-via-usb)
@ -88,7 +88,7 @@ There are three methods to upload firmware to an STM32 module:
**Note:** 'Flash from TX' is only available with radios running ersky9x r221e2 or newer
**Flash from TX** is highly recommended if your transmitter supports it, **Upload via USB** is recommended for all others. **Upload via Serial** can be used if your module does not have a working USB port and your trasmitter does not run ersky9x.
**Flash from TX** is highly recommended if your transmitter supports it, **Upload via USB** is recommended for all others. **Upload via Serial** can be used if your module does not have a working USB port and your transmitter does not run ersky9x.
1. Under **Tools -> Upload Method** select an upload method
@ -116,7 +116,7 @@ In order to flash the bootloader the **BOOT0** jumper must be installed.
1. Switch on the transmitter
1. Verify that you have selected the correct upload method under **Tools -> Upload Method**
1. Verify that you have selected **stm32flash (FTDI)** as the programmer under **Tools -> Programmer**
1. Verify that the USB-to-TTL adapter is correctly connected to your module
1. Verify that the USB-to-TTL adapter is correctly connected to your module and you have selected the correct port under **Tools -> Port**
1. Click on **Tools -> Burn Bootloader**
Output will look similar to this:
@ -152,9 +152,9 @@ Starting execution at address 0x08000000... done.
Assuming the process is successful:
1. Power off the transmitter
1. Remove the **BOOT0** jumper
1. Disconnect the USB-to-TTL adapter now
1. Disconnect the USB-to-TTL adapter
## Uploading the firmare
## Uploading the firmware
Follow the instructions which apply to the **Upload method** you previously selected.
* [Flash from TX](#flash-from-tx)
* [Upload via USB](#upload-via-usb)
@ -181,7 +181,7 @@ In order for these devices to be correctly identified in Windows it is necessary
1. Download and install the legacy Windows XP drivers from [here](https://github.com/rogerclarkmelbourne/Arduino_STM32/tree/master/drivers/win/win_xp_legacy)
### Upload the firmware via USB
**Note:** Power to the module will be supplied via the USB cable. If the module is installed in a transmitter, the trasnmitter should be switched off.
**Note:** Power to the module will be supplied via the USB cable. If the module is installed in a transmitter, the transmitter should be switched off.
1. Connect the USB cable to the Multiprotocol module
1. Verify that a Maple device appears in Device Manager (**Maple DFU** for a module with only a bootloader, **Maple Serial** for a module with a bootloader and firmware)