diff --git a/drivers/AnalogIn.h b/drivers/AnalogIn.h index ed6c14b69d..d227edfd3f 100644 --- a/drivers/AnalogIn.h +++ b/drivers/AnalogIn.h @@ -93,7 +93,8 @@ public: */ unsigned short read_u16(); - /** Read the input voltage in volts. The output depends on the target board's + /** + * Read the input voltage in volts. The output depends on the target board's * ADC reference voltage (typically equal to supply voltage). The ADC reference voltage * sets the maximum voltage the ADC can quantify (ie: Vin == Vref when ADC output == ADC_MAX_VALUE) * @@ -104,16 +105,23 @@ public: float read_volts(); /** - * Sets this ADC instance's reference voltage. + * Sets this AnalogIn instance's reference voltage. * * Defaults to the configurable MBED_CONF_DRIVERS_DEFAULT_ADC_VREF setting. * - * The ADC's reference voltage is used to scale the output when calling AnalogIn::read_volts + * The AnalogIn's reference voltage is used to scale the output when calling AnalogIn::read_volts * - * @param[in] vref New ADC reference voltage for this ADC instance. + * @param[in] vref New ADC reference voltage for this AnalogIn instance. */ void set_reference_voltage(float vref); + /** + * Gets this AnalogIn instance's reference voltage. + * + * @returns A floating-point value representing this AnalogIn's reference voltage, measured in volts. + */ + float get_reference_voltage(void); + /** An operator shorthand for read() * * The float() operator can be used as a shorthand for read() to simplify common code sequences diff --git a/drivers/source/AnalogIn.cpp b/drivers/source/AnalogIn.cpp index 1370a71863..df8fa65917 100644 --- a/drivers/source/AnalogIn.cpp +++ b/drivers/source/AnalogIn.cpp @@ -63,6 +63,10 @@ void AnalogIn::set_reference_voltage(float vref) { this->vref = vref; } +float AnalogIn::get_reference_voltage(void) { + return this->vref; +} + } // namespace mbed #endif