simulavr
1.1.0
|
Implements the I/O hardware necessary to do UART transfers. More...
#include <hwuart.h>
Public Member Functions | |
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) |
![]() | |
Hardware (AvrDevice *core) | |
virtual | ~Hardware () |
virtual bool | IsLevelInterrupt (unsigned int vector) |
virtual bool | LevelInterruptPending (unsigned int vector) |
![]() | |
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... | |
Public Attributes | |
IOReg< HWUart > | udr_reg |
IOReg< HWUart > | usr_reg |
IOReg< HWUart > | ucr_reg |
IOReg< HWUart > | ucsra_reg |
IOReg< HWUart > | ucsrb_reg |
IOReg< HWUart > | ubrr_reg |
IO register "UBRRxL" - baudrate. More... | |
IOReg< HWUart > | ubrrhi_reg |
IO register "UBRRxH" - baudrate. More... | |
Protected Types | |
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 | |
unsigned int | CpuCycleRx () |
unsigned int | CpuCycleTx () |
void | SetFrameLengthFromRegister () |
![]() | |
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 | |
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... | |
HWIrqSystem * | irqSystem |
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 |
Implements the I/O hardware necessary to do UART transfers.
|
protected |
|
protected |
HWUart::HWUart | ( | AvrDevice * | core, |
HWIrqSystem * | s, | ||
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.
Definition at line 525 of file hwuart.cpp.
References AvrDevice::AddToCycleList(), HWIrqSystem::DebugVerifyInterruptVector(), irqSystem, Reset(), trace_direct(), ubrr, ucr, udrRead, udrWrite, usr, vectorRx, vectorTx, and vectorUdre.
void HWUart::CheckForNewClearIrq | ( | unsigned char | val | ) |
Definition at line 600 of file hwuart.cpp.
References HWIrqSystem::ClearIrqFlag(), irqSystem, RXC, TXC, UDRE, vectorRx, vectorTx, and vectorUdre.
Referenced by CpuCycleRx(), CpuCycleTx(), SetUcr(), and SetUsr().
void HWUart::CheckForNewSetIrq | ( | unsigned char | val | ) |
Definition at line 594 of file hwuart.cpp.
References irqSystem, RXC, HWIrqSystem::SetIrqFlag(), TXC, UDRE, vectorRx, vectorTx, and vectorUdre.
Referenced by CpuCycleRx(), CpuCycleTx(), SetUcr(), and SetUsr().
|
virtual |
This signals the hardware that the given IRQ vector has been handled by the AVR core.
Reimplemented from Hardware.
Definition at line 586 of file hwuart.cpp.
References HWIrqSystem::ClearIrqFlag(), irqSystem, TXC, usr, and vectorTx.
|
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 170 of file hwuart.cpp.
References baudCnt, CpuCycleRx(), CpuCycleTx(), regSeq, and ubrr.
|
protected |
Definition at line 185 of file hwuart.cpp.
References CheckForNewClearIrq(), CheckForNewSetIrq(), CHR9, cntRxSamples, FE, frameLength, OR, pinRx, readParity, RX_DISABLED, RX_READ_DATABIT, RX_READ_PARITY, RX_READ_STARTBIT, RX_READ_STOPBIT, RX_READ_STOPBIT2, RX_WAIT_FOR_HIGH, RX_WAIT_FOR_LOWEDGE, RXB8, rxBitCnt, RXC, rxDataTmp, RXEN, rxHighCnt, rxLowCnt, rxState, ucr, ucsrc, udrRead, UPE, UPM0, UPM1, USBS, and usr.
Referenced by CpuCycle().
|
protected |
Definition at line 386 of file hwuart.cpp.
References baudCnt16, CheckForNewClearIrq(), CheckForNewSetIrq(), frameLength, pinTx, PinAtPort::SetAlternatePort(), TX_AFTER_STOPBIT, TX_DISABLED, TX_FINISH, TX_FIRST_RUN, TX_SEND_DATABIT, TX_SEND_PARITY, TX_SEND_STARTBIT, TX_SEND_STOPBIT, TX_SEND_STOPBIT2, TXB8, txBitCnt, TXC, txDataTmp, TXEN, txState, ucr, ucsrc, UDRE, udrWrite, UPM0, UPM1, USBS, usr, and writeParity.
Referenced by CpuCycle().
unsigned char HWUart::GetUbrr | ( | ) |
Definition at line 583 of file hwuart.cpp.
References ubrr.
unsigned char HWUart::GetUbrrhi | ( | ) |
unsigned char HWUart::GetUcr | ( | ) |
Definition at line 582 of file hwuart.cpp.
References ucr.
unsigned char HWUart::GetUdr | ( | ) |
Definition at line 571 of file hwuart.cpp.
References HWIrqSystem::ClearIrqFlag(), irqSystem, RXC, ucr, udrRead, usr, and vectorRx.
unsigned char HWUart::GetUsr | ( | ) |
Definition at line 581 of file hwuart.cpp.
References usr.
|
virtual |
Implement the hardware's reset functionality here. The default is no action on reset.
Reimplemented from Hardware.
Definition at line 606 of file hwuart.cpp.
References baudCnt, baudCnt16, regSeq, RX_WAIT_FOR_LOWEDGE, rxState, SetFrameLengthFromRegister(), TX_FIRST_RUN, txState, ubrr, ucr, ucsrc, UCSZ0, UCSZ1, UDRE, udrRead, udrWrite, and usr.
Referenced by HWUart(), and HWUsart::HWUsart().
|
protected |
Definition at line 100 of file hwuart.cpp.
References frameLength, ucr, ucsrc, UCSZ0, UCSZ1, and UCSZ2.
Referenced by Reset(), SetUcr(), and HWUsart::SetUcsrc().
void HWUart::SetUbrr | ( | unsigned char | val | ) |
Definition at line 92 of file hwuart.cpp.
References ubrr.
void HWUart::SetUbrrhi | ( | unsigned char | val | ) |
void HWUart::SetUcr | ( | unsigned char | val | ) |
Definition at line 126 of file hwuart.cpp.
References CheckForNewClearIrq(), CheckForNewSetIrq(), pinRx, pinTx, RXEN, PinAtPort::SetAlternateDdr(), PinAtPort::SetAlternatePort(), SetFrameLengthFromRegister(), PinAtPort::SetUseAlternateDdr(), PinAtPort::SetUseAlternatePort(), TX_FIRST_RUN, TX_SEND_STARTBIT, TXEN, txState, ucr, and usr.
void HWUart::SetUdr | ( | unsigned char | val | ) |
Definition at line 62 of file hwuart.cpp.
References HWIrqSystem::ClearIrqFlag(), irqSystem, ucr, UDRE, UDRIE, udrWrite, usr, and vectorUdre.
void HWUart::SetUsr | ( | unsigned char | val | ) |
Definition at line 73 of file hwuart.cpp.
References CheckForNewClearIrq(), CheckForNewSetIrq(), TXC, ucr, and usr.
|
protected |
Definition at line 64 of file hwuart.h.
Referenced by CpuCycle(), and Reset().
|
protected |
Definition at line 101 of file hwuart.h.
Referenced by CpuCycleTx(), and Reset().
|
protected |
Definition at line 95 of file hwuart.h.
Referenced by CpuCycleRx().
|
protected |
Hold length of UART frame.
Definition at line 51 of file hwuart.h.
Referenced by CpuCycleRx(), CpuCycleTx(), and SetFrameLengthFromRegister().
|
protected |
Connection to interrupt system.
Definition at line 53 of file hwuart.h.
Referenced by CheckForNewClearIrq(), CheckForNewSetIrq(), ClearIrqFlag(), GetUdr(), HWUart(), and SetUdr().
|
protected |
|
protected |
|
protected |
|
protected |
Cycle timer for controling read access to UCSRC/UBRRH combined register.
Definition at line 62 of file hwuart.h.
Referenced by CpuCycle(), HWUsart::GetUcsrcUbrrh(), and Reset().
|
protected |
Definition at line 99 of file hwuart.h.
Referenced by CpuCycleRx().
|
protected |
Definition at line 98 of file hwuart.h.
Referenced by CpuCycleRx().
|
protected |
Definition at line 97 of file hwuart.h.
Referenced by CpuCycleRx().
|
protected |
Definition at line 96 of file hwuart.h.
Referenced by CpuCycleRx().
|
protected |
Definition at line 89 of file hwuart.h.
Referenced by CpuCycleRx(), and Reset().
|
protected |
Definition at line 103 of file hwuart.h.
Referenced by CpuCycleTx().
|
protected |
Definition at line 102 of file hwuart.h.
Referenced by CpuCycleTx().
|
protected |
Definition at line 90 of file hwuart.h.
Referenced by CpuCycleTx(), Reset(), and SetUcr().
|
protected |
Baud rate register value (UBRR)
Definition at line 46 of file hwuart.h.
Referenced by CpuCycle(), GetUbrr(), GetUbrrhi(), HWUart(), Reset(), SetUbrr(), and SetUbrrhi().
IO register "UBRRxL" - baudrate.
Definition at line 136 of file hwuart.h.
Referenced by AvrDevice_at90canbase::AvrDevice_at90canbase(), AvrDevice_atmega1284Abase::AvrDevice_atmega1284Abase(), AvrDevice_atmega128base::AvrDevice_atmega128base(), AvrDevice_atmega16_32::AvrDevice_atmega16_32(), AvrDevice_atmega2560base::AvrDevice_atmega2560base(), AvrDevice_atmega668base::AvrDevice_atmega668base(), and AvrDevice_attiny2313::AvrDevice_attiny2313().
IO register "UBRRxH" - baudrate.
Definition at line 136 of file hwuart.h.
Referenced by AvrDevice_at90canbase::AvrDevice_at90canbase(), AvrDevice_atmega1284Abase::AvrDevice_atmega1284Abase(), AvrDevice_atmega128base::AvrDevice_atmega128base(), AvrDevice_atmega2560base::AvrDevice_atmega2560base(), and AvrDevice_atmega668base::AvrDevice_atmega668base().
|
protected |
UCR register value, also used as UCSRB register value.
Definition at line 44 of file hwuart.h.
Referenced by CpuCycleRx(), CpuCycleTx(), GetUcr(), GetUdr(), HWUart(), Reset(), SetFrameLengthFromRegister(), SetUcr(), SetUdr(), and SetUsr().
Definition at line 136 of file hwuart.h.
Referenced by AvrDevice_at90canbase::AvrDevice_at90canbase(), AvrDevice_atmega1284Abase::AvrDevice_atmega1284Abase(), AvrDevice_atmega128base::AvrDevice_atmega128base(), AvrDevice_atmega16_32::AvrDevice_atmega16_32(), AvrDevice_atmega2560base::AvrDevice_atmega2560base(), AvrDevice_atmega668base::AvrDevice_atmega668base(), and AvrDevice_attiny2313::AvrDevice_attiny2313().
Definition at line 136 of file hwuart.h.
Referenced by AvrDevice_at90canbase::AvrDevice_at90canbase(), AvrDevice_atmega1284Abase::AvrDevice_atmega1284Abase(), AvrDevice_atmega128base::AvrDevice_atmega128base(), AvrDevice_atmega16_32::AvrDevice_atmega16_32(), AvrDevice_atmega2560base::AvrDevice_atmega2560base(), AvrDevice_atmega668base::AvrDevice_atmega668base(), and AvrDevice_attiny2313::AvrDevice_attiny2313().
|
protected |
UCSRC register value.
Definition at line 45 of file hwuart.h.
Referenced by CpuCycleRx(), CpuCycleTx(), HWUsart::GetUcsrc(), Reset(), SetFrameLengthFromRegister(), and HWUsart::SetUcsrc().
Definition at line 136 of file hwuart.h.
Referenced by AvrDevice_at90canbase::AvrDevice_at90canbase(), AvrDevice_atmega1284Abase::AvrDevice_atmega1284Abase(), AvrDevice_atmega128base::AvrDevice_atmega128base(), AvrDevice_atmega16_32::AvrDevice_atmega16_32(), AvrDevice_atmega2560base::AvrDevice_atmega2560base(), AvrDevice_atmega668base::AvrDevice_atmega668base(), and AvrDevice_attiny2313::AvrDevice_attiny2313().
|
protected |
|
protected |
|
protected |
USR register value, also used as UCSRA register value.
Definition at line 43 of file hwuart.h.
Referenced by ClearIrqFlag(), CpuCycleRx(), CpuCycleTx(), GetUdr(), GetUsr(), HWUart(), Reset(), SetUcr(), SetUdr(), and SetUsr().
|
protected |
Interrupt vector ID for receive interrupt.
Definition at line 58 of file hwuart.h.
Referenced by CheckForNewClearIrq(), CheckForNewSetIrq(), GetUdr(), and HWUart().
|
protected |
Interrupt vector ID for sent byte interrupt.
Definition at line 60 of file hwuart.h.
Referenced by CheckForNewClearIrq(), CheckForNewSetIrq(), ClearIrqFlag(), and HWUart().
|
protected |
Interrupt vector ID for UDR empty interrupt.
Definition at line 59 of file hwuart.h.
Referenced by CheckForNewClearIrq(), CheckForNewSetIrq(), HWUart(), and SetUdr().
|
protected |
The write parity flag for usart.
Definition at line 49 of file hwuart.h.
Referenced by CpuCycleTx().