simulavr  1.1.0
HWAd Class Reference

#include <hwad.h>

Inheritance diagram for HWAd:

Public Types

enum  {
  AD_4433, AD_M8, AD_M16, AD_M64,
  AD_M128, AD_M48, AD_M164, AD_T25,
  AD_M2560
}
 

Public Member Functions

 HWAd (AvrDevice *c, int _typ, HWIrqSystem *i, unsigned int iv, HWAdmux *a, HWARef *r)
 
virtual ~HWAd ()
 
unsigned int CpuCycle ()
 
unsigned char GetAdch (void)
 
unsigned char GetAdcl (void)
 
unsigned char GetAdcsrA (void)
 
unsigned char GetAdcsrB (void)
 
unsigned char GetAdmux (void)
 
void SetAdcsrA (unsigned char)
 
void SetAdcsrB (unsigned char)
 
void SetAdmux (unsigned char val)
 
void Reset (void)
 
void ClearIrqFlag (unsigned int vec)
 
void NotifySignalChanged (void)
 
bool IsADEnabled (void)
 Check, if ADC is enabled. More...
 
bool IsSetACME (void)
 Check, if ACME bit is set, return false, if not available. More...
 
float GetADMuxValue (float vcc)
 Get analog value from ADC multiplexer. More...
 
void RegisterNotifyClient (AnalogSignalChange *client)
 Register analog comparator for notification of multiplexer signal change. More...
 
void UnregisterNotifyClient (void)
 Unregister client for signal change notification. More...
 
- Public Member Functions inherited from Hardware
 Hardware (AvrDevice *core)
 
virtual ~Hardware ()
 
virtual bool IsLevelInterrupt (unsigned int vector)
 
virtual bool LevelInterruptPending (unsigned int vector)
 
- Public Member Functions inherited from TraceValueRegister
 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...
 
TraceValueRegisterGetScopeGroupByName (const std::string &name)
 Get a here registered TraceValueRegister by it's name. More...
 
virtual TraceValueGetTraceValueByName (const std::string &name)
 Get a here registered TraceValue by it's name. More...
 
TraceValueRegisterFindScopeGroupByName (const std::string &name)
 Seek for a TraceValueRegister by it's name. More...
 
TraceValueFindTraceValueByName (const std::string &name)
 Seek for a TraceValue by it's name. More...
 
TraceSetGetAllTraceValues (void)
 Get all here registered TraceValue's only (not with descending values) More...
 
TraceSetGetAllTraceValuesRecursive (void)
 Get all here registered TraceValue's with descending values. More...
 
- Public Member Functions inherited from AnalogSignalChange
virtual ~AnalogSignalChange ()
 

Public Attributes

IOReg< HWAdadch_reg
 
IOReg< HWAdadcl_reg
 
IOReg< HWAdadcsra_reg
 
IOReg< HWAdadcsrb_reg
 
IOReg< HWAdadmux_reg
 

Protected Types

enum  T_State { IDLE, INIT, RUNNING }
 
enum  {
  ADEN = 0x80, BIN = 0x80, ADSC = 0x40, ACME = 0x40,
  ADFR = 0x20, ADATE = 0x20, ADLAR = 0x20, IPR = 0x20,
  ADIF = 0x10, ADIE = 0x08, MUX5 = 0x08, ADPS = 0x07,
  ADTS = 0x07
}
 

Protected Member Functions

bool IsPrescalerClock (void)
 
bool IsFreeRunning (void)
 
virtual int GetTriggerSource (void)
 
int ConversionBipolar (float value, float ref)
 
int ConversionUnipolar (float value, float ref)
 
- Protected Member Functions inherited from TraceValueRegister
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

int adType
 
unsigned char adch
 
unsigned char adcl
 
unsigned char adcsra
 
unsigned char adcsrb
 
unsigned char admux
 
AvrDevicecore
 
HWAdmuxmux
 
HWARefaref
 
HWIrqSystemirqSystem
 
unsigned int irqVec
 
bool adchLocked
 
int adSample
 
int adMuxConfig
 
int prescaler
 
int prescalerSelect
 
int conversionState
 
bool firstConversion
 
AnalogSignalChangenotifyClient
 
enum HWAd::T_State state
 

Detailed Description

Analog-digital converter (ADC)

Definition at line 204 of file hwad.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
ADEN 
BIN 
ADSC 
ACME 
ADFR 
ADATE 
ADLAR 
IPR 
ADIF 
ADIE 
MUX5 
ADPS 
ADTS 

Definition at line 234 of file hwad.h.

◆ anonymous enum

anonymous enum
Enumerator
AD_4433 

ADC type 4433: ADC on at90s/l4433.

AD_M8 

ADC type M8: ADC on atmega8.

AD_M16 

ADC type M16: ADC on atmega16 and atmega32.

AD_M64 

ADC type M64: ADC on atmega64.

AD_M128 

ADC type M128: ADC on atmega128.

AD_M48 

ADC type M48: ADC on atmega48/88/168/328.

AD_M164 

ADC type M164: ADC on atmega164/324/644/1284 and at90can32/64/128.

AD_T25 

ADC type T25: ADC on attiny25/45/85.

AD_M2560 

ADC type M2560: ADC on atmega2560.

Definition at line 257 of file hwad.h.

◆ T_State

enum HWAd::T_State
protected
Enumerator
IDLE 
INIT 
RUNNING 

Definition at line 228 of file hwad.h.

Constructor & Destructor Documentation

◆ HWAd()

HWAd::HWAd ( AvrDevice c,
int  _typ,
HWIrqSystem i,
unsigned int  iv,
HWAdmux a,
HWARef r 
)

◆ ~HWAd()

virtual HWAd::~HWAd ( )
inlinevirtual

Definition at line 276 of file hwad.h.

References HWAdmux::UnregisterNotifyClient().

Member Function Documentation

◆ ClearIrqFlag()

void HWAd::ClearIrqFlag ( unsigned int  vector)
virtual

This signals the hardware that the given IRQ vector has been handled by the AVR core.

Reimplemented from Hardware.

Definition at line 510 of file hwad.cpp.

References adcsra, ADIF, HWIrqSystem::ClearIrqFlag(), irqSystem, and irqVec.

◆ ConversionBipolar()

int HWAd::ConversionBipolar ( float  value,
float  ref 
)
protected

Definition at line 577 of file hwad.cpp.

Referenced by CpuCycle().

◆ ConversionUnipolar()

int HWAd::ConversionUnipolar ( float  value,
float  ref 
)
protected

Definition at line 596 of file hwad.cpp.

Referenced by CpuCycle().

◆ CpuCycle()

unsigned int HWAd::CpuCycle ( void  )
virtual

Called for each AVR cycle when this hardware has registered itself as a receiver for AVR clocks. Returns nonzero if instructions should not be executed (e.g. a Flash write is in progress).

Reimplemented from Hardware.

Definition at line 612 of file hwad.cpp.

References AD_T25, adch, adchLocked, adcl, adcsra, adcsrb, ADIE, ADIF, ADLAR, admux, adMuxConfig, adSample, ADSC, adType, aref, BIN, ConversionBipolar(), conversionState, ConversionUnipolar(), core, firstConversion, Pin::GetRawAnalog(), HWARef::GetRefValue(), HWAdmux::GetValue(), IDLE, INIT, IPR, irqSystem, irqVec, HWAdmux::IsDifferenceChannel(), IsFreeRunning(), IsPrescalerClock(), mux, MUX5, RUNNING, HWIrqSystem::SetIrqFlag(), state, AvrDevice::trace_on, traceOut, and AvrDevice::v_supply.

◆ GetAdch()

unsigned char HWAd::GetAdch ( void  )

Definition at line 444 of file hwad.cpp.

References adch, and adchLocked.

◆ GetAdcl()

unsigned char HWAd::GetAdcl ( void  )

Definition at line 449 of file hwad.cpp.

References adchLocked, and adcl.

◆ GetAdcsrA()

unsigned char HWAd::GetAdcsrA ( void  )
inline

Definition at line 282 of file hwad.h.

◆ GetAdcsrB()

unsigned char HWAd::GetAdcsrB ( void  )
inline

Definition at line 283 of file hwad.h.

◆ GetAdmux()

unsigned char HWAd::GetAdmux ( void  )
inline

Definition at line 284 of file hwad.h.

◆ GetADMuxValue()

float HWAd::GetADMuxValue ( float  vcc)
inline

Get analog value from ADC multiplexer.

Definition at line 300 of file hwad.h.

References HWAdmux::GetValueAComp().

Referenced by HWAcomp::GetIn1().

◆ GetTriggerSource()

int HWAd::GetTriggerSource ( void  )
protectedvirtual

Reimplemented in HWAd_SFIOR.

Definition at line 560 of file hwad.cpp.

References adcsrb, and ADTS.

Referenced by IsFreeRunning().

◆ IsADEnabled()

bool HWAd::IsADEnabled ( void  )
inline

Check, if ADC is enabled.

Definition at line 296 of file hwad.h.

Referenced by HWAcomp::isSetACME(), and NotifySignalChanged().

◆ IsFreeRunning()

bool HWAd::IsFreeRunning ( void  )
protected

Definition at line 564 of file hwad.cpp.

References AD_4433, AD_M128, AD_M8, ADATE, adcsra, ADFR, adType, and GetTriggerSource().

Referenced by CpuCycle().

◆ IsPrescalerClock()

bool HWAd::IsPrescalerClock ( void  )
protected

Definition at line 520 of file hwad.cpp.

References adcsra, ADEN, prescaler, and prescalerSelect.

Referenced by CpuCycle().

◆ IsSetACME()

bool HWAd::IsSetACME ( void  )
inline

Check, if ACME bit is set, return false, if not available.

Definition at line 298 of file hwad.h.

Referenced by HWAcomp::isSetACME().

◆ NotifySignalChanged()

void HWAd::NotifySignalChanged ( void  )
virtual

Implements AnalogSignalChange.

Definition at line 439 of file hwad.cpp.

References IsADEnabled(), notifyClient, and AnalogSignalChange::NotifySignalChanged().

Referenced by SetAdcsrA(), and SetAdcsrB().

◆ RegisterNotifyClient()

void HWAd::RegisterNotifyClient ( AnalogSignalChange client)
inline

Register analog comparator for notification of multiplexer signal change.

Definition at line 302 of file hwad.h.

Referenced by HWAcomp::HWAcomp().

◆ Reset()

void HWAd::Reset ( void  )
virtual

Implement the hardware's reset functionality here. The default is no action on reset.

Reimplemented from Hardware.

Reimplemented in HWAd_SFIOR.

Definition at line 426 of file hwad.cpp.

References adch, adchLocked, adcl, adcsra, adcsrb, admux, adMuxConfig, conversionState, firstConversion, IDLE, prescaler, prescalerSelect, and state.

Referenced by HWAd(), and HWAd_SFIOR::Reset().

◆ SetAdcsrA()

void HWAd::SetAdcsrA ( unsigned char  val)

◆ SetAdcsrB()

void HWAd::SetAdcsrB ( unsigned char  val)

Definition at line 484 of file hwad.cpp.

References AD_M2560, AD_M64, AD_T25, adcsrb, adType, and NotifySignalChanged().

◆ SetAdmux()

void HWAd::SetAdmux ( unsigned char  val)

Definition at line 500 of file hwad.cpp.

References AD_4433, AD_M48, AD_M8, adcsrb, admux, adType, mux, MUX5, and HWAdmux::SetMuxSelect().

◆ UnregisterNotifyClient()

void HWAd::UnregisterNotifyClient ( void  )
inline

Unregister client for signal change notification.

Definition at line 304 of file hwad.h.

Referenced by HWAcomp::~HWAcomp().

Member Data Documentation

◆ adch

unsigned char HWAd::adch
protected

Definition at line 208 of file hwad.h.

Referenced by CpuCycle(), GetAdch(), and Reset().

◆ adch_reg

◆ adchLocked

bool HWAd::adchLocked
protected

Definition at line 219 of file hwad.h.

Referenced by CpuCycle(), GetAdch(), GetAdcl(), and Reset().

◆ adcl

unsigned char HWAd::adcl
protected

Definition at line 209 of file hwad.h.

Referenced by CpuCycle(), GetAdcl(), and Reset().

◆ adcl_reg

◆ adcsra

unsigned char HWAd::adcsra
protected

Definition at line 210 of file hwad.h.

Referenced by ClearIrqFlag(), CpuCycle(), IsFreeRunning(), IsPrescalerClock(), Reset(), and SetAdcsrA().

◆ adcsra_reg

◆ adcsrb

unsigned char HWAd::adcsrb
protected

Definition at line 211 of file hwad.h.

Referenced by CpuCycle(), GetTriggerSource(), Reset(), SetAdcsrB(), and SetAdmux().

◆ adcsrb_reg

◆ admux

unsigned char HWAd::admux
protected

Definition at line 212 of file hwad.h.

Referenced by CpuCycle(), Reset(), and SetAdmux().

◆ admux_reg

◆ adMuxConfig

int HWAd::adMuxConfig
protected

Definition at line 221 of file hwad.h.

Referenced by CpuCycle(), and Reset().

◆ adSample

int HWAd::adSample
protected

Definition at line 220 of file hwad.h.

Referenced by CpuCycle().

◆ adType

int HWAd::adType
protected

Definition at line 207 of file hwad.h.

Referenced by CpuCycle(), IsFreeRunning(), SetAdcsrB(), and SetAdmux().

◆ aref

HWARef* HWAd::aref
protected

Definition at line 215 of file hwad.h.

Referenced by CpuCycle().

◆ conversionState

int HWAd::conversionState
protected

Definition at line 224 of file hwad.h.

Referenced by CpuCycle(), and Reset().

◆ core

AvrDevice* HWAd::core
protected

Definition at line 213 of file hwad.h.

Referenced by CpuCycle(), and HWAd().

◆ firstConversion

bool HWAd::firstConversion
protected

Definition at line 225 of file hwad.h.

Referenced by CpuCycle(), Reset(), and SetAdcsrA().

◆ irqSystem

HWIrqSystem* HWAd::irqSystem
protected

Definition at line 216 of file hwad.h.

Referenced by ClearIrqFlag(), CpuCycle(), HWAd(), and SetAdcsrA().

◆ irqVec

unsigned int HWAd::irqVec
protected

Definition at line 217 of file hwad.h.

Referenced by ClearIrqFlag(), CpuCycle(), HWAd(), and SetAdcsrA().

◆ mux

HWAdmux* HWAd::mux
protected

Definition at line 214 of file hwad.h.

Referenced by CpuCycle(), HWAd(), and SetAdmux().

◆ notifyClient

AnalogSignalChange* HWAd::notifyClient
protected

Definition at line 226 of file hwad.h.

Referenced by NotifySignalChanged().

◆ prescaler

int HWAd::prescaler
protected

Definition at line 222 of file hwad.h.

Referenced by IsPrescalerClock(), and Reset().

◆ prescalerSelect

int HWAd::prescalerSelect
protected

Definition at line 223 of file hwad.h.

Referenced by IsPrescalerClock(), Reset(), and SetAdcsrA().

◆ state

enum HWAd::T_State HWAd::state
protected

Referenced by CpuCycle(), and Reset().


The documentation for this class was generated from the following files: