mirror of
https://github.com/opentx/opentx.git
synced 2025-07-19 14:25:11 +03:00
Taranis internal module fix
This commit is contained in:
parent
8c9ba8d1e5
commit
aef7a1074f
6 changed files with 10 additions and 109 deletions
|
@ -149,7 +149,7 @@ void disablePulses(uint8_t module, uint8_t protocol)
|
|||
|
||||
#if defined(CROSSFIRE)
|
||||
case PROTOCOL_CHANNELS_CROSSFIRE:
|
||||
disable_module_timer(module);
|
||||
// TODO disable_module_timer(module);
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
@ -167,10 +167,6 @@ void disablePulses(uint8_t module, uint8_t protocol)
|
|||
case PROTOCOL_CHANNELS_PPM:
|
||||
disable_ppm(module);
|
||||
break;
|
||||
|
||||
default:
|
||||
disable_no_pulses(module);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,7 +191,7 @@ void enablePulses(uint8_t module, uint8_t protocol)
|
|||
|
||||
#if defined(CROSSFIRE)
|
||||
case PROTOCOL_CHANNELS_CROSSFIRE:
|
||||
init_module_timer(module, CROSSFIRE_PERIOD, true);
|
||||
// TODO init_module_timer(module, CROSSFIRE_PERIOD, true);
|
||||
break;
|
||||
#endif
|
||||
|
||||
|
@ -216,10 +212,6 @@ void enablePulses(uint8_t module, uint8_t protocol)
|
|||
case PROTOCOL_CHANNELS_PPM:
|
||||
init_ppm(module);
|
||||
break;
|
||||
|
||||
default:
|
||||
init_no_pulses(module);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,11 +34,6 @@ 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();
|
||||
|
|
|
@ -39,37 +39,6 @@ void extmoduleStop()
|
|||
}
|
||||
}
|
||||
|
||||
void extmoduleTimerStart(uint32_t period, uint8_t state)
|
||||
{
|
||||
if (state)
|
||||
EXTERNAL_MODULE_ON();
|
||||
else if (!IS_TRAINER_EXTERNAL_MODULE())
|
||||
EXTERNAL_MODULE_OFF();
|
||||
|
||||
GPIO_PinAFConfig(EXTMODULE_TX_GPIO, EXTMODULE_TX_GPIO_PinSource, 0);
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_InitStructure.GPIO_Pin = EXTMODULE_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(EXTMODULE_TX_GPIO, &GPIO_InitStructure);
|
||||
GPIO_SetBits(EXTMODULE_TX_GPIO, EXTMODULE_TX_GPIO_PIN); // Set high
|
||||
|
||||
EXTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN;
|
||||
EXTMODULE_TIMER->PSC = EXTMODULE_TIMER_FREQ / 2000000 - 1; // 0.5uS from 30MHz
|
||||
EXTMODULE_TIMER->ARR = (2000 * period);
|
||||
EXTMODULE_TIMER->CCR2 = (2000 * period) - 1000;
|
||||
EXTMODULE_TIMER->EGR = 1; // Restart
|
||||
EXTMODULE_TIMER->SR &= ~TIM_SR_CC2IF;
|
||||
EXTMODULE_TIMER->DIER |= TIM_DIER_CC2IE; // Enable this interrupt
|
||||
EXTMODULE_TIMER->CR1 |= TIM_CR1_CEN;
|
||||
|
||||
NVIC_EnableIRQ(EXTMODULE_TIMER_CC_IRQn);
|
||||
NVIC_SetPriority(EXTMODULE_TIMER_CC_IRQn, 7);
|
||||
}
|
||||
|
||||
void extmodulePpmStart()
|
||||
{
|
||||
EXTERNAL_MODULE_ON();
|
||||
|
|
|
@ -32,37 +32,6 @@ void intmoduleStop()
|
|||
INTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN;
|
||||
}
|
||||
|
||||
void intmoduleTimerStart(uint32_t period, uint8_t state)
|
||||
{
|
||||
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;
|
||||
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 = 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
|
||||
INTMODULE_TIMER->CR1 |= TIM_CR1_CEN;
|
||||
|
||||
NVIC_EnableIRQ(INTMODULE_TIMER_CC_IRQn);
|
||||
NVIC_SetPriority(INTMODULE_TIMER_CC_IRQn, 7);
|
||||
}
|
||||
|
||||
void intmoduleSendNextFrame()
|
||||
{
|
||||
if (moduleSettings[INTERNAL_MODULE].protocol == PROTOCOL_CHANNELS_PXX) {
|
||||
|
@ -122,7 +91,7 @@ void intmodulePxxStart()
|
|||
INTMODULE_TIMER->DIER |= TIM_DIER_UDE; // Enable DMA on update
|
||||
INTMODULE_TIMER->CCMR2 = TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3M_2;
|
||||
INTMODULE_TIMER->SR &= ~TIM_SR_CC2IF; // Clear flag
|
||||
INTMODULE_TIMER->CCR2 = 40000; // The first frame will be sent in 20ms
|
||||
INTMODULE_TIMER->CCR2 = 16000; // The first frame will be sent in 20ms
|
||||
INTMODULE_TIMER->DIER |= TIM_DIER_CC2IE; // Enable this interrupt
|
||||
INTMODULE_TIMER->CR1 |= TIM_CR1_CEN;
|
||||
|
||||
|
|
|
@ -106,32 +106,3 @@ void disable_ppm(uint8_t module)
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void init_no_pulses(uint8_t module)
|
||||
{
|
||||
init_module_timer(module, 18, false);
|
||||
}
|
||||
|
||||
void disable_no_pulses(uint8_t module)
|
||||
{
|
||||
if (module == INTERNAL_MODULE)
|
||||
intmoduleStop();
|
||||
else
|
||||
extmoduleStop();
|
||||
}
|
||||
|
||||
void init_module_timer(uint8_t module, uint32_t period, uint8_t state)
|
||||
{
|
||||
if (module == INTERNAL_MODULE)
|
||||
intmoduleTimerStart(period, state);
|
||||
else
|
||||
extmoduleTimerStart(period, state);
|
||||
}
|
||||
|
||||
void disable_module_timer(uint8_t module)
|
||||
{
|
||||
if (module == INTERNAL_MODULE)
|
||||
intmoduleStop();
|
||||
else
|
||||
extmoduleStop();
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ bool isForcePowerOffRequested()
|
|||
|
||||
bool isProtocolSynchronous(uint8_t protocol)
|
||||
{
|
||||
return (protocol == PROTOCOL_CHANNELS_PXX2 || protocol == PROTOCOL_CHANNELS_NONE);
|
||||
return (protocol == PROTOCOL_CHANNELS_PXX2 || protocol == PROTOCOL_CHANNELS_CROSSFIRE || protocol == PROTOCOL_CHANNELS_NONE);
|
||||
}
|
||||
|
||||
void sendSynchronousPulses()
|
||||
|
@ -83,7 +83,12 @@ void sendSynchronousPulses()
|
|||
for (uint8_t module = 0; module < NUM_MODULES; module++) {
|
||||
uint8_t protocol = moduleSettings[module].protocol;
|
||||
if (isProtocolSynchronous(protocol) && setupPulses(module)) {
|
||||
intmoduleSendNextFrame();
|
||||
if (module == INTERNAL_MODULE) {
|
||||
intmoduleSendNextFrame();
|
||||
}
|
||||
else {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue