2015-12-30 01:41:12 +01:00
|
|
|
/*
|
|
|
|
This project is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Multiprotocol is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Multiprotocol. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2016-09-21 14:28:37 +02:00
|
|
|
/********************/
|
|
|
|
/** A7105 routines **/
|
|
|
|
/********************/
|
2016-10-16 19:51:42 +02:00
|
|
|
#ifdef A7105_INSTALLED
|
2015-12-30 01:41:12 +01:00
|
|
|
#include "iface_a7105.h"
|
|
|
|
|
|
|
|
void A7105_WriteData(uint8_t len, uint8_t channel)
|
|
|
|
{
|
|
|
|
uint8_t i;
|
2016-09-19 23:43:14 +02:00
|
|
|
A7105_CSN_off;
|
2016-08-01 21:57:18 +02:00
|
|
|
SPI_Write(A7105_RST_WRPTR);
|
2016-10-24 23:14:42 +02:00
|
|
|
SPI_Write(A7105_05_FIFO_DATA);
|
2015-12-30 01:41:12 +01:00
|
|
|
for (i = 0; i < len; i++)
|
2016-08-01 21:57:18 +02:00
|
|
|
SPI_Write(packet[i]);
|
2016-09-19 23:43:14 +02:00
|
|
|
A7105_CSN_on;
|
2020-09-30 11:06:30 +02:00
|
|
|
if(!(protocol==PROTO_FLYSKY || protocol==PROTO_KYOSHO))
|
2016-10-24 23:14:42 +02:00
|
|
|
{
|
2016-10-26 13:51:54 +02:00
|
|
|
A7105_Strobe(A7105_STANDBY); //Force standby mode, ie cancel any TX or RX...
|
|
|
|
A7105_SetTxRxMode(TX_EN); //Switch to PA
|
2016-10-24 23:14:42 +02:00
|
|
|
}
|
|
|
|
A7105_WriteReg(A7105_0F_PLL_I, channel);
|
2015-12-30 01:41:12 +01:00
|
|
|
A7105_Strobe(A7105_TX);
|
|
|
|
}
|
|
|
|
|
2016-10-20 19:29:46 +02:00
|
|
|
void A7105_ReadData(uint8_t len)
|
2016-10-16 19:51:42 +02:00
|
|
|
{
|
2015-12-30 01:41:12 +01:00
|
|
|
uint8_t i;
|
2016-10-24 23:14:42 +02:00
|
|
|
A7105_Strobe(A7105_RST_RDPTR);
|
2016-09-19 23:43:14 +02:00
|
|
|
A7105_CSN_off;
|
2016-10-24 23:14:42 +02:00
|
|
|
SPI_Write(0x40 | A7105_05_FIFO_DATA); //bit 6 =1 for reading
|
2016-10-20 19:29:46 +02:00
|
|
|
for (i=0;i<len;i++)
|
2016-10-16 19:51:42 +02:00
|
|
|
packet[i]=SPI_SDI_Read();
|
2016-09-19 23:43:14 +02:00
|
|
|
A7105_CSN_on;
|
2015-12-30 01:41:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void A7105_WriteReg(uint8_t address, uint8_t data) {
|
2016-09-19 23:43:14 +02:00
|
|
|
A7105_CSN_off;
|
2016-08-01 21:57:18 +02:00
|
|
|
SPI_Write(address);
|
2015-12-30 01:41:12 +01:00
|
|
|
NOP();
|
2016-08-01 21:57:18 +02:00
|
|
|
SPI_Write(data);
|
2016-09-19 23:43:14 +02:00
|
|
|
A7105_CSN_on;
|
2015-12-30 01:41:12 +01:00
|
|
|
}
|
|
|
|
|
2016-10-16 19:51:42 +02:00
|
|
|
uint8_t A7105_ReadReg(uint8_t address)
|
|
|
|
{
|
2015-12-30 01:41:12 +01:00
|
|
|
uint8_t result;
|
2016-09-19 23:43:14 +02:00
|
|
|
A7105_CSN_off;
|
2016-10-24 23:14:42 +02:00
|
|
|
SPI_Write(address |=0x40); //bit 6 =1 for reading
|
2016-10-16 19:51:42 +02:00
|
|
|
result = SPI_SDI_Read();
|
2016-09-19 23:43:14 +02:00
|
|
|
A7105_CSN_on;
|
2015-12-30 01:41:12 +01:00
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------
|
|
|
|
void A7105_SetTxRxMode(uint8_t mode)
|
|
|
|
{
|
2016-10-24 23:14:42 +02:00
|
|
|
if(mode == TX_EN)
|
|
|
|
{
|
2015-12-30 01:41:12 +01:00
|
|
|
A7105_WriteReg(A7105_0B_GPIO1_PIN1, 0x33);
|
|
|
|
A7105_WriteReg(A7105_0C_GPIO2_PIN_II, 0x31);
|
|
|
|
}
|
2016-10-24 23:14:42 +02:00
|
|
|
else
|
|
|
|
if (mode == RX_EN)
|
|
|
|
{
|
|
|
|
A7105_WriteReg(A7105_0B_GPIO1_PIN1, 0x31);
|
|
|
|
A7105_WriteReg(A7105_0C_GPIO2_PIN_II, 0x33);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//The A7105 seems to some with a cross-wired power-amp (A7700)
|
|
|
|
//On the XL7105-D03, TX_EN -> RXSW and RX_EN -> TXSW
|
|
|
|
//This means that sleep mode is wired as RX_EN = 1 and TX_EN = 1
|
|
|
|
//If there are other amps in use, we'll need to fix this
|
|
|
|
A7105_WriteReg(A7105_0B_GPIO1_PIN1, 0x33);
|
|
|
|
A7105_WriteReg(A7105_0C_GPIO2_PIN_II, 0x33);
|
|
|
|
}
|
2015-12-30 01:41:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------
|
|
|
|
uint8_t A7105_Reset()
|
|
|
|
{
|
|
|
|
uint8_t result;
|
|
|
|
|
2016-10-24 23:14:42 +02:00
|
|
|
A7105_WriteReg(A7105_00_MODE, 0x00);
|
2016-08-22 18:17:14 +02:00
|
|
|
delayMilliseconds(1);
|
2016-10-24 23:14:42 +02:00
|
|
|
A7105_SetTxRxMode(TXRX_OFF); //Set both GPIO as output and low
|
|
|
|
result=A7105_ReadReg(A7105_10_PLL_II) == 0x9E; //check if is reset.
|
2015-12-30 01:41:12 +01:00
|
|
|
A7105_Strobe(A7105_STANDBY);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-10-24 23:14:42 +02:00
|
|
|
void A7105_WriteID(uint32_t ida)
|
|
|
|
{
|
2016-09-19 23:43:14 +02:00
|
|
|
A7105_CSN_off;
|
2016-10-24 23:14:42 +02:00
|
|
|
SPI_Write(A7105_06_ID_DATA); //ex id=0x5475c52a ;txid3txid2txid1txid0
|
|
|
|
SPI_Write((ida>>24)&0xff); //53
|
|
|
|
SPI_Write((ida>>16)&0xff); //75
|
|
|
|
SPI_Write((ida>>8)&0xff); //c5
|
|
|
|
SPI_Write((ida>>0)&0xff); //2a
|
2016-09-19 23:43:14 +02:00
|
|
|
A7105_CSN_on;
|
2015-12-30 01:41:12 +01:00
|
|
|
}
|
|
|
|
|
Core and all protocols have been updated
Lot of changes in this new master
ChangeLog:
- Core: LED flashing when an invalid protocol has been selected
- Core: Channels 5 to 12 available as switches for all protocols: code
and size optimization
- Documentation (readme.md): fully updated, all protocols/sub
protocols/channels described, models example, many improvements
- All protocols have been updated in some way, here are some highlights:
* Bayang: added picture, video and inverted channels
* CG023->H8_3D: added light and calibration channels
* CX10: added sub protocols Q282, JC3015_1, JC3015_2, MK33041
* ESky: added new protocol - untested
* Hubsan: added compatibility with the new Hubsan Plus protocol
* KN: fully rewritten protocol: added sub protocols WLTOYS and FEILUN,
11 channels support
New version successfully tested on all my models: Flysky RX/F939/V911
protocol Flysky, Frsky RX protocol Frsky, Hubsan X4 protocol Hubsan,
Hisky HCP100/HCP80 protocol Hisky, HK-3000/HK3100 RX protocol
Hisky/HK310, XINXUN X39 protocol YD717/XINXUN, Symax X5C-1 protocol
SymaX/SYMAX, Cheerson CX-10A protocol CX10/BLUE, Eachine 3D-X4 protocol
CG023.
To access new protocols from er9x/ersky9x, you need to build a version
from this github repository https://github.com/pascallanger/mbtx based
on the latest er9x r820 and ersky9x r218.
2016-01-20 10:50:56 +01:00
|
|
|
/*
|
|
|
|
static void A7105_SetPower_Value(int power)
|
2015-12-30 01:41:12 +01:00
|
|
|
{
|
Core and all protocols have been updated
Lot of changes in this new master
ChangeLog:
- Core: LED flashing when an invalid protocol has been selected
- Core: Channels 5 to 12 available as switches for all protocols: code
and size optimization
- Documentation (readme.md): fully updated, all protocols/sub
protocols/channels described, models example, many improvements
- All protocols have been updated in some way, here are some highlights:
* Bayang: added picture, video and inverted channels
* CG023->H8_3D: added light and calibration channels
* CX10: added sub protocols Q282, JC3015_1, JC3015_2, MK33041
* ESky: added new protocol - untested
* Hubsan: added compatibility with the new Hubsan Plus protocol
* KN: fully rewritten protocol: added sub protocols WLTOYS and FEILUN,
11 channels support
New version successfully tested on all my models: Flysky RX/F939/V911
protocol Flysky, Frsky RX protocol Frsky, Hubsan X4 protocol Hubsan,
Hisky HCP100/HCP80 protocol Hisky, HK-3000/HK3100 RX protocol
Hisky/HK310, XINXUN X39 protocol YD717/XINXUN, Symax X5C-1 protocol
SymaX/SYMAX, Cheerson CX-10A protocol CX10/BLUE, Eachine 3D-X4 protocol
CG023.
To access new protocols from er9x/ersky9x, you need to build a version
from this github repository https://github.com/pascallanger/mbtx based
on the latest er9x r820 and ersky9x r218.
2016-01-20 10:50:56 +01:00
|
|
|
//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
|
2015-12-30 01:41:12 +01:00
|
|
|
uint8_t pac, tbg;
|
|
|
|
switch(power) {
|
|
|
|
case 0: pac = 0; tbg = 0; break;
|
|
|
|
case 1: pac = 0; tbg = 1; break;
|
|
|
|
case 2: pac = 0; tbg = 2; break;
|
|
|
|
case 3: pac = 0; tbg = 4; break;
|
|
|
|
case 4: pac = 1; tbg = 5; break;
|
|
|
|
case 5: pac = 2; tbg = 7; break;
|
|
|
|
case 6: pac = 3; tbg = 7; break;
|
|
|
|
case 7: pac = 3; tbg = 7; break;
|
|
|
|
default: pac = 0; tbg = 0; break;
|
|
|
|
};
|
|
|
|
A7105_WriteReg(0x28, (pac << 3) | tbg);
|
|
|
|
}
|
Core and all protocols have been updated
Lot of changes in this new master
ChangeLog:
- Core: LED flashing when an invalid protocol has been selected
- Core: Channels 5 to 12 available as switches for all protocols: code
and size optimization
- Documentation (readme.md): fully updated, all protocols/sub
protocols/channels described, models example, many improvements
- All protocols have been updated in some way, here are some highlights:
* Bayang: added picture, video and inverted channels
* CG023->H8_3D: added light and calibration channels
* CX10: added sub protocols Q282, JC3015_1, JC3015_2, MK33041
* ESky: added new protocol - untested
* Hubsan: added compatibility with the new Hubsan Plus protocol
* KN: fully rewritten protocol: added sub protocols WLTOYS and FEILUN,
11 channels support
New version successfully tested on all my models: Flysky RX/F939/V911
protocol Flysky, Frsky RX protocol Frsky, Hubsan X4 protocol Hubsan,
Hisky HCP100/HCP80 protocol Hisky, HK-3000/HK3100 RX protocol
Hisky/HK310, XINXUN X39 protocol YD717/XINXUN, Symax X5C-1 protocol
SymaX/SYMAX, Cheerson CX-10A protocol CX10/BLUE, Eachine 3D-X4 protocol
CG023.
To access new protocols from er9x/ersky9x, you need to build a version
from this github repository https://github.com/pascallanger/mbtx based
on the latest er9x r820 and ersky9x r218.
2016-01-20 10:50:56 +01:00
|
|
|
*/
|
2015-12-30 01:41:12 +01:00
|
|
|
|
|
|
|
void A7105_SetPower()
|
|
|
|
{
|
|
|
|
uint8_t power=A7105_BIND_POWER;
|
2018-01-03 13:04:58 +01:00
|
|
|
if(IS_BIND_DONE)
|
2017-02-23 11:23:25 +01:00
|
|
|
#ifdef A7105_ENABLE_LOW_POWER
|
|
|
|
power=IS_POWER_FLAG_on?A7105_HIGH_POWER:A7105_LOW_POWER;
|
|
|
|
#else
|
|
|
|
power=A7105_HIGH_POWER;
|
|
|
|
#endif
|
2016-01-02 13:51:16 +01:00
|
|
|
if(IS_RANGE_FLAG_on)
|
|
|
|
power=A7105_RANGE_POWER;
|
2016-08-15 11:52:43 +02:00
|
|
|
if(prev_power != power)
|
|
|
|
{
|
2016-10-24 23:14:42 +02:00
|
|
|
A7105_WriteReg(A7105_28_TX_TEST, power);
|
2016-08-15 11:52:43 +02:00
|
|
|
prev_power=power;
|
|
|
|
}
|
2015-12-30 01:41:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void A7105_Strobe(uint8_t address) {
|
2016-09-19 23:43:14 +02:00
|
|
|
A7105_CSN_off;
|
2016-08-01 21:57:18 +02:00
|
|
|
SPI_Write(address);
|
2016-09-19 23:43:14 +02:00
|
|
|
A7105_CSN_on;
|
2015-12-30 01:41:12 +01:00
|
|
|
}
|
2017-11-30 13:00:10 +01:00
|
|
|
|
|
|
|
// Fine tune A7105 LO base frequency
|
|
|
|
// this is required for some A7105 modules and/or RXs with inaccurate crystal oscillator
|
2018-01-04 14:37:05 +01:00
|
|
|
void A7105_AdjustLOBaseFreq(uint8_t cmd)
|
2017-11-30 13:00:10 +01:00
|
|
|
{
|
2018-01-04 14:37:05 +01:00
|
|
|
static int16_t old_offset=2048;
|
|
|
|
int16_t offset=1024;
|
|
|
|
if(cmd==0)
|
|
|
|
{ // Called at init of the A7105
|
|
|
|
old_offset=2048;
|
|
|
|
switch(protocol)
|
|
|
|
{
|
2018-01-30 12:02:45 +01:00
|
|
|
case PROTO_HUBSAN:
|
2018-01-04 14:37:05 +01:00
|
|
|
#ifdef FORCE_HUBSAN_TUNING
|
|
|
|
offset=(int16_t)FORCE_HUBSAN_TUNING;
|
|
|
|
#endif
|
|
|
|
break;
|
2018-08-28 16:13:28 +02:00
|
|
|
case PROTO_BUGS:
|
2019-08-17 22:37:00 +02:00
|
|
|
#ifdef FORCE_BUGS_TUNING
|
|
|
|
offset=(int16_t)FORCE_BUGS_TUNING;
|
2018-08-28 16:13:28 +02:00
|
|
|
#endif
|
|
|
|
break;
|
2018-01-30 12:02:45 +01:00
|
|
|
case PROTO_FLYSKY:
|
2018-01-04 14:37:05 +01:00
|
|
|
#ifdef FORCE_FLYSKY_TUNING
|
|
|
|
offset=(int16_t)FORCE_FLYSKY_TUNING;
|
|
|
|
#endif
|
|
|
|
break;
|
2020-08-01 19:19:11 +02:00
|
|
|
case PROTO_HEIGHT:
|
|
|
|
#ifdef FORCE_HEIGHT_TUNING
|
|
|
|
offset=(int16_t)FORCE_HEIGHT_TUNING;
|
2019-08-17 22:37:00 +02:00
|
|
|
#endif
|
|
|
|
break;
|
2019-12-20 15:43:44 +01:00
|
|
|
case PROTO_PELIKAN:
|
|
|
|
#ifdef FORCE_PELIKAN_TUNING
|
|
|
|
offset=(int16_t)FORCE_PELIKAN_TUNING;
|
|
|
|
#endif
|
|
|
|
break;
|
2020-07-10 15:25:32 +02:00
|
|
|
case PROTO_KYOSHO:
|
|
|
|
#ifdef FORCE_KYOSHO_TUNING
|
|
|
|
offset=(int16_t)FORCE_KYOSHO_TUNING;
|
|
|
|
#endif
|
|
|
|
break;
|
2018-01-30 12:02:45 +01:00
|
|
|
case PROTO_AFHDS2A:
|
2019-10-01 20:44:26 +02:00
|
|
|
case PROTO_AFHDS2A_RX:
|
2018-01-04 14:37:05 +01:00
|
|
|
#ifdef FORCE_AFHDS2A_TUNING
|
|
|
|
offset=(int16_t)FORCE_AFHDS2A_TUNING;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(offset==1024) // Use channel 15 as an input
|
2018-01-08 19:37:14 +01:00
|
|
|
offset=convert_channel_16b_nolimit(CH15,-300,300);
|
2018-01-04 14:37:05 +01:00
|
|
|
|
|
|
|
if(old_offset==offset) // offset is the same as before...
|
|
|
|
return;
|
|
|
|
old_offset=offset;
|
|
|
|
|
2017-11-30 13:00:10 +01:00
|
|
|
// LO base frequency = 32e6*(bip+(bfp/(2^16)))
|
2018-01-04 14:37:05 +01:00
|
|
|
uint8_t bip; // LO base frequency integer part
|
|
|
|
uint16_t bfp; // LO base frequency fractional part
|
|
|
|
offset++; // as per datasheet, not sure why recommended, but that's a +1kHz drift only ...
|
|
|
|
offset<<=1;
|
2017-11-30 13:00:10 +01:00
|
|
|
if(offset < 0)
|
|
|
|
{
|
2020-01-12 13:00:30 +01:00
|
|
|
bip = 0x4a; // 2368 MHz
|
2018-01-04 14:37:05 +01:00
|
|
|
bfp = 0xffff + offset;
|
2017-11-30 13:00:10 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-01-12 13:00:30 +01:00
|
|
|
bip = 0x4b; // 2400 MHz (default)
|
2018-01-04 14:37:05 +01:00
|
|
|
bfp = offset;
|
2017-11-30 13:00:10 +01:00
|
|
|
}
|
|
|
|
A7105_WriteReg( A7105_11_PLL_III, bip);
|
|
|
|
A7105_WriteReg( A7105_12_PLL_IV, (bfp >> 8) & 0xff);
|
|
|
|
A7105_WriteReg( A7105_13_PLL_V, bfp & 0xff);
|
2018-01-04 14:37:05 +01:00
|
|
|
//debugln("Channel: %d, offset: %d, bip: %2x, bfp: %4x", Channel_data[14], offset, bip, bfp);
|
2017-11-30 13:00:10 +01:00
|
|
|
}
|
|
|
|
|
2018-08-28 16:13:28 +02:00
|
|
|
static void __attribute__((unused)) A7105_SetVCOBand(uint8_t vb1, uint8_t vb2)
|
|
|
|
{ // Set calibration band value to best match
|
|
|
|
uint8_t diff1, diff2;
|
|
|
|
|
|
|
|
if (vb1 >= 4)
|
|
|
|
diff1 = vb1 - 4;
|
|
|
|
else
|
|
|
|
diff1 = 4 - vb1;
|
|
|
|
|
|
|
|
if (vb2 >= 4)
|
|
|
|
diff2 = vb2 - 4;
|
|
|
|
else
|
|
|
|
diff2 = 4 - vb2;
|
|
|
|
|
|
|
|
if (diff1 == diff2 || diff1 > diff2)
|
|
|
|
A7105_WriteReg(A7105_25_VCO_SBCAL_I, vb1 | 0x08);
|
|
|
|
else
|
|
|
|
A7105_WriteReg(A7105_25_VCO_SBCAL_I, vb2 | 0x08);
|
|
|
|
}
|
2017-11-30 13:00:10 +01:00
|
|
|
|
2019-10-01 20:44:26 +02:00
|
|
|
#if defined(AFHDS2A_A7105_INO) || defined(AFHDS2A_RX_A7105_INO)
|
2016-10-20 19:29:46 +02:00
|
|
|
const uint8_t PROGMEM AFHDS2A_A7105_regs[] = {
|
|
|
|
0xFF, 0x42 | (1<<5), 0x00, 0x25, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3c, 0x05, 0x00, 0x50, // 00 - 0f
|
|
|
|
0x9e, 0x4b, 0x00, 0x02, 0x16, 0x2b, 0x12, 0x4f, 0x62, 0x80, 0xFF, 0xFF, 0x2a, 0x32, 0xc3, 0x1f, // 10 - 1f
|
|
|
|
0x1e, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x3b, 0x00, 0x17, 0x47, 0x80, 0x03, 0x01, 0x45, 0x18, 0x00, // 20 - 2f
|
2016-10-20 22:55:50 +02:00
|
|
|
0x01, 0x0f // 30 - 31
|
2016-10-20 19:29:46 +02:00
|
|
|
};
|
|
|
|
#endif
|
2018-08-28 16:13:28 +02:00
|
|
|
#ifdef BUGS_A7105_INO
|
|
|
|
const uint8_t PROGMEM BUGS_A7105_regs[] = {
|
|
|
|
0xFF, 0x42, 0x00, 0x15, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x05, 0x01, 0x50, // 00 - 0f
|
|
|
|
0x9e, 0x4b, 0x00, 0x02, 0x16, 0x2b, 0x12, 0x40, 0x62, 0x80, 0x80, 0x00, 0x0a, 0x32, 0xc3, 0x0f, // 10 - 1f
|
|
|
|
0x16, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x3b, 0x00, 0x0b, 0x47, 0x80, 0x03, 0x01, 0x45, 0x18, 0x00, // 20 - 2f
|
|
|
|
0x01, 0x0f // 30 - 31
|
|
|
|
};
|
|
|
|
#endif
|
2019-08-17 22:37:00 +02:00
|
|
|
#ifdef FLYSKY_A7105_INO
|
|
|
|
const uint8_t PROGMEM FLYSKY_A7105_regs[] = {
|
|
|
|
0xff, 0x42, 0x00, 0x14, 0x00, 0xff, 0xff ,0x00, 0x00, 0x00, 0x00, 0x01, 0x21, 0x05, 0x00, 0x50, // 00 - 0f
|
|
|
|
0x9e, 0x4b, 0x00, 0x02, 0x16, 0x2b, 0x12, 0x00, 0x62, 0x80, 0x80, 0x00, 0x0a, 0x32, 0xc3, 0x0f, // 10 - 1f
|
|
|
|
0x13, 0xc3, 0x00, 0xff, 0x00, 0x00, 0x3b, 0x00, 0x17, 0x47, 0x80, 0x03, 0x01, 0x45, 0x18, 0x00, // 20 - 2f
|
|
|
|
0x01, 0x0f // 30 - 31
|
|
|
|
};
|
|
|
|
#endif
|
2020-08-01 19:19:11 +02:00
|
|
|
#ifdef HEIGHT_A7105_INO
|
|
|
|
const uint8_t PROGMEM HEIGHT_A7105_regs[] = {
|
2019-08-17 22:37:00 +02:00
|
|
|
0xff, 0x42, 0x00, 0x07, 0x00, 0xff, 0xff ,0x00, 0x00, 0x00, 0x00, 0x01, 0x21, 0x05, 0x01, 0x50, // 00 - 0f
|
|
|
|
0x9e, 0x4b, 0x00, 0x02, 0x16, 0x2b, 0x12, 0x00, 0x62, 0x80, 0x80, 0x00, 0x0a, 0x32, 0xc3, 0x1f, // 10 - 1f
|
|
|
|
0x12, 0x00, 0x00, 0xff, 0x00, 0x00, 0x3a, 0x00, 0x3f, 0x47, 0x80, 0x03, 0x01, 0x45, 0x18, 0x00, // 20 - 2f
|
|
|
|
0x01, 0x0f // 30 - 31
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
#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, // 00 - 0f
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x2B, 0xFF, 0xFF, 0x62, 0x80, 0xFF, 0xFF, 0x0A, 0xFF, 0xFF, 0x07, // 10 - 1f
|
|
|
|
0x17, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 20 - 2f
|
|
|
|
0xFF, 0xFF // 30 - 31
|
|
|
|
};
|
|
|
|
#endif
|
2019-12-19 22:39:01 +01:00
|
|
|
#ifdef PELIKAN_A7105_INO
|
|
|
|
const uint8_t PROGMEM PELIKAN_A7105_regs[] = {
|
2020-01-12 13:00:30 +01:00
|
|
|
0xff, 0x42, 0x00, 0x0F, 0x00, 0xff, 0xff ,0x00, 0x00, 0x00, 0x00, 0x01, 0x21, 0x05, 0x01, 0x50, // 00 - 0f
|
|
|
|
0x9e, 0x4b, 0x00, 0x02, 0x16, 0x2b, 0x12, 0x00, 0x62, 0x80, 0x80, 0x00, 0x0a, 0x32, 0xc3, 0x07, // 10 - 1f
|
2019-12-20 15:43:44 +01:00
|
|
|
0x16, 0x00, 0x00, 0xff, 0x00, 0x00, 0x3b, 0x00, 0x1f, 0x47, 0x80, 0x03, 0x01, 0x45, 0x18, 0x00, // 20 - 2f
|
2019-12-19 22:39:01 +01:00
|
|
|
0x01, 0x0f // 30 - 31
|
|
|
|
};
|
|
|
|
#endif
|
2020-07-10 15:25:32 +02:00
|
|
|
#ifdef KYOSHO_A7105_INO
|
|
|
|
const uint8_t PROGMEM KYOSHO_A7105_regs[] = {
|
|
|
|
0xff, 0x42, 0xff, 0x25, 0x00, 0xff, 0xff ,0x00, 0x00, 0x00, 0x00, 0x01, 0x21, 0x05, 0x00, 0x50, // 00 - 0f
|
|
|
|
0x9e, 0x4b, 0x00, 0x02, 0x16, 0x2b, 0x12, 0x40, 0x62, 0x80, 0x80, 0x00, 0x0a, 0x32, 0x03, 0x1f, // 10 - 1f
|
|
|
|
0x1e, 0x00, 0x00, 0xff, 0x00, 0x00, 0x23, 0x70, 0x1F, 0x47, 0x80, 0x57, 0x01, 0x45, 0x19, 0x00, // 20 - 2f
|
|
|
|
0x01, 0x0f // 30 - 31
|
|
|
|
};
|
2020-09-29 11:24:55 +02:00
|
|
|
const uint8_t PROGMEM KYOSHO_HYPE_A7105_regs[] = {
|
2020-09-29 17:06:01 +02:00
|
|
|
0xff, 0x42, 0x00, 0x10, 0xC0, 0xff, 0xff ,0x00, 0x00, 0x00, 0x00, 0x01, 0x09, 0x05, 0x01, 0x04, // 00 - 0f
|
2020-09-29 11:24:55 +02:00
|
|
|
0x9e, 0x4b, 0x00, 0x02, 0x16, 0x2b, 0x12, 0x00, 0x62, 0x80, 0x80, 0x00, 0x0a, 0x96, 0xc2, 0x1f, // 10 - 1f
|
|
|
|
0x12, 0x00, 0x00, 0xff, 0x00, 0x00, 0x3a, 0x00, 0x17, 0x47, 0x80, 0x03, 0x01, 0x45, 0x18, 0x00, // 20 - 2f
|
|
|
|
0x01, 0x0f // 30 - 31
|
|
|
|
};
|
2020-07-10 15:25:32 +02:00
|
|
|
#endif
|
2016-10-20 19:29:46 +02:00
|
|
|
|
Core and all protocols have been updated
Lot of changes in this new master
ChangeLog:
- Core: LED flashing when an invalid protocol has been selected
- Core: Channels 5 to 12 available as switches for all protocols: code
and size optimization
- Documentation (readme.md): fully updated, all protocols/sub
protocols/channels described, models example, many improvements
- All protocols have been updated in some way, here are some highlights:
* Bayang: added picture, video and inverted channels
* CG023->H8_3D: added light and calibration channels
* CX10: added sub protocols Q282, JC3015_1, JC3015_2, MK33041
* ESky: added new protocol - untested
* Hubsan: added compatibility with the new Hubsan Plus protocol
* KN: fully rewritten protocol: added sub protocols WLTOYS and FEILUN,
11 channels support
New version successfully tested on all my models: Flysky RX/F939/V911
protocol Flysky, Frsky RX protocol Frsky, Hubsan X4 protocol Hubsan,
Hisky HCP100/HCP80 protocol Hisky, HK-3000/HK3100 RX protocol
Hisky/HK310, XINXUN X39 protocol YD717/XINXUN, Symax X5C-1 protocol
SymaX/SYMAX, Cheerson CX-10A protocol CX10/BLUE, Eachine 3D-X4 protocol
CG023.
To access new protocols from er9x/ersky9x, you need to build a version
from this github repository https://github.com/pascallanger/mbtx based
on the latest er9x r820 and ersky9x r218.
2016-01-20 10:50:56 +01:00
|
|
|
#define ID_NORMAL 0x55201041
|
|
|
|
#define ID_PLUS 0xAA201041
|
2016-10-20 19:29:46 +02:00
|
|
|
void A7105_Init(void)
|
2015-12-30 01:41:12 +01:00
|
|
|
{
|
2016-10-20 19:29:46 +02:00
|
|
|
uint8_t *A7105_Regs=0;
|
2018-08-28 16:13:28 +02:00
|
|
|
uint8_t vco_calibration0, vco_calibration1;
|
2015-12-30 01:41:12 +01:00
|
|
|
|
2020-08-01 19:19:11 +02:00
|
|
|
#ifdef HEIGHT_A7105_INO
|
|
|
|
if(protocol==PROTO_HEIGHT)
|
2019-08-17 22:37:00 +02:00
|
|
|
{
|
2020-08-01 19:19:11 +02:00
|
|
|
A7105_Regs=(uint8_t*)HEIGHT_A7105_regs;
|
2019-08-17 22:37:00 +02:00
|
|
|
A7105_WriteID(0x25A53C45);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2019-12-19 22:39:01 +01:00
|
|
|
#ifdef PELIKAN_A7105_INO
|
|
|
|
if(protocol==PROTO_PELIKAN)
|
|
|
|
{
|
|
|
|
A7105_Regs=(uint8_t*)PELIKAN_A7105_regs;
|
|
|
|
A7105_WriteID(0x06230623);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2018-08-28 16:13:28 +02:00
|
|
|
#ifdef BUGS_A7105_INO
|
|
|
|
if(protocol==PROTO_BUGS)
|
|
|
|
A7105_Regs=(uint8_t*)BUGS_A7105_regs;
|
|
|
|
else
|
|
|
|
#endif
|
2016-10-20 19:29:46 +02:00
|
|
|
#ifdef HUBSAN_A7105_INO
|
2018-01-30 12:02:45 +01:00
|
|
|
if(protocol==PROTO_HUBSAN)
|
2016-10-20 19:29:46 +02:00
|
|
|
{
|
|
|
|
A7105_WriteID(ID_NORMAL);
|
|
|
|
A7105_Regs=(uint8_t*)HUBSAN_A7105_regs;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
A7105_WriteID(0x5475c52A);//0x2Ac57554
|
|
|
|
#ifdef FLYSKY_A7105_INO
|
2018-01-30 12:02:45 +01:00
|
|
|
if(protocol==PROTO_FLYSKY)
|
2016-10-20 19:29:46 +02:00
|
|
|
A7105_Regs=(uint8_t*)FLYSKY_A7105_regs;
|
|
|
|
#endif
|
2020-07-10 15:25:32 +02:00
|
|
|
#if defined(AFHDS2A_A7105_INO) || defined(AFHDS2A_RX_A7105_INO)
|
|
|
|
if(protocol==PROTO_AFHDS2A)
|
|
|
|
A7105_Regs=(uint8_t*)AFHDS2A_A7105_regs;
|
|
|
|
#endif
|
|
|
|
#ifdef KYOSHO_A7105_INO
|
2020-10-03 10:52:11 +02:00
|
|
|
if(protocol==PROTO_KYOSHO)
|
|
|
|
{
|
|
|
|
if(sub_protocol==KYOSHO_FHSS)
|
|
|
|
A7105_Regs=(uint8_t*)KYOSHO_A7105_regs;
|
|
|
|
else
|
|
|
|
A7105_Regs=(uint8_t*)KYOSHO_HYPE_A7105_regs;
|
|
|
|
}
|
2020-07-10 15:25:32 +02:00
|
|
|
#endif
|
2016-10-20 19:29:46 +02:00
|
|
|
}
|
|
|
|
|
2016-10-20 22:55:50 +02:00
|
|
|
for (uint8_t i = 0; i < 0x32; i++)
|
2015-12-30 01:41:12 +01:00
|
|
|
{
|
2016-10-20 22:55:50 +02:00
|
|
|
uint8_t val=pgm_read_byte_near(&A7105_Regs[i]);
|
2016-11-29 22:30:03 +01:00
|
|
|
#ifdef FLYSKY_A7105_INO
|
2018-01-30 12:02:45 +01:00
|
|
|
if(protocol==PROTO_FLYSKY && sub_protocol==CX20)
|
2016-11-29 22:30:03 +01:00
|
|
|
{
|
2016-11-30 07:55:07 +01:00
|
|
|
if(i==0x0E) val=0x01;
|
|
|
|
if(i==0x1F) val=0x1F;
|
|
|
|
if(i==0x20) val=0x1E;
|
2016-11-29 22:30:03 +01:00
|
|
|
}
|
|
|
|
#endif
|
2020-08-01 19:19:11 +02:00
|
|
|
#ifdef HEIGHT_A7105_INO
|
|
|
|
if(protocol==PROTO_HEIGHT && sub_protocol==HEIGHT_8CH)
|
2020-07-31 10:42:10 +02:00
|
|
|
if(i==0x03) val=0x0A;
|
|
|
|
#endif
|
2016-10-20 22:55:50 +02:00
|
|
|
if( val != 0xFF)
|
|
|
|
A7105_WriteReg(i, val);
|
2015-12-30 01:41:12 +01:00
|
|
|
}
|
|
|
|
A7105_Strobe(A7105_STANDBY);
|
|
|
|
|
2020-09-29 11:24:55 +02:00
|
|
|
if(protocol==PROTO_KYOSHO && sub_protocol==KYOSHO_FHSS)
|
2020-07-10 15:25:32 +02:00
|
|
|
{//strange calibration...
|
|
|
|
//IF Filter Bank Calibration
|
|
|
|
A7105_WriteReg(A7105_02_CALC,0x0F);
|
|
|
|
while(A7105_ReadReg(A7105_02_CALC)); // Wait for calibration to end
|
|
|
|
// A7105_ReadReg(A7105_22_IF_CALIB_I);
|
|
|
|
// A7105_ReadReg(A7105_24_VCO_CURCAL);
|
|
|
|
// A7105_ReadReg(25_VCO_SBCAL_I);
|
|
|
|
// A7105_ReadReg(1A_RX_GAIN_II);
|
|
|
|
// A7105_ReadReg(1B_RX_GAIN_III);
|
2015-12-30 01:41:12 +01:00
|
|
|
}
|
2018-08-28 16:13:28 +02:00
|
|
|
else
|
2020-07-10 15:25:32 +02:00
|
|
|
{
|
|
|
|
//IF Filter Bank Calibration
|
|
|
|
A7105_WriteReg(A7105_02_CALC,1);
|
|
|
|
while(A7105_ReadReg(A7105_02_CALC)); // Wait for calibration to end
|
|
|
|
// A7105_ReadReg(A7105_22_IF_CALIB_I);
|
|
|
|
// A7105_ReadReg(A7105_24_VCO_CURCAL);
|
|
|
|
|
2018-08-28 16:13:28 +02:00
|
|
|
if(protocol!=PROTO_HUBSAN)
|
2019-08-17 22:37:00 +02:00
|
|
|
{
|
2020-07-10 15:25:32 +02:00
|
|
|
//VCO Current Calibration
|
|
|
|
A7105_WriteReg(A7105_24_VCO_CURCAL,0x13); //Recommended calibration from A7105 Datasheet
|
|
|
|
//VCO Bank Calibration
|
|
|
|
A7105_WriteReg(A7105_26_VCO_SBCAL_II,0x3b); //Recommended calibration from A7105 Datasheet
|
|
|
|
}
|
|
|
|
|
|
|
|
//VCO Bank Calibrate channel 0
|
|
|
|
A7105_WriteReg(A7105_0F_CHANNEL, 0);
|
|
|
|
A7105_WriteReg(A7105_02_CALC,2);
|
|
|
|
while(A7105_ReadReg(A7105_02_CALC)); // Wait for calibration to end
|
|
|
|
vco_calibration0 = A7105_ReadReg(A7105_25_VCO_SBCAL_I);
|
|
|
|
|
|
|
|
//VCO Bank Calibrate channel A0
|
|
|
|
A7105_WriteReg(A7105_0F_CHANNEL, 0xa0);
|
|
|
|
A7105_WriteReg(A7105_02_CALC, 2);
|
|
|
|
while(A7105_ReadReg(A7105_02_CALC)); // Wait for calibration to end
|
|
|
|
vco_calibration1 = A7105_ReadReg(A7105_25_VCO_SBCAL_I);
|
|
|
|
|
|
|
|
if(protocol==PROTO_BUGS)
|
|
|
|
A7105_SetVCOBand(vco_calibration0 & 0x07, vco_calibration1 & 0x07); // Set calibration band value to best match
|
|
|
|
else
|
|
|
|
if(protocol!=PROTO_HUBSAN)
|
2019-08-17 22:37:00 +02:00
|
|
|
{
|
2020-07-10 15:25:32 +02:00
|
|
|
switch(protocol)
|
|
|
|
{
|
|
|
|
case PROTO_FLYSKY:
|
|
|
|
vco_calibration1=0x08;
|
|
|
|
break;
|
2020-08-01 19:19:11 +02:00
|
|
|
case PROTO_HEIGHT:
|
2020-07-10 15:25:32 +02:00
|
|
|
vco_calibration1=0x02;
|
|
|
|
break;
|
|
|
|
case PROTO_PELIKAN:
|
2020-09-29 11:24:55 +02:00
|
|
|
case PROTO_KYOSHO: //sub_protocol Hype
|
2020-07-10 15:25:32 +02:00
|
|
|
vco_calibration1=0x0C;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
vco_calibration1=0x0A;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
A7105_WriteReg(A7105_25_VCO_SBCAL_I,vco_calibration1); //Reset VCO Band calibration
|
2019-08-17 22:37:00 +02:00
|
|
|
}
|
2020-07-10 15:25:32 +02:00
|
|
|
}
|
2015-12-30 01:41:12 +01:00
|
|
|
A7105_SetTxRxMode(TX_EN);
|
|
|
|
A7105_SetPower();
|
|
|
|
|
2019-12-20 15:43:44 +01:00
|
|
|
#ifdef USE_A7105_CH15_TUNING
|
|
|
|
A7105_AdjustLOBaseFreq(0);
|
|
|
|
#endif
|
2017-11-30 20:12:23 +01:00
|
|
|
|
2015-12-30 01:41:12 +01:00
|
|
|
A7105_Strobe(A7105_STANDBY);
|
|
|
|
}
|
2016-10-16 19:51:42 +02:00
|
|
|
#endif
|