simulavr  1.1.0
HWUsart Class Reference

Implements the I/O hardware necessary to do USART transfers. More...

#include <hwuart.h>

Inheritance diagram for HWUsart:

Public Member Functions

 HWUsart (AvrDevice *core, HWIrqSystem *, PinAtPort tx, PinAtPort rx, PinAtPort xck, unsigned int rx_interrupt, unsigned int udre_interrupt, unsigned int tx_interrupt, int instance_id=0, bool mxReg=true)
 Creates a instance of HWUsart class. More...
 
void SetUcsrc (unsigned char val)
 
void SetUcsrcUbrrh (unsigned char val)
 
unsigned char GetUcsrc ()
 
unsigned char GetUcsrcUbrrh ()
 
- Public Member Functions inherited from HWUart
 HWUart (AvrDevice *core, HWIrqSystem *, PinAtPort tx, PinAtPort rx, unsigned int rx_interrupt, unsigned int udre_interrupt, unsigned int tx_interrupt, int instance_id=0)
 Creates a instance of HWUart class. More...
 
virtual unsigned int CpuCycle ()
 
void Reset ()
 
void SetUdr (unsigned char val)
 
void SetUsr (unsigned char val)
 
void SetUcr (unsigned char val)
 
void SetUbrr (unsigned char val)
 
void SetUbrrhi (unsigned char val)
 
unsigned char GetUdr ()
 
unsigned char GetUsr ()
 
unsigned char GetUcr ()
 
unsigned char GetUbrr ()
 
unsigned char GetUbrrhi ()
 
void ClearIrqFlag (unsigned int)
 
void CheckForNewSetIrq (unsigned char)
 
void CheckForNewClearIrq (unsigned char)
 
- 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 Attributes

IOReg< HWUsartucsrc_reg
 
IOReg< HWUsartubrrh_reg
 
IOReg< HWUsartucsrc_ubrrh_reg
 
- Public Attributes inherited from HWUart
IOReg< HWUartudr_reg
 
IOReg< HWUartusr_reg
 
IOReg< HWUartucr_reg
 
IOReg< HWUartucsra_reg
 
IOReg< HWUartucsrb_reg
 
IOReg< HWUartubrr_reg
 IO register "UBRRxL" - baudrate. More...
 
IOReg< HWUartubrrhi_reg
 IO register "UBRRxH" - baudrate. More...
 

Protected Attributes

PinAtPort pinXck
 Clock pin for synchronous mode. More...
 
- Protected Attributes inherited from HWUart
unsigned char udrWrite
 Write stage of UDR register value. More...
 
unsigned char udrRead
 Read stage of UDR register value. More...
 
unsigned char usr
 USR register value, also used as UCSRA register value. More...
 
unsigned char ucr
 UCR register value, also used as UCSRB register value. More...
 
unsigned char ucsrc
 UCSRC register value. More...
 
unsigned short ubrr
 Baud rate register value (UBRR) More...
 
bool readParity
 The read parity flag for usart. More...
 
bool writeParity
 The write parity flag for usart. More...
 
int frameLength
 Hold length of UART frame. More...
 
HWIrqSystemirqSystem
 Connection to interrupt system. More...
 
PinAtPort pinTx
 TX pin. More...
 
PinAtPort pinRx
 RX pin. More...
 
unsigned int vectorRx
 Interrupt vector ID for receive interrupt. More...
 
unsigned int vectorUdre
 Interrupt vector ID for UDR empty interrupt. More...
 
unsigned int vectorTx
 Interrupt vector ID for sent byte interrupt. More...
 
unsigned char regSeq
 Cycle timer for controling read access to UCSRC/UBRRH combined register. More...
 
int baudCnt
 
T_RxState rxState
 
T_TxState txState
 
int cntRxSamples
 
int rxLowCnt
 
int rxHighCnt
 
unsigned int rxDataTmp
 
int rxBitCnt
 
int baudCnt16
 
unsigned char txDataTmp
 
int txBitCnt
 

Additional Inherited Members

- Protected Types inherited from HWUart
enum  T_RxState {
  RX_DISABLED, RX_WAIT_FOR_HIGH, RX_WAIT_FOR_LOWEDGE, RX_READ_STARTBIT,
  RX_READ_DATABIT, RX_READ_PARITY, RX_READ_STOPBIT, RX_READ_STOPBIT2
}
 
enum  T_TxState {
  TX_DISABLED, TX_SEND_STARTBIT, TX_SEND_DATABIT, TX_SEND_PARITY,
  TX_SEND_STOPBIT, TX_SEND_STOPBIT2, TX_AFTER_STOPBIT, TX_FIRST_RUN,
  TX_FINISH
}
 
- Protected Member Functions inherited from HWUart
unsigned int CpuCycleRx ()
 
unsigned int CpuCycleTx ()
 
void SetFrameLengthFromRegister ()
 
- 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...
 

Detailed Description

Implements the I/O hardware necessary to do USART transfers.

Definition at line 149 of file hwuart.h.

Constructor & Destructor Documentation

◆ HWUsart()

HWUsart::HWUsart ( AvrDevice core,
HWIrqSystem s,
PinAtPort  tx,
PinAtPort  rx,
PinAtPort  xck,
unsigned int  rx_interrupt,
unsigned int  udre_interrupt,
unsigned int  tx_interrupt,
int  instance_id = 0,
bool  mxReg = true 
)

Creates a instance of HWUsart class.

Definition at line 651 of file hwuart.cpp.

References IOReg< P >::releaseTraceValue(), HWUart::Reset(), ubrrh_reg, ucsrc_reg, and ucsrc_ubrrh_reg.

Member Function Documentation

◆ GetUcsrc()

unsigned char HWUsart::GetUcsrc ( )

Definition at line 639 of file hwuart.cpp.

References HWUart::ucsrc.

◆ GetUcsrcUbrrh()

unsigned char HWUsart::GetUcsrcUbrrh ( )

Definition at line 641 of file hwuart.cpp.

References HWUart::GetUbrrhi(), and HWUart::regSeq.

◆ SetUcsrc()

void HWUsart::SetUcsrc ( unsigned char  val)

Definition at line 626 of file hwuart.cpp.

References HWUart::SetFrameLengthFromRegister(), and HWUart::ucsrc.

◆ SetUcsrcUbrrh()

void HWUsart::SetUcsrcUbrrh ( unsigned char  val)

Definition at line 631 of file hwuart.cpp.

References HWUart::SetUbrrhi(), and URSEL.

Member Data Documentation

◆ pinXck

PinAtPort HWUsart::pinXck
protected

Clock pin for synchronous mode.

Definition at line 152 of file hwuart.h.

◆ ubrrh_reg

IOReg<HWUsart> HWUsart::ubrrh_reg

Definition at line 173 of file hwuart.h.

Referenced by AvrDevice_attiny2313::AvrDevice_attiny2313(), and HWUsart().

◆ ucsrc_reg

◆ ucsrc_ubrrh_reg

IOReg<HWUsart> HWUsart::ucsrc_ubrrh_reg

Definition at line 173 of file hwuart.h.

Referenced by AvrDevice_atmega16_32::AvrDevice_atmega16_32(), and HWUsart().


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