mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 21:53:33 +08:00
Updated PX4 use / API of low level GPIO and other hardware-centric system facilities
This commit is contained in:
@@ -321,14 +321,14 @@ void PWMIN::_timer_init(void)
|
||||
{
|
||||
/* run with interrupts disabled in case the timer is already
|
||||
* setup. We don't want it firing while we are doing the setup */
|
||||
irqstate_t flags = irqsave();
|
||||
irqstate_t flags = px4_enter_critical_section();
|
||||
|
||||
/* configure input pin */
|
||||
stm32_configgpio(GPIO_PWM_IN);
|
||||
px4_arch_configgpio(GPIO_PWM_IN);
|
||||
|
||||
// XXX refactor this out of this driver
|
||||
/* configure reset pin */
|
||||
stm32_configgpio(GPIO_VDD_RANGEFINDER_EN);
|
||||
px4_arch_configgpio(GPIO_VDD_RANGEFINDER_EN);
|
||||
|
||||
/* claim our interrupt vector */
|
||||
irq_attach(PWMIN_TIMER_VECTOR, pwmin_tim_isr);
|
||||
@@ -373,7 +373,7 @@ void PWMIN::_timer_init(void)
|
||||
/* enable interrupts */
|
||||
up_enable_irq(PWMIN_TIMER_VECTOR);
|
||||
|
||||
irqrestore(flags);
|
||||
px4_leave_critical_section(flags);
|
||||
|
||||
_timer_started = true;
|
||||
}
|
||||
@@ -392,14 +392,14 @@ PWMIN::_freeze_test()
|
||||
void
|
||||
PWMIN::_turn_on()
|
||||
{
|
||||
stm32_gpiowrite(GPIO_VDD_RANGEFINDER_EN, 1);
|
||||
px4_arch_gpiowrite(GPIO_VDD_RANGEFINDER_EN, 1);
|
||||
}
|
||||
|
||||
// XXX refactor this out of this driver
|
||||
void
|
||||
PWMIN::_turn_off()
|
||||
{
|
||||
stm32_gpiowrite(GPIO_VDD_RANGEFINDER_EN, 0);
|
||||
px4_arch_gpiowrite(GPIO_VDD_RANGEFINDER_EN, 0);
|
||||
}
|
||||
|
||||
// XXX refactor this out of this driver
|
||||
@@ -444,14 +444,14 @@ PWMIN::ioctl(struct file *filp, int cmd, unsigned long arg)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
irqstate_t flags = irqsave();
|
||||
irqstate_t flags = px4_enter_critical_section();
|
||||
|
||||
if (!_reports->resize(arg)) {
|
||||
irqrestore(flags);
|
||||
px4_leave_critical_section(flags);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
irqrestore(flags);
|
||||
px4_leave_critical_section(flags);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user