mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 02:16:53 +08:00
stm32_common:board_hw_rev_ver Support 16 Bit ADC
This commit is contained in:
committed by
Daniel Agar
parent
2c9a522f71
commit
bd1f69fb76
@@ -79,6 +79,14 @@ static char hw_info[] = HW_INFO_INIT;
|
|||||||
|
|
||||||
static int dn_to_ordinal(uint16_t dn)
|
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 {
|
const struct {
|
||||||
uint16_t low; // High(n-1) + 1
|
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) {
|
if (px4_arch_adc_init(HW_REV_VER_ADC_BASE) == OK) {
|
||||||
|
|
||||||
/* Read the value */
|
/* Read the value */
|
||||||
|
|
||||||
for (unsigned av = 0; av < samples; av++) {
|
for (unsigned av = 0; av < samples; av++) {
|
||||||
dn = px4_arch_adc_sample(HW_REV_VER_ADC_BASE, adc_channel);
|
dn = px4_arch_adc_sample(HW_REV_VER_ADC_BASE, adc_channel);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user