stm32_common:board_hw_rev_ver Support 16 Bit ADC

This commit is contained in:
David Sidrane 2020-05-21 12:22:46 -07:00 committed by Daniel Agar
parent 2c9a522f71
commit bd1f69fb76

View File

@ -79,6 +79,14 @@ static char hw_info[] = HW_INFO_INIT;
static int dn_to_ordinal(uint16_t dn)
{
/* Table is scaled for 12, so if ADC is in 16 bit mode
* scale the result
*/
if (px4_arch_adc_dn_fullcount() > (1 << 12)) {
dn /= (px4_arch_adc_dn_fullcount() / (1 << 12));
}
const struct {
uint16_t low; // High(n-1) + 1
@ -204,6 +212,7 @@ static int read_id_dn(int *id, uint32_t gpio_drive, uint32_t gpio_sense, int adc
if (px4_arch_adc_init(HW_REV_VER_ADC_BASE) == OK) {
/* Read the value */
for (unsigned av = 0; av < samples; av++) {
dn = px4_arch_adc_sample(HW_REV_VER_ADC_BASE, adc_channel);