mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 01:05:10 +03:00
Allow PCBSKY9X compilation
This commit is contained in:
parent
ba887720bf
commit
78dd516069
4 changed files with 73 additions and 2 deletions
|
@ -502,6 +502,7 @@ void evalFlightModeMixes(uint8_t mode, uint8_t tick10ms);
|
||||||
void evalMixes(uint8_t tick10ms);
|
void evalMixes(uint8_t tick10ms);
|
||||||
void doMixerCalculations();
|
void doMixerCalculations();
|
||||||
void doMixerPeriodicUpdates();
|
void doMixerPeriodicUpdates();
|
||||||
|
void scheduleNextMixerCalculation(uint8_t module, uint32_t period_ms);
|
||||||
|
|
||||||
void checkTrims();
|
void checkTrims();
|
||||||
extern uint8_t currentBacklightBright;
|
extern uint8_t currentBacklightBright;
|
||||||
|
|
|
@ -241,8 +241,12 @@ void enablePulsesExternalModule(uint8_t protocol)
|
||||||
case PROTOCOL_CHANNELS_DSM2_LP45:
|
case PROTOCOL_CHANNELS_DSM2_LP45:
|
||||||
case PROTOCOL_CHANNELS_DSM2_DSM2:
|
case PROTOCOL_CHANNELS_DSM2_DSM2:
|
||||||
case PROTOCOL_CHANNELS_DSM2_DSMX:
|
case PROTOCOL_CHANNELS_DSM2_DSMX:
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
extmoduleSerialStart(DSM2_BAUDRATE, DSM2_PERIOD * 2000, false);
|
||||||
|
#else
|
||||||
extmoduleSerialStart();
|
extmoduleSerialStart();
|
||||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, DSM2_PERIOD);
|
mixerSchedulerSetPeriod(EXTERNAL_MODULE, DSM2_PERIOD);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -274,15 +278,23 @@ void enablePulsesExternalModule(uint8_t protocol)
|
||||||
|
|
||||||
#if defined(MULTIMODULE)
|
#if defined(MULTIMODULE)
|
||||||
case PROTOCOL_CHANNELS_MULTIMODULE:
|
case PROTOCOL_CHANNELS_MULTIMODULE:
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
extmoduleSerialStart(MULTIMODULE_BAUDRATE, MULTIMODULE_PERIOD * 2000, true);
|
||||||
|
#else
|
||||||
extmoduleSerialStart();
|
extmoduleSerialStart();
|
||||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, MULTIMODULE_PERIOD);
|
mixerSchedulerSetPeriod(EXTERNAL_MODULE, MULTIMODULE_PERIOD);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SBUS)
|
#if defined(SBUS)
|
||||||
case PROTOCOL_CHANNELS_SBUS:
|
case PROTOCOL_CHANNELS_SBUS:
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
extmoduleSerialStart(SBUS_BAUDRATE, SBUS_PERIOD_HALF_US, false);
|
||||||
|
#else
|
||||||
extmoduleSerialStart();
|
extmoduleSerialStart();
|
||||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, SBUS_PERIOD);
|
mixerSchedulerSetPeriod(EXTERNAL_MODULE, SBUS_PERIOD);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -314,12 +326,18 @@ bool setupPulsesExternalModule(uint8_t protocol)
|
||||||
#if defined(PXX1)
|
#if defined(PXX1)
|
||||||
case PROTOCOL_CHANNELS_PXX1_PULSES:
|
case PROTOCOL_CHANNELS_PXX1_PULSES:
|
||||||
extmodulePulsesData.pxx.setupFrame(EXTERNAL_MODULE);
|
extmodulePulsesData.pxx.setupFrame(EXTERNAL_MODULE);
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
scheduleNextMixerCalculation(EXTERNAL_MODULE, PXX_PULSES_PERIOD);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PXX1) && defined(HARDWARE_EXTERNAL_MODULE_SIZE_SML)
|
#if defined(PXX1) && defined(HARDWARE_EXTERNAL_MODULE_SIZE_SML)
|
||||||
case PROTOCOL_CHANNELS_PXX1_SERIAL:
|
case PROTOCOL_CHANNELS_PXX1_SERIAL:
|
||||||
extmodulePulsesData.pxx_uart.setupFrame(EXTERNAL_MODULE);
|
extmodulePulsesData.pxx_uart.setupFrame(EXTERNAL_MODULE);
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
scheduleNextMixerCalculation(EXTERNAL_MODULE, EXTMODULE_PXX1_SERIAL_PERIOD);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -327,13 +345,18 @@ bool setupPulsesExternalModule(uint8_t protocol)
|
||||||
case PROTOCOL_CHANNELS_PXX2_HIGHSPEED:
|
case PROTOCOL_CHANNELS_PXX2_HIGHSPEED:
|
||||||
case PROTOCOL_CHANNELS_PXX2_LOWSPEED:
|
case PROTOCOL_CHANNELS_PXX2_LOWSPEED:
|
||||||
extmodulePulsesData.pxx2.setupFrame(EXTERNAL_MODULE);
|
extmodulePulsesData.pxx2.setupFrame(EXTERNAL_MODULE);
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
sheduleNextMixerCalculation(EXTERNAL_MODULE, PXX2_PERIOD);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SBUS)
|
#if defined(SBUS)
|
||||||
case PROTOCOL_CHANNELS_SBUS:
|
case PROTOCOL_CHANNELS_SBUS:
|
||||||
setupPulsesSbus();
|
setupPulsesSbus();
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
scheduleNextMixerCalculation(EXTERNAL_MODULE, SBUS_PERIOD);
|
||||||
|
#endif
|
||||||
// SBUS_PERIOD is not a constant! It can be set from UI
|
// SBUS_PERIOD is not a constant! It can be set from UI
|
||||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, SBUS_PERIOD);
|
mixerSchedulerSetPeriod(EXTERNAL_MODULE, SBUS_PERIOD);
|
||||||
return true;
|
return true;
|
||||||
|
@ -344,6 +367,9 @@ bool setupPulsesExternalModule(uint8_t protocol)
|
||||||
case PROTOCOL_CHANNELS_DSM2_DSM2:
|
case PROTOCOL_CHANNELS_DSM2_DSM2:
|
||||||
case PROTOCOL_CHANNELS_DSM2_DSMX:
|
case PROTOCOL_CHANNELS_DSM2_DSMX:
|
||||||
setupPulsesDSM2();
|
setupPulsesDSM2();
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
scheduleNextMixerCalculation(EXTERNAL_MODULE, DSM2_PERIOD);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -356,6 +382,9 @@ bool setupPulsesExternalModule(uint8_t protocol)
|
||||||
else
|
else
|
||||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, CROSSFIRE_PERIOD);
|
mixerSchedulerSetPeriod(EXTERNAL_MODULE, CROSSFIRE_PERIOD);
|
||||||
setupPulsesCrossfire();
|
setupPulsesCrossfire();
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
scheduleNextMixerCalculation(EXTERNAL_MODULE, CROSSFIRE_PERIOD);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -369,6 +398,9 @@ bool setupPulsesExternalModule(uint8_t protocol)
|
||||||
else
|
else
|
||||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, GHOST_PERIOD);
|
mixerSchedulerSetPeriod(EXTERNAL_MODULE, GHOST_PERIOD);
|
||||||
setupPulsesGhost();
|
setupPulsesGhost();
|
||||||
|
#if defined(PCBSKPCBSKY9X)
|
||||||
|
scheduleNextMixerCalculation(EXTERNAL_MODULE, GHOST_PERIOD);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -382,6 +414,9 @@ bool setupPulsesExternalModule(uint8_t protocol)
|
||||||
else
|
else
|
||||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, MULTIMODULE_PERIOD);
|
mixerSchedulerSetPeriod(EXTERNAL_MODULE, MULTIMODULE_PERIOD);
|
||||||
setupPulsesMultiExternalModule();
|
setupPulsesMultiExternalModule();
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
scheduleNextMixerCalculation(EXTERNAL_MODULE, MULTIMODULE_PERIOD);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -389,12 +424,18 @@ bool setupPulsesExternalModule(uint8_t protocol)
|
||||||
#if defined(PPM)
|
#if defined(PPM)
|
||||||
case PROTOCOL_CHANNELS_PPM:
|
case PROTOCOL_CHANNELS_PPM:
|
||||||
setupPulsesPPMExternalModule();
|
setupPulsesPPMExternalModule();
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
scheduleNextMixerCalculation(EXTERNAL_MODULE, PPM_PERIOD(EXTERNAL_MODULE));
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(AFHDS3)
|
#if defined(AFHDS3)
|
||||||
case PROTOCOL_CHANNELS_AFHDS3:
|
case PROTOCOL_CHANNELS_AFHDS3:
|
||||||
extmodulePulsesData.afhds3.setupFrame();
|
extmodulePulsesData.afhds3.setupFrame();
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
scheduleNextMixerCalculation(EXTERNAL_MODULE, AFHDS3_COMMAND_TIMEOUT);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,9 @@ TASK_FUNCTION(mixerTask)
|
||||||
s_pulses_paused = true;
|
s_pulses_paused = true;
|
||||||
|
|
||||||
mixerSchedulerInit();
|
mixerSchedulerInit();
|
||||||
|
#if !defined(PCBSKY9X)
|
||||||
mixerSchedulerStart();
|
mixerSchedulerStart();
|
||||||
|
#endif
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
#if defined(SBUS_TRAINER)
|
#if defined(SBUS_TRAINER)
|
||||||
|
@ -142,8 +144,10 @@ TASK_FUNCTION(mixerTask)
|
||||||
GPIO_ResetBits(EXTMODULE_TX_GPIO, EXTMODULE_TX_GPIO_PIN);
|
GPIO_ResetBits(EXTMODULE_TX_GPIO, EXTMODULE_TX_GPIO_PIN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(PCBSKY9X)
|
||||||
// re-enable trigger
|
// re-enable trigger
|
||||||
mixerSchedulerEnableTrigger();
|
mixerSchedulerEnableTrigger();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
if (pwrCheck() == e_power_off) {
|
if (pwrCheck() == e_power_off) {
|
||||||
|
@ -164,7 +168,11 @@ TASK_FUNCTION(mixerTask)
|
||||||
doMixerCalculations();
|
doMixerCalculations();
|
||||||
|
|
||||||
// TODO: fix runMask
|
// TODO: fix runMask
|
||||||
|
#if defined(PCBSKY9X)
|
||||||
|
sendSynchronousPulses(1 << EXTERNAL_MODULE);
|
||||||
|
#else
|
||||||
sendSynchronousPulses((1 << INTERNAL_MODULE) | (1 << EXTERNAL_MODULE));
|
sendSynchronousPulses((1 << INTERNAL_MODULE) | (1 << EXTERNAL_MODULE));
|
||||||
|
#endif
|
||||||
|
|
||||||
doMixerPeriodicUpdates();
|
doMixerPeriodicUpdates();
|
||||||
|
|
||||||
|
@ -200,12 +208,32 @@ TASK_FUNCTION(mixerTask)
|
||||||
// TODO:
|
// TODO:
|
||||||
// - check the cause of timeouts when switching
|
// - check the cause of timeouts when switching
|
||||||
// between protocols with multi-proto RF
|
// between protocols with multi-proto RF
|
||||||
|
#if defined(DEBUG)
|
||||||
if (timeout)
|
if (timeout)
|
||||||
serialPrint("mix sched timeout!");
|
serialPrint("mix sched timeout!");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void scheduleNextMixerCalculation(uint8_t module, uint32_t period_ms)
|
||||||
|
{
|
||||||
|
// Schedule next mixer calculation time,
|
||||||
|
|
||||||
|
if (isModuleSynchronous(module)) {
|
||||||
|
nextMixerTime[module] += period_ms / RTOS_MS_PER_TICK;
|
||||||
|
if (nextMixerTime[module] < RTOS_GET_TIME()) {
|
||||||
|
// we are late ... let's add some small delay
|
||||||
|
nextMixerTime[module] = (uint32_t) RTOS_GET_TIME() + (period_ms / RTOS_MS_PER_TICK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// for now assume mixer calculation takes 2 ms.
|
||||||
|
nextMixerTime[module] = (uint32_t) RTOS_GET_TIME() + (period_ms / RTOS_MS_PER_TICK);
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG_TIMER_STOP(debugTimerMixerCalcToUsage);
|
||||||
|
}
|
||||||
|
|
||||||
#define MENU_TASK_PERIOD_TICKS (50 / RTOS_MS_PER_TICK) // 50ms
|
#define MENU_TASK_PERIOD_TICKS (50 / RTOS_MS_PER_TICK) // 50ms
|
||||||
|
|
||||||
|
|
|
@ -252,8 +252,9 @@ static void processMultiSyncPacket(const uint8_t * data, uint8_t module)
|
||||||
// inputLag -= refreshRate;
|
// inputLag -= refreshRate;
|
||||||
|
|
||||||
status.update(refreshRate, inputLag);
|
status.update(refreshRate, inputLag);
|
||||||
|
#if defined(DEBUG)
|
||||||
serialPrint("MP ADJ: R %d, L %04d", refreshRate, inputLag);
|
serialPrint("MP ADJ: R %d, L %04d", refreshRate, inputLag);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PCBTARANIS) || defined(PCBHORUS)
|
#if defined(PCBTARANIS) || defined(PCBHORUS)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue