Reorganize module type/subType/rfProtocol
This commit is contained in:
committed by
Raphael Coeffic
parent
049f337665
commit
86d1ca4364
@@ -41,37 +41,37 @@ extern uint32_t NV14internalModuleFwVersion;
|
||||
|
||||
#if defined (MULTIMODULE)
|
||||
#define IS_D16_MULTI(module) \
|
||||
(((g_model.moduleData[module].getMultiProtocol() == \
|
||||
(((g_model.moduleData[module].multi.rfProtocol == \
|
||||
MODULE_SUBTYPE_MULTI_FRSKY) && \
|
||||
(g_model.moduleData[module].subType == MM_RF_FRSKY_SUBTYPE_D16 || \
|
||||
g_model.moduleData[module].subType == MM_RF_FRSKY_SUBTYPE_D16_8CH || \
|
||||
g_model.moduleData[module].subType == MM_RF_FRSKY_SUBTYPE_D16_LBT || \
|
||||
g_model.moduleData[module].subType == MM_RF_FRSKY_SUBTYPE_D16_LBT_8CH || \
|
||||
g_model.moduleData[module].subType == MM_RF_FRSKY_SUBTYPE_D16_CLONED)) || \
|
||||
(g_model.moduleData[module].getMultiProtocol() == \
|
||||
(g_model.moduleData[module].multi.rfProtocol == \
|
||||
MODULE_SUBTYPE_MULTI_FRSKYX2))
|
||||
|
||||
#define IS_R9_MULTI(module) \
|
||||
(g_model.moduleData[module].getMultiProtocol() == \
|
||||
(g_model.moduleData[module].multi.rfProtocol == \
|
||||
MODULE_SUBTYPE_MULTI_FRSKY_R9)
|
||||
|
||||
#define IS_HOTT_MULTI(module) \
|
||||
(g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_HOTT)
|
||||
(g_model.moduleData[module].multi.rfProtocol == MODULE_SUBTYPE_MULTI_HOTT)
|
||||
|
||||
#define IS_CONFIG_MULTI(module) \
|
||||
(g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_CONFIG)
|
||||
(g_model.moduleData[module].multi.rfProtocol == MODULE_SUBTYPE_MULTI_CONFIG)
|
||||
|
||||
#define IS_DSM_MULTI(module) \
|
||||
(g_model.moduleData[module].getMultiProtocol() == MODULE_SUBTYPE_MULTI_DSM2)
|
||||
(g_model.moduleData[module].multi.rfProtocol == MODULE_SUBTYPE_MULTI_DSM2)
|
||||
|
||||
#define IS_RX_MULTI(module) \
|
||||
((g_model.moduleData[module].getMultiProtocol() == \
|
||||
((g_model.moduleData[module].multi.rfProtocol == \
|
||||
MODULE_SUBTYPE_MULTI_AFHDS2A_RX) || \
|
||||
(g_model.moduleData[module].getMultiProtocol() == \
|
||||
(g_model.moduleData[module].multi.rfProtocol == \
|
||||
MODULE_SUBTYPE_MULTI_FRSKYX_RX) || \
|
||||
(g_model.moduleData[module].getMultiProtocol() == \
|
||||
(g_model.moduleData[module].multi.rfProtocol == \
|
||||
MODULE_SUBTYPE_MULTI_BAYANG_RX) || \
|
||||
(g_model.moduleData[module].getMultiProtocol() == \
|
||||
(g_model.moduleData[module].multi.rfProtocol == \
|
||||
MODULE_SUBTYPE_MULTI_DSM_RX))
|
||||
|
||||
#if defined(HARDWARE_INTERNAL_MODULE)
|
||||
@@ -123,7 +123,7 @@ const mm_protocol_definition *getMultiProtocolDefinition (uint8_t protocol);
|
||||
inline uint8_t getMaxMultiSubtype(uint8_t moduleIdx)
|
||||
{
|
||||
MultiModuleStatus &status = getMultiModuleStatus(moduleIdx);
|
||||
auto proto = g_model.moduleData[moduleIdx].getMultiProtocol();
|
||||
auto proto = g_model.moduleData[moduleIdx].multi.rfProtocol;
|
||||
if (proto == MODULE_SUBTYPE_MULTI_FRSKY) {
|
||||
return 7;
|
||||
}
|
||||
@@ -148,7 +148,7 @@ inline bool isModuleMultimodule(uint8_t idx)
|
||||
inline bool isModuleMultimoduleDSM2(uint8_t idx)
|
||||
{
|
||||
return isModuleMultimodule(idx) &&
|
||||
g_model.moduleData[idx].getMultiProtocol() ==
|
||||
g_model.moduleData[idx].multi.rfProtocol ==
|
||||
MODULE_SUBTYPE_MULTI_DSM2;
|
||||
}
|
||||
#else
|
||||
@@ -593,7 +593,7 @@ inline bool isModuleFailsafeAvailable(uint8_t moduleIdx)
|
||||
return status.supportsFailsafe();
|
||||
}
|
||||
else {
|
||||
auto proto = g_model.moduleData[moduleIdx].getMultiProtocol();
|
||||
auto proto = g_model.moduleData[moduleIdx].multi.rfProtocol;
|
||||
const mm_protocol_definition * pdef = getMultiProtocolDefinition(proto);
|
||||
if (pdef) return pdef->failsafe;
|
||||
return false;
|
||||
@@ -649,7 +649,7 @@ inline uint8_t getMaxRxNum(uint8_t idx)
|
||||
|
||||
#if defined(MULTIMODULE)
|
||||
if (isModuleMultimodule(idx)) {
|
||||
switch (g_model.moduleData[idx].getMultiProtocol()) {
|
||||
switch (g_model.moduleData[idx].multi.rfProtocol) {
|
||||
case MODULE_SUBTYPE_MULTI_OLRS:
|
||||
return 4;
|
||||
case MODULE_SUBTYPE_MULTI_BUGS:
|
||||
@@ -776,7 +776,7 @@ inline void resetAccessAuthenticationCount()
|
||||
inline void resetAfhds3Options(uint8_t moduleIdx)
|
||||
{
|
||||
auto & data = g_model.moduleData[moduleIdx];
|
||||
data.rfProtocol = 0;
|
||||
//data.rfProtocol = 0;
|
||||
data.subType = 0;
|
||||
#if defined(AFHDS3)
|
||||
data.afhds3.bindPower = 0;
|
||||
@@ -824,7 +824,7 @@ inline void resetMultiProtocolsOptions(uint8_t moduleIdx)
|
||||
return;
|
||||
|
||||
// Sensible default for DSM2 (same as for ppm): 7ch@22ms + Autodetect settings enabled
|
||||
if (g_model.moduleData[moduleIdx].getMultiProtocol() == MODULE_SUBTYPE_MULTI_DSM2) {
|
||||
if (g_model.moduleData[moduleIdx].multi.rfProtocol == MODULE_SUBTYPE_MULTI_DSM2) {
|
||||
g_model.moduleData[moduleIdx].multi.autoBindMode = 1;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -65,49 +65,6 @@ etx_serial_init multiSerialInitParams = {
|
||||
};
|
||||
#endif
|
||||
|
||||
void multiPatchCustom(uint8_t moduleIdx)
|
||||
{
|
||||
if (g_model.moduleData[moduleIdx].multi.customProto) {
|
||||
uint8_t type = g_model.moduleData[moduleIdx].getMultiProtocol() - 1; // custom where starting at 1, etx list at 0
|
||||
int subtype = g_model.moduleData[moduleIdx].subType;
|
||||
|
||||
g_model.moduleData[moduleIdx].multi.customProto = 0;
|
||||
|
||||
if (type == 2) { // multi PROTO_FRSKYD
|
||||
g_model.moduleData[moduleIdx].subType = 1; // D8
|
||||
return;
|
||||
}
|
||||
else if (type == 14) { // multi PROTO_FRSKYX
|
||||
g_model.moduleData[moduleIdx].setMultiProtocol(2);
|
||||
switch (subtype) {
|
||||
case 0: //D16-16
|
||||
g_model.moduleData[moduleIdx].subType = 0;
|
||||
break;
|
||||
case 1: //D16-8
|
||||
g_model.moduleData[moduleIdx].subType = 2;
|
||||
break;
|
||||
case 2: //EU-16
|
||||
g_model.moduleData[moduleIdx].subType = 4;
|
||||
break;
|
||||
case 3: //EU-8
|
||||
g_model.moduleData[moduleIdx].subType = 5;
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (type == 24) { // multi PROTO_FRSKYV
|
||||
g_model.moduleData[moduleIdx].setMultiProtocol(2);
|
||||
g_model.moduleData[moduleIdx].subType = 3;
|
||||
return;
|
||||
}
|
||||
if (type > 14)
|
||||
type -= 1;
|
||||
if (type > 24)
|
||||
type -= 1;
|
||||
g_model.moduleData[moduleIdx].setMultiProtocol(type);
|
||||
}
|
||||
}
|
||||
|
||||
static void sendMulti(uint8_t moduleIdx, uint8_t b)
|
||||
{
|
||||
#if defined(HARDWARE_INTERNAL_MODULE)
|
||||
@@ -201,7 +158,7 @@ void setupPulsesMulti(uint8_t moduleIdx)
|
||||
sendMulti(moduleIdx, invert[moduleIdx] & 0x08);
|
||||
}
|
||||
else {
|
||||
sendMulti(moduleIdx, (uint8_t) (((g_model.moduleData[moduleIdx].getMultiProtocol() + 3) & 0xC0)
|
||||
sendMulti(moduleIdx, (uint8_t) (((g_model.moduleData[moduleIdx].multi.rfProtocol + 3) & 0xC0)
|
||||
| (g_model.header.modelId[moduleIdx] & 0x30)
|
||||
| (invert[moduleIdx] & 0x08)
|
||||
//| 0x04 // Future use
|
||||
@@ -430,7 +387,7 @@ void sendFrameProtocolHeader(uint8_t moduleIdx, bool failsafe)
|
||||
{// byte 1+2, protocol information
|
||||
|
||||
// Our enumeration starts at 0
|
||||
int type = g_model.moduleData[moduleIdx].getMultiProtocol() + 1;
|
||||
int type = g_model.moduleData[moduleIdx].multi.rfProtocol + 1;
|
||||
int subtype = g_model.moduleData[moduleIdx].subType;
|
||||
int8_t optionValue = g_model.moduleData[moduleIdx].multi.optionValue;
|
||||
|
||||
@@ -481,12 +438,12 @@ void sendFrameProtocolHeader(uint8_t moduleIdx, bool failsafe)
|
||||
|
||||
// Set the highest bit of option byte in AFHDS2A protocol to instruct MULTI to passthrough telemetry bytes instead
|
||||
// of sending Frsky D telemetry
|
||||
if (g_model.moduleData[moduleIdx].getMultiProtocol() == MODULE_SUBTYPE_MULTI_FS_AFHDS2A)
|
||||
if (g_model.moduleData[moduleIdx].multi.rfProtocol == MODULE_SUBTYPE_MULTI_FS_AFHDS2A)
|
||||
optionValue = optionValue | 0x80;
|
||||
|
||||
// For custom protocol send unmodified type byte
|
||||
if (g_model.moduleData[moduleIdx].getMultiProtocol() == MM_RF_CUSTOM_SELECTED)
|
||||
type = g_model.moduleData[moduleIdx].getMultiProtocol();
|
||||
if (g_model.moduleData[moduleIdx].multi.rfProtocol == MM_RF_CUSTOM_SELECTED)
|
||||
type = g_model.moduleData[moduleIdx].multi.rfProtocol;
|
||||
|
||||
uint8_t headerByte = 0x55;
|
||||
// header, byte 0, 0x55 for proto 0-31, 0x54 for proto 32-63
|
||||
@@ -500,7 +457,7 @@ void sendFrameProtocolHeader(uint8_t moduleIdx, bool failsafe)
|
||||
|
||||
// protocol byte
|
||||
protoByte |= (type & 0x1f);
|
||||
if (g_model.moduleData[moduleIdx].getMultiProtocol() != MODULE_SUBTYPE_MULTI_DSM2)
|
||||
if (g_model.moduleData[moduleIdx].multi.rfProtocol != MODULE_SUBTYPE_MULTI_DSM2)
|
||||
protoByte |= (g_model.moduleData[moduleIdx].multi.autoBindMode << 6);
|
||||
|
||||
sendMulti(moduleIdx, protoByte);
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "hal/serial_driver.h"
|
||||
#include "hal/module_driver.h"
|
||||
|
||||
void multiPatchCustom(uint8_t moduleIdx);
|
||||
void convertEtxProtocolToMulti(int *protocol, int *subprotocol);
|
||||
void convertMultiProtocolToEtx(int *protocol, int *subprotocol);
|
||||
|
||||
|
||||
@@ -262,7 +262,10 @@ uint8_t getRequiredProtocol(uint8_t module)
|
||||
|
||||
#if defined(DSM2)
|
||||
case MODULE_TYPE_DSM2:
|
||||
protocol = limit<uint8_t>(PROTOCOL_CHANNELS_DSM2_LP45, PROTOCOL_CHANNELS_DSM2_LP45+g_model.moduleData[module].rfProtocol, PROTOCOL_CHANNELS_DSM2_DSMX);
|
||||
protocol = limit<uint8_t>(
|
||||
PROTOCOL_CHANNELS_DSM2_LP45,
|
||||
PROTOCOL_CHANNELS_DSM2_LP45 + g_model.moduleData[module].subType,
|
||||
PROTOCOL_CHANNELS_DSM2_DSMX);
|
||||
// The module is set to OFF during one second before BIND start
|
||||
{
|
||||
static tmr10ms_t bindStartTime = 0;
|
||||
|
||||
Reference in New Issue
Block a user