AFHDS2A protocol addition: UNTESTED

Protocol number: 28
Sub protocols:  PWM_IBUS = 0, PPM_IBUS = 1, PWM_SBUS = 2, PPM_SBUS = 3
Option value =0->50Hz, =1->400Hz, =2->5Hz
Extended channel range supported
Telemetry supported for voltage and RSSI (RX RSSI)
This commit is contained in:
pascallanger
2016-10-20 19:29:46 +02:00
parent a0186ce8e4
commit 999c630c5a
10 changed files with 411 additions and 36 deletions

View File

@@ -31,13 +31,13 @@ void A7105_WriteData(uint8_t len, uint8_t channel)
A7105_Strobe(A7105_TX);
}
void A7105_ReadData()
void A7105_ReadData(uint8_t len)
{
uint8_t i;
A7105_Strobe(0xF0); //A7105_RST_RDPTR
A7105_CSN_off;
SPI_Write(0x45);
for (i=0;i<16;i++)
for (i=0;i<len;i++)
packet[i]=SPI_SDI_Read();
A7105_CSN_on;
}
@@ -149,36 +149,61 @@ void A7105_Strobe(uint8_t address) {
SPI_Write(address);
A7105_CSN_on;
}
#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,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x2B, 0xFF, 0xFF, 0x62, 0x80, 0xFF, 0xFF, 0x0A, 0xFF, 0xFF, 0x07,
0x17, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x47, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF
};
#endif
#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,
0x9e, 0x4b, 0x00, 0x02, 0x16, 0x2b, 0x12, 0x00, 0x62, 0x80, 0x80, 0x00, 0x0a, 0x32, 0xc3, 0x0f,
0x13, 0xc3, 0x00, 0xff, 0x00, 0x00, 0x3b, 0x00, 0x17, 0x47, 0x80, 0x03, 0x01, 0x45, 0x18, 0x00,
0x01, 0x0f, 0xff
};
#endif
#ifdef AFHDS2A_A7105_INO
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
0x01, 0x0f, 0xFF // 30 - 32
};
#endif
#define ID_NORMAL 0x55201041
#define ID_PLUS 0xAA201041
void A7105_Init(uint8_t protocol)
void A7105_Init(void)
{
uint8_t *A7105_Regs;
uint8_t *A7105_Regs=0;
if(protocol==INIT_FLYSKY)
#ifdef HUBSAN_A7105_INO
if(protocol==MODE_HUBSAN)
{
A7105_WriteID(ID_NORMAL);
A7105_Regs=(uint8_t*)HUBSAN_A7105_regs;
}
else
#endif
{
A7105_WriteID(0x5475c52A);//0x2Ac57554
#ifdef FLYSKY_A7105_INO
if(protocol==MODE_FLYSKY)
A7105_Regs=(uint8_t*)FLYSKY_A7105_regs;
else
#endif
{
#ifdef AFHDS2A_A7105_INO
A7105_Regs=(uint8_t*)AFHDS2A_A7105_regs;
#endif
}
}
for (uint8_t i = 0; i < 0x33; i++)
{
A7105_WriteID(0x5475c52A);//0x2Ac57554
A7105_Regs=(uint8_t*)FLYSKY_A7105_regs;
}
else
{
A7105_WriteID(ID_NORMAL);
A7105_Regs=(uint8_t*)HUBSAN_A7105_regs;
}
for (uint8_t i = 0; i < 0x33; i++){
if( pgm_read_byte_near(&A7105_Regs[i]) != 0xFF)
A7105_WriteReg(i, pgm_read_byte_near(&A7105_Regs[i]));
}
@@ -186,16 +211,16 @@ void A7105_Init(uint8_t protocol)
//IF Filter Bank Calibration
A7105_WriteReg(A7105_02_CALC,1);
while(A7105_ReadReg(A7105_02_CALC)); // Wait for calibration to end
while(A7105_ReadReg(A7105_02_CALC)); // Wait for calibration to end
// A7105_ReadReg(A7105_22_IF_CALIB_I);
// A7105_ReadReg(A7105_24_VCO_CURCAL);
if(protocol==INIT_FLYSKY)
if(protocol!=MODE_HUBSAN)
{
//VCO Current Calibration
A7105_WriteReg(A7105_24_VCO_CURCAL,0x13); //Recommended calibration from A7105 Datasheet
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
A7105_WriteReg(A7105_26_VCO_SBCAL_II,0x3b); //Recommended calibration from A7105 Datasheet
}
//VCO Bank Calibrate channel 0
@@ -211,8 +236,8 @@ void A7105_Init(uint8_t protocol)
// A7105_ReadReg(A7105_25_VCO_SBCAL_I);
//Reset VCO Band calibration
if(protocol==INIT_FLYSKY)
A7105_WriteReg(A7105_25_VCO_SBCAL_I,0x08);
if(protocol!=MODE_HUBSAN)
A7105_WriteReg(A7105_25_VCO_SBCAL_I,protocol==MODE_FLYSKY?0x08:0x0A);
A7105_SetTxRxMode(TX_EN);
A7105_SetPower();