Skip to content

Commit 6a4165e

Browse files
committed
Add reference voltage getter and clarify some comments
1 parent f243ec4 commit 6a4165e

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

drivers/AnalogIn.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ class AnalogIn {
9393
*/
9494
unsigned short read_u16();
9595

96-
/** Read the input voltage in volts. The output depends on the target board's
96+
/**
97+
* Read the input voltage in volts. The output depends on the target board's
9798
* ADC reference voltage (typically equal to supply voltage). The ADC reference voltage
9899
* sets the maximum voltage the ADC can quantify (ie: Vin == Vref when ADC output == ADC_MAX_VALUE)
99100
*
@@ -104,16 +105,23 @@ class AnalogIn {
104105
float read_volts();
105106

106107
/**
107-
* Sets this ADC instance's reference voltage.
108+
* Sets this AnalogIn instance's reference voltage.
108109
*
109110
* Defaults to the configurable MBED_CONF_DRIVERS_DEFAULT_ADC_VREF setting.
110111
*
111-
* The ADC's reference voltage is used to scale the output when calling AnalogIn::read_volts
112+
* The AnalogIn's reference voltage is used to scale the output when calling AnalogIn::read_volts
112113
*
113-
* @param[in] vref New ADC reference voltage for this ADC instance.
114+
* @param[in] vref New ADC reference voltage for this AnalogIn instance.
114115
*/
115116
void set_reference_voltage(float vref);
116117

118+
/**
119+
* Gets this AnalogIn instance's reference voltage.
120+
*
121+
* @returns A floating-point value representing this AnalogIn's reference voltage, measured in volts.
122+
*/
123+
float get_reference_voltage(void);
124+
117125
/** An operator shorthand for read()
118126
*
119127
* The float() operator can be used as a shorthand for read() to simplify common code sequences

drivers/source/AnalogIn.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ void AnalogIn::set_reference_voltage(float vref) {
6363
this->vref = vref;
6464
}
6565

66+
float AnalogIn::get_reference_voltage(void) {
67+
return this->vref;
68+
}
69+
6670
} // namespace mbed
6771

6872
#endif

0 commit comments

Comments
 (0)