Fixes #2592 - No more reset on 9XR-PRO when leaving PXX protocol
I would like a code review for this one (both Taranis and 9XR-PRO), thanks!
This commit is contained in:
@@ -58,7 +58,15 @@ void setupPulsesPPM(unsigned int port) // Don't enable interru
|
||||
pwmptr->PWM_CH_NUM[pwmCh].PWM_CMR |= 0x00000200 ; // CPOL
|
||||
#endif
|
||||
|
||||
uint16_t * ptr = (port == TRAINER_MODULE ? trainerPulsesData.ppm.pulses : modulePulsesData[port].ppm.pulses);
|
||||
PpmPulsesData * ppmPulsesData = (port == TRAINER_MODULE ? &trainerPulsesData.ppm : &modulePulsesData[port].ppm);
|
||||
uint16_t * ptr = ppmPulsesData->pulses;
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
ppmPulsesData->index = 0;
|
||||
#else
|
||||
ppmPulsesData->ptr = ptr;
|
||||
#endif
|
||||
|
||||
int32_t rest = 22500u * 2;
|
||||
rest += (int32_t(g_model.moduleData[port].ppmFrameLength)) * 1000;
|
||||
for (uint32_t i=firstCh; i<lastCh; i++) {
|
||||
@@ -81,10 +89,11 @@ void setupPulsesPPM(unsigned int port) // Don't enable interru
|
||||
else if (port == EXTERNAL_MODULE) {
|
||||
set_external_ppm_parameters(rest, ppmDelay, !g_model.moduleData[EXTERNAL_MODULE].ppmPulsePol);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(TARANIS_INTERNAL_PPM)
|
||||
else if (port == INTERNAL_MODULE) {
|
||||
set_internal_ppm_parameters(rest, ppmDelay, !g_model.moduleData[INTERNAL_MODULE].ppmPulsePol);
|
||||
}
|
||||
#endif // #if defined(TARANIS_INTERNAL_PPM)
|
||||
#endif
|
||||
#endif // #if defined(TARANIS_INTERNAL_PPM)
|
||||
}
|
||||
|
||||
@@ -49,8 +49,10 @@ void module_output_active()
|
||||
else {
|
||||
pioptr->PIO_MDER = PIO_PA17 ; // Open Drain O/p in A17
|
||||
}
|
||||
pioptr->PIO_PUER = PIO_PA17 ; // With pull up
|
||||
#else
|
||||
pioptr->PIO_MDDR = PIO_PA17 ; // Push Pull O/p in A17
|
||||
#endif
|
||||
pioptr->PIO_PUER = PIO_PA17 ; // With pull up
|
||||
}
|
||||
|
||||
void init_main_ppm(uint32_t period, uint32_t out_enable)
|
||||
@@ -65,9 +67,10 @@ void init_main_ppm(uint32_t period, uint32_t out_enable)
|
||||
|
||||
pwmptr = PWM ;
|
||||
// PWM3 for PPM output
|
||||
pwmptr->PWM_CH_NUM[3].PWM_CMR = 0x0000000B ; // CLKA
|
||||
if (!g_model.moduleData[EXTERNAL_MODULE].ppmPulsePol)
|
||||
pwmptr->PWM_CH_NUM[3].PWM_CMR = 0x0004000B ; // CLKA
|
||||
if (!g_model.moduleData[EXTERNAL_MODULE].ppmPulsePol) {
|
||||
pwmptr->PWM_CH_NUM[3].PWM_CMR |= 0x00000200 ; // CPOL
|
||||
}
|
||||
pwmptr->PWM_CH_NUM[3].PWM_CPDR = period ; // Period in half uS
|
||||
pwmptr->PWM_CH_NUM[3].PWM_CPDRUPD = period ; // Period in half uS
|
||||
pwmptr->PWM_CH_NUM[3].PWM_CDTY = g_model.moduleData[EXTERNAL_MODULE].ppmDelay*100+600; // Duty in half uS
|
||||
@@ -79,16 +82,18 @@ void init_main_ppm(uint32_t period, uint32_t out_enable)
|
||||
// PWM1 for PPM2
|
||||
configure_pins(PIO_PC15, PIN_PERIPHERAL | PIN_INPUT | PIN_PER_B | PIN_PORTC | PIN_NO_PULLUP ) ;
|
||||
pwmptr->PWM_CH_NUM[1].PWM_CMR = 0x0000000B ; // CLKB
|
||||
if (!g_model.moduleData[EXTRA_MODULE].ppmPulsePol)
|
||||
if (!g_model.moduleData[EXTRA_MODULE].ppmPulsePol) {
|
||||
pwmptr->PWM_CH_NUM[1].PWM_CMR |= 0x00000200 ; // CPOL
|
||||
}
|
||||
pwmptr->PWM_CH_NUM[1].PWM_CPDR = period ; // Period
|
||||
pwmptr->PWM_CH_NUM[1].PWM_CPDRUPD = period ; // Period
|
||||
pwmptr->PWM_CH_NUM[1].PWM_CDTY = g_model.moduleData[EXTRA_MODULE].ppmDelay*100+600 ; // Duty
|
||||
pwmptr->PWM_CH_NUM[1].PWM_CDTYUPD = g_model.moduleData[EXTRA_MODULE].ppmDelay*100+600 ; // Duty
|
||||
pwmptr->PWM_ENA = PWM_ENA_CHID1 ; // Enable channel 1
|
||||
pwmptr->PWM_IER1 = PWM_IER1_CHID1 ;
|
||||
#endif
|
||||
|
||||
pwmptr->PWM_IER1 = PWM_IER1_CHID1 ;
|
||||
NVIC_SetPriority(PWM_IRQn, 3 ) ;
|
||||
NVIC_EnableIRQ(PWM_IRQn) ;
|
||||
}
|
||||
|
||||
@@ -232,7 +237,7 @@ extern "C" void PWM_IRQHandler(void)
|
||||
// Alternate periods of 15.5mS and 2.5 mS
|
||||
period = pwmptr->PWM_CH_NUM[3].PWM_CPDR;
|
||||
if (period == 5000) { // 2.5 mS
|
||||
period = 15500 * 2;
|
||||
period = 6500 * 2;
|
||||
}
|
||||
else {
|
||||
period = 5000;
|
||||
@@ -285,6 +290,7 @@ extern "C" void PWM_IRQHandler(void)
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(REVA) && !defined(REVX)
|
||||
if (reason & PWM_ISR1_CHID1) {
|
||||
pwmptr->PWM_CH_NUM[1].PWM_CPDRUPD = modulePulsesData[EXTRA_MODULE].ppm.pulses[modulePulsesData[EXTRA_MODULE].ppm.index++] ; // Period in half uS
|
||||
if (modulePulsesData[EXTRA_MODULE].ppm.pulses[modulePulsesData[EXTRA_MODULE].ppm.index] == 0) {
|
||||
@@ -292,5 +298,6 @@ extern "C" void PWM_IRQHandler(void)
|
||||
setupPulsesPPM(EXTRA_MODULE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -289,9 +289,8 @@ static void intmodulePxxStop()
|
||||
static void intmodulePpmStart()
|
||||
{
|
||||
INTERNAL_MODULE_ON();
|
||||
// Timer1
|
||||
modulePulsesData[INTERNAL_MODULE].ppm.ptr = modulePulsesData[INTERNAL_MODULE].ppm.pulses;
|
||||
|
||||
// Timer1
|
||||
configure_pins(INTMODULE_GPIO_PIN, PIN_PERIPHERAL | PIN_PORTA | PIN_PER_1 | PIN_OS25);
|
||||
|
||||
INTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN ;
|
||||
@@ -352,7 +351,6 @@ extern "C" void TIM1_CC_IRQHandler()
|
||||
}
|
||||
#if defined(TARANIS_INTERNAL_PPM)
|
||||
else if (s_current_protocol[INTERNAL_MODULE] == PROTO_PPM) {
|
||||
modulePulsesData[INTERNAL_MODULE].ppm.ptr = modulePulsesData[INTERNAL_MODULE].ppm.pulses;
|
||||
INTMODULE_TIMER->DIER |= TIM_DIER_UDE;
|
||||
INTMODULE_TIMER->SR &= ~TIM_SR_UIF;
|
||||
INTMODULE_TIMER->DIER |= TIM_DIER_UIE;
|
||||
@@ -368,8 +366,7 @@ extern "C" void TIM1_UP_TIM10_IRQHandler()
|
||||
INTMODULE_TIMER->SR &= ~TIM_SR_UIF ; // Clear flag
|
||||
|
||||
INTMODULE_TIMER->ARR = *modulePulsesData[INTERNAL_MODULE].ppm.ptr++ ;
|
||||
if ( *modulePulsesData[INTERNAL_MODULE].ppm.ptr == 0 )
|
||||
{
|
||||
if (*modulePulsesData[INTERNAL_MODULE].ppm.ptr == 0) {
|
||||
INTMODULE_TIMER->SR &= ~TIM_SR_CC2IF ; // Clear this flag
|
||||
INTMODULE_TIMER->DIER |= TIM_DIER_CC2IE ; // Enable this interrupt
|
||||
}
|
||||
@@ -505,8 +502,6 @@ static void extmodulePpmStart()
|
||||
EXTERNAL_MODULE_ON();
|
||||
|
||||
// Timer1
|
||||
modulePulsesData[EXTERNAL_MODULE].ppm.ptr = modulePulsesData[EXTERNAL_MODULE].ppm.pulses;
|
||||
|
||||
configure_pins(EXTMODULE_GPIO_PIN, PIN_PERIPHERAL | PIN_PORTA | PIN_PER_3 | PIN_OS25);
|
||||
EXTMODULE_TIMER->CR1 &= ~TIM_CR1_CEN ;
|
||||
|
||||
@@ -572,7 +567,6 @@ extern "C" void TIM8_CC_IRQHandler()
|
||||
}
|
||||
#endif
|
||||
else if (s_current_protocol[EXTERNAL_MODULE] == PROTO_PPM) {
|
||||
modulePulsesData[EXTERNAL_MODULE].ppm.ptr = modulePulsesData[EXTERNAL_MODULE].ppm.pulses;
|
||||
EXTMODULE_TIMER->DIER |= TIM_DIER_UDE ;
|
||||
EXTMODULE_TIMER->SR &= ~TIM_SR_UIF ; // Clear this flag
|
||||
EXTMODULE_TIMER->DIER |= TIM_DIER_UIE ; // Enable this interrupt
|
||||
|
||||
Reference in New Issue
Block a user