mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-01 12:54:07 +08:00
stm32_common:board_hw_rev_ver Support 16 Bit ADC
This commit is contained in:
parent
2c9a522f71
commit
bd1f69fb76
@ -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);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user