Browse Source

Simplify ADC driver

sbg
Lorenz Meier 9 years ago
parent
commit
c8c7c84110
  1. 46
      src/drivers/stm32/adc/adc.cpp

46
src/drivers/stm32/adc/adc.cpp

@ -314,7 +314,9 @@ ADC::_tick() @@ -314,7 +314,9 @@ ADC::_tick()
void
ADC::update_system_power(void)
{
#if defined (CONFIG_ARCH_BOARD_PX4FMU_V2) || defined (CONFIG_ARCH_BOARD_MINDPX_V2)
#if defined (CONFIG_ARCH_BOARD_PX4FMU_V2) || \
defined (CONFIG_ARCH_BOARD_MINDPX_V2) || \
defined (CONFIG_ARCH_BOARD_PX4FMU_V4)
system_power_s system_power = {};
system_power.timestamp = hrt_absolute_time();
@ -339,6 +341,14 @@ ADC::update_system_power(void) @@ -339,6 +341,14 @@ ADC::update_system_power(void)
// 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);
@ -358,40 +368,6 @@ ADC::update_system_power(void) @@ -358,40 +368,6 @@ ADC::update_system_power(void)
}
#endif // CONFIG_ARCH_BOARD_PX4FMU_V2
#ifdef CONFIG_ARCH_BOARD_PX4FMU_V4
system_power_s system_power = {};
system_power.timestamp = hrt_absolute_time();
system_power.voltage5V_v = 0;
for (unsigned i = 0; i < _channel_count; i++) {
if (_samples[i].am_channel == ADC_5V_RAIL_SENSE) {
// it is 2:1 scaled
system_power.voltage5V_v = _samples[i].am_data * (6.6f / 4096);
}
}
// 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);
// 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;
/* lazily publish */
if (_to_system_power != nullptr) {
orb_publish(ORB_ID(system_power), _to_system_power, &system_power);
} else {
_to_system_power = orb_advertise(ORB_ID(system_power), &system_power);
}
#endif // CONFIG_ARCH_BOARD_PX4FMU_V4
}
uint16_t

Loading…
Cancel
Save