simulavr
1.1.0
|
Analog comparator peripheral. More...
#include <hwacomp.h>
Public Types | |
enum | { ACD = 0x80, ACBG = 0x40, ACO = 0x20, ACI = 0x10, ACIE = 0x08, ACIC = 0x04, ACIS1 = 0x02, ACIS0 = 0x01 } |
Public Member Functions | |
HWAcomp (AvrDevice *core, HWIrqSystem *irqsys, PinAtPort ain0, PinAtPort ain1, unsigned int irqVec, HWAd *_ad, BasicTimerUnit *_timerA, IOSpecialReg *_sfior=NULL, BasicTimerUnit *_timerB=NULL, bool _useBG=true) | |
constructor to instantiate a analog comparator peripheral More... | |
~HWAcomp () | |
unsigned char | GetAcsr () |
Get method for ACSR register. More... | |
void | SetAcsr (unsigned char val) |
Set method for ACSR register. More... | |
void | Reset () |
Reset the unit. More... | |
void | ClearIrqFlag (unsigned int vec) |
Reflect irq processing, reset interrupt source. More... | |
void | PinStateHasChanged (Pin *) |
Get informed about input pin change. More... | |
float | GetIn0 (void) |
Get analog value for comparator input 0. More... | |
float | GetIn1 (void) |
Get analog value for comparator input 1. More... | |
bool | GetACO (void) |
Return last state of analog comparator (assume, that this is correct, if unit is disabled) More... | |
void | NotifySignalChanged (void) |
![]() | |
Hardware (AvrDevice *core) | |
virtual | ~Hardware () |
virtual unsigned int | CpuCycle (void) |
virtual bool | IsLevelInterrupt (unsigned int vector) |
virtual bool | LevelInterruptPending (unsigned int vector) |
![]() | |
virtual | ~HasPinNotifyFunction () |
![]() | |
TraceValueRegister (TraceValueRegister *parent, const std::string &name) | |
Create a TraceValueRegister, with a scope prefix built on parent scope + name. More... | |
TraceValueRegister () | |
Create a TraceValueRegister, with a empty scope name, single device application. More... | |
virtual | ~TraceValueRegister () |
const std::string | GetTraceValuePrefix (void) |
Returns the scope prefix. More... | |
const std::string | GetScopeName (void) |
Returns the scope name. More... | |
void | RegisterTraceValue (TraceValue *t) |
Registers a TraceValue for this register. More... | |
void | UnregisterTraceValue (TraceValue *t) |
Unregisters a TraceValue, remove it from register. More... | |
TraceValueRegister * | GetScopeGroupByName (const std::string &name) |
Get a here registered TraceValueRegister by it's name. More... | |
virtual TraceValue * | GetTraceValueByName (const std::string &name) |
Get a here registered TraceValue by it's name. More... | |
TraceValueRegister * | FindScopeGroupByName (const std::string &name) |
Seek for a TraceValueRegister by it's name. More... | |
TraceValue * | FindTraceValueByName (const std::string &name) |
Seek for a TraceValue by it's name. More... | |
TraceSet * | GetAllTraceValues (void) |
Get all here registered TraceValue's only (not with descending values) More... | |
TraceSet * | GetAllTraceValuesRecursive (void) |
Get all here registered TraceValue's with descending values. More... | |
![]() | |
virtual | ~IOSpecialRegClient () |
![]() | |
virtual | ~AnalogSignalChange () |
Public Attributes | |
IOReg< HWAcomp > | acsr_reg |
ACSR IO register. More... | |
Protected Member Functions | |
unsigned char | set_from_reg (const IOSpecialReg *reg, unsigned char nv) |
unsigned char | get_from_client (const IOSpecialReg *reg, unsigned char v) |
bool | isSetACME (void) |
Check, if ACME flag is set (from ADC or SFIOR register) More... | |
![]() | |
virtual size_t | _tvr_getValuesCount (void) |
Get the count of all TraceValues, that are registered here and descending. More... | |
virtual void | _tvr_insertTraceValuesToSet (TraceSet &t) |
Insert all TraceValues into TraceSet, that registered here and descending. More... | |
Protected Attributes | |
HWIrqSystem * | irqSystem |
connection to IRQ controller More... | |
PinAtPort | pinAin0 |
port pin AIN0 More... | |
PinAtPort | pinAin1 |
port pin AIN1 More... | |
Pin * | v_bg |
get access to bandgap reference More... | |
Pin * | v_cc |
get access to voltage supply level More... | |
bool | useBG |
has ADBG register bit and can switch In0 to bandgap ref More... | |
bool | acme_sfior |
ACME flag in SFIOR register is set. More... | |
bool | enabled |
analog comparator is enabled More... | |
unsigned char | acsr |
ACSR register value. More... | |
unsigned int | irqVec |
stores the IRQ vector number More... | |
BasicTimerUnit * | timerA |
connection to timerA for input capture event. NULL, if not available More... | |
BasicTimerUnit * | timerB |
connection to timerB for input capture event. NULL, if not available More... | |
HWAd * | ad |
connection to ADC for analog input mux. NULL, if not available More... | |
IOSpecialReg * | sfior |
connection to SFIOR register, if necessary. NULL, if not used More... | |
anonymous enum |
HWAcomp::HWAcomp | ( | AvrDevice * | core, |
HWIrqSystem * | irqsys, | ||
PinAtPort | ain0, | ||
PinAtPort | ain1, | ||
unsigned int | irqVec, | ||
HWAd * | _ad, | ||
BasicTimerUnit * | _timerA, | ||
IOSpecialReg * | _sfior = NULL , |
||
BasicTimerUnit * | _timerB = NULL , |
||
bool | _useBG = true |
||
) |
constructor to instantiate a analog comparator peripheral
Definition at line 32 of file hwacomp.cpp.
References ad, IOSpecialReg::connectSRegClient(), HWIrqSystem::DebugVerifyInterruptVector(), PinAtPort::GetPin(), irqSystem, irqVec, BasicTimerUnit::RegisterACompForICapture(), Pin::RegisterCallback(), HWAd::RegisterNotifyClient(), Reset(), sfior, timerA, timerB, AvrDevice::v_bandgap, v_bg, v_cc, and AvrDevice::v_supply.
HWAcomp::~HWAcomp | ( | ) |
Definition at line 80 of file hwacomp.cpp.
References ad, and HWAd::UnregisterNotifyClient().
|
virtual |
Reflect irq processing, reset interrupt source.
Reimplemented from Hardware.
Definition at line 182 of file hwacomp.cpp.
References ACI, acsr, HWIrqSystem::ClearIrqFlag(), irqSystem, and irqVec.
Referenced by GetAcsr().
|
inlineprotectedvirtual |
Informs your class, that a read access from IO register happens
v | the internal saved register value (but maybe changed by other clients) |
Implements IOSpecialRegClient.
Definition at line 65 of file hwacomp.h.
References isSetACME().
|
inline |
Return last state of analog comparator (assume, that this is correct, if unit is disabled)
Definition at line 112 of file hwacomp.h.
References ACO, and NotifySignalChanged().
Referenced by ICaptureSource::GetSourceState().
|
inline |
Get method for ACSR register.
Definition at line 98 of file hwacomp.h.
References acsr, ClearIrqFlag(), GetIn0(), GetIn1(), PinStateHasChanged(), Reset(), and SetAcsr().
float HWAcomp::GetIn0 | ( | void | ) |
Get analog value for comparator input 0.
Definition at line 126 of file hwacomp.cpp.
References ACBG, acsr, PinAtPort::GetAnalogValue(), Pin::GetRawAnalog(), pinAin0, useBG, v_bg, and v_cc.
Referenced by GetAcsr(), PinStateHasChanged(), and Reset().
float HWAcomp::GetIn1 | ( | void | ) |
Get analog value for comparator input 1.
Definition at line 133 of file hwacomp.cpp.
References ad, HWAd::GetADMuxValue(), PinAtPort::GetAnalogValue(), Pin::GetRawAnalog(), isSetACME(), pinAin1, and v_cc.
Referenced by GetAcsr(), PinStateHasChanged(), and Reset().
|
protected |
Check, if ACME flag is set (from ADC or SFIOR register)
Definition at line 197 of file hwacomp.cpp.
References acme_sfior, ad, HWAd::IsADEnabled(), HWAd::IsSetACME(), and sfior.
Referenced by get_from_client(), GetIn1(), and NotifySignalChanged().
|
virtual |
Implements AnalogSignalChange.
Definition at line 176 of file hwacomp.cpp.
References isSetACME(), and PinStateHasChanged().
Referenced by GetACO().
|
virtual |
Get informed about input pin change.
Implements HasPinNotifyFunction.
Definition at line 141 of file hwacomp.cpp.
References ACI, ACIE, ACIS0, ACIS1, ACO, acsr, enabled, GetIn0(), GetIn1(), irqSystem, irqVec, and HWIrqSystem::SetIrqFlag().
Referenced by GetAcsr(), NotifySignalChanged(), set_from_reg(), and SetAcsr().
|
virtual |
|
protectedvirtual |
Informs your class, that a write access to IO register is happen
reg | caller register instance |
nv | the value, which is written to IO register (but maybe changed by other clients) |
Implements IOSpecialRegClient.
Definition at line 189 of file hwacomp.cpp.
References acme_sfior, and PinStateHasChanged().
void HWAcomp::SetAcsr | ( | unsigned char | val | ) |
Set method for ACSR register.
Definition at line 93 of file hwacomp.cpp.
References ACBG, ACD, ACI, ACIC, ACIE, ACO, acsr, HWIrqSystem::ClearIrqFlag(), enabled, irqSystem, irqVec, PinStateHasChanged(), BasicTimerUnit::SetACIC(), HWIrqSystem::SetIrqFlag(), timerA, timerB, and useBG.
Referenced by GetAcsr().
|
protected |
ACME flag in SFIOR register is set.
Definition at line 55 of file hwacomp.h.
Referenced by isSetACME(), Reset(), and set_from_reg().
|
protected |
ACSR register value.
Definition at line 57 of file hwacomp.h.
Referenced by ClearIrqFlag(), GetAcsr(), GetIn0(), PinStateHasChanged(), Reset(), and SetAcsr().
ACSR IO register.
Definition at line 82 of file hwacomp.h.
Referenced by AvrDevice_at90canbase::AvrDevice_at90canbase(), AvrDevice_atmega1284Abase::AvrDevice_atmega1284Abase(), AvrDevice_atmega2560base::AvrDevice_atmega2560base(), AvrDevice_atmega668base::AvrDevice_atmega668base(), and AvrDevice_attinyX5::AvrDevice_attinyX5().
|
protected |
connection to ADC for analog input mux. NULL, if not available
Definition at line 61 of file hwacomp.h.
Referenced by GetIn1(), HWAcomp(), isSetACME(), and ~HWAcomp().
|
protected |
analog comparator is enabled
Definition at line 56 of file hwacomp.h.
Referenced by PinStateHasChanged(), Reset(), and SetAcsr().
|
protected |
connection to IRQ controller
Definition at line 49 of file hwacomp.h.
Referenced by ClearIrqFlag(), HWAcomp(), PinStateHasChanged(), and SetAcsr().
|
protected |
stores the IRQ vector number
Definition at line 58 of file hwacomp.h.
Referenced by ClearIrqFlag(), HWAcomp(), PinStateHasChanged(), and SetAcsr().
|
protected |
|
protected |
|
protected |
connection to SFIOR register, if necessary. NULL, if not used
Definition at line 62 of file hwacomp.h.
Referenced by HWAcomp(), and isSetACME().
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |