mirror of
https://github.com/opentx/opentx.git
synced 2025-07-13 11:29:51 +03:00
Simplified #8019
This commit is contained in:
parent
ef77001497
commit
c561160d54
3 changed files with 21 additions and 19 deletions
|
@ -53,9 +53,7 @@ void stop_intmodule_heartbeat()
|
||||||
{
|
{
|
||||||
heartbeatCapture.valid = false;
|
heartbeatCapture.valid = false;
|
||||||
|
|
||||||
#if !defined(INTMODULE_HEARTBEAT_REUSE_INTERRUPT_ROTARY_ENCODER)
|
// Never disable EXTI_IRQ, just remove INTMODULE_HEARTBEAT_EXTI_LINE from configuration as EXTI can be reused
|
||||||
NVIC_DisableIRQ(INTMODULE_HEARTBEAT_EXTI_IRQn);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
EXTI_InitTypeDef EXTI_InitStructure;
|
EXTI_InitTypeDef EXTI_InitStructure;
|
||||||
EXTI_StructInit(&EXTI_InitStructure);
|
EXTI_StructInit(&EXTI_InitStructure);
|
||||||
|
@ -89,9 +87,11 @@ void check_intmodule_heartbeat()
|
||||||
#if defined(INTMODULE_HEARTBEAT) && !defined(INTMODULE_HEARTBEAT_REUSE_INTERRUPT_ROTARY_ENCODER)
|
#if defined(INTMODULE_HEARTBEAT) && !defined(INTMODULE_HEARTBEAT_REUSE_INTERRUPT_ROTARY_ENCODER)
|
||||||
extern "C" void INTMODULE_HEARTBEAT_EXTI_IRQHandler()
|
extern "C" void INTMODULE_HEARTBEAT_EXTI_IRQHandler()
|
||||||
{
|
{
|
||||||
|
// Check as first because it is the most critical one
|
||||||
|
#if defined(TELEMETRY_EXTI_REUSE_INTERRUPT_INTMODULE_HEARTBEAT)
|
||||||
|
check_telemetry_exti();
|
||||||
|
#endif
|
||||||
|
|
||||||
check_intmodule_heartbeat();
|
check_intmodule_heartbeat();
|
||||||
#if defined(TELEMETRY_EXTI_REUSE_INTERRUPT_INTMODULE_HEARTBEAT)
|
|
||||||
check_telemetry_exti();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -118,6 +118,11 @@ void rotaryEncoderStartDelay()
|
||||||
|
|
||||||
extern "C" void ROTARY_ENCODER_EXTI_IRQHandler1(void)
|
extern "C" void ROTARY_ENCODER_EXTI_IRQHandler1(void)
|
||||||
{
|
{
|
||||||
|
// Check as first because it is the most critical one
|
||||||
|
#if !defined(BOOT) && defined(TELEMETRY_EXTI_REUSE_INTERRUPT_ROTARY_ENCODER)
|
||||||
|
check_telemetry_exti();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (EXTI_GetITStatus(ROTARY_ENCODER_EXTI_LINE1) != RESET) {
|
if (EXTI_GetITStatus(ROTARY_ENCODER_EXTI_LINE1) != RESET) {
|
||||||
rotaryEncoderStartDelay();
|
rotaryEncoderStartDelay();
|
||||||
EXTI_ClearITPendingBit(ROTARY_ENCODER_EXTI_LINE1);
|
EXTI_ClearITPendingBit(ROTARY_ENCODER_EXTI_LINE1);
|
||||||
|
@ -133,10 +138,6 @@ extern "C" void ROTARY_ENCODER_EXTI_IRQHandler1(void)
|
||||||
#if !defined(BOOT) && defined(INTMODULE_HEARTBEAT_REUSE_INTERRUPT_ROTARY_ENCODER)
|
#if !defined(BOOT) && defined(INTMODULE_HEARTBEAT_REUSE_INTERRUPT_ROTARY_ENCODER)
|
||||||
check_intmodule_heartbeat();
|
check_intmodule_heartbeat();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOT) && defined(TELEMETRY_EXTI_REUSE_INTERRUPT_ROTARY_ENCODER)
|
|
||||||
check_telemetry_exti();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ROTARY_ENCODER_EXTI_IRQn2)
|
#if defined(ROTARY_ENCODER_EXTI_IRQn2)
|
||||||
|
|
|
@ -166,13 +166,15 @@ void telemetryPortInvertedInit(uint32_t baudrate)
|
||||||
//TODO:
|
//TODO:
|
||||||
// - handle conflict with HEARTBEAT disabled for trainer input...
|
// - handle conflict with HEARTBEAT disabled for trainer input...
|
||||||
// - probably need to stop trainer input/output and restore after this is closed
|
// - probably need to stop trainer input/output and restore after this is closed
|
||||||
#if !defined(TELEMETRY_EXTI_REUSE_INTERRUPT_ROTARY_ENCODER) && !defined(TELEMETRY_EXTI_REUSE_INTERRUPT_INTMODULE_HEARTBEAT)
|
|
||||||
NVIC_SetPriority(TELEMETRY_EXTI_IRQn, 0);
|
NVIC_SetPriority(TELEMETRY_EXTI_IRQn, 0);
|
||||||
NVIC_EnableIRQ(TELEMETRY_EXTI_IRQn);
|
|
||||||
#endif
|
// In case shared IRQ is not enabled
|
||||||
|
if ((NVIC->ISER[(uint32_t)((int32_t)TELEMETRY_EXTI_IRQn) >> 5] & (uint32_t)(1 << ((uint32_t)((int32_t)TELEMETRY_EXTI_IRQn) & (uint32_t)0x1F))) == 0) {
|
||||||
|
NVIC_EnableIRQ(TELEMETRY_EXTI_IRQn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void telemetryPortInvertedRxBit()
|
inline void telemetryPortInvertedRxBit()
|
||||||
{
|
{
|
||||||
if (rxBitCount < 8) {
|
if (rxBitCount < 8) {
|
||||||
if (rxBitCount == 0) {
|
if (rxBitCount == 0) {
|
||||||
|
@ -189,15 +191,14 @@ void telemetryPortInvertedRxBit()
|
||||||
++rxBitCount;
|
++rxBitCount;
|
||||||
}
|
}
|
||||||
else if (rxBitCount == 8) {
|
else if (rxBitCount == 8) {
|
||||||
|
// disable timer
|
||||||
|
TELEMETRY_TIMER->CR1 &= ~TIM_CR1_CEN;
|
||||||
|
|
||||||
telemetryFifo.push(rxByte);
|
telemetryFifo.push(rxByte);
|
||||||
rxBitCount = 0;
|
rxBitCount = 0;
|
||||||
|
|
||||||
// disable timer
|
|
||||||
TELEMETRY_TIMER->CR1 &= ~TIM_CR1_CEN;
|
|
||||||
|
|
||||||
// re-enable start bit interrupt
|
// re-enable start bit interrupt
|
||||||
EXTI->IMR |= EXTI_IMR_MR6;
|
EXTI->IMR |= TELEMETRY_EXTI_LINE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +362,7 @@ void check_telemetry_exti()
|
||||||
TELEMETRY_TIMER->CR1 |= TIM_CR1_CEN;
|
TELEMETRY_TIMER->CR1 |= TIM_CR1_CEN;
|
||||||
|
|
||||||
// disable start bit interrupt
|
// disable start bit interrupt
|
||||||
EXTI->IMR &= ~EXTI_IMR_MR6;
|
EXTI->IMR &= ~TELEMETRY_EXTI_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXTI_ClearITPendingBit(TELEMETRY_EXTI_LINE);
|
EXTI_ClearITPendingBit(TELEMETRY_EXTI_LINE);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue