mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-23 11:47:35 +08:00
stm32 : deinit trigger pins properly
This commit is contained in:
committed by
Lorenz Meier
parent
82a1bd83bc
commit
704de4f88f
@@ -73,12 +73,10 @@ int up_pwm_trigger_init(uint32_t channel_mask)
|
||||
// First free any that were not trigger mode before
|
||||
if (-EBUSY == io_timer_is_channel_free(channel)) {
|
||||
io_timer_free_channel(channel);
|
||||
PX4_INFO("FREE PIN");
|
||||
}
|
||||
|
||||
io_timer_channel_init(channel, IOTimerChanMode_Trigger, NULL, NULL);
|
||||
channel_mask &= ~(1 << channel);
|
||||
PX4_INFO("SET PIN TO TRIGGER");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,15 +86,25 @@ int up_pwm_trigger_init(uint32_t channel_mask)
|
||||
return OK;
|
||||
}
|
||||
|
||||
void up_pwm_trigger_deinit(void)
|
||||
void up_pwm_trigger_deinit()
|
||||
{
|
||||
/* disable the timers */
|
||||
up_pwm_trigger_arm(false);
|
||||
|
||||
/* Deinit channels */
|
||||
uint32_t current = io_timer_get_mode_channels(IOTimerChanMode_Trigger);
|
||||
|
||||
for (unsigned channel = 0; current != 0 && channel < MAX_TIMER_IO_CHANNELS; channel++) {
|
||||
if (current & (1 << channel)) {
|
||||
|
||||
io_timer_channel_init(channel, IOTimerChanMode_NotUsed, NULL, NULL);
|
||||
current &= ~(1 << channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
up_pwm_trigger_arm(bool armed)
|
||||
{
|
||||
io_timer_set_enable(armed, IOTimerChanMode_Trigger, IO_TIMER_ALL_MODES_CHANNELS);
|
||||
PX4_INFO("ENABLE PIN : %d", (int)armed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,4 +39,4 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <drivers/drv_pwm_trigger.h>
|
||||
#include <drivers/drv_pwm_trigger.h>
|
||||
|
||||
Reference in New Issue
Block a user