mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 13:23:34 +08:00
Updated PX4 use / API of low level GPIO and other hardware-centric system facilities
This commit is contained in:
@@ -273,9 +273,9 @@ ADC::read(file *filp, char *buffer, size_t len)
|
||||
}
|
||||
|
||||
/* block interrupts while copying samples to avoid racing with an update */
|
||||
irqstate_t flags = irqsave();
|
||||
irqstate_t flags = px4_enter_critical_section();
|
||||
memcpy(buffer, _samples, len);
|
||||
irqrestore(flags);
|
||||
px4_leave_critical_section(flags);
|
||||
|
||||
return len;
|
||||
}
|
||||
@@ -343,9 +343,7 @@ ADC::update_adc_report(hrt_abstime now)
|
||||
void
|
||||
ADC::update_system_power(hrt_abstime now)
|
||||
{
|
||||
#if defined (CONFIG_ARCH_BOARD_PX4FMU_V2) || \
|
||||
defined (CONFIG_ARCH_BOARD_MINDPX_V2) || \
|
||||
defined (CONFIG_ARCH_BOARD_PX4FMU_V4)
|
||||
#if defined (BOARD_ADC_USB_CONNECTED)
|
||||
system_power_s system_power = {};
|
||||
system_power.timestamp = now;
|
||||
|
||||
@@ -358,35 +356,19 @@ ADC::update_system_power(hrt_abstime now)
|
||||
}
|
||||
}
|
||||
|
||||
/* Note once the board_config.h provides BOARD_ADC_USB_CONNECTED,
|
||||
* It must provide the true logic GPIO BOARD_ADC_xxxx macros.
|
||||
*/
|
||||
// these are not ADC related, but it is convenient to
|
||||
// publish these to the same topic
|
||||
system_power.usb_connected = stm32_gpioread(GPIO_OTGFS_VBUS);
|
||||
system_power.usb_connected = BOARD_ADC_USB_CONNECTED;
|
||||
|
||||
#if defined (CONFIG_ARCH_BOARD_MINDPX_V2)
|
||||
// note that the valid pins are active low
|
||||
system_power.brick_valid = 1;
|
||||
system_power.servo_valid = 1;
|
||||
system_power.brick_valid = BOARD_ADC_BRICK_VALID;
|
||||
system_power.servo_valid = BOARD_ADC_SERVO_VALID;
|
||||
|
||||
// OC pins are active low
|
||||
system_power.periph_5V_OC = 1;
|
||||
system_power.hipower_5V_OC = 1;
|
||||
#elif defined (CONFIG_ARCH_BOARD_PX4FMU_V4)
|
||||
// note that the valid pins are active high
|
||||
system_power.brick_valid = stm32_gpioread(GPIO_VDD_BRICK_VALID);
|
||||
system_power.servo_valid = 1;
|
||||
|
||||
// OC pins are not supported
|
||||
system_power.periph_5V_OC = 0;
|
||||
system_power.hipower_5V_OC = 0;
|
||||
#else
|
||||
// note that the valid pins are active low
|
||||
system_power.brick_valid = !stm32_gpioread(GPIO_VDD_BRICK_VALID);
|
||||
system_power.servo_valid = !stm32_gpioread(GPIO_VDD_SERVO_VALID);
|
||||
|
||||
// OC pins are active low
|
||||
system_power.periph_5V_OC = !stm32_gpioread(GPIO_VDD_5V_PERIPH_OC);
|
||||
system_power.hipower_5V_OC = !stm32_gpioread(GPIO_VDD_5V_HIPOWER_OC);
|
||||
#endif
|
||||
system_power.periph_5V_OC = BOARD_ADC_PERIPH_5V_OC;
|
||||
system_power.hipower_5V_OC = BOARD_ADC_HIPOWER_5V_OC;
|
||||
|
||||
/* lazily publish */
|
||||
if (_to_system_power != nullptr) {
|
||||
@@ -396,7 +378,7 @@ ADC::update_system_power(hrt_abstime now)
|
||||
_to_system_power = orb_advertise(ORB_ID(system_power), &system_power);
|
||||
}
|
||||
|
||||
#endif // CONFIG_ARCH_BOARD_PX4FMU_V2
|
||||
#endif // BOARD_ADC_USB_CONNECTED
|
||||
}
|
||||
|
||||
uint16_t
|
||||
|
||||
Reference in New Issue
Block a user