1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 08:15:17 +03:00

Compilation fixes

This commit is contained in:
Bertrand Songis 2019-03-20 16:32:58 +01:00
parent 683a737c99
commit 04ba9e5c68
32 changed files with 110 additions and 71 deletions

View file

@ -190,7 +190,7 @@ enum BeeperMode {
enum ModuleIndex {
INTERNAL_MODULE,
EXTERNAL_MODULE,
FLASHING_MODULE,
SPORT_MODULE,
};
enum TrainerMode {
TRAINER_MODE_MASTER_TRAINER_JACK,
@ -208,7 +208,8 @@ enum BeeperMode {
#elif defined(PCBSKY9X)
enum ModuleIndex {
EXTERNAL_MODULE,
EXTRA_MODULE
EXTRA_MODULE,
SPORT_MODULE
};
#endif

View file

@ -944,8 +944,8 @@ static inline void check_struct()
CHKSIZE(RadioData, 880);
CHKSIZE(ModelData, 6422);
#elif defined(PCBSKY9X)
CHKSIZE(RadioData, 727);
CHKSIZE(ModelData, 5188);
CHKSIZE(RadioData, 735);
CHKSIZE(ModelData, 5101);
#elif defined(PCBHORUS)
CHKSIZE(RadioData, 855);
CHKSIZE(ModelData, 9771);

View file

@ -1181,7 +1181,7 @@ void menuModelSetup(event_t event)
CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.channelsStart, 32-8-moduleData.channelsCount);
break;
case 1:
CHECK_INCDEC_MODELVAR_CHECK(event, moduleData.channelsCount, -4, min<int8_t>(maxModuleChannels_M8(moduleIdx), 32-8-moduleData.channelsStart), isInternalModuleChannelCountAvailable);
CHECK_INCDEC_MODELVAR_CHECK(event, moduleData.channelsCount, -4, min<int8_t>(maxModuleChannels_M8(moduleIdx), 32-8-moduleData.channelsStart), moduleData.type == MODULE_TYPE_XJT2 ? isPXX2ChannelsCountAllowed : nullptr);
if ((k == ITEM_MODEL_EXTERNAL_MODULE_CHANNELS && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_PPM)) {
SET_DEFAULT_PPM_FRAME_LENGTH(moduleIdx);
}

View file

@ -152,7 +152,7 @@ void onSdManagerMenu(const char * result)
}
else if (result == STR_FLASH_EXTERNAL_DEVICE) {
getSelectionFullPath(lfn);
DeviceFirmwareUpdate device(FLASHING_MODULE);
DeviceFirmwareUpdate device(SPORT_MODULE);
device.flashFile(lfn);
}
#if defined(LUA)

View file

@ -29,7 +29,14 @@ if(SDCARD)
${GUI_SRC}
../common/stdlcd/radio_sdmanager.cpp
../common/stdlcd/radio_tools.cpp
)
endif()
if(PXX2)
set(GUI_SRC
${GUI_SRC}
../common/stdlcd/radio_spectrum_analyser.cpp
../common/stdlcd/radio_power_meter.cpp
)
endif()

View file

@ -153,7 +153,7 @@ void onSdManagerMenu(const char * result)
}
else if (result == STR_FLASH_EXTERNAL_DEVICE) {
getSelectionFullPath(lfn);
DeviceFirmwareUpdate device(FLASHING_MODULE);
DeviceFirmwareUpdate device(SPORT_MODULE);
device.flashFile(lfn);
}
#endif

View file

@ -37,6 +37,8 @@ void menuRadioTools(event_t event)
{
SIMPLE_MENU("TOOLS", menuTabGeneral, MENU_RADIO_TOOLS, HEADER_LINE + 2);
#if defined(PXX2)
addRadioTool(0, "Spectrum Analyser", menuRadioSpectrumAnalyser, event);
addRadioTool(1, "Power Meter", menuRadioPowerMeter, event);
#endif
}

View file

@ -56,7 +56,7 @@ bool isSwitchAvailableInTimers(int swtch);
bool isR9MModeAvailable(int mode);
bool isR9ModuleRunning(int module);
bool isR9MMFlex(int module);
bool isInternalModuleChannelCountAvailable(int module);
bool isPXX2ChannelsCountAllowed(int channels);
bool isExternalModuleAvailable(int module);
bool isInternalModuleAvailable(int module);
bool isRfProtocolAvailable(int protocol);

View file

@ -515,14 +515,9 @@ bool isR9MMFlex(int module)
return g_model.moduleData[module].r9m.region == MODULE_R9M_REGION_FLEX;
}
bool isInternalModuleChannelCountAvailable(int channels)
bool isPXX2ChannelsCountAllowed(int channels)
{
if (g_model.moduleData[INTERNAL_MODULE].type == MODULE_TYPE_XJT2) {
if ( channels % 8 != 0)
return false;
}
return true;
return (channels % 8 == 0);
}
bool isInternalModuleAvailable(int module)

View file

@ -71,8 +71,8 @@ void DeviceFirmwareUpdate::processFrame(const uint8_t * frame)
void DeviceFirmwareUpdate::startup()
{
switch(module) {
case INTERNAL_MODULE:
#if defined(INTMODULE_USART)
case INTERNAL_MODULE:
intmoduleSerialStart(57600, true);
break;
#endif
@ -138,8 +138,8 @@ const uint8_t * DeviceFirmwareUpdate::readHalfDuplexFrame(uint32_t timeout)
const uint8_t * DeviceFirmwareUpdate::readFrame(uint32_t timeout)
{
switch(module) {
case INTERNAL_MODULE:
#if defined(INTMODULE_USART)
case INTERNAL_MODULE:
return readFullDuplexFrame(intmoduleFifo, timeout);
#endif
@ -177,7 +177,7 @@ void DeviceFirmwareUpdate::startFrame(uint8_t command)
// TODO merge this function
void DeviceFirmwareUpdate::sendFrame()
{
uint8_t * ptr = outputTelemetryBuffer;
uint8_t * ptr = outputTelemetryBuffer.data;
*ptr++ = 0x7E;
*ptr++ = 0xFF;
frame[7] = crc16(frame, 7);
@ -192,13 +192,13 @@ void DeviceFirmwareUpdate::sendFrame()
}
switch(module) {
case INTERNAL_MODULE:
#if defined(INTMODULE_USART)
return intmoduleSendBuffer(outputTelemetryBuffer, ptr-outputTelemetryBuffer);
case INTERNAL_MODULE:
return intmoduleSendBuffer(outputTelemetryBuffer.data, ptr - outputTelemetryBuffer.data);
#endif
default:
return sportSendBuffer(outputTelemetryBuffer, ptr-outputTelemetryBuffer);
return sportSendBuffer(outputTelemetryBuffer.data, ptr - outputTelemetryBuffer.data);
}
}

View file

@ -22,17 +22,17 @@
bool isSportOutputBufferAvailable()
{
return (outputTelemetryBufferSize == 0 && outputTelemetryBufferTrigger == 0x7E);
return (outputTelemetryBuffer.size == 0 && outputTelemetryBuffer.trigger == 0x7E);
}
void sportOutputPushByte(uint8_t byte)
{
if (byte == 0x7E || byte == 0x7D) {
telemetryOutputPushByte(0x7D);
telemetryOutputPushByte(0x20 ^ byte);
outputTelemetryBuffer.push(0x7D);
outputTelemetryBuffer.push(0x20 ^ byte);
}
else {
telemetryOutputPushByte(byte);
outputTelemetryBuffer.push(byte);
}
}
@ -49,6 +49,7 @@ void sportOutputPushPacket(SportTelemetryPacket * packet)
crc &= 0x00ff;
}
telemetryOutputPushByte(0xFF-crc);
telemetryOutputSetTrigger(packet->raw[0]); // physicalId
outputTelemetryBuffer.push(0xFF - crc);
outputTelemetryBuffer.setTrigger(packet->raw[0]); // physicalId
outputTelemetryBuffer.setDestination(SPORT_MODULE);
}

View file

@ -306,9 +306,11 @@ void generalDefault()
theme->init();
#endif
#if defined(PXX2)
for (uint8_t i=0; i<PXX2_LEN_REGISTRATION_ID; i++) {
g_eeGeneral.ownerRegistrationID[i] = (cpu_uid[1 + i] & 0x3f) - 26;
}
#endif
g_eeGeneral.chkSum = 0xFFFF;
}

View file

@ -148,7 +148,7 @@ void setupPulsesDSM2()
dsmDat[0] |= DSM2_SEND_RANGECHECK;
}
else {
moduleSettings[port].mode = 0;
moduleSettings[EXTERNAL_MODULE].mode = 0;
}
#else
if (moduleSettings[EXTERNAL_MODULE].mode == MODULE_MODE_BIND) {

View file

@ -48,7 +48,6 @@ inline bool isModuleMultimoduleDSM2(uint8_t)
}
#endif
#if defined(PCBHORUS) || defined(PCBTARANIS)
inline bool isModuleXJT(uint8_t idx)
{
return g_model.moduleData[idx].type == MODULE_TYPE_XJT;
@ -64,12 +63,6 @@ inline bool isModuleXJTVariant(uint8_t idx)
return g_model.moduleData[idx].type == MODULE_TYPE_XJT || g_model.moduleData[idx].type == MODULE_TYPE_XJT2;
}
#else
inline bool isModuleXJT(uint8_t idx)
{
return idx == EXTERNAL_MODULE && g_model.moduleData[EXTERNAL_MODULE].type == MODULE_TYPE_XJT;
}
#endif
#if defined(CROSSFIRE)
inline bool isModuleCrossfire(uint8_t idx)

View file

@ -65,7 +65,7 @@ void setupPulsesPPMTrainer()
setupPulsesPPM<trainer_pulse_duration_t>(&trainerPulsesData.ppm, g_model.trainerData.channelsStart, g_model.trainerData.channelsCount, g_model.trainerData.frameLength);
}
#if defined(PCBSKY9X) || defined(TARANIS_INTERNAL_PPM)
#if defined(PCBTARANIS) && defined(TARANIS_INTERNAL_PPM)
void setupPulsesPPMInternalModule()
{
setupPulsesPPM(&intmodulePulsesData.ppm, g_model.moduleData[INTERNAL_MODULE].channelsStart, g_model.moduleData[INTERNAL_MODULE].channelsCount, g_model.moduleData[INTERNAL_MODULE].ppm.frameLength);

View file

@ -31,9 +31,11 @@ TrainerPulsesData trainerPulsesData __DMA;
uint8_t getModuleType(uint8_t module)
{
uint8_t type = g_model.moduleData[module].type;
#if defined(PCBTARANIS) || defined(PCBHORUS)
if (module == INTERNAL_MODULE && isInternalModuleAvailable(type)) {
return type;
}
#endif
if (module == EXTERNAL_MODULE && isExternalModuleAvailable(type)) {
return type;
}
@ -255,7 +257,7 @@ void setupPulsesInternalModule(uint8_t protocol)
break;
#endif
#if defined(PCBSKY9X) || defined(TARANIS_INTERNAL_PPM)
#if defined(PCBTARANIS) && defined(TARANIS_INTERNAL_PPM)
case PROTOCOL_CHANNELS_PPM:
setupPulsesPPM(&extmodulePulsesData.ppm, g_model.moduleData[INTERNAL_MODULE].channelsStart, g_model.moduleData[INTERNAL_MODULE].channelsCount, g_model.moduleData[INTERNAL_MODULE].ppm.frameLength);
scheduleNextMixerCalculation(INTERNAL_MODULE, PPM_PERIOD(INTERNAL_MODULE));
@ -332,9 +334,11 @@ void setupPulsesExternalModule(uint8_t protocol)
void setupPulses(uint8_t module, uint8_t protocol)
{
switch (module) {
#if defined(PCBTARANIS) && defined(PCBHORUS)
case INTERNAL_MODULE:
setupPulsesInternalModule(protocol);
break;
#endif
case EXTERNAL_MODULE:
setupPulsesExternalModule(protocol);

View file

@ -550,7 +550,7 @@ PACK(typedef struct {
#define MODELDATA_EXTRA_217 \
uint8_t spare:6; \
uint8_t potsWarnMode:2; \
ModuleData moduleData[NUM_MODULES+1]; \
ModuleData_v217 moduleData[NUM_MODULES+1]; \
uint8_t potsWarnEnabled; \
int8_t potsWarnPosition[NUM_POTS+NUM_SLIDERS]; \
uint8_t rxBattAlarms[2];

View file

@ -56,19 +56,23 @@ void convertModelData_218_to_219(ModelData &model)
}
}
#if !defined(PCBSKY9X)
newModel.trainerData.mode = oldModel.trainerMode;
#endif
newModel.trainerData.channelsStart = oldModel.moduleData[NUM_MODULES].channelsStart;
newModel.trainerData.channelsCount = oldModel.moduleData[NUM_MODULES].channelsCount;
newModel.trainerData.frameLength = oldModel.moduleData[NUM_MODULES].ppm.frameLength;
newModel.trainerData.delay = oldModel.moduleData[NUM_MODULES].ppm.delay;
newModel.trainerData.pulsePol = oldModel.moduleData[NUM_MODULES].ppm.pulsePol;
#if !defined(PCBSKY9X)
memcpy(newModel.scriptsData, oldModel.scriptsData,
sizeof(newModel.scriptsData) +
sizeof(newModel.inputNames) +
sizeof(newModel.potsWarnEnabled) +
sizeof(newModel.potsWarnPosition) +
sizeof(oldModel.telemetrySensors));
#endif
#if defined(PCBX9E)
newModel.toplcdTimer = oldModel.toplcdTimer;

View file

@ -456,7 +456,7 @@ PACK(typedef struct {
uint8_t templateSetup; // RETA order for receiver channels
int8_t PPM_Multiplier;
int8_t hapticLength;
N_HORUS_FIELD(N_TARANIS_FIELD(N_PCBSTD_FIELD(uint8_t reNavigation)));
N_HORUS_FIELD(N_TARANIS_FIELD(uint8_t reNavigation));
N_HORUS_FIELD(N_TARANIS_FIELD(uint8_t stickReverse));
int8_t beepLength:3;
int8_t hapticStrength:3;

View file

@ -23,6 +23,7 @@
#include <string.h>
#include "opentx.h"
#include "timers.h"
#include "conversions/conversions.h"
#define EEPROM_MARK 0x84697771 /* thanks ;) */
#define EEPROM_ZONE_SIZE (8*1024)
@ -584,7 +585,7 @@ const char * eeRestoreModel(uint8_t i_fileDst, char *model_name)
#if defined(EEPROM_CONVERSIONS)
if (version < EEPROM_VER) {
convertModel(i_fileDst, version);
convertModelData(i_fileDst, version);
eeLoadModel(g_eeGeneral.currModel);
}
#endif

View file

@ -141,7 +141,6 @@ set(SRC
tasks.cpp
audio.cpp
io/frsky_sport.cpp
io/frsky_device_firmware_update.cpp
telemetry/telemetry.cpp
telemetry/telemetry_holders.cpp
telemetry/telemetry_sensors.cpp

View file

@ -135,6 +135,12 @@ void intmoduleSendNextFrame()
switch(moduleSettings[INTERNAL_MODULE].protocol) {
#if defined(PXX2)
case PROTOCOL_CHANNELS_PXX2:
#if defined(LUA)
if (outputTelemetryBuffer.size > 0 && outputTelemetryBuffer.destination == INTERNAL_MODULE) {
intmoduleSendBuffer(outputTelemetryBuffer.data, outputTelemetryBuffer.size);
break;
}
#endif
intmoduleSendBuffer(intmodulePulsesData.pxx2.getData(), intmodulePulsesData.pxx2.getSize());
break;
#endif

View file

@ -146,6 +146,7 @@ add_definitions(-DBLUETOOTH)
set(SRC
${SRC}
bluetooth.cpp
io/frsky_device_firmware_update.cpp
)
set(STM32LIB_SRC

View file

@ -176,8 +176,8 @@ extern "C" void TELEMETRY_DMA_TX_IRQHandler(void)
DMA_ClearITPendingBit(TELEMETRY_DMA_Stream_TX, TELEMETRY_DMA_TX_FLAG_TC);
TELEMETRY_USART->CR1 |= USART_CR1_TCIE;
if (telemetryProtocol == PROTOCOL_TELEMETRY_FRSKY_SPORT) {
outputTelemetryBufferSize = 0;
outputTelemetryBufferTrigger = 0x7E;
outputTelemetryBuffer.size = 0;
outputTelemetryBuffer.trigger = 0x7E;
}
}
}
@ -207,8 +207,8 @@ extern "C" void TELEMETRY_USART_IRQHandler(void)
#if defined(LUA)
if (telemetryProtocol == PROTOCOL_TELEMETRY_FRSKY_SPORT) {
static uint8_t prevdata;
if (prevdata == 0x7E && outputTelemetryBufferSize > 0 && data == outputTelemetryBufferTrigger) {
sportSendBuffer(outputTelemetryBuffer, outputTelemetryBufferSize);
if (prevdata == 0x7E && outputTelemetryBuffer.size > 0 && data == outputTelemetryBuffer.trigger && outputTelemetryBuffer.destination == SPORT_MODULE) {
sportSendBuffer(outputTelemetryBuffer.data, outputTelemetryBuffer.size);
}
prevdata = data;
}

View file

@ -263,6 +263,7 @@ void init_serial(uint32_t port, uint32_t baudrate, uint32_t period_half_us);
void disable_serial(uint32_t port);
void init_module_timer( uint32_t module_index, uint32_t period, uint8_t state);
void disable_module_timer( uint32_t module_index);
void extmoduleSendNextFrame();
// SD driver
#if defined(SIMU)

View file

@ -265,6 +265,10 @@ void disable_serial(uint32_t port)
}
}
void extmoduleSendNextFrame()
{
}
#if !defined(SIMU)
extern "C" void PWM_IRQHandler(void)
{

View file

@ -202,6 +202,11 @@ endif()
add_definitions(-DPCBTARANIS)
add_definitions(-DAUDIO -DVOICE -DRTCLOCK)
set(SRC
${SRC}
io/frsky_device_firmware_update.cpp
)
set(GUI_SRC
${GUI_SRC}
model_input_edit.cpp

View file

@ -128,8 +128,7 @@ extern "C" void TELEMETRY_DMA_TX_IRQHandler(void)
DMA_ClearITPendingBit(TELEMETRY_DMA_Stream_TX, TELEMETRY_DMA_TX_FLAG_TC);
TELEMETRY_USART->CR1 |= USART_CR1_TCIE;
if (telemetryProtocol == PROTOCOL_TELEMETRY_FRSKY_SPORT || telemetryProtocol == PROTOCOL_TELEMETRY_PXX2) {
outputTelemetryBufferSize = 0;
outputTelemetryBufferTrigger = 0x7E;
outputTelemetryBuffer.reset();
}
}
}
@ -159,8 +158,8 @@ extern "C" void TELEMETRY_USART_IRQHandler(void)
#if defined(LUA)
if (telemetryProtocol == PROTOCOL_TELEMETRY_FRSKY_SPORT) {
static uint8_t prevdata;
if (prevdata == 0x7E && outputTelemetryBufferSize > 0 && data == outputTelemetryBufferTrigger) {
sportSendBuffer(outputTelemetryBuffer, outputTelemetryBufferSize);
if (prevdata == 0x7E && outputTelemetryBuffer.size > 0 && data == outputTelemetryBuffer.trigger && outputTelemetryBuffer.destination == SPORT_MODULE) {
sportSendBuffer(outputTelemetryBuffer.data, outputTelemetryBuffer.size);
}
prevdata = data;
}

View file

@ -89,9 +89,11 @@ void sendSynchronousPulses()
{
for (uint8_t module = 0; module < NUM_MODULES; module++) {
if (isModuleSynchronous(module) && setupPulses(module)) {
#if defined(PCBHORUS) || defined(PCBTARAHIS)
if (module == INTERNAL_MODULE)
intmoduleSendNextFrame();
else
#endif
if (module == EXTERNAL_MODULE)
extmoduleSendNextFrame();
}
}

View file

@ -290,15 +290,13 @@ void telemetryInit(uint8_t protocol)
else if (protocol == PROTOCOL_TELEMETRY_PXX2) {
telemetryPortInit(PXX2_ON_SPORT_BAUDRATE, TELEMETRY_SERIAL_WITHOUT_DMA);
#if defined(LUA)
outputTelemetryBufferSize = 0;
outputTelemetryBufferTrigger = 0x7E;
outputTelemetryBuffer.reset();
#endif
}
else {
telemetryPortInit(FRSKY_SPORT_BAUDRATE, TELEMETRY_SERIAL_WITHOUT_DMA);
#if defined(LUA)
outputTelemetryBufferSize = 0;
outputTelemetryBufferTrigger = 0x7E;
outputTelemetryBuffer.reset();
#endif
}
@ -333,9 +331,7 @@ void logTelemetryWriteByte(uint8_t data)
}
#endif
uint8_t outputTelemetryBuffer[TELEMETRY_OUTPUT_FIFO_SIZE] __DMA;
uint8_t outputTelemetryBufferSize = 0;
uint8_t outputTelemetryBufferTrigger = 0;
OutputTelemetryBuffer outputTelemetryBuffer __DMA;
#if defined(LUA)
Fifo<uint8_t, LUA_TELEMETRY_INPUT_FIFO_SIZE> * luaInputTelemetryFifo = NULL;

View file

@ -156,20 +156,35 @@ void logTelemetryWriteByte(uint8_t data);
#endif
#define TELEMETRY_OUTPUT_FIFO_SIZE 20
extern uint8_t outputTelemetryBuffer[TELEMETRY_OUTPUT_FIFO_SIZE] __DMA;
extern uint8_t outputTelemetryBufferSize;
extern uint8_t outputTelemetryBufferTrigger;
inline void telemetryOutputPushByte(uint8_t byte)
{
outputTelemetryBuffer[outputTelemetryBufferSize++] = byte;
class OutputTelemetryBuffer {
public:
void push(uint8_t byte) {
data[size++] = byte;
}
inline void telemetryOutputSetTrigger(uint8_t byte)
{
outputTelemetryBufferTrigger = byte;
void setTrigger(uint8_t byte) {
trigger = byte;
}
void setDestination(uint8_t module) {
destination = module;
}
void reset() {
size = 0;
trigger = 0x7E;
}
public:
uint8_t data[TELEMETRY_OUTPUT_FIFO_SIZE];
uint8_t size;
uint8_t trigger;
uint8_t destination;
};
extern OutputTelemetryBuffer outputTelemetryBuffer __DMA;
#if defined(LUA)
#define LUA_TELEMETRY_INPUT_FIFO_SIZE 256
extern Fifo<uint8_t, LUA_TELEMETRY_INPUT_FIFO_SIZE> * luaInputTelemetryFifo;

View file

@ -538,11 +538,12 @@
#define TR_OK TR_ENTER
#else
#define TR_EXIT "[EXIT]"
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
#endif
#if defined(PCBTARANIS)
#define TR_POPUPS_ENTER_EXIT TR(TR_EXIT "\010" TR_ENTER, TR_EXIT "\010" "\010" "\010" "\010" TR_ENTER)
#define TR_OK TR("\010" "\010" "\010" "[OK]", "\010" "\010" "\010" "\010" "\010" "[OK]")
#else
#define TR_POPUPS_ENTER_EXIT TR_ENTER "\010" TR_EXIT
#define OFS_EXIT sizeof(TR_ENTER)