HAL/LL: Generic EXTI & trainer driver
Changes: - generic EXTI driver - generic trainer driver - relocated rotary encoder timer (simple 100us delay) from TIM4 to TIM12 - taranis & horus use now TIM4 for trainer pulses - serial driver handles periph clocks for UARTs TODO: - SBUS on heartbeat pin (USART or soft-serial)
This commit is contained in:
committed by
Raphael Coeffic
parent
d4cd3d0ddf
commit
042d5091f2
@@ -19,6 +19,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "stm32_exti_driver.h"
|
||||
#include "mixer_scheduler.h"
|
||||
#include "board.h"
|
||||
#include "debug.h"
|
||||
@@ -32,6 +33,17 @@
|
||||
|
||||
volatile HeartbeatCapture heartbeatCapture;
|
||||
|
||||
static void trigger_intmodule_heartbeat()
|
||||
{
|
||||
heartbeatCapture.timestamp = getTmr2MHz();
|
||||
#if defined(DEBUG_LATENCY)
|
||||
heartbeatCapture.count++;
|
||||
#endif
|
||||
|
||||
mixerSchedulerResetTimer();
|
||||
mixerSchedulerISRTrigger();
|
||||
}
|
||||
|
||||
void init_intmodule_heartbeat()
|
||||
{
|
||||
TRACE("init_intmodule_heartbeat");
|
||||
@@ -54,11 +66,7 @@ void init_intmodule_heartbeat()
|
||||
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
|
||||
EXTI_Init(&EXTI_InitStructure);
|
||||
|
||||
NVIC_SetPriority(INTMODULE_HEARTBEAT_EXTI_IRQn,
|
||||
// Highest priority interrupt
|
||||
configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
|
||||
|
||||
NVIC_EnableIRQ(INTMODULE_HEARTBEAT_EXTI_IRQn);
|
||||
stm32_exti_enable(INTMODULE_HEARTBEAT_EXTI_LINE, trigger_intmodule_heartbeat);
|
||||
heartbeatCapture.valid = true;
|
||||
}
|
||||
|
||||
@@ -67,9 +75,7 @@ void stop_intmodule_heartbeat()
|
||||
TRACE("stop_intmodule_heartbeat");
|
||||
heartbeatCapture.valid = false;
|
||||
|
||||
#if !defined(INTMODULE_HEARTBEAT_REUSE_INTERRUPT_ROTARY_ENCODER)
|
||||
NVIC_DisableIRQ(INTMODULE_HEARTBEAT_EXTI_IRQn);
|
||||
#endif
|
||||
stm32_exti_disable(INTMODULE_HEARTBEAT_EXTI_LINE);
|
||||
|
||||
EXTI_InitTypeDef EXTI_InitStructure;
|
||||
EXTI_StructInit(&EXTI_InitStructure);
|
||||
@@ -80,27 +86,4 @@ void stop_intmodule_heartbeat()
|
||||
EXTI_Init(&EXTI_InitStructure);
|
||||
}
|
||||
|
||||
void check_intmodule_heartbeat()
|
||||
{
|
||||
if (EXTI_GetITStatus(INTMODULE_HEARTBEAT_EXTI_LINE) != RESET) {
|
||||
heartbeatCapture.timestamp = getTmr2MHz();
|
||||
#if defined(DEBUG_LATENCY)
|
||||
heartbeatCapture.count++;
|
||||
#endif
|
||||
EXTI_ClearITPendingBit(INTMODULE_HEARTBEAT_EXTI_LINE);
|
||||
|
||||
mixerSchedulerResetTimer();
|
||||
mixerSchedulerISRTrigger();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(INTMODULE_HEARTBEAT) && !defined(INTMODULE_HEARTBEAT_REUSE_INTERRUPT_ROTARY_ENCODER)
|
||||
extern "C" void INTMODULE_HEARTBEAT_EXTI_IRQHandler()
|
||||
{
|
||||
check_intmodule_heartbeat();
|
||||
#if defined(TELEMETRY_EXTI_REUSE_INTERRUPT_INTMODULE_HEARTBEAT)
|
||||
check_telemetry_exti();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user