forked from Archive/PX4-Autopilot
ADC driver report back vref alone with sample count (#14136)
* Introduce "px4_arch_adc_reference_v" * Revert "Introduce "px4_arch_adc_reference_v"" This reverts commit 93691fbbd55a1b8da8c190e225b318067d90399b. * use structure to return sample count and vref at the same time * Revert "use structure to return sample count and vref at the same time" This reverts commit 9cfd1c173cda51495f766a3f678c2202d67725fd. * Revert "Revert "Introduce "px4_arch_adc_reference_v""" This reverts commit edb7f7603e4471163ffb0fc6fc62ad2e30336e91. * fix missed reference * remove unecessary channel specific vref * Update src/drivers/drv_adc.h Co-Authored-By: David Sidrane <David.Sidrane@Nscdg.com> * Update src/drivers/drv_adc.h Co-Authored-By: David Sidrane <David.Sidrane@Nscdg.com> * Introduce BOARD_ADC_POS_REF_V Co-authored-by: David Sidrane <David.Sidrane@Nscdg.com>
This commit is contained in:
parent
e0d6f94318
commit
77a9135036
|
@ -92,6 +92,11 @@ uint32_t px4_arch_adc_sample(uint32_t base_address, unsigned channel)
|
|||
return atoi(buffer);
|
||||
}
|
||||
|
||||
float px4_arch_adc_reference_v()
|
||||
{
|
||||
return BOARD_ADC_POS_REF_V;
|
||||
}
|
||||
|
||||
uint32_t px4_arch_adc_dn_fullcount()
|
||||
{
|
||||
return 1 << 12; // 12 bit ADC
|
||||
|
|
|
@ -92,6 +92,11 @@ uint32_t px4_arch_adc_sample(uint32_t base_address, unsigned channel)
|
|||
return atoi(buffer);
|
||||
}
|
||||
|
||||
float px4_arch_adc_reference_v()
|
||||
{
|
||||
return BOARD_ADC_POS_REF_V; // 12-bit 1.8V ADC
|
||||
}
|
||||
|
||||
uint32_t px4_arch_adc_dn_fullcount()
|
||||
{
|
||||
return 1 << 12; // 12 bit ADC
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
|
||||
// ADC channels:
|
||||
#define ADC_CHANNELS (1 << 5)
|
||||
#define BOARD_ADC_POS_REF_V (1.8f)
|
||||
|
||||
#define ADC_BATTERY_VOLTAGE_CHANNEL 5
|
||||
#define ADC_BATTERY_CURRENT_CHANNEL ((uint8_t)(-1))
|
||||
|
|
|
@ -92,6 +92,11 @@ uint32_t px4_arch_adc_sample(uint32_t base_address, unsigned channel)
|
|||
return atoi(buffer);
|
||||
}
|
||||
|
||||
float px4_arch_adc_reference_v()
|
||||
{
|
||||
return BOARD_ADC_POS_REF_V;
|
||||
}
|
||||
|
||||
uint32_t px4_arch_adc_dn_fullcount()
|
||||
{
|
||||
return 1 << 12; // 12 bit ADC
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
// A4 - ADC2 (ADC port)
|
||||
// A5 - ADC3 (ADC port)
|
||||
#define ADC_CHANNELS (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5)
|
||||
#define BOARD_ADC_POS_REF_V (4.096f) // TODO: need confirmation
|
||||
|
||||
#define ADC_BATTERY_VOLTAGE_CHANNEL 2
|
||||
#define ADC_BATTERY_CURRENT_CHANNEL 3
|
||||
|
|
|
@ -147,6 +147,10 @@
|
|||
#define ADC_3V3_SCALE (2.0f) // The scale factor defined by HW's resistive divider (Rt+Rb)/ Rb
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_ADC_POS_REF_V
|
||||
#define BOARD_ADC_POS_REF_V (3.3f) // Default reference voltage for every channels
|
||||
#endif
|
||||
|
||||
#ifndef BOARD_ADC_POS_REF_V_FOR_CURRENT_CHAN
|
||||
#define BOARD_ADC_POS_REF_V_FOR_CURRENT_CHAN (3.3f) // Reference voltage for reading out the current channel
|
||||
#endif
|
||||
|
|
|
@ -186,6 +186,12 @@ uint32_t px4_arch_adc_sample(uint32_t base_address, unsigned channel)
|
|||
result = rR0(base_address);
|
||||
return result;
|
||||
}
|
||||
|
||||
float px4_arch_adc_reference_v()
|
||||
{
|
||||
return BOARD_ADC_POS_REF_V; // TODO: provide true vref
|
||||
}
|
||||
|
||||
uint32_t px4_arch_adc_temp_sensor_mask()
|
||||
{
|
||||
return 0;
|
||||
|
|
|
@ -176,6 +176,11 @@ uint32_t px4_arch_adc_sample(uint32_t base_address, unsigned channel)
|
|||
return result;
|
||||
}
|
||||
|
||||
float px4_arch_adc_reference_v()
|
||||
{
|
||||
return BOARD_ADC_POS_REF_V; // TODO: provide true vref
|
||||
}
|
||||
|
||||
uint32_t px4_arch_adc_temp_sensor_mask()
|
||||
{
|
||||
return 1 << (ADC_SC1_ADCH_TEMP >> ADC_SC1_ADCH_SHIFT);
|
||||
|
|
|
@ -179,6 +179,11 @@ uint32_t px4_arch_adc_sample(uint32_t base_address, unsigned channel)
|
|||
return result;
|
||||
}
|
||||
|
||||
float px4_arch_adc_reference_v()
|
||||
{
|
||||
return BOARD_ADC_POS_REF_V; // TODO: provide true vref
|
||||
}
|
||||
|
||||
uint32_t px4_arch_adc_temp_sensor_mask()
|
||||
{
|
||||
return 1 << (ADC_SC1_ADCH_TEMP >> ADC_SC1_ADCH_SHIFT);
|
||||
|
|
|
@ -224,6 +224,11 @@ uint32_t px4_arch_adc_sample(uint32_t base_address, unsigned channel)
|
|||
return result;
|
||||
}
|
||||
|
||||
float px4_arch_adc_reference_v()
|
||||
{
|
||||
return BOARD_ADC_POS_REF_V; // TODO: provide true vref
|
||||
}
|
||||
|
||||
uint32_t px4_arch_adc_temp_sensor_mask()
|
||||
{
|
||||
return 1 << 16;
|
||||
|
|
|
@ -304,6 +304,11 @@ uint32_t px4_arch_adc_sample(uint32_t base_address, unsigned channel)
|
|||
return result;
|
||||
}
|
||||
|
||||
float px4_arch_adc_reference_v()
|
||||
{
|
||||
return BOARD_ADC_POS_REF_V; // TODO: provide true vref
|
||||
}
|
||||
|
||||
uint32_t px4_arch_adc_temp_sensor_mask()
|
||||
{
|
||||
return 1 << 16;
|
||||
|
|
|
@ -82,6 +82,13 @@ void px4_arch_adc_uninit(uint32_t base_address);
|
|||
*/
|
||||
uint32_t px4_arch_adc_sample(uint32_t base_address, unsigned channel);
|
||||
|
||||
/**
|
||||
* Get the ADC positive reference voltage
|
||||
* N.B This assume that all ADC channels share the same vref.
|
||||
* @return v_ref
|
||||
*/
|
||||
float px4_arch_adc_reference_v(void);
|
||||
|
||||
/**
|
||||
* Get the temperature sensor channel bitmask
|
||||
*/
|
||||
|
@ -93,4 +100,3 @@ uint32_t px4_arch_adc_temp_sensor_mask(void);
|
|||
uint32_t px4_arch_adc_dn_fullcount(void);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in New Issue