diff --git a/radio/src/datastructs.h b/radio/src/datastructs.h index e7ae9b8b1f..75591e4db7 100644 --- a/radio/src/datastructs.h +++ b/radio/src/datastructs.h @@ -435,15 +435,6 @@ PACK(struct ModuleData { uint8_t lowPowerMode : 1; int8_t optionValue; } multi); - NOBACKUP(struct { - uint8_t power : 2; // 0=10 mW, 1=100 mW, 2=500 mW, 3=1W - uint8_t spare1 : 2; - uint8_t receiver_telem_off : 1; // false = receiver telem enabled - uint8_t receiver_channel_9_16 : 1; // false = pwm out 1-8, true 9-16 - uint8_t external_antenna : 1; // false = internal antenna, true = external antenna - uint8_t fast : 1; // TODO: to be used later by external module (fast means serial @ high speed) - uint8_t spare2; - } pxx); NOBACKUP(struct { uint8_t spare1 : 6; uint8_t noninverted : 1; diff --git a/radio/src/gui/128x64/model_setup.cpp b/radio/src/gui/128x64/model_setup.cpp index 8e451f0731..85a1e10ce4 100644 --- a/radio/src/gui/128x64/model_setup.cpp +++ b/radio/src/gui/128x64/model_setup.cpp @@ -217,6 +217,7 @@ void editTimerCountdown(int timerIdx, coord_t y, LcdFlags attr, event_t event) } } +#if defined(PCBTARANIS) void onBindMenu(const char * result) { uint8_t moduleIdx = CURRENT_MODULE_EDITED(menuVerticalPosition); @@ -243,6 +244,7 @@ void onBindMenu(const char * result) moduleState[moduleIdx].mode = MODULE_MODE_BIND; } +#endif void menuModelSetup(event_t event) @@ -360,9 +362,11 @@ void menuModelSetup(event_t event) TITLE(STR_MENUSETUP); +#if defined(PXX) if (event == EVT_ENTRY) { reusableBuffer.modelsetup.r9mPower = g_model.moduleData[EXTERNAL_MODULE].pxx.power; } +#endif uint8_t sub = menuVerticalPosition - HEADER_LINE; int8_t editMode = s_editMode; diff --git a/radio/src/mixer.cpp b/radio/src/mixer.cpp index e20c7e6646..c92feb2ab2 100644 --- a/radio/src/mixer.cpp +++ b/radio/src/mixer.cpp @@ -313,7 +313,7 @@ getvalue_t getValue(mixsrc_t i) } #endif -#if defined(PCBGRUVIN9X) || defined(PCBMEGA2560) || defined(ROTARY_ENCODERS) +#if defined(ROTARY_ENCODERS) else if (i <= MIXSRC_LAST_ROTARY_ENCODER) { return getRotaryEncoder(i-MIXSRC_REa); } diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 04465d19ee..0695b22be1 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1734,7 +1734,7 @@ void opentxInit() globalData.unexpectedShutdown = 1; } -#if defined(SDCARD) && !defined(PCBMEGA2560) +#if defined(SDCARD) // SDCARD related stuff, only done if not unexpectedShutdown if (!globalData.unexpectedShutdown) { sdInit(); diff --git a/radio/src/pulses/crossfire.cpp b/radio/src/pulses/crossfire.cpp index 476abf57b3..ee31926f5e 100644 --- a/radio/src/pulses/crossfire.cpp +++ b/radio/src/pulses/crossfire.cpp @@ -133,24 +133,24 @@ uint8_t createCrossfireChannelsFrame(uint8_t* frame, int16_t * pulses) { } void setupPulsesCrossfire() { - uint8_t* pulses = modulePulsesData[EXTERNAL_MODULE].crossfire.pulses; + uint8_t* pulses = extmodulePulsesData.crossfire.pulses; if (outputTelemetryBufferSize > 0) { memcpy(pulses, outputTelemetryBuffer, outputTelemetryBufferSize); - modulePulsesData[EXTERNAL_MODULE].crossfire.length = outputTelemetryBufferSize; + extmodulePulsesData.crossfire.length = outputTelemetryBufferSize; outputTelemetryBufferSize = 0; outputTelemetryBufferTrigger = 0; } else { if (moduleState[EXTERNAL_MODULE].counter == CRSF_FRAME_MODELID) { - modulePulsesData[EXTERNAL_MODULE].crossfire.length = createCrossfireModelIDFrame(pulses); + extmodulePulsesData.crossfire.length = createCrossfireModelIDFrame(pulses); moduleState[EXTERNAL_MODULE].counter = CRSF_FRAME_MODELID_SENT; } else if (moduleState[EXTERNAL_MODULE].counter == CRSF_FRAME_MODELID_SENT && crossfireModuleStatus.queryCompleted == false) { - modulePulsesData[EXTERNAL_MODULE].crossfire.length = createCrossfirePingFrame(pulses); + extmodulePulsesData.crossfire.length = createCrossfirePingFrame(pulses); // } else if (moduleState[EXTERNAL_MODULE].mode == MODULE_MODE_BIND) { // p_buf += createCrossfireBindFrame(p_buf); // moduleState[module].mode = MODULE_MODE_NORMAL; } else { - modulePulsesData[EXTERNAL_MODULE].crossfire.length = createCrossfireChannelsFrame( + extmodulePulsesData.crossfire.length = createCrossfireChannelsFrame( pulses, &channelOutputs[g_model.moduleData[EXTERNAL_MODULE].channelsStart]); } diff --git a/radio/src/pulses/dsm2_arm.cpp b/radio/src/pulses/dsm2_arm.cpp index 912870dee1..90e7a7646b 100644 --- a/radio/src/pulses/dsm2_arm.cpp +++ b/radio/src/pulses/dsm2_arm.cpp @@ -34,13 +34,13 @@ #if defined(PPM_PIN_SERIAL) void putDsm2SerialBit(uint8_t bit) { - modulePulsesData[EXTERNAL_MODULE].dsm2.serialByte >>= 1; + extmodulePulsesData.dsm2.serialByte >>= 1; if (bit & 1) { - modulePulsesData[EXTERNAL_MODULE].dsm2.serialByte |= 0x80; + extmodulePulsesData.dsm2.serialByte |= 0x80; } - if (++modulePulsesData[EXTERNAL_MODULE].dsm2.serialBitCount >= 8) { - *modulePulsesData[EXTERNAL_MODULE].dsm2.ptr++ = modulePulsesData[EXTERNAL_MODULE].dsm2.serialByte; - modulePulsesData[EXTERNAL_MODULE].dsm2.serialBitCount = 0; + if (++extmodulePulsesData.dsm2.serialBitCount >= 8) { + *extmodulePulsesData.dsm2.ptr++ = extmodulePulsesData.dsm2.serialByte; + extmodulePulsesData.dsm2.serialBitCount = 0; } } @@ -65,14 +65,14 @@ void putDsm2Flush() #else void _send_1(uint8_t v) { - if (modulePulsesData[EXTERNAL_MODULE].dsm2.index & 1) + if (extmodulePulsesData.dsm2.index & 1) v += 2; else v -= 2; - *modulePulsesData[EXTERNAL_MODULE].dsm2.ptr++ = v - 1; - modulePulsesData[EXTERNAL_MODULE].dsm2.index += 1; - modulePulsesData[EXTERNAL_MODULE].dsm2.rest -= v; + *extmodulePulsesData.dsm2.ptr++ = v - 1; + extmodulePulsesData.dsm2.index += 1; + extmodulePulsesData.dsm2.rest -= v; } void sendByteDsm2(uint8_t b) // max 10 changes 0 10 10 10 10 1 @@ -96,10 +96,10 @@ void sendByteDsm2(uint8_t b) // max 10 changes 0 10 10 10 10 1 void putDsm2Flush() { - if (modulePulsesData[EXTERNAL_MODULE].dsm2.index & 1) - *modulePulsesData[EXTERNAL_MODULE].dsm2.ptr++ = modulePulsesData[EXTERNAL_MODULE].dsm2.rest; + if (extmodulePulsesData.dsm2.index & 1) + *extmodulePulsesData.dsm2.ptr++ = extmodulePulsesData.dsm2.rest; else - *(modulePulsesData[EXTERNAL_MODULE].dsm2.ptr - 1) = modulePulsesData[EXTERNAL_MODULE].dsm2.rest; + *(extmodulePulsesData.dsm2.ptr - 1) = extmodulePulsesData.dsm2.rest; } #endif @@ -111,14 +111,14 @@ void setupPulsesDSM2(uint8_t port) uint8_t dsmDat[14]; #if defined(PPM_PIN_SERIAL) - modulePulsesData[EXTERNAL_MODULE].dsm2.serialByte = 0 ; - modulePulsesData[EXTERNAL_MODULE].dsm2.serialBitCount = 0 ; + extmodulePulsesData.dsm2.serialByte = 0 ; + extmodulePulsesData.dsm2.serialBitCount = 0 ; #else - modulePulsesData[EXTERNAL_MODULE].dsm2.index = 0; - modulePulsesData[EXTERNAL_MODULE].dsm2.rest = DSM2_PERIOD * 2000; + extmodulePulsesData.dsm2.index = 0; + extmodulePulsesData.dsm2.rest = DSM2_PERIOD * 2000; #endif - modulePulsesData[EXTERNAL_MODULE].dsm2.ptr = modulePulsesData[EXTERNAL_MODULE].dsm2.pulses; + extmodulePulsesData.dsm2.ptr = extmodulePulsesData.dsm2.pulses; switch (moduleState[port].protocol) { case PROTO_DSM2_LP45: diff --git a/radio/src/pulses/multi_arm.cpp b/radio/src/pulses/multi_arm.cpp index 709c2359f3..86311c6358 100644 --- a/radio/src/pulses/multi_arm.cpp +++ b/radio/src/pulses/multi_arm.cpp @@ -91,14 +91,14 @@ void setupPulsesMultimodule(uint8_t port) static int counter = 0; #if defined(PPM_PIN_SERIAL) - modulePulsesData[EXTERNAL_MODULE].dsm2.serialByte = 0 ; - modulePulsesData[EXTERNAL_MODULE].dsm2.serialBitCount = 0 ; + extmodulePulsesData.dsm2.serialByte = 0 ; + extmodulePulsesData.dsm2.serialBitCount = 0 ; #else - modulePulsesData[EXTERNAL_MODULE].dsm2.rest = multiSyncStatus.getAdjustedRefreshRate(); - modulePulsesData[EXTERNAL_MODULE].dsm2.index = 0; + extmodulePulsesData.dsm2.rest = multiSyncStatus.getAdjustedRefreshRate(); + extmodulePulsesData.dsm2.index = 0; #endif - modulePulsesData[EXTERNAL_MODULE].dsm2.ptr = modulePulsesData[EXTERNAL_MODULE].dsm2.pulses; + extmodulePulsesData.dsm2.ptr = extmodulePulsesData.dsm2.pulses; // Every 1000 cycles (=9s) send a config packet that configures the multimodule (inversion, telemetry type) counter++; diff --git a/radio/src/pulses/ppm_arm.cpp b/radio/src/pulses/ppm_arm.cpp index 37bd03d19d..62a814cc5d 100644 --- a/radio/src/pulses/ppm_arm.cpp +++ b/radio/src/pulses/ppm_arm.cpp @@ -21,7 +21,7 @@ #include "opentx.h" template -void setupPulsesPPM(uint8_t port, PpmPulsesData * ppmPulsesData) +void setupPulsesPPM(PpmPulsesData * ppmPulsesData, uint8_t channelsStart, int8_t channelsCount, int8_t frameLength) { // range of 0.7 .. 1.7msec int16_t PPM_range = g_model.extendedLimits ? (512*LIMIT_EXT_PERCENT/100) * 2 : 512 * 2; @@ -30,8 +30,8 @@ void setupPulsesPPM(uint8_t port, PpmPulsesData * ppmPulsesData) // each pulse is 0.7..1.7ms long with a 0.3ms stop tail // The pulse ISR is 2mhz that's why everything is multiplied by 2 - uint32_t firstCh = g_model.moduleData[port].channelsStart; - uint32_t lastCh = min(MAX_OUTPUT_CHANNELS, firstCh + 8 + g_model.moduleData[port].channelsCount); + uint8_t firstCh = channelsStart; + uint8_t lastCh = min(MAX_OUTPUT_CHANNELS, firstCh + 8 + channelsCount); #if defined(STM32) ppmPulsesData->ptr = ppmPulsesData->pulses; @@ -41,7 +41,7 @@ void setupPulsesPPM(uint8_t port, PpmPulsesData * ppmPulsesData) #endif int32_t rest = 22500u * 2; - rest += (int32_t(g_model.moduleData[port].ppm.frameLength)) * 1000; + rest += (int32_t(frameLength)) * 1000; for (uint32_t i=firstCh; i * ppmPulsesData) //TRACE("ppmPulsesData: %p",(void*)&ppmPulsesData); } -void setupPulsesPPMModule(uint8_t port) +void setupPulsesPPMTrainer() { - setupPulsesPPM(port, &modulePulsesData[port].ppm); + setupPulsesPPM(&trainerPulsesData.ppm, g_model.moduleData[TRAINER_MODULE].channelsStart, g_model.moduleData[TRAINER_MODULE].channelsCount, g_model.moduleData[TRAINER_MODULE].ppm.frameLength); } -void setupPulsesPPMTrainer() +#if defined(TARANIS_INTERNAL_PPM) +void setupPulsesPPMInternalModule() { - setupPulsesPPM(TRAINER_MODULE, &trainerPulsesData.ppm); + setupPulsesPPM(&intmodulePulsesData.ppm, g_model.moduleData[INTERNAL_MODULE].channelsStart, g_model.moduleData[INTERNAL_MODULE].channelsCount, g_model.moduleData[INTERNAL_MODULE].ppm.frameLength); } +#endif + +void setupPulsesPPMExternalModule() +{ + setupPulsesPPM(&extmodulePulsesData.ppm, g_model.moduleData[EXTERNAL_MODULE].channelsStart, g_model.moduleData[EXTERNAL_MODULE].channelsCount, g_model.moduleData[EXTERNAL_MODULE].ppm.frameLength); +} \ No newline at end of file diff --git a/radio/src/pulses/pulses_arm.cpp b/radio/src/pulses/pulses_arm.cpp index 443d24defc..13d7e05db0 100755 --- a/radio/src/pulses/pulses_arm.cpp +++ b/radio/src/pulses/pulses_arm.cpp @@ -28,7 +28,8 @@ uint8_t s_pulses_paused = 0; ModuleState moduleState[NUM_MODULES]; -ModulePulsesData modulePulsesData[NUM_MODULES] __DMA; +InternalModulePulsesData intmodulePulsesData __DMA; +ExternalModulePulsesData extmodulePulsesData __DMA; TrainerPulsesData trainerPulsesData __DMA; #if defined(CROSSFIRE) @@ -155,28 +156,10 @@ bool setupPulses(uint8_t port) { TRACE("setupPulses %d: %d->%d", port, moduleState[port].protocol, required_protocol); init_needed = true; switch (moduleState[port].protocol) { // stop existing protocol hardware -#if defined(PXX) - case PROTO_PXX: - disable_pxx(port); - break; -#endif -#if defined(DSM2) - case PROTO_DSM2_LP45: - case PROTO_DSM2_DSM2: - case PROTO_DSM2_DSMX: - disable_serial(port); - break; -#endif #if defined(CROSSFIRE) case PROTOCOL_CHANNELS_CROSSFIRE: - disable_module_timer(port); - break; -#endif - -#if defined(PXX2) - case PROTO_PXX2: - disable_module_timer(port); + disable_module_timer(EXTERNAL_MODULE); break; #endif @@ -184,15 +167,15 @@ bool setupPulses(uint8_t port) { case PROTOCOL_CHANNELS_MULTIMODULE: #endif case PROTOCOL_CHANNELS_AFHDS2A_SPI: - disable_afhds2a(port); + disable_afhds2a(INTERNAL_MODULE); break; #if !defined(PCBI6X) case PROTOCOL_CHANNELS_SBUS: - disable_serial(port); + disable_serial(EXTERNAL_MODULE); break; #endif case PROTOCOL_CHANNELS_PPM: - disable_ppm(port); + disable_ppm(EXTERNAL_MODULE); break; default: @@ -204,26 +187,11 @@ bool setupPulses(uint8_t port) { // Set up output data here switch (required_protocol) { -#if defined(PXX) - case PROTO_PXX: - setupPulsesPXX(port); - scheduleNextMixerCalculation(port, PXX_PERIOD); - break; -#endif #if !defined(PCBI6X) case PROTOCOL_CHANNELS_SBUS: - setupPulsesSbus(port); - scheduleNextMixerCalculation(port, SBUS_PERIOD); - break; -#endif - -#if defined(DSM2) - case PROTO_DSM2_LP45: - case PROTO_DSM2_DSM2: - case PROTO_DSM2_DSMX: - setupPulsesDSM2(port); - scheduleNextMixerCalculation(port, DSM2_PERIOD); + setupPulsesSbus(); + scheduleNextMixerCalculation(EXTERNAL_MODULE, SBUS_PERIOD); break; #endif @@ -242,26 +210,16 @@ bool setupPulses(uint8_t port) { break; #endif -#if defined(PXX2) - case PROTO_PXX2: - if (telemetryProtocol == PROTOCOL_TELEMETRY_FRSKY_SPORT && !init_needed) { - modulePulsesData[port].pxx2.setupFrame(port); - sportSendBuffer(modulePulsesData[port].pxx2.getData(), modulePulsesData[port].pxx2.getSize()); - } - scheduleNextMixerCalculation(port, PXX2_PERIOD); - break; -#endif - #if defined(MULTIMODULE) case PROTOCOL_CHANNELS_MULTIMODULE: - setupPulsesMultimodule(port); - scheduleNextMixerCalculation(port, MULTIMODULE_PERIOD); + setupPulsesMultimodule(EXTERNAL_MODULE); + scheduleNextMixerCalculation(EXTERNAL_MODULE, MULTIMODULE_PERIOD); break; #endif case PROTOCOL_CHANNELS_PPM: - setupPulsesPPMModule(port); - mixerSchedulerSetPeriod(port, PPM_PERIOD(port)); + setupPulsesPPMExternalModule(); + mixerSchedulerSetPeriod(EXTERNAL_MODULE, PPM_PERIOD(EXTERNAL_MODULE)); break; case PROTOCOL_CHANNELS_AFHDS2A_SPI: @@ -275,18 +233,6 @@ bool setupPulses(uint8_t port) { if (init_needed) { switch (required_protocol) { // Start new protocol hardware here -#if defined(PXX) - case PROTO_PXX: - init_pxx(port); - break; -#endif -#if defined(DSM2) - case PROTO_DSM2_LP45: - case PROTO_DSM2_DSM2: - case PROTO_DSM2_DSMX: - init_serial(port, DSM2_BAUDRATE, DSM2_PERIOD * 2000); - break; -#endif #if defined(CROSSFIRE) case PROTOCOL_CHANNELS_CROSSFIRE: @@ -296,27 +242,21 @@ bool setupPulses(uint8_t port) { break; #endif -#if defined(PXX2) - case PROTO_PXX2: - init_module_timer(port, PXX2_PERIOD, true); - break; -#endif - #if defined(MULTIMODULE) case PROTOCOL_CHANNELS_MULTIMODULE: - init_serial(port, MULTIMODULE_BAUDRATE, MULTIMODULE_PERIOD * 2000); + init_serial(EXTERNAL_MODULE, MULTIMODULE_BAUDRATE, MULTIMODULE_PERIOD * 2000); break; #endif #if !defined(PCBI6X) case PROTOCOL_CHANNELS_SBUS: - init_serial(port, SBUS_BAUDRATE, SBUS_PERIOD_HALF_US); + init_serial(EXTERNAL_MODULE, SBUS_BAUDRATE, SBUS_PERIOD_HALF_US); break; #endif case PROTOCOL_CHANNELS_PPM: - init_ppm(port); + init_ppm(EXTERNAL_MODULE); break; case PROTOCOL_CHANNELS_AFHDS2A_SPI: - init_afhds2a(port); + init_afhds2a(INTERNAL_MODULE); mixerSchedulerSetPeriod(INTERNAL_MODULE, AFHDS2A_PERIOD); break; default: diff --git a/radio/src/pulses/pulses_arm.h b/radio/src/pulses/pulses_arm.h index a6a6f9d49c..0be6c19832 100644 --- a/radio/src/pulses/pulses_arm.h +++ b/radio/src/pulses/pulses_arm.h @@ -87,31 +87,18 @@ PACK(struct CrossfirePulsesData { uint8_t length; }); -union ModulePulsesData { +// TODO Move AFHDS2A pulses here? +union InternalModulePulsesData { +#if defined(TARANIS_INTERNAL_PPM) PpmPulsesData ppm; -#if defined(PXX2) - Pxx2Pulses pxx2; #endif +} __ALIGNED(4); + +union ExternalModulePulsesData { + PpmPulsesData ppm; #if defined(CROSSFIRE) CrossfirePulsesData crossfire; #endif -#if defined(PXX) -#if defined(INTMODULE_USART) || defined(EXTMODULE_USART) - UartPxxPulses pxx_uart; -#endif -#if defined(PPM_PIN_SERIAL) - SerialPxxPulses pxx; -#elif !defined(INTMODULE_USART) || !defined(EXTMODULE_USART) - PwmPxxPulses pxx; -#endif -#endif -#if defined(DSM2) -#if defined(PPM_PIN_SERIAL) - Dsm2SerialPulsesData dsm2; -#else - Dsm2TimerPulsesData dsm2; -#endif -#endif } __ALIGNED(4); //TRACE("sizeof ModulePulsesData %d",sizeof(ModulePulsesData)); @@ -122,8 +109,8 @@ union ModulePulsesData { * sizeof(ModulePulsesData). __ALIGNED is required for sizeof(ModulePulsesData) to be a multiple of the alignment. */ -/* TODO: internal pulsedata only needs 200 bytes vs 300 bytes for external, both use 300 byte since we have a common struct */ -extern ModulePulsesData modulePulsesData[NUM_MODULES]; +extern InternalModulePulsesData intmodulePulsesData; +extern ExternalModulePulsesData extmodulePulsesData; union TrainerPulsesData { PpmPulsesData ppm; @@ -132,13 +119,13 @@ union TrainerPulsesData { extern TrainerPulsesData trainerPulsesData; extern const uint16_t CRCTable[]; -bool setupPulses(uint8_t port); +bool setupPulses(uint8_t module); void setupPulsesCrossfire(); -void setupPulsesDSM2(uint8_t port); -void setupPulsesMultimodule(uint8_t port); -void setupPulsesSbus(uint8_t port); -void setupPulsesPXX(uint8_t port); -void setupPulsesPPMModule(uint8_t port); +void setupPulsesDSM2(); +void setupPulsesMultimodule(); +void setupPulsesSbus(); +void setupPulsesPXX(); +void setupPulsesPPMExternalModule(); void setupPulsesPPMTrainer(); void sendByteDsm2(uint8_t b); void putDsm2Flush(); diff --git a/radio/src/pulses/sbus_arm.cpp b/radio/src/pulses/sbus_arm.cpp index 5824f17fe2..9b2ba113fa 100644 --- a/radio/src/pulses/sbus_arm.cpp +++ b/radio/src/pulses/sbus_arm.cpp @@ -48,14 +48,14 @@ static void _send_level(uint8_t v) { /* Copied over from DSM, this looks doubious and in my logic analyzer output the low->high is about 2 ns late */ - if (modulePulsesData[EXTERNAL_MODULE].dsm2.index & 1) + if (extmodulePulsesData.dsm2.index & 1) v += 2; else v -= 2; - *modulePulsesData[EXTERNAL_MODULE].dsm2.ptr++ = v - 1; - modulePulsesData[EXTERNAL_MODULE].dsm2.index+=1; - modulePulsesData[EXTERNAL_MODULE].dsm2.rest -=v; + *extmodulePulsesData.dsm2.ptr++ = v - 1; + extmodulePulsesData.dsm2.index+=1; + extmodulePulsesData.dsm2.rest -=v; } void sendByteSbus(uint8_t b) //max 11 changes 0 10 10 10 10 P 1 @@ -107,17 +107,17 @@ inline int getChannelValue(uint8_t port, int channel) return channelOutputs[ch] + 2 * PPM_CH_CENTER(ch) - 2*PPM_CENTER; } -void setupPulsesSbus(uint8_t port) +void setupPulsesSbus() { #if defined(PPM_PIN_SERIAL) - modulePulsesData[EXTERNAL_MODULE].dsm2.serialByte = 0; - modulePulsesData[EXTERNAL_MODULE].dsm2.serialBitCount = 0; + extmodulePulsesData.dsm2.serialByte = 0; + extmodulePulsesData.dsm2.serialBitCount = 0; #else - modulePulsesData[EXTERNAL_MODULE].dsm2.rest = SBUS_PERIOD_HALF_US; - modulePulsesData[EXTERNAL_MODULE].dsm2.index = 0; + extmodulePulsesData.dsm2.rest = SBUS_PERIOD_HALF_US; + extmodulePulsesData.dsm2.index = 0; #endif - modulePulsesData[EXTERNAL_MODULE].dsm2.ptr = modulePulsesData[EXTERNAL_MODULE].dsm2.pulses; + extmodulePulsesData.dsm2.ptr = extmodulePulsesData.dsm2.pulses; // Sync Byte sendByteSbus(SBUS_FRAME_BEGIN_BYTE); @@ -127,7 +127,7 @@ void setupPulsesSbus(uint8_t port) // byte 1-22, channels 0..2047, limits not really clear (B for (int i=0; i 0) + if (getChannelValue(EXTERNAL_MODULE, 16) > 0) flags |=SBUS_FLAG_CHANNEL_17; - if (getChannelValue(port, 17) > 0) + if (getChannelValue(EXTERNAL_MODULE, 17) > 0) flags |=SBUS_FLAG_CHANNEL_18; sendByteSbus(flags); diff --git a/radio/src/targets/common/arm/stm32/intmodule_serial_driver.cpp b/radio/src/targets/common/arm/stm32/intmodule_serial_driver.cpp index 65d80cf108..cc3ff546a1 100755 --- a/radio/src/targets/common/arm/stm32/intmodule_serial_driver.cpp +++ b/radio/src/targets/common/arm/stm32/intmodule_serial_driver.cpp @@ -130,8 +130,8 @@ void intmoduleSendNextFrame() DMA_InitStructure.DMA_Channel = INTMODULE_DMA_CHANNEL; DMA_InitStructure.DMA_PeripheralBaseAddr = CONVERT_PTR_UINT(&INTMODULE_USART->DR); DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; - DMA_InitStructure.DMA_Memory0BaseAddr = CONVERT_PTR_UINT(modulePulsesData[INTERNAL_MODULE].pxx_uart.getData()); - DMA_InitStructure.DMA_BufferSize = modulePulsesData[INTERNAL_MODULE].pxx_uart.getSize(); + DMA_InitStructure.DMA_Memory0BaseAddr = CONVERT_PTR_UINT(intmodulePulsesData.pxx_uart.getData()); + DMA_InitStructure.DMA_BufferSize = intmodulePulsesData.pxx_uart.getSize(); DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; diff --git a/radio/src/targets/flysky/board.h b/radio/src/targets/flysky/board.h index 12e37883df..d45a1ac19c 100644 --- a/radio/src/targets/flysky/board.h +++ b/radio/src/targets/flysky/board.h @@ -203,17 +203,13 @@ void init_no_pulses(uint32_t port); void disable_no_pulses(uint32_t port); void init_ppm( uint32_t module_index ); void disable_ppm( uint32_t module_index ); -void init_pxx( uint32_t module_index ); -void disable_pxx( uint32_t module_index ); void init_serial( uint32_t module_index, uint32_t baudrate, uint32_t period); void disable_serial( uint32_t module_index); void init_module_timer( uint32_t module_index, uint32_t period, uint8_t state); void disable_module_timer( uint32_t module_index); -//jsut to allow compilation -void setupPulsesSbus(uint8_t port); +//just to allow compilation void extmoduleSendNextFrame(); -//void intmoduleSendNextFrame(); // Trainer driver #define SLAVE_MODE() (false) // (g_model.trainerMode == TRAINER_MODE_SLAVE) diff --git a/radio/src/targets/flysky/extmodule_driver.cpp b/radio/src/targets/flysky/extmodule_driver.cpp index 731a9b19bc..ee2bbe9c05 100644 --- a/radio/src/targets/flysky/extmodule_driver.cpp +++ b/radio/src/targets/flysky/extmodule_driver.cpp @@ -129,20 +129,20 @@ inline void extmoduleSendNextFrame() { static bool delay = true; static uint16_t delay_halfus = GET_PPM_DELAY(EXTERNAL_MODULE) * 2; if (moduleState[EXTERNAL_MODULE].protocol == PROTOCOL_CHANNELS_PPM) { - //TRACE("modulePulsesData[EXTERNAL_MODULE].ppm: %p",(void*)&modulePulsesData[EXTERNAL_MODULE].ppm); - //DUMP((uint8_t*)(modulePulsesData[EXTERNAL_MODULE].ppm.pulses), 40); - static uint16_t *pulsePtr = modulePulsesData[EXTERNAL_MODULE].ppm.ptr; + //TRACE("extmodulePulsesData.ppm: %p",(void*)&extmodulePulsesData.ppm); + //DUMP((uint8_t*)(extmodulePulsesData.ppm.pulses), 40); + static uint16_t *pulsePtr = extmodulePulsesData.ppm.ptr; if (*pulsePtr != 0) { if (delay) { EXTMODULE_TIMER->CCR2 = EXTMODULE_TIMER->CCR2 + delay_halfus; } else { - //TRACE("ptr %d val %d", (uint8_t)(pulsePtr - modulePulsesData[EXTERNAL_MODULE].ppm.pulses), *pulsePtr); + //TRACE("ptr %d val %d", (uint8_t)(pulsePtr - extmodulePulsesData.ppm.pulses), *pulsePtr); EXTMODULE_TIMER->CCR2 = EXTMODULE_TIMER->CCR2 + *pulsePtr - delay_halfus; pulsePtr += 1; } } else { - pulsePtr = modulePulsesData[EXTERNAL_MODULE].ppm.pulses; + pulsePtr = extmodulePulsesData.ppm.pulses; // polarity 1 + // polarity 0 - EXTMODULE_TIMER->CCER = TIM_CCER_CC2E | (GET_PPM_POLARITY(EXTERNAL_MODULE) ? 0 : TIM_CCER_CC2P); @@ -153,10 +153,10 @@ inline void extmoduleSendNextFrame() { delay = !delay; #if defined(CROSSFIRE) } else if (moduleState[EXTERNAL_MODULE].protocol == PROTOCOL_CHANNELS_CROSSFIRE) { - if (modulePulsesData[EXTERNAL_MODULE].crossfire.length > 0) { + if (extmodulePulsesData.crossfire.length > 0) { sportSendBuffer( - modulePulsesData[EXTERNAL_MODULE].crossfire.pulses, - modulePulsesData[EXTERNAL_MODULE].crossfire.length); + extmodulePulsesData.crossfire.pulses, + extmodulePulsesData.crossfire.length); } #endif } else { diff --git a/radio/src/targets/flysky/pulses_driver.cpp b/radio/src/targets/flysky/pulses_driver.cpp index 14ed0f0df7..a888967e8e 100644 --- a/radio/src/targets/flysky/pulses_driver.cpp +++ b/radio/src/targets/flysky/pulses_driver.cpp @@ -76,9 +76,7 @@ void disable_no_pulses(uint32_t port) { } } -void init_sbusOut(uint32_t module_index) {} -void disable_sbusOut(uint32_t module_index) {} -void setupPulsesSbus(uint8_t port) {} +void setupPulsesSbus() {} void init_serial(uint32_t port, uint32_t baudrate, uint32_t period_half_us) { } diff --git a/radio/src/targets/horus/extmodule_driver.cpp b/radio/src/targets/horus/extmodule_driver.cpp index 1bf2e3c018..a2bcd97046 100644 --- a/radio/src/targets/horus/extmodule_driver.cpp +++ b/radio/src/targets/horus/extmodule_driver.cpp @@ -219,23 +219,23 @@ void extmoduleSendNextFrame() #if defined(PCBX10) || PCBREV >= 13 EXTMODULE_TIMER->CCR3 = GET_PPM_DELAY(EXTERNAL_MODULE)*2; EXTMODULE_TIMER->CCER = TIM_CCER_CC3E | (GET_PPM_POLARITY(EXTERNAL_MODULE) ? TIM_CCER_CC3P : 0); - EXTMODULE_TIMER->CCR2 = *(modulePulsesData[EXTERNAL_MODULE].ppm.ptr - 1) - 4000; // 2mS in advance + EXTMODULE_TIMER->CCR2 = *(extmodulePulsesData.ppm.ptr - 1) - 4000; // 2mS in advance EXTMODULE_DMA_STREAM->CR &= ~DMA_SxCR_EN; // Disable DMA EXTMODULE_DMA_STREAM->CR |= EXTMODULE_DMA_CHANNEL | DMA_SxCR_DIR_0 | DMA_SxCR_MINC | DMA_SxCR_PSIZE_0 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PL_0 | DMA_SxCR_PL_1; #else EXTMODULE_TIMER->CCR1 = GET_PPM_DELAY(EXTERNAL_MODULE)*2; EXTMODULE_TIMER->CCER = TIM_CCER_CC1E | (GET_PPM_POLARITY(EXTERNAL_MODULE) ? TIM_CCER_CC1P : 0); - EXTMODULE_TIMER->CCR2 = *(modulePulsesData[EXTERNAL_MODULE].ppm.ptr - 1) - 4000; // 2mS in advance + EXTMODULE_TIMER->CCR2 = *(extmodulePulsesData.ppm.ptr - 1) - 4000; // 2mS in advance EXTMODULE_DMA_STREAM->CR &= ~DMA_SxCR_EN; // Disable DMA EXTMODULE_DMA_STREAM->CR |= EXTMODULE_DMA_CHANNEL | DMA_SxCR_DIR_0 | DMA_SxCR_MINC | DMA_SxCR_PSIZE_1 | DMA_SxCR_MSIZE_1 | DMA_SxCR_PL_0 | DMA_SxCR_PL_1; #endif EXTMODULE_DMA_STREAM->PAR = CONVERT_PTR_UINT(&EXTMODULE_TIMER->ARR); - EXTMODULE_DMA_STREAM->M0AR = CONVERT_PTR_UINT(modulePulsesData[EXTERNAL_MODULE].ppm.pulses); - EXTMODULE_DMA_STREAM->NDTR = modulePulsesData[EXTERNAL_MODULE].ppm.ptr - modulePulsesData[EXTERNAL_MODULE].ppm.pulses; + EXTMODULE_DMA_STREAM->M0AR = CONVERT_PTR_UINT(extmodulePulsesData.ppm.pulses); + EXTMODULE_DMA_STREAM->NDTR = extmodulePulsesData.ppm.ptr - extmodulePulsesData.ppm.pulses; EXTMODULE_DMA_STREAM->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE; // Enable DMA } else if (moduleState[EXTERNAL_MODULE].protocol == PROTO_PXX) { - EXTMODULE_TIMER->CCR2 = modulePulsesData[EXTERNAL_MODULE].pxx.getLast() - 4000; // 2mS in advance + EXTMODULE_TIMER->CCR2 = extmodulePulsesData.pxx.getLast() - 4000; // 2mS in advance EXTMODULE_DMA_STREAM->CR &= ~DMA_SxCR_EN; // Disable DMA #if defined(PCBX10) || PCBREV >= 13 EXTMODULE_DMA_STREAM->CR |= EXTMODULE_DMA_CHANNEL | DMA_SxCR_DIR_0 | DMA_SxCR_MINC | DMA_SxCR_PSIZE_0 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PL_0 | DMA_SxCR_PL_1; @@ -243,12 +243,12 @@ void extmoduleSendNextFrame() EXTMODULE_DMA_STREAM->CR |= EXTMODULE_DMA_CHANNEL | DMA_SxCR_DIR_0 | DMA_SxCR_MINC | DMA_SxCR_PSIZE_1 | DMA_SxCR_MSIZE_1 | DMA_SxCR_PL_0 | DMA_SxCR_PL_1; #endif EXTMODULE_DMA_STREAM->PAR = CONVERT_PTR_UINT(&EXTMODULE_TIMER->ARR); - EXTMODULE_DMA_STREAM->M0AR = CONVERT_PTR_UINT(modulePulsesData[EXTERNAL_MODULE].pxx.getData()); - EXTMODULE_DMA_STREAM->NDTR = modulePulsesData[EXTERNAL_MODULE].pxx.getSize(); + EXTMODULE_DMA_STREAM->M0AR = CONVERT_PTR_UINT(extmodulePulsesData.pxx.getData()); + EXTMODULE_DMA_STREAM->NDTR = extmodulePulsesData.pxx.getSize(); EXTMODULE_DMA_STREAM->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE; // Enable DMA } else if (IS_DSM2_PROTOCOL(moduleState[EXTERNAL_MODULE].protocol) || IS_MULTIMODULE_PROTOCOL(moduleState[EXTERNAL_MODULE].protocol) || IS_SBUS_PROTOCOL(moduleState[EXTERNAL_MODULE].protocol)) { - EXTMODULE_TIMER->CCR2 = *(modulePulsesData[EXTERNAL_MODULE].dsm2.ptr - 1) - 4000; // 2mS in advance + EXTMODULE_TIMER->CCR2 = *(extmodulePulsesData.dsm2.ptr - 1) - 4000; // 2mS in advance EXTMODULE_DMA_STREAM->CR &= ~DMA_SxCR_EN; // Disable DMA #if defined(PCBX10) || PCBREV >= 13 EXTMODULE_DMA_STREAM->CR |= EXTMODULE_DMA_CHANNEL | DMA_SxCR_DIR_0 | DMA_SxCR_MINC | DMA_SxCR_PSIZE_0 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PL_0 | DMA_SxCR_PL_1; @@ -260,8 +260,8 @@ void extmoduleSendNextFrame() EXTMODULE_TIMER->CCER = TIM_CCER_CC1E | (GET_SBUS_POLARITY(EXTERNAL_MODULE) ? TIM_CCER_CC1P : 0); // reverse polarity for Sbus if needed #endif EXTMODULE_DMA_STREAM->PAR = CONVERT_PTR_UINT(&EXTMODULE_TIMER->ARR); - EXTMODULE_DMA_STREAM->M0AR = CONVERT_PTR_UINT(modulePulsesData[EXTERNAL_MODULE].dsm2.pulses); - EXTMODULE_DMA_STREAM->NDTR = modulePulsesData[EXTERNAL_MODULE].dsm2.ptr - modulePulsesData[EXTERNAL_MODULE].dsm2.pulses; + EXTMODULE_DMA_STREAM->M0AR = CONVERT_PTR_UINT(extmodulePulsesData.dsm2.pulses); + EXTMODULE_DMA_STREAM->NDTR = extmodulePulsesData.dsm2.ptr - extmodulePulsesData.dsm2.pulses; EXTMODULE_DMA_STREAM->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE; // Enable DMA } else { diff --git a/radio/src/targets/taranis/extmodule_driver.cpp b/radio/src/targets/taranis/extmodule_driver.cpp index c2b7be8939..969df52347 100644 --- a/radio/src/targets/taranis/extmodule_driver.cpp +++ b/radio/src/targets/taranis/extmodule_driver.cpp @@ -241,12 +241,12 @@ void extmoduleSendNextFrame() if (moduleState[EXTERNAL_MODULE].protocol == PROTOCOL_CHANNELS_PPM) { EXTMODULE_TIMER->CCR1 = GET_PPM_DELAY(EXTERNAL_MODULE)*2; EXTMODULE_TIMER->CCER = EXTMODULE_TIMER_OUTPUT_ENABLE | (GET_PPM_POLARITY(EXTERNAL_MODULE) ? EXTMODULE_TIMER_OUTPUT_POLARITY : 0); // // we are using complementary output so logic has to be reversed here - EXTMODULE_TIMER->CCR2 = *(modulePulsesData[EXTERNAL_MODULE].ppm.ptr - 1) - 4000; // 2mS in advance + EXTMODULE_TIMER->CCR2 = *(extmodulePulsesData.ppm.ptr - 1) - 4000; // 2mS in advance EXTMODULE_TIMER_DMA_STREAM->CR &= ~DMA_SxCR_EN; // Disable DMA EXTMODULE_TIMER_DMA_STREAM->CR |= EXTMODULE_TIMER_DMA_CHANNEL | DMA_SxCR_DIR_0 | DMA_SxCR_MINC | DMA_SxCR_PSIZE_0 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PL_0 | DMA_SxCR_PL_1; EXTMODULE_TIMER_DMA_STREAM->PAR = CONVERT_PTR_UINT(&EXTMODULE_TIMER->ARR); - EXTMODULE_TIMER_DMA_STREAM->M0AR = CONVERT_PTR_UINT(modulePulsesData[EXTERNAL_MODULE].ppm.pulses); - EXTMODULE_TIMER_DMA_STREAM->NDTR = modulePulsesData[EXTERNAL_MODULE].ppm.ptr - modulePulsesData[EXTERNAL_MODULE].ppm.pulses; + EXTMODULE_TIMER_DMA_STREAM->M0AR = CONVERT_PTR_UINT(extmodulePulsesData.ppm.pulses); + EXTMODULE_TIMER_DMA_STREAM->NDTR = extmodulePulsesData.ppm.ptr - extmodulePulsesData.ppm.pulses; EXTMODULE_TIMER_DMA_STREAM->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE; // Enable DMA } else if (moduleState[EXTERNAL_MODULE].protocol == PROTO_PXX) { @@ -256,8 +256,8 @@ void extmoduleSendNextFrame() DMA_InitStructure.DMA_Channel = EXTMODULE_USART_DMA_CHANNEL; DMA_InitStructure.DMA_PeripheralBaseAddr = CONVERT_PTR_UINT(&EXTMODULE_USART->DR); DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; - DMA_InitStructure.DMA_Memory0BaseAddr = CONVERT_PTR_UINT(modulePulsesData[EXTERNAL_MODULE].pxx_uart.getData()); - DMA_InitStructure.DMA_BufferSize = modulePulsesData[EXTERNAL_MODULE].pxx_uart.getSize(); + DMA_InitStructure.DMA_Memory0BaseAddr = CONVERT_PTR_UINT(extmodulePulsesData.pxx_uart.getData()); + DMA_InitStructure.DMA_BufferSize = extmodulePulsesData.pxx_uart.getSize(); DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; @@ -273,24 +273,24 @@ void extmoduleSendNextFrame() USART_DMACmd(EXTMODULE_USART, USART_DMAReq_Tx, ENABLE); EXTMODULE_TIMER->DIER |= TIM_DIER_CC2IE; #else - EXTMODULE_TIMER->CCR2 = modulePulsesData[EXTERNAL_MODULE].pxx.getLast() - 4000; // 2mS in advance + EXTMODULE_TIMER->CCR2 = extmodulePulsesData.pxx.getLast() - 4000; // 2mS in advance EXTMODULE_TIMER_DMA_STREAM->CR &= ~DMA_SxCR_EN; // Disable DMA EXTMODULE_TIMER_DMA_STREAM->CR |= EXTMODULE_TIMER_DMA_CHANNEL | DMA_SxCR_DIR_0 | DMA_SxCR_MINC | DMA_SxCR_PSIZE_0 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PL_0 | DMA_SxCR_PL_1; EXTMODULE_TIMER_DMA_STREAM->PAR = CONVERT_PTR_UINT(&EXTMODULE_TIMER->ARR); - EXTMODULE_TIMER_DMA_STREAM->M0AR = CONVERT_PTR_UINT(modulePulsesData[EXTERNAL_MODULE].pxx.getData()); - EXTMODULE_TIMER_DMA_STREAM->NDTR = modulePulsesData[EXTERNAL_MODULE].pxx.getSize(); + EXTMODULE_TIMER_DMA_STREAM->M0AR = CONVERT_PTR_UINT(extmodulePulsesData.pxx.getData()); + EXTMODULE_TIMER_DMA_STREAM->NDTR = extmodulePulsesData.pxx.getSize(); EXTMODULE_TIMER_DMA_STREAM->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE; // Enable DMA #endif } else if (IS_DSM2_PROTOCOL(moduleState[EXTERNAL_MODULE].protocol) || IS_MULTIMODULE_PROTOCOL(moduleState[EXTERNAL_MODULE].protocol) || IS_SBUS_PROTOCOL(moduleState[EXTERNAL_MODULE].protocol)) { if (IS_SBUS_PROTOCOL(moduleState[EXTERNAL_MODULE].protocol)) EXTMODULE_TIMER->CCER = EXTMODULE_TIMER_OUTPUT_ENABLE | (GET_SBUS_POLARITY(EXTERNAL_MODULE) ? EXTMODULE_TIMER_OUTPUT_POLARITY : 0); // reverse polarity for Sbus if needed - EXTMODULE_TIMER->CCR2 = *(modulePulsesData[EXTERNAL_MODULE].dsm2.ptr - 1) - 4000; // 2mS in advance + EXTMODULE_TIMER->CCR2 = *(extmodulePulsesData.dsm2.ptr - 1) - 4000; // 2mS in advance EXTMODULE_TIMER_DMA_STREAM->CR &= ~DMA_SxCR_EN; // Disable DMA EXTMODULE_TIMER_DMA_STREAM->CR |= EXTMODULE_TIMER_DMA_CHANNEL | DMA_SxCR_DIR_0 | DMA_SxCR_MINC | DMA_SxCR_PSIZE_0 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PL_0 | DMA_SxCR_PL_1; EXTMODULE_TIMER_DMA_STREAM->PAR = CONVERT_PTR_UINT(&EXTMODULE_TIMER->ARR); - EXTMODULE_TIMER_DMA_STREAM->M0AR = CONVERT_PTR_UINT(modulePulsesData[EXTERNAL_MODULE].dsm2.pulses); - EXTMODULE_TIMER_DMA_STREAM->NDTR = modulePulsesData[EXTERNAL_MODULE].dsm2.ptr - modulePulsesData[EXTERNAL_MODULE].dsm2.pulses; + EXTMODULE_TIMER_DMA_STREAM->M0AR = CONVERT_PTR_UINT(extmodulePulsesData.dsm2.pulses); + EXTMODULE_TIMER_DMA_STREAM->NDTR = extmodulePulsesData.dsm2.ptr - extmodulePulsesData.dsm2.pulses; EXTMODULE_TIMER_DMA_STREAM->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE; // Enable DMA } else { diff --git a/radio/src/targets/taranis/intmodule_pulses_driver.cpp b/radio/src/targets/taranis/intmodule_pulses_driver.cpp index d8c6a9d68f..ed805ab656 100644 --- a/radio/src/targets/taranis/intmodule_pulses_driver.cpp +++ b/radio/src/targets/taranis/intmodule_pulses_driver.cpp @@ -61,24 +61,24 @@ void intmoduleNoneStart() void intmoduleSendNextFrame() { if (moduleState[INTERNAL_MODULE].protocol == PROTO_PXX) { - INTMODULE_TIMER->CCR2 = modulePulsesData[INTERNAL_MODULE].pxx.getLast() - 4000; // 2mS in advance + INTMODULE_TIMER->CCR2 = intmodulePulsesData.pxx.getLast() - 4000; // 2mS in advance INTMODULE_DMA_STREAM->CR &= ~DMA_SxCR_EN; // Disable DMA INTMODULE_DMA_STREAM->CR |= INTMODULE_DMA_CHANNEL | DMA_SxCR_DIR_0 | DMA_SxCR_MINC | DMA_SxCR_PSIZE_0 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PL_0 | DMA_SxCR_PL_1; INTMODULE_DMA_STREAM->PAR = CONVERT_PTR_UINT(&INTMODULE_TIMER->ARR); - INTMODULE_DMA_STREAM->M0AR = CONVERT_PTR_UINT(modulePulsesData[INTERNAL_MODULE].pxx.getData()); - INTMODULE_DMA_STREAM->NDTR = modulePulsesData[INTERNAL_MODULE].pxx.getSize(); + INTMODULE_DMA_STREAM->M0AR = CONVERT_PTR_UINT(intmodulePulsesData.pxx.getData()); + INTMODULE_DMA_STREAM->NDTR = intmodulePulsesData.pxx.getSize(); INTMODULE_DMA_STREAM->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE; // Enable DMA } #if defined(TARANIS_INTERNAL_PPM) else if (moduleState[INTERNAL_MODULE].protocol == PROTOCOL_CHANNELS_PPM) { INTMODULE_TIMER->CCR3 = GET_PPM_DELAY(INTERNAL_MODULE)*2; INTMODULE_TIMER->CCER = TIM_CCER_CC3E | (GET_PPM_POLARITY(INTERNAL_MODULE) ? 0 : TIM_CCER_CC3P); - INTMODULE_TIMER->CCR2 = *(modulePulsesData[INTERNAL_MODULE].ppm.ptr - 1) - 4000; // 2mS in advance + INTMODULE_TIMER->CCR2 = *(intmodulePulsesData.ppm.ptr - 1) - 4000; // 2mS in advance INTMODULE_DMA_STREAM->CR &= ~DMA_SxCR_EN; // Disable DMA INTMODULE_DMA_STREAM->CR |= INTMODULE_DMA_CHANNEL | DMA_SxCR_DIR_0 | DMA_SxCR_MINC | DMA_SxCR_PSIZE_0 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PL_0 | DMA_SxCR_PL_1; INTMODULE_DMA_STREAM->PAR = CONVERT_PTR_UINT(&INTMODULE_TIMER->ARR); - INTMODULE_DMA_STREAM->M0AR = CONVERT_PTR_UINT(modulePulsesData[INTERNAL_MODULE].ppm.pulses); - INTMODULE_DMA_STREAM->NDTR = modulePulsesData[INTERNAL_MODULE].ppm.ptr - modulePulsesData[INTERNAL_MODULE].ppm.pulses; + INTMODULE_DMA_STREAM->M0AR = CONVERT_PTR_UINT(intmodulePulsesData.ppm.pulses); + INTMODULE_DMA_STREAM->NDTR = intmodulePulsesData.ppm.ptr - intmodulePulsesData.ppm.pulses; INTMODULE_DMA_STREAM->CR |= DMA_SxCR_EN | DMA_SxCR_TCIE; // Enable DMA } #endif diff --git a/radio/src/telemetry/multi.cpp b/radio/src/telemetry/multi.cpp index 35ccbe517f..377f092b2d 100644 --- a/radio/src/telemetry/multi.cpp +++ b/radio/src/telemetry/multi.cpp @@ -90,7 +90,7 @@ static void processMultiSyncPacket(const uint8_t *data) multiSyncStatus.calcAdjustedRefreshRate(data[0] << 8 | data[1], data[2] << 8 | data[3]); #if !defined(PPM_PIN_SERIAL) - TRACE("MP ADJ: rest: %d, lag %04d, diff: %04d target: %d, interval: %d, Refresh: %d, intAdjRefresh: %d, adjRefresh %d\r\n", modulePulsesData[EXTERNAL_MODULE].dsm2.rest, + TRACE("MP ADJ: rest: %d, lag %04d, diff: %04d target: %d, interval: %d, Refresh: %d, intAdjRefresh: %d, adjRefresh %d\r\n", extmodulePulsesData.dsm2.rest, multiSyncStatus.inputLag, oldlag-multiSyncStatus.inputLag, multiSyncStatus.target, multiSyncStatus.interval, multiSyncStatus.refreshRate, multiSyncStatus.adjustedRefreshRate/50, multiSyncStatus.getAdjustedRefreshRate()); #endif