Class VREF
Defined in File sim_vref.h
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public Peripheral(Class Peripheral)
Derived Types
public ArchAVR_VREF(Class ArchAVR_VREF)public ArchXT_VREF(Class ArchXT_VREF)
Class Documentation
-
class VREF : public Peripheral
Generic model for managing VREF for analog peripherals (ADC, analog comparator)
Note
Setting VCC in the firmware is required for using any analog feature of a MCU. Failing to do so will trigger a device crash.
Subclassed by ArchAVR_VREF, ArchXT_VREF
Public Types
-
enum Source
Enumation value for the sources of voltage references.
Values:
-
enumerator Source_VCC
VCC voltage value.
-
enumerator Source_AVCC
AVCC voltage value (always equal to VCC for now)
-
enumerator Source_AREF
AREF voltage value.
-
enumerator Source_Internal
Internal reference voltage value.
-
enumerator Source_VCC
-
enum SignalId
Values:
-
enumerator Signal_ARefChange
Raised when the AREF reference value is changed. data carries the new value (absolute)
-
enumerator Signal_IntRefChange
Raised when an internal reference value is changed. data carries the new value (relative to VCC) and index the reference index.
-
enumerator Signal_VCCChange
Raised when VCC value is changed. data carries the new value (absolute)
-
enumerator Signal_ARefChange
Public Functions
-
explicit VREF(unsigned int ref_count)
-
inline bool active() const
-
virtual bool ctlreq(ctlreq_id_t req, ctlreq_data_t *data) override
Virtual method called for a CTL request. The method must return true if the request has been processed.
Protected Functions
-
void set_reference(unsigned int index, Source source, double voltage = 1.0)
Set a voltage reference value
If source is VCC or AVCC, the voltage value is ignored (it is by definition 1.0).
If source is AREF, voltage must be a value relative to VCC/AVCC.
If source is Internal, voltage must be an absolute value in Volts.
- Parameters:
index – channel index of the reference
source – source of the reference
voltage – Value of the reference (optional, default value is 1.0)
-
double reference(unsigned int index) const
Returns a voltage reference value.
The value returned is always relative to VCC, even if set with an absolute value.
The value is also constrained to the range [0; VCC].
If index is out of range or VCC is not set, 0.0 is returned.
-
enum Source