1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-19 14:25:11 +03:00

More work on pulses ...

This commit is contained in:
Bertrand Songis 2019-02-05 11:47:04 +01:00
parent 53bb46ef81
commit 9aa75b1056
19 changed files with 261 additions and 222 deletions

View file

@ -28,7 +28,7 @@ extern uint8_t cliTracesEnabled;
#ifdef __cplusplus
#include "fifo.h"
extern Fifo<uint8_t, 256> cliRxFifo;
#include "tasks_arm.h"
#include "tasks.h"
extern RTOS_TASK_HANDLE cliTaskId;
extern RTOS_DEFINE_STACK(cliStack, CLI_STACK_SIZE);
#endif

View file

@ -1907,7 +1907,6 @@ void opentxInit(OPENTX_INIT_ARGS)
init_trainer_capture();
#endif
startPulses();
wdt_enable(WDTO_500MS);

View file

@ -657,7 +657,7 @@ uint16_t isqrt32(uint32_t n);
#define pauseMixerCalculations()
#define resumeMixerCalculations()
#else
#include "tasks_arm.h"
#include "tasks.h"
extern RTOS_MUTEX_HANDLE mixerMutex;
inline void pauseMixerCalculations()
{
@ -1040,7 +1040,7 @@ enum AUDIO_SOUNDS {
};
#if defined(AUDIO)
#include "audio_arm.h"
#include "audio.h"
#endif
#include "buzzer.h"

View file

@ -48,7 +48,7 @@ uint8_t getRequiredProtocol(uint8_t port)
break;
#endif
case MODULE_TYPE_XJT:
required_protocol = PROTOCOL_CHANNELS_PXX;
required_protocol = PROTOCOL_CHANNELS_PXX2;
break;
default:
required_protocol = PROTOCOL_CHANNELS_NONE;
@ -139,58 +139,118 @@ void setupPulsesPXX(uint8_t port)
#endif
}
void setupPulses(uint8_t port)
void setupPulsesPXX2(uint8_t module)
{
bool init_needed = false;
uint8_t required_protocol = getRequiredProtocol(port);
if (module == INTERNAL_MODULE) {
modulePulsesData[module].pxx2.setupFrame(module);
intmoduleSendNextFrame();
}
heartbeat |= (HEART_TIMER_PULSES << port);
#if 0
// here we have to wait that telemetryInit() is called, hence this test
if (telemetryProtocol == PROTOCOL_TELEMETRY_PXX2) {
modulePulsesData[port].pxx2.setupFrame(port);
sportSendBuffer(modulePulsesData[port].pxx2.getData(), modulePulsesData[port].pxx2.getSize());
}
#endif
}
if (s_current_protocol[port] != required_protocol) {
init_needed = true;
switch (s_current_protocol[port]) { // stop existing protocol hardware
case PROTOCOL_CHANNELS_PXX:
disable_pxx(port);
break;
void disablePulses(uint8_t port, uint8_t protocol)
{
// stop existing protocol hardware
switch (protocol) {
case PROTOCOL_CHANNELS_PXX:
disable_pxx(port);
break;
#if defined(DSM2)
case PROTOCOL_CHANNELS_DSM2_LP45:
case PROTOCOL_CHANNELS_DSM2_DSM2:
case PROTOCOL_CHANNELS_DSM2_DSMX:
disable_serial(port);
break;
case PROTOCOL_CHANNELS_DSM2_LP45:
case PROTOCOL_CHANNELS_DSM2_DSM2:
case PROTOCOL_CHANNELS_DSM2_DSMX:
disable_serial(port);
break;
#endif
#if defined(CROSSFIRE)
case PROTOCOL_CHANNELS_CROSSFIRE:
disable_module_timer(port);
break;
case PROTOCOL_CHANNELS_CROSSFIRE:
disable_module_timer(port);
break;
#endif
case PROTOCOL_CHANNELS_PXX2:
disable_module_timer(port);
break;
case PROTOCOL_CHANNELS_PXX2:
disable_pxx2(port);
break;
#if defined(MULTIMODULE)
case PROTOCOL_CHANNELS_MULTIMODULE:
#endif
case PROTOCOL_CHANNELS_SBUS:
disable_serial(port);
break;
case PROTOCOL_CHANNELS_SBUS:
disable_serial(port);
break;
case PROTOCOL_CHANNELS_PPM:
disable_ppm(port);
break;
case PROTOCOL_CHANNELS_PPM:
disable_ppm(port);
break;
default:
disable_no_pulses(port);
break;
}
s_current_protocol[port] = required_protocol;
default:
disable_no_pulses(port);
break;
}
}
// Set up output data here
switch (required_protocol) {
void enablePulses(uint8_t port, uint8_t protocol)
{
// start new protocol hardware here
#warning "CHECK THAT ALL PROTOCOL INIT WON'T SEND A FIRST WRONG FRAME HERE"
switch (protocol) {
case PROTOCOL_CHANNELS_PXX:
init_pxx(port);
break;
#if defined(DSM2)
case PROTOCOL_CHANNELS_DSM2_LP45:
case PROTOCOL_CHANNELS_DSM2_DSM2:
case PROTOCOL_CHANNELS_DSM2_DSMX:
init_serial(port, DSM2_BAUDRATE, DSM2_PERIOD * 2000);
break;
#endif
#if defined(CROSSFIRE)
case PROTOCOL_CHANNELS_CROSSFIRE:
init_module_timer(port, CROSSFIRE_PERIOD, true);
break;
#endif
case PROTOCOL_CHANNELS_PXX2:
init_pxx2(port);
break;
#if defined(MULTIMODULE)
case PROTOCOL_CHANNELS_MULTIMODULE:
init_serial(port, MULTIMODULE_BAUDRATE, MULTIMODULE_PERIOD * 2000);
break;
#endif
case PROTOCOL_CHANNELS_SBUS:
init_serial(port, SBUS_BAUDRATE, SBUS_PERIOD_HALF_US);
break;
case PROTOCOL_CHANNELS_PPM:
init_ppm(port);
break;
default:
init_no_pulses(port);
break;
}
}
void sendPulses(uint8_t port, uint8_t protocol)
{
switch (protocol) {
case PROTOCOL_CHANNELS_PXX:
setupPulsesPXX(port);
scheduleNextMixerCalculation(port, PXX_PERIOD);
@ -212,7 +272,7 @@ void setupPulses(uint8_t port)
#if defined(CROSSFIRE)
case PROTOCOL_CHANNELS_CROSSFIRE:
if (telemetryProtocol == PROTOCOL_TELEMETRY_CROSSFIRE && !init_needed) {
if (telemetryProtocol == PROTOCOL_TELEMETRY_CROSSFIRE) {
uint8_t * crossfire = modulePulsesData[port].crossfire.pulses;
uint8_t len;
#if defined(LUA)
@ -234,11 +294,7 @@ void setupPulses(uint8_t port)
#endif
case PROTOCOL_CHANNELS_PXX2:
// here we have to wait that telemetryInit() is called, hence this test
if (telemetryProtocol == PROTOCOL_TELEMETRY_PXX2 && !init_needed) {
modulePulsesData[port].pxx2.setupFrame(port);
sportSendBuffer(modulePulsesData[port].pxx2.getData(), modulePulsesData[port].pxx2.getSize());
}
setupPulsesPXX2(port);
scheduleNextMixerCalculation(port, PXX2_PERIOD);
break;
@ -251,7 +307,7 @@ void setupPulses(uint8_t port)
case PROTOCOL_CHANNELS_PPM:
#if defined(PCBSKY9X)
case PROTOCOL_CHANNELS_NONE:
case PROTOCOL_CHANNELS_NONE:
#endif
setupPulsesPPMModule(port);
scheduleNextMixerCalculation(port, PPM_PERIOD(port));
@ -260,49 +316,21 @@ void setupPulses(uint8_t port)
default:
break;
}
}
if (init_needed) {
switch (required_protocol) { // Start new protocol hardware here
case PROTOCOL_CHANNELS_PXX:
init_pxx(port);
break;
void setupPulses(uint8_t module)
{
uint8_t required_protocol = getRequiredProtocol(module);
#if defined(DSM2)
case PROTOCOL_CHANNELS_DSM2_LP45:
case PROTOCOL_CHANNELS_DSM2_DSM2:
case PROTOCOL_CHANNELS_DSM2_DSMX:
init_serial(port, DSM2_BAUDRATE, DSM2_PERIOD * 2000);
break;
#endif
heartbeat |= (HEART_TIMER_PULSES << module);
#if defined(CROSSFIRE)
case PROTOCOL_CHANNELS_CROSSFIRE:
init_module_timer(port, CROSSFIRE_PERIOD, true);
break;
#endif
case PROTOCOL_CHANNELS_PXX2:
init_module_timer(port, PXX2_PERIOD, true);
break;
#if defined(MULTIMODULE)
case PROTOCOL_CHANNELS_MULTIMODULE:
init_serial(port, MULTIMODULE_BAUDRATE, MULTIMODULE_PERIOD * 2000);
break;
#endif
case PROTOCOL_CHANNELS_SBUS:
init_serial(port, SBUS_BAUDRATE, SBUS_PERIOD_HALF_US);
break;
case PROTOCOL_CHANNELS_PPM:
init_ppm(port);
break;
default:
init_no_pulses(port);
break;
}
if (s_current_protocol[module] != required_protocol) {
disablePulses(module, s_current_protocol[module]);
s_current_protocol[module] = required_protocol;
enablePulses(module, required_protocol);
}
else {
sendPulses(module, required_protocol);
}
}

View file

@ -88,9 +88,9 @@ foreach(LANGUAGE ${TTS_LANGUAGES})
endforeach()
set(SRC
${SRC}
main_arm.cpp
tasks_arm.cpp
audio_arm.cpp
main.cpp
tasks.cpp
audio.cpp
io/frsky_sport.cpp
telemetry/telemetry.cpp
telemetry/telemetry_holders.cpp

View file

@ -23,40 +23,20 @@
void intmoduleStop()
{
INTERNAL_MODULE_OFF();
NVIC_DisableIRQ(INTMODULE_TIMER_IRQn);
INTMODULE_DMA_STREAM->CR &= ~DMA_SxCR_EN; // Disable DMA
INTMODULE_TIMER->DIER &= ~TIM_DIER_CC2IE;
INTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN;
}
void intmoduleNoneStart()
{
INTERNAL_MODULE_OFF();
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = INTMODULE_TX_GPIO_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(INTMODULE_TX_GPIO, &GPIO_InitStructure);
GPIO_SetBits(INTMODULE_TX_GPIO, INTMODULE_TX_GPIO_PIN); // Set high
INTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN;
INTMODULE_TIMER->PSC = INTMODULE_TIMER_FREQ / 2000000 - 1; // 0.5uS (2Mhz)
INTMODULE_TIMER->ARR = 36000; // 18mS
INTMODULE_TIMER->CCR2 = 32000; // Update time
INTMODULE_TIMER->EGR = 1; // Restart
INTMODULE_TIMER->SR &= ~TIM_SR_CC2IF; // Clear flag
INTMODULE_TIMER->DIER |= TIM_DIER_CC2IE; // Enable this interrupt
INTMODULE_TIMER->CR1 |= TIM_CR1_CEN;
NVIC_EnableIRQ(INTMODULE_TIMER_IRQn);
NVIC_SetPriority(INTMODULE_TIMER_IRQn, 7);
}
void intmodulePxxStart()
{
// shouldn't be used anymore
}
void intmoduleTimerStart(uint32_t period, uint8_t state)
{
// shouldn't be used anymore
}
void intmodulePxx2Start()
{
INTERNAL_MODULE_ON();
@ -94,23 +74,6 @@ void intmodulePxxStart()
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(INTMODULE_USART, &USART_InitStructure);
USART_Cmd(INTMODULE_USART, ENABLE);
// Timer
INTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN;
INTMODULE_TIMER->PSC = INTMODULE_TIMER_FREQ / 2000000 - 1; // 0.5uS (2Mhz)
INTMODULE_TIMER->ARR = PXX_PERIOD_HALF_US;
INTMODULE_TIMER->CCR2 = PXX_PERIOD_HALF_US - 2000; // Update time
INTMODULE_TIMER->CCER = TIM_CCER_CC3E;
INTMODULE_TIMER->CCMR2 = 0;
INTMODULE_TIMER->EGR = 1; // Restart
INTMODULE_TIMER->CCMR2 = TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3M_0; // Toggle CC1 o/p
INTMODULE_TIMER->SR &= ~TIM_SR_CC2IF; // Clear flag
INTMODULE_TIMER->DIER |= TIM_DIER_CC2IE; // Enable this interrupt
INTMODULE_TIMER->CR1 |= TIM_CR1_CEN;
NVIC_EnableIRQ(INTMODULE_TIMER_IRQn);
NVIC_SetPriority(INTMODULE_TIMER_IRQn, 7);
}
extern "C" void INTMODULE_DMA_STREAM_IRQHandler(void)
@ -124,14 +87,14 @@ extern "C" void INTMODULE_DMA_STREAM_IRQHandler(void)
void intmoduleSendNextFrame()
{
if (s_current_protocol[INTERNAL_MODULE] == PROTOCOL_CHANNELS_PXX) {
if (s_current_protocol[INTERNAL_MODULE] == PROTOCOL_CHANNELS_PXX2) {
DMA_InitTypeDef DMA_InitStructure;
DMA_DeInit(INTMODULE_DMA_STREAM);
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(modulePulsesData[INTERNAL_MODULE].pxx2.getData());
DMA_InitStructure.DMA_BufferSize = modulePulsesData[INTERNAL_MODULE].pxx2.getSize();
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
@ -143,21 +106,7 @@ void intmoduleSendNextFrame()
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(INTMODULE_DMA_STREAM, &DMA_InitStructure);
DMA_Cmd(INTMODULE_DMA_STREAM, ENABLE);
USART_DMACmd(INTMODULE_USART, USART_DMAReq_Tx, ENABLE);
}
}
extern "C" void INTMODULE_TIMER_IRQHandler()
{
DEBUG_INTERRUPT(INT_TIM1CC);
DEBUG_TIMER_SAMPLE(debugTimerIntPulses);
DEBUG_TIMER_START(debugTimerIntPulsesDuration);
INTMODULE_TIMER->SR &= ~TIM_SR_CC2IF; // clear flag
setupPulses(INTERNAL_MODULE);
intmoduleSendNextFrame();
DEBUG_TIMER_STOP(debugTimerIntPulsesDuration);
}

View file

@ -65,7 +65,6 @@ void extmoduleTimerStart(uint32_t period, uint8_t state)
NVIC_SetPriority(EXTMODULE_TIMER_IRQn, 7);
}
void extmodulePpmStart()
{
EXTERNAL_MODULE_ON();
@ -165,6 +164,11 @@ void extmodulePxxStart()
NVIC_SetPriority(EXTMODULE_TIMER_IRQn, 7);
}
void extmodulePxx2Start()
{
// TODO just enable the S.PORT line (or let telemetry init do it)
}
#if defined(DSM2)
void extmoduleSerialStart(uint32_t /*baudrate*/, uint32_t period_half_us)
{

View file

@ -20,23 +20,20 @@
#include "opentx.h"
void intmoduleStop(void);
void extmoduleStop(void);
void intmoduleNoneStart(void);
void intmodulePxxStart(void);
void intmoduleStop();
void intmoduleTimerStart(uint32_t period, uint8_t state);
void intmodulePxxStart();
void extmoduleStop();
void extmoduleTimerStart(uint32_t period, uint8_t state);
void extmodulePpmStart(void);
void extmodulePxxStart(void);
void extmodulePpmStart();
void extmodulePxxStart();
void extmodulePxx2Start();
void extmoduleSerialStart(uint32_t baudrate, uint32_t period_half_us);
void init_no_pulses(uint32_t port)
{
if (port == INTERNAL_MODULE)
intmoduleNoneStart();
else
extmoduleTimerStart(18, false);
init_module_timer(port, 18, false);
}
void disable_no_pulses(uint32_t port)
@ -61,6 +58,14 @@ void disable_ppm(uint32_t port)
}
}
void init_pxx2(uint32_t port)
{
if (port == INTERNAL_MODULE)
intmodulePxx2Start();
else
extmodulePxx2Start();
}
void init_pxx(uint32_t port)
{
if (port == INTERNAL_MODULE)
@ -95,15 +100,17 @@ void disable_serial(uint32_t port)
void init_module_timer(uint32_t port, uint32_t period, uint8_t state)
{
if (port == EXTERNAL_MODULE) {
if (port == INTERNAL_MODULE)
intmoduleTimerStart(period, state);
else
extmoduleTimerStart(period, state);
}
}
void disable_module_timer(uint32_t port)
{
if (port == EXTERNAL_MODULE) {
if (port == INTERNAL_MODULE)
intmoduleStop();
else
extmoduleStop();
}
}

View file

@ -119,6 +119,7 @@ elseif(PCB STREQUAL XLITES)
endif()
if(PCB STREQUAL XLITE OR PCB STREQUAL XLITES)
add_definitions(-DINTERNAL_MODULE_SERIAL)
if(PXX_FREQUENCY STREQUAL HIGH)
add_definitions(-DPXX_FREQUENCY_HIGH)
endif()

View file

@ -180,16 +180,19 @@ uint32_t isBootloaderStart(const uint8_t * buffer);
#else
#define IS_UART_MODULE(port) (false)
#endif
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);
void init_no_pulses(uint8_t module);
void disable_no_pulses(uint8_t module);
void init_ppm(uint8_t module);
void disable_ppm(uint8_t module);
void intmoduleSendNextFrame();
void init_pxx2(uint8_t module);
void disable_pxx2(uint8_t module);
void init_pxx(uint8_t module);
void disable_pxx(uint8_t module);
void init_serial(uint8_t module, uint32_t baudrate, uint32_t period);
void disable_serial(uint8_t module);
void init_module_timer(uint8_t module, uint32_t period, uint8_t state);
void disable_module_timer(uint8_t module);
// Trainer driver
#define SLAVE_MODE() (g_model.trainerData.mode == TRAINER_MODE_SLAVE)

View file

@ -200,6 +200,11 @@ void extmodulePxxStart()
{
extmoduleInvertedSerialStart(EXTMODULE_USART_PXX_BAUDRATE, PXX_PERIOD_HALF_US);
}
void extmodulePxx2Start()
{
extmoduleInvertedSerialStart(EXTMODULE_USART_PXX_BAUDRATE, PXX_PERIOD_HALF_US);
}
#else
void extmodulePxxStart()
{
@ -234,6 +239,11 @@ void extmodulePxxStart()
NVIC_EnableIRQ(EXTMODULE_TIMER_CC_IRQn);
NVIC_SetPriority(EXTMODULE_TIMER_CC_IRQn, 7);
}
void extmodulePxx2Start()
{
// TODO just enable the S.PORT line (or let telemetry init do it)
}
#endif
void extmoduleSendNextFrame()

View file

@ -32,9 +32,14 @@ void intmoduleStop()
INTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN;
}
void intmoduleNoneStart()
void intmoduleTimerStart(uint32_t period, uint8_t state)
{
INTERNAL_MODULE_OFF();
if (state)
INTERNAL_MODULE_ON();
else
INTERNAL_MODULE_OFF();
GPIO_PinAFConfig(EXTMODULE_TX_GPIO, EXTMODULE_TX_GPIO_PinSource, 0);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = INTMODULE_TX_GPIO_PIN;
@ -46,9 +51,9 @@ void intmoduleNoneStart()
GPIO_SetBits(INTMODULE_TX_GPIO, INTMODULE_TX_GPIO_PIN); // Set high
INTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN;
INTMODULE_TIMER->PSC = INTMODULE_TIMER_FREQ / 2000000 - 1; // 0.5uS from 30MHz
INTMODULE_TIMER->ARR = 36000; // 18mS
INTMODULE_TIMER->CCR2 = 32000; // Update time
INTMODULE_TIMER->PSC = EXTMODULE_TIMER_FREQ / 2000000 - 1; // 0.5uS from 30MHz
INTMODULE_TIMER->ARR = (2000 * period);
INTMODULE_TIMER->CCR2 = (2000 * period) - 1000;
INTMODULE_TIMER->EGR = 1; // Restart
INTMODULE_TIMER->SR &= ~TIM_SR_CC2IF; // Clear flag
INTMODULE_TIMER->DIER |= TIM_DIER_CC2IE; // Enable this interrupt

View file

@ -20,103 +20,118 @@
#include "opentx.h"
void intmoduleStop(void);
void extmoduleStop(void);
void intmoduleNoneStart(void);
void intmodulePxxStart(void);
void intmoduleStop();
void intmoduleTimerStart(uint32_t period, uint8_t state);
void intmodulePxxStart();
void intmodulePxx2Start();
#if defined(TARANIS_INTERNAL_PPM)
void intmodulePpmStart(void);
#endif
void extmoduleStop();
void extmoduleTimerStart(uint32_t period, uint8_t state);
void extmodulePpmStart(void);
void extmodulePxxStart(void);
void extmodulePpmStart();
void extmodulePxxStart();
void extmodulePxx2Start();
void extmoduleSerialStart(uint32_t baudrate, uint32_t period_half_us);
void init_pxx(uint32_t port)
void init_pxx(uint8_t module)
{
if (port == INTERNAL_MODULE)
if (module == INTERNAL_MODULE)
intmodulePxxStart();
else
extmodulePxxStart();
}
void disable_pxx(uint32_t port)
void disable_pxx(uint8_t module)
{
if (port == INTERNAL_MODULE)
if (module == INTERNAL_MODULE)
intmoduleStop();
else
extmoduleStop();
}
void init_pxx2(uint8_t module)
{
if (module == INTERNAL_MODULE)
intmodulePxx2Start();
else
extmodulePxx2Start();
}
void disable_pxx2(uint8_t module)
{
if (module == INTERNAL_MODULE)
intmoduleStop();
else
extmoduleStop();
}
#if defined(DSM2)
void init_serial(uint32_t port, uint32_t baudrate, uint32_t period_half_us)
void init_serial(uint8_t module, uint32_t baudrate, uint32_t period_half_us)
{
if (port == EXTERNAL_MODULE) {
if (module == EXTERNAL_MODULE) {
extmoduleSerialStart(baudrate, period_half_us);
}
}
void disable_serial(uint32_t port)
void disable_serial(uint8_t module)
{
if (port == EXTERNAL_MODULE) {
if (module == EXTERNAL_MODULE) {
extmoduleStop();
}
}
#endif
void init_ppm(uint32_t port)
void init_ppm(uint8_t module)
{
if (port == EXTERNAL_MODULE) {
if (module == EXTERNAL_MODULE) {
extmodulePpmStart();
}
#if defined(TARANIS_INTERNAL_PPM)
else if (port == INTERNAL_MODULE) {
else {
intmodulePpmStart();
}
#endif
}
void disable_ppm(uint32_t port)
void disable_ppm(uint8_t module)
{
if (port == EXTERNAL_MODULE) {
if (module == EXTERNAL_MODULE) {
extmoduleStop();
}
#if defined(TARANIS_INTERNAL_PPM)
else if (port == INTERNAL_MODULE) {
else {
intmoduleStop();
}
#endif
}
void init_no_pulses(uint32_t port)
void init_no_pulses(uint8_t module)
{
if (port == INTERNAL_MODULE)
intmoduleNoneStart();
else
extmoduleTimerStart(18, false);
init_module_timer(module, 18, false);
}
void disable_no_pulses(uint32_t port)
void disable_no_pulses(uint8_t module)
{
if (port == INTERNAL_MODULE)
if (module == INTERNAL_MODULE)
intmoduleStop();
else
extmoduleStop();
}
void init_module_timer(uint32_t port, uint32_t period, uint8_t state)
void init_module_timer(uint8_t module, uint32_t period, uint8_t state)
{
if (port == EXTERNAL_MODULE) {
if (module == INTERNAL_MODULE)
intmoduleTimerStart(period, state);
else
extmoduleTimerStart(period, state);
}
}
void disable_module_timer(uint32_t port)
void disable_module_timer(uint8_t module)
{
if (port == EXTERNAL_MODULE) {
if (module == INTERNAL_MODULE)
intmoduleStop();
else
extmoduleStop();
}
}

View file

@ -73,6 +73,21 @@ bool isForcePowerOffRequested()
return false;
}
bool isProtocolSynchronous(uint8_t protocol)
{
return (protocol == PROTOCOL_CHANNELS_PXX2 || protocol == PROTOCOL_CHANNELS_NONE);
}
void sendSynchronousPulses()
{
for (uint8_t module = 0; module < NUM_MODULES; module++) {
uint8_t protocol = s_current_protocol[module];
if (isProtocolSynchronous(protocol)) {
setupPulses(module);
}
}
}
uint32_t nextMixerTime[NUM_MODULES];
TASK_FUNCTION(mixerTask)
@ -89,8 +104,9 @@ TASK_FUNCTION(mixerTask)
RTOS_WAIT_TICKS(1);
#if defined(SIMU)
if (pwrCheck() == e_power_off)
if (pwrCheck() == e_power_off) {
TASK_RETURN();
}
#else
if (isForcePowerOffRequested()) {
pwrOff();
@ -153,7 +169,9 @@ TASK_FUNCTION(mixerTask)
}
t0 = getTmr2MHz() - t0;
if (t0 > maxMixerDuration) maxMixerDuration = t0 ;
if (t0 > maxMixerDuration) maxMixerDuration = t0;
sendSynchronousPulses();
}
}
}

View file

@ -24,7 +24,7 @@ int16_t ppmInput[MAX_TRAINER_CHANNELS];
uint8_t ppmInputValidityTimer;
#include "audio_arm.h"
#include "audio.h"
void checkTrainerSignalWarning()
{