drivers/adc: provide API to access reference voltage
Required for any real-world use of ADC_REF_INTERNAL. Relates-to: issue #11922 Signed-off-by: Peter A. Bigot <pab@pabigot.com>
This commit is contained in:
parent
9f34d17cc1
commit
5a39bcae84
3 changed files with 20 additions and 0 deletions
|
@ -274,6 +274,7 @@ static const struct adc_driver_api adc_nrfx_driver_api = {
|
||||||
#ifdef CONFIG_ADC_ASYNC
|
#ifdef CONFIG_ADC_ASYNC
|
||||||
.read_async = adc_nrfx_read_async,
|
.read_async = adc_nrfx_read_async,
|
||||||
#endif
|
#endif
|
||||||
|
.ref_internal = 1200,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_ADC_0
|
#ifdef CONFIG_ADC_0
|
||||||
|
|
|
@ -406,6 +406,7 @@ static const struct adc_driver_api adc_nrfx_driver_api = {
|
||||||
#ifdef CONFIG_ADC_ASYNC
|
#ifdef CONFIG_ADC_ASYNC
|
||||||
.read_async = adc_nrfx_read_async,
|
.read_async = adc_nrfx_read_async,
|
||||||
#endif
|
#endif
|
||||||
|
.ref_internal = 600,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_ADC_0
|
#ifdef CONFIG_ADC_0
|
||||||
|
|
|
@ -302,6 +302,7 @@ struct adc_driver_api {
|
||||||
#ifdef CONFIG_ADC_ASYNC
|
#ifdef CONFIG_ADC_ASYNC
|
||||||
adc_api_read_async read_async;
|
adc_api_read_async read_async;
|
||||||
#endif
|
#endif
|
||||||
|
u16_t ref_internal; /* mV */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -394,6 +395,23 @@ static inline int z_impl_adc_read_async(struct device *dev,
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_ADC_ASYNC */
|
#endif /* CONFIG_ADC_ASYNC */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the internal reference voltage.
|
||||||
|
*
|
||||||
|
* Returns the voltage corresponding to @ref ADC_REF_INTERNAL,
|
||||||
|
* measured in millivolts.
|
||||||
|
*
|
||||||
|
* @return a positive value is the reference voltage value. Returns
|
||||||
|
* zero if reference voltage information is not available.
|
||||||
|
*/
|
||||||
|
static inline u16_t adc_ref_internal(struct device *dev)
|
||||||
|
{
|
||||||
|
const struct adc_driver_api *api =
|
||||||
|
(const struct adc_driver_api *)dev->driver_api;
|
||||||
|
|
||||||
|
return api->ref_internal;
|
||||||
|
}
|
||||||
|
|
||||||
#include <syscalls/adc.h>
|
#include <syscalls/adc.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue