Skip to content

Commit

Permalink
Add Fayee FY805 format
Browse files Browse the repository at this point in the history
  • Loading branch information
goebish committed Mar 20, 2017
1 parent 17f6a6f commit b2f0b4b
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/protocol/mt99xx_nrf24l01.c
Expand Up @@ -53,6 +53,7 @@

#define PACKET_PERIOD_MT 2625 // Timeout for callback in uSec
#define PACKET_PERIOD_YZ 3125 // Yi Zhan i6S
#define PACKET_PERIOD_FY 2460 // Fayee FY805
#define INITIAL_WAIT 500
#define PACKET_SIZE 9

Expand Down Expand Up @@ -112,14 +113,19 @@ enum{
FLAG_LS_FLIP = 0x80,
};

enum{
// flags going to packet[7] (FY805)
FLAG_FY805_HEADLESS= 0x10,
};

enum {
MT99XX_INIT = 0,
MT99XX_BIND,
MT99XX_DATA
};

static const char * const mt99xx_opts[] = {
_tr_noop("Format"), "MT9916", "H7", "YZ i6S", "LS114", NULL,
_tr_noop("Format"), "MT9916", "H7", "YZ i6S", "LS114", "FY805", NULL,
NULL
};

Expand All @@ -134,6 +140,7 @@ enum {
PROTOOPTS_FORMAT_H7,
PROTOOPTS_FORMAT_YZ,
PROTOOPTS_FORMAT_LS,
PROTOOPTS_FORMAT_FY805,
};

static u8 packet[PACKET_SIZE];
Expand Down Expand Up @@ -208,6 +215,13 @@ static void mt99xx_send_packet()
if(ls_counter >= sizeof(ls_mys_byte))
ls_counter = 0;
}
else if (Model.proto_opts[PROTOOPTS_FORMAT] == PROTOOPTS_FORMAT_FY805) {
packet[6] = 0x20;
packet[7] = 0x01 // high rate ?
| GET_FLAG( CHANNEL_FLIP, FLAG_MT_FLIP)
| GET_FLAG( CHANNEL_HEADLESS, FLAG_FY805_HEADLESS);
checksum_offset = 0;
}

packet[8] = calcChecksum();
break;
Expand Down Expand Up @@ -240,6 +254,9 @@ static void mt99xx_send_packet()
if (Model.proto_opts[PROTOOPTS_FORMAT] == PROTOOPTS_FORMAT_LS) {
NRF24L01_WriteReg(NRF24L01_05_RF_CH, 0x2d); // LS always transmits on the same channel
}
else if (Model.proto_opts[PROTOOPTS_FORMAT] == PROTOOPTS_FORMAT_FY805) {
NRF24L01_WriteReg(NRF24L01_05_RF_CH, 0x4B); // FY805 always transmits on the same channel
}
else {
NRF24L01_WriteReg(NRF24L01_05_RF_CH, data_freq[rf_chan] + channel_offset);
}
Expand Down Expand Up @@ -340,6 +357,10 @@ static void initialize_txid()
txid[0] = 0x53; // test (SB id)
txid[1] = 0x00;
}
else if(Model.proto_opts[PROTOOPTS_FORMAT] == PROTOOPTS_FORMAT_FY805) {
txid[0] = 0x81;
txid[1] = 0x0f;
}
checksum_offset = (Model.proto_opts[PROTOOPTS_FORMAT] == PROTOOPTS_FORMAT_LS) ? 0xcc : 0;
checksum_offset += txid[0];
checksum_offset += txid[1];
Expand Down Expand Up @@ -376,6 +397,9 @@ static u16 mt99xx_callback()
if(Model.proto_opts[PROTOOPTS_FORMAT] == PROTOOPTS_FORMAT_LS) {
NRF24L01_WriteReg(NRF24L01_05_RF_CH, 0x2d);
}
else if(Model.proto_opts[PROTOOPTS_FORMAT] == PROTOOPTS_FORMAT_FY805) {
NRF24L01_WriteReg(NRF24L01_05_RF_CH, 0x4b);
}
else {
NRF24L01_WriteReg(NRF24L01_05_RF_CH, data_freq[rf_chan]);
}
Expand Down Expand Up @@ -429,6 +453,14 @@ static void initialize()
packet[1] = 0x14;
packet[2] = 0x05;
packet[3] = 0x11;
break;
case PROTOOPTS_FORMAT_FY805:
packet_period = PACKET_PERIOD_FY;
packet[0] = 0x20;
packet[1] = 0x15;
packet[2] = 0x12;
packet[3] = 0x17;
break;
}

if(Model.proto_opts[PROTOOPTS_FORMAT] == PROTOOPTS_FORMAT_LS) {
Expand Down

0 comments on commit b2f0b4b

Please sign in to comment.