This commit is contained in:
3djc
2018-12-13 12:59:04 +01:00
parent cc6660291d
commit 1c3d306c48
8 changed files with 19 additions and 66 deletions
-51
View File
@@ -1,51 +0,0 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* This file is based on work published at http://www.coranac.com/documents/working-with-bits-and-bitfields
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program 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.
*/
#ifndef BITFIELD_H
#define BITFIELD_H
// A set of bitfield handling macros
#define BF_BIT(n) ( 1<<(n) )
#define BF_BIT_GET(y, mask) ( y & (mask) )
#define BF_BIT_SET(y, mask) ( y |= (mask) )
#define BF_BIT_CLEAR(y, mask) ( y &= ~(mask) )
#define BF_BIT_FLIP(y, mask) ( y ^= (mask) )
#define BF_SINGLE_BIT_GET(y, i) BF_BIT_GET(y, BF_BIT(i))
#define BF_SINGLE_BIT_SET(y, i) BF_BIT_SET(y, BF_BIT(i))
//! Create a bitmask of length 'len'.
#define BF_BITMASK(len) ( BF_BIT(len)-1 )
//! Create a bitfield mask of length 'len' starting at bit 'start'.
#define BF_MASK(start, len) ( BF_BITMASK(len)<<(start) )
//! Prepare a bitmask for insertion or combining.
#define BF_PREP(x, start, len) ( ((x)&BF_BITMASK(len)) << (start) )
//! Extract a bitfield of length 'len' starting at bit 'start' from 'y'.
#define BF_GET(y, start, len) ( ((y)>>(start)) & BF_BITMASK(len) )
//! Insert 'len' bits of 'x 'into 'y', starting at bit 'start' from 'y'.
#define BF_SET(y, x, start, len) \
( y= ((y) &~ BF_MASK(start, len)) | BF_PREP(x, start, len) )
#endif //BITFIELD_H
+1
View File
@@ -1239,6 +1239,7 @@ void menuModelSetup(event_t event)
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.moduleData[moduleIdx].r9m.freq, 1);
}
}
break;
#if defined(MULTIMODULE)
case ITEM_MODEL_EXTERNAL_MODULE_AUTOBIND:
+3 -3
View File
@@ -502,7 +502,7 @@ bool isR9MModeAvailable(int mode)
bool isR9MMFlex(int module)
{
return g_model.moduleData[module].r9m.region == 0x02;
return g_model.moduleData[module].r9m.region == MODULE_R9M_REGION_FLEX;
}
bool isModuleAvailable(int module)
@@ -526,7 +526,7 @@ bool isModuleAvailable(int module)
return false;
}
#endif
#if !defined(PCBSKY9X)
#if defined(PCBTARANIS) || defined(PCBHORUS)
if (module == MODULE_TYPE_R9M && g_model.moduleData[INTERNAL_MODULE].type != MODULE_TYPE_NONE) {
return false;
}
@@ -548,7 +548,7 @@ bool isRfProtocolAvailable(int protocol)
return false;
}
#endif
#if defined(pxx)
#if defined(PCBTARANIS) || defined(PCBHORUS)
if (protocol != RF_PROTO_OFF && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_R9M) {
return false;
}
+10 -4
View File
@@ -323,12 +323,18 @@ enum R9MSubTypes
enum R9MRegion
{
MODULE_REGION_R9M_FCC,
MODULE_REGION_R9M_EU,
MODULE_REGION_R9M_FLEX,
MODULE_REGION_R9M_LAST=MODULE_REGION_R9M_FLEX
MODULE_R9M_REGION_FCC,
MODULE_R9M_REGION_EU,
MODULE_R9M_REGION_FLEX,
MODULE_R9M_REGION_LAST=MODULE_R9M_REGION_FLEX
};
enum R9MFrenquency
{
MODULE_R9M_FREQ_868MHZ
MODULE_R9M_FREQ_915MHZ,
MODULE_R9M_FREQ_LAST=MODULE_R9M_FREQ_915MHZ
};
enum MultiModuleRFProtocols {
MM_RF_PROTO_CUSTOM = -1,
-1
View File
@@ -27,7 +27,6 @@
#include <stdlib.h>
#include "definitions.h"
#include "opentx_types.h"
#include "bitfield.h"
#if defined(STM32)
#include "usbd_conf.h"
#endif
+5 -5
View File
@@ -106,27 +106,27 @@ inline bool isModuleR9M(uint8_t idx)
inline bool isModuleR9M_FCC(uint8_t idx)
{
return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region == MODULE_REGION_R9M_FCC;
return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region == MODULE_R9M_REGION_FCC;
}
inline bool isModuleR9M_LBT(uint8_t idx)
{
return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region == MODULE_REGION_R9M_EU;
return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region == MODULE_R9M_REGION_EU;
}
inline bool isModuleR9M_FCC_VARIANT(uint8_t idx)
{
return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region != MODULE_REGION_R9M_EU;
return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region != MODULE_R9M_REGION_EU;
}
inline bool isModuleR9M_EUPLUS(uint8_t idx)
{
return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region == MODULE_REGION_R9M_FLEX && g_model.moduleData[idx].r9m.freq == 0x00;
return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region == MODULE_R9M_REGION_FLEX && g_model.moduleData[idx].r9m.freq == MODULE_R9M_FREQ_868MHZ;
}
inline bool isModuleR9M_AU_PLUS(uint8_t idx)
{
return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region == MODULE_REGION_R9M_FLEX && g_model.moduleData[idx].r9m.freq == 0x01;
return isModuleR9M(idx) && g_model.moduleData[idx].r9m.region == MODULE_R9M_REGION_FLEX && g_model.moduleData[idx].r9m.freq == MODULE_R9M_FREQ_915MHZ;
}
-1
View File
@@ -45,7 +45,6 @@ void Pxx2Pulses::setupFrame(uint8_t port)
#if defined(LUA)
if (outputTelemetryBufferTrigger != 0x00 && outputTelemetryBufferSize > 0) {
TRACE("SENDING TELEM");
// primID (1 byte) + dataID (2 bytes) + value (4 bytes)
for (uint8_t i=0; i<7; i++) {
addByte(outputTelemetryBuffer[i]);
-1
View File
@@ -76,7 +76,6 @@ void processFrskyPXX2Data(uint8_t data)
if (telemetryRxBuffer[0] == 0x0c) {
sportProcessTelemetryPacketWithoutCrc(telemetryRxBuffer + 5 /* LEN, TYPE, RSSI/BAT, TP/SS/FW_T, FW_VER, Data ID */);
TRACE("Got TELEM data");
}
}
telemetryRxBufferCount = 0;