This component manages the ADC12's reference voltage generator.
The internal turn-on time is 17ms, thus the component is programmed
split-phase, i.e. after the command get
has been called
you will eventually get the event isStable
when vref is
stable.
The generator should be turned off to both save power and allow other
components to switch to another reference voltage when not in use. To
do so, the release
command is available.
There are two different reference voltages available with this
component. They are a 1.5 reference voltage and a 2.5 reference
voltage. Only one can be set at any given time, however. If a
component, therefore, tries to call the get
command on the
reference voltage that is not currently set, the get
command will return a FAIL. Only once all components using a certain
reference voltage have called the release
command, will a
call to the get
command with a different reference voltage
return a SUCCESS.
Since the 17 millisecond delay is only required when switching the RefVolt component on after it has been turned off, a timer is used to delay the actual switching off of the component after it has been released for the last time. This allows other components to start using the reference voltage immediately if they try to access it within a reasonable amount of time. The delay for this timer is set in RefVolt.h as SWITCHOFF_INTERVAL.
If a component calls the get
command when the RefVolt
component is in the off state and no other components have called the
get
command before this component calls release, AND the
release
command is called before the isStable
event returns, then the RefVolt component will never be turned on and the
isStable
event will never be triggered.