mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 11:38:56 +08:00
PX4 System changes Supporting STM32H7
stm32:ToneAlarmInterfacePWM TIM15-TIM17 have a BDTR Register common:board_crashdump Add H7 support stm32/board_mcu_version:Support H7 PX4 ADC:Use 32 interface and resoution abstraction Added PX4 stm32h7 ADC driver stm32h7:adc fix ADC ready check fmu: handle BOARD_HAS_PWM==5 cmake: improve error handling for NuttX olddefconfig failures WorkQueueManager:Quiet loadmon stack warning camera_trigger:GPIO support < 6 GPIO Adjust stack sizes (under hw stack check) PX4 System changes Supporting STM32H7 PX4IO Driver aerotenna_ocpoc:ADC add px4_arch_adc_dn_fullcount init.cmake:Track Upstream change needing Make.def at config time PX4 System changes Supporting STM32H7 NuttX CMakeLists.txt Track upstream changes Common board_crashdump add header and px4 config NuttX simplify callinb make libapps Use UINT32_MAX for error return drivers:uavcannode NuttX chip is now hardware drivers:uavcanesc NuttX chip is now hardware px4io:Avoid Race on AP to PX4 IO upgrade
This commit is contained in:
committed by
Lorenz Meier
parent
58799dc7d1
commit
e847698c9f
+10
-9
@@ -37,7 +37,7 @@
|
||||
* Driver for an ADC.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <drivers/drv_adc.h>
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <lib/cdev/CDev.hpp>
|
||||
@@ -82,9 +82,9 @@ private:
|
||||
* Sample a single channel and return the measured value.
|
||||
*
|
||||
* @param channel The channel to sample.
|
||||
* @return The sampled value, or 0xffff if sampling failed.
|
||||
* @return The sampled value, or UINT32_MAX if sampling failed.
|
||||
*/
|
||||
uint16_t sample(unsigned channel);
|
||||
uint32_t sample(unsigned channel);
|
||||
|
||||
void update_adc_report(hrt_abstime now);
|
||||
void update_system_power(hrt_abstime now);
|
||||
@@ -233,7 +233,8 @@ ADC::update_adc_report(hrt_abstime now)
|
||||
|
||||
for (unsigned i = 0; i < max_num; i++) {
|
||||
adc.channel_id[i] = _samples[i].am_channel;
|
||||
adc.channel_value[i] = _samples[i].am_data * 3.3f / 4096.0f;
|
||||
adc.channel_value[i] = _samples[i].am_data * 3.3f / px4_arch_adc_dn_fullcount();
|
||||
;
|
||||
}
|
||||
|
||||
_to_adc_report.publish(adc);
|
||||
@@ -258,7 +259,7 @@ ADC::update_system_power(hrt_abstime now)
|
||||
|
||||
if (_samples[i].am_channel == ADC_SCALED_V5_SENSE) {
|
||||
// it is 2:1 scaled
|
||||
system_power.voltage5v_v = _samples[i].am_data * (ADC_V5_V_FULL_SCALE / 4096.0f);
|
||||
system_power.voltage5v_v = _samples[i].am_data * (ADC_V5_V_FULL_SCALE / px4_arch_adc_dn_fullcount());
|
||||
cnt--;
|
||||
|
||||
} else
|
||||
@@ -267,7 +268,7 @@ ADC::update_system_power(hrt_abstime now)
|
||||
{
|
||||
if (_samples[i].am_channel == ADC_SCALED_V3V3_SENSORS_SENSE) {
|
||||
// it is 2:1 scaled
|
||||
system_power.voltage3v3_v = _samples[i].am_data * (ADC_3V3_SCALE * (3.3f / 4096.0f));
|
||||
system_power.voltage3v3_v = _samples[i].am_data * (ADC_3V3_SCALE * (3.3f / px4_arch_adc_dn_fullcount()));
|
||||
system_power.v3v3_valid = 1;
|
||||
cnt--;
|
||||
}
|
||||
@@ -323,13 +324,13 @@ ADC::update_system_power(hrt_abstime now)
|
||||
#endif // BOARD_ADC_USB_CONNECTED
|
||||
}
|
||||
|
||||
uint16_t
|
||||
uint32_t
|
||||
ADC::sample(unsigned channel)
|
||||
{
|
||||
perf_begin(_sample_perf);
|
||||
uint16_t result = px4_arch_adc_sample(_base_address, channel);
|
||||
uint32_t result = px4_arch_adc_sample(_base_address, channel);
|
||||
|
||||
if (result == 0xffff) {
|
||||
if (result == UINT32_MAX) {
|
||||
PX4_ERR("sample timeout");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user