simulavr  1.1.0
HWUSI Class Reference

#include <hwusi.h>

Inheritance diagram for HWUSI:

Public Member Functions

 HWUSI (AvrDevice *core, HWIrqSystem *, PinAtPort din, PinAtPort dout, PinAtPort sck, unsigned int irq_start, unsigned int irq_ovr)
 
virtual ~HWUSI ()
 
virtual void Reset ()
 
virtual void fireEvent (int event)
 
int Step (bool &untilCoreStepFinished, SystemClockOffset *nextStepIn_ns=0)
 Return nonzero if a breakpoint was hit. More...
 
void SetUSIDR (unsigned char val)
 
void SetUSISR (unsigned char val)
 
void SetUSICR (unsigned char val)
 
unsigned char GetUSIDR (void)
 
unsigned char GetUSISR (void)
 
unsigned char GetUSICR (void)
 
- Public Member Functions inherited from Hardware
 Hardware (AvrDevice *core)
 
virtual ~Hardware ()
 
virtual unsigned int CpuCycle (void)
 
virtual void ClearIrqFlag (unsigned int vector)
 
virtual bool IsLevelInterrupt (unsigned int vector)
 
virtual bool LevelInterruptPending (unsigned int vector)
 
- Public Member Functions inherited from SimulationMember
virtual ~SimulationMember ()
 
- 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 HasPinNotifyFunction
virtual ~HasPinNotifyFunction ()
 
- Public Member Functions inherited from TimerEventListener
virtual ~TimerEventListener ()
 

Public Attributes

IOReg< HWUSIusidr_reg
 
IOReg< HWUSIusisr_reg
 
IOReg< HWUSIusicr_reg
 

Protected Member Functions

virtual void setDataBuffer (unsigned char data)
 
virtual void registerDIandSCK (HWUSI *cb)
 
virtual void toggleSCK (void)
 
virtual void setDO (bool state)
 
virtual void setDI (bool state, bool ddr, bool port)
 
virtual void setSCK_TWI (bool hold, bool ddr, bool port)
 
virtual void controlDO (bool state)
 
virtual void controlTWI (bool state)
 
- 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...
 

Private Types

enum  WMtype {
  WM_OFF = 0, WM_3WIRE, WM_2WIRE, WM_2WIRE_OVR,
  WM_tablesize
}
 

Private Member Functions

void doCount (void)
 
void setDout (void)
 
void doShift (void)
 
void PinStateHasChanged (Pin *)
 

Private Attributes

HWIrqSystemirq
 
unsigned char shift_data
 
unsigned char control_data
 
PinAtPort DI
 
PinAtPort DO
 
PinAtPort SCK
 
bool sck_state
 
bool sck_port
 
bool sck_ddr
 
bool di_state
 
bool di_port
 
bool di_ddr
 
bool scl_hold
 
unsigned int irq_start
 
bool irqen_start
 
bool irqactive_start
 
unsigned int irq_ovr
 
bool irqen_ovr
 
bool irqactive_ovr
 
bool flag_stop
 
bool flag_dcol
 
WMtype wire_mode
 
unsigned char clock_mode
 
unsigned char counter_data
 
bool is_DI_change
 

Detailed Description

Implements USI base module (w/o buffer register or alternate pins)

Definition at line 41 of file hwusi.h.

Member Enumeration Documentation

◆ WMtype

enum HWUSI::WMtype
private

types of wiremodes

Enumerator
WM_OFF 
WM_3WIRE 
WM_2WIRE 
WM_2WIRE_OVR 
WM_tablesize 

Definition at line 45 of file hwusi.h.

Constructor & Destructor Documentation

◆ HWUSI()

HWUSI::HWUSI ( AvrDevice core,
HWIrqSystem _irq,
PinAtPort  din,
PinAtPort  dout,
PinAtPort  sck,
unsigned int  irq_start,
unsigned int  irq_ovr 
)

◆ ~HWUSI()

virtual HWUSI::~HWUSI ( )
inlinevirtual

Definition at line 148 of file hwusi.h.

References fireEvent(), Reset(), SetUSICR(), SetUSIDR(), SetUSISR(), and Step().

Member Function Documentation

◆ controlDO()

void HWUSI::controlDO ( bool  state)
protectedvirtual

set output control for DO pin

Definition at line 187 of file hwusi.cpp.

References DO, and PinAtPort::SetUseAlternatePortIfDdrSet().

Referenced by Reset(), setDataBuffer(), and SetUSICR().

◆ controlTWI()

void HWUSI::controlTWI ( bool  state)
protectedvirtual

◆ doCount()

void HWUSI::doCount ( void  )
private

◆ doShift()

void HWUSI::doShift ( void  )
private

process shift event, store DI in LSB

Definition at line 142 of file hwusi.cpp.

References DI, and shift_data.

Referenced by fireEvent(), and PinStateHasChanged().

◆ fireEvent()

void HWUSI::fireEvent ( int  event)
virtual

Implements TimerEventListener.

Definition at line 352 of file hwusi.cpp.

References clock_mode, doCount(), doShift(), BasicTimerUnit::EVT_COMPARE_1, and setDout().

Referenced by ~HWUSI().

◆ GetUSICR()

unsigned char HWUSI::GetUSICR ( void  )
inline

Definition at line 165 of file hwusi.h.

References control_data.

◆ GetUSIDR()

unsigned char HWUSI::GetUSIDR ( void  )
inline

Definition at line 163 of file hwusi.h.

References GetUSISR(), and shift_data.

◆ GetUSISR()

unsigned char HWUSI::GetUSISR ( void  )

Definition at line 37 of file hwusi.cpp.

References counter_data, flag_dcol, flag_stop, irqactive_ovr, and irqactive_start.

Referenced by GetUSIDR().

◆ PinStateHasChanged()

◆ registerDIandSCK()

void HWUSI::registerDIandSCK ( HWUSI cb)
protectedvirtual

register notify for SCK pin

Definition at line 168 of file hwusi.cpp.

References DI, PinAtPort::GetPin(), Pin::RegisterCallback(), and SCK.

Referenced by HWUSI(), and setDataBuffer().

◆ Reset()

void HWUSI::Reset ( void  )
virtual

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

Reimplemented from Hardware.

Reimplemented in HWUSI_BR.

Definition at line 229 of file hwusi.cpp.

References clock_mode, control_data, controlDO(), controlTWI(), counter_data, di_ddr, di_port, di_state, flag_dcol, flag_stop, irqactive_ovr, irqactive_start, irqen_ovr, irqen_start, is_DI_change, sck_ddr, sck_port, sck_state, scl_hold, shift_data, wire_mode, and WM_OFF.

Referenced by HWUSI(), HWUSI_BR::Reset(), and ~HWUSI().

◆ setDataBuffer()

virtual void HWUSI::setDataBuffer ( unsigned char  data)
inlineprotectedvirtual

interface to store data to buffer register

Reimplemented in HWUSI_BR.

Definition at line 121 of file hwusi.h.

References controlDO(), controlTWI(), HWUSI(), registerDIandSCK(), setDI(), setDO(), setSCK_TWI(), and toggleSCK().

Referenced by doCount().

◆ setDI()

void HWUSI::setDI ( bool  state,
bool  ddr,
bool  port 
)
protectedvirtual

set state for DI pin

Definition at line 177 of file hwusi.cpp.

References DI, and PinAtPort::SetAlternateDdr().

Referenced by setDataBuffer(), setDout(), SetUSICR(), and Step().

◆ setDO()

void HWUSI::setDO ( bool  state)
protectedvirtual

set state for DO pin

Definition at line 173 of file hwusi.cpp.

References DO, and PinAtPort::SetAlternatePort().

Referenced by setDataBuffer(), and setDout().

◆ setDout()

void HWUSI::setDout ( void  )
private

set DO output pin

Definition at line 147 of file hwusi.cpp.

References di_ddr, di_port, setDI(), setDO(), shift_data, wire_mode, WM_3WIRE, and WM_OFF.

Referenced by fireEvent(), PinStateHasChanged(), SetUSICR(), and SetUSIDR().

◆ setSCK_TWI()

void HWUSI::setSCK_TWI ( bool  hold,
bool  ddr,
bool  port 
)
protectedvirtual

set state for SCK pin in two wire modes

Definition at line 182 of file hwusi.cpp.

References SCK, and PinAtPort::SetAlternateDdr().

Referenced by setDataBuffer(), SetUSICR(), SetUSISR(), and Step().

◆ SetUSICR()

void HWUSI::SetUSICR ( unsigned char  val)

◆ SetUSIDR()

void HWUSI::SetUSIDR ( unsigned char  val)

Definition at line 32 of file hwusi.cpp.

References setDout(), and shift_data.

Referenced by ~HWUSI().

◆ SetUSISR()

void HWUSI::SetUSISR ( unsigned char  val)

◆ Step()

int HWUSI::Step ( bool &  trueHwStep,
SystemClockOffset timeToNextStepIn_ns = 0 
)
virtual

Return nonzero if a breakpoint was hit.

Implements SimulationMember.

Definition at line 255 of file hwusi.cpp.

References di_ddr, di_port, is_DI_change, sck_ddr, sck_port, scl_hold, setDI(), setSCK_TWI(), and shift_data.

Referenced by ~HWUSI().

◆ toggleSCK()

void HWUSI::toggleSCK ( void  )
protectedvirtual

toggle port state for SCK pin

Definition at line 161 of file hwusi.cpp.

References PinAtPort::GetPort(), SCK, and PinAtPort::SetPort().

Referenced by setDataBuffer(), and SetUSICR().

Member Data Documentation

◆ clock_mode

unsigned char HWUSI::clock_mode
private

USI clock mode [USICS1 USICS0 USICLK]

Definition at line 102 of file hwusi.h.

Referenced by doCount(), fireEvent(), PinStateHasChanged(), Reset(), and SetUSICR().

◆ control_data

unsigned char HWUSI::control_data
private

USI control register

Definition at line 59 of file hwusi.h.

Referenced by GetUSICR(), Reset(), and SetUSICR().

◆ counter_data

unsigned char HWUSI::counter_data
private

USI 4bit counter

Definition at line 107 of file hwusi.h.

Referenced by doCount(), GetUSISR(), HWUSI(), Reset(), and SetUSISR().

◆ DI

PinAtPort HWUSI::DI
private

data input port pin

Definition at line 62 of file hwusi.h.

Referenced by controlTWI(), doShift(), PinStateHasChanged(), registerDIandSCK(), and setDI().

◆ di_ddr

bool HWUSI::di_ddr
private

DDR register value for DI port pin

Definition at line 78 of file hwusi.h.

Referenced by PinStateHasChanged(), Reset(), setDout(), SetUSICR(), and Step().

◆ di_port

bool HWUSI::di_port
private

PORT register value for DI port pin

Definition at line 76 of file hwusi.h.

Referenced by PinStateHasChanged(), Reset(), setDout(), SetUSICR(), and Step().

◆ di_state

bool HWUSI::di_state
private

stored input state for DI port pin

Definition at line 74 of file hwusi.h.

Referenced by PinStateHasChanged(), and Reset().

◆ DO

PinAtPort HWUSI::DO
private

data output port pin

Definition at line 64 of file hwusi.h.

Referenced by controlDO(), and setDO().

◆ flag_dcol

bool HWUSI::flag_dcol
private

active flag for data collision (no interrupt)

Definition at line 97 of file hwusi.h.

Referenced by GetUSISR(), and Reset().

◆ flag_stop

bool HWUSI::flag_stop
private

active flag for stop condition (no interrupt)

Definition at line 95 of file hwusi.h.

Referenced by GetUSISR(), Reset(), and SetUSISR().

◆ irq

HWIrqSystem* HWUSI::irq
private

connected irq system controller

Definition at line 54 of file hwusi.h.

Referenced by doCount(), HWUSI(), PinStateHasChanged(), and SetUSISR().

◆ irq_ovr

unsigned int HWUSI::irq_ovr
private

irq vector for USI counter overflow interrupt

Definition at line 89 of file hwusi.h.

Referenced by doCount(), and SetUSISR().

◆ irq_start

unsigned int HWUSI::irq_start
private

irq vector for USI start condition interrupt

Definition at line 83 of file hwusi.h.

Referenced by PinStateHasChanged(), and SetUSISR().

◆ irqactive_ovr

bool HWUSI::irqactive_ovr
private

active flag for USI counter overflow interrupt

Definition at line 93 of file hwusi.h.

Referenced by doCount(), GetUSISR(), Reset(), and SetUSISR().

◆ irqactive_start

bool HWUSI::irqactive_start
private

active flag for start condition interrupt

Definition at line 87 of file hwusi.h.

Referenced by GetUSISR(), PinStateHasChanged(), Reset(), and SetUSISR().

◆ irqen_ovr

bool HWUSI::irqen_ovr
private

enable flag for USI counter overflow interrupt

Definition at line 91 of file hwusi.h.

Referenced by doCount(), Reset(), and SetUSICR().

◆ irqen_start

bool HWUSI::irqen_start
private

enable flag for start condition interrupt

Definition at line 85 of file hwusi.h.

Referenced by PinStateHasChanged(), Reset(), and SetUSICR().

◆ is_DI_change

bool HWUSI::is_DI_change
private

flag for save, which output state is to change

Definition at line 117 of file hwusi.h.

Referenced by doCount(), PinStateHasChanged(), Reset(), and Step().

◆ SCK

PinAtPort HWUSI::SCK
private

data clock port pin

Definition at line 66 of file hwusi.h.

Referenced by controlTWI(), PinStateHasChanged(), registerDIandSCK(), setSCK_TWI(), and toggleSCK().

◆ sck_ddr

bool HWUSI::sck_ddr
private

DDR register value for SCK port pin

Definition at line 72 of file hwusi.h.

Referenced by PinStateHasChanged(), Reset(), SetUSICR(), SetUSISR(), and Step().

◆ sck_port

bool HWUSI::sck_port
private

PORT register value for SCK port pin

Definition at line 70 of file hwusi.h.

Referenced by PinStateHasChanged(), Reset(), SetUSICR(), SetUSISR(), and Step().

◆ sck_state

bool HWUSI::sck_state
private

stored input state for SCK port pin

Definition at line 68 of file hwusi.h.

Referenced by PinStateHasChanged(), and Reset().

◆ scl_hold

bool HWUSI::scl_hold
private

USI SCL hold state

Definition at line 80 of file hwusi.h.

Referenced by doCount(), PinStateHasChanged(), Reset(), SetUSISR(), and Step().

◆ shift_data

unsigned char HWUSI::shift_data
private

USI shift register

Definition at line 57 of file hwusi.h.

Referenced by doCount(), doShift(), GetUSIDR(), HWUSI(), Reset(), setDout(), SetUSICR(), SetUSIDR(), and Step().

◆ usicr_reg

IOReg<HWUSI> HWUSI::usicr_reg

◆ usidr_reg

IOReg<HWUSI> HWUSI::usidr_reg

◆ usisr_reg

IOReg<HWUSI> HWUSI::usisr_reg

◆ wire_mode

WMtype HWUSI::wire_mode
private

USI wire mode

Definition at line 100 of file hwusi.h.

Referenced by doCount(), PinStateHasChanged(), Reset(), setDout(), and SetUSICR().


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