mirror of
https://github.com/pascallanger/DIY-Multiprotocol-TX-Module.git
synced 2026-01-01 11:13:18 +00:00
Devo protocol: number of channels
This commit is contained in:
@@ -17,8 +17,6 @@
|
||||
|
||||
#include "iface_cyrf6936.h"
|
||||
|
||||
#define DEVO_NUM_CHANNELS 8
|
||||
|
||||
//For Debug
|
||||
//#define NO_SCRAMBLE
|
||||
|
||||
@@ -93,7 +91,7 @@ static void __attribute__((unused)) DEVO_add_pkt_suffix()
|
||||
|
||||
static void __attribute__((unused)) DEVO_build_beacon_pkt(uint8_t upper)
|
||||
{
|
||||
packet[0] = (DEVO_NUM_CHANNELS << 4) | 0x07;
|
||||
packet[0] = (num_ch << 4) | 0x07;
|
||||
uint8_t max = 8, offset = 0, enable = 0;
|
||||
if (upper)
|
||||
{
|
||||
@@ -105,7 +103,7 @@ static void __attribute__((unused)) DEVO_build_beacon_pkt(uint8_t upper)
|
||||
{
|
||||
#ifdef FAILSAFE_ENABLE
|
||||
uint16_t failsafe=Failsafe_data[CH_EATR[i+offset]];
|
||||
if(i + offset < DEVO_NUM_CHANNELS && failsafe!=FAILSAFE_CHANNEL_HOLD && IS_FAILSAFE_VALUES_on)
|
||||
if(i + offset < num_ch && failsafe!=FAILSAFE_CHANNEL_HOLD && IS_FAILSAFE_VALUES_on)
|
||||
{
|
||||
enable |= 0x80 >> i;
|
||||
packet[i+1] = ((failsafe*25)>>8)-100;
|
||||
@@ -122,7 +120,7 @@ static void __attribute__((unused)) DEVO_build_beacon_pkt(uint8_t upper)
|
||||
|
||||
static void __attribute__((unused)) DEVO_build_bind_pkt()
|
||||
{
|
||||
packet[0] = (DEVO_NUM_CHANNELS << 4) | 0x0a;
|
||||
packet[0] = (num_ch << 4) | 0x0a;
|
||||
packet[1] = bind_counter & 0xff;
|
||||
packet[2] = (bind_counter >> 8);
|
||||
packet[3] = *hopping_frequency_ptr;
|
||||
@@ -144,7 +142,7 @@ static void __attribute__((unused)) DEVO_build_data_pkt()
|
||||
{
|
||||
static uint8_t ch_idx=0;
|
||||
|
||||
packet[0] = (DEVO_NUM_CHANNELS << 4) | (0x0b + ch_idx);
|
||||
packet[0] = (num_ch << 4) | (0x0b + ch_idx);
|
||||
uint8_t sign = 0x0b;
|
||||
for (uint8_t i = 0; i < 4; i++)
|
||||
{
|
||||
@@ -159,7 +157,7 @@ static void __attribute__((unused)) DEVO_build_data_pkt()
|
||||
}
|
||||
packet[9] = sign;
|
||||
ch_idx++;
|
||||
if (ch_idx * 4 >= DEVO_NUM_CHANNELS)
|
||||
if (ch_idx * 4 >= num_ch)
|
||||
ch_idx = 0;
|
||||
DEVO_add_pkt_suffix();
|
||||
}
|
||||
@@ -258,7 +256,7 @@ static void __attribute__((unused)) DEVO_BuildPacket()
|
||||
}
|
||||
break;
|
||||
case DEVO_BOUND_10:
|
||||
DEVO_build_beacon_pkt(DEVO_NUM_CHANNELS > 8 ? failsafe_pkt : 0);
|
||||
DEVO_build_beacon_pkt(num_ch > 8 ? failsafe_pkt : 0);
|
||||
failsafe_pkt = failsafe_pkt ? 0 : 1;
|
||||
DEVO_scramble_pkt();
|
||||
phase = DEVO_BOUND_1;
|
||||
@@ -301,6 +299,24 @@ uint16_t devo_callback()
|
||||
|
||||
uint16_t DevoInit()
|
||||
{
|
||||
switch(sub_protocol)
|
||||
{
|
||||
case 1:
|
||||
num_ch=10;
|
||||
break;
|
||||
case 2:
|
||||
num_ch=12;
|
||||
break;
|
||||
case 3:
|
||||
num_ch=6;
|
||||
break;
|
||||
case 4:
|
||||
num_ch=7;
|
||||
break;
|
||||
default:
|
||||
num_ch=8;
|
||||
break;
|
||||
}
|
||||
DEVO_cyrf_init();
|
||||
CYRF_GetMfgData(cyrfmfg_id);
|
||||
CYRF_SetTxRxMode(TX_EN);
|
||||
|
||||
Reference in New Issue
Block a user