35 #define DOR 0x08 //same for usart 36 #define UPE 0x04 //only usart 37 #define U2X 0x02 //only usart 38 #define MPCM 0x01 //only usart 47 #define CHR9 0x04 //same as ucsz2 74 unsigned char usrold=
usr;
77 unsigned char irqold=
ucr & usrold;
78 unsigned char irqnew=
ucr &
usr;
84 unsigned char changed=irqold^irqnew;
85 unsigned char setnew= changed&irqnew;
86 unsigned char clearnew= changed& (~irqnew);
97 ubrr = (
ubrr & 0xff) | ((val & 0xf) << 8);
127 unsigned char ucrold=
ucr;
151 if (
ucr & ( RXEN|TXEN) ) {
152 if ( !(ucrold & (RXEN|TXEN)) ) {
153 core->AddToCycleList(
this);
158 unsigned char irqold= ucrold&
usr;
159 unsigned char irqnew=
ucr&
usr;
162 unsigned char changed=irqold^irqnew;
163 unsigned char setnew= changed&irqnew;
164 unsigned char clearnew= changed& (~irqnew);
191 unsigned char usr_old=
usr;
282 actParity=!actParity;
371 unsigned char irqold=
ucr&usr_old;
372 unsigned char irqnew=
ucr&
usr;
375 unsigned char changed=irqold^irqnew;
376 unsigned char setnew= changed&irqnew;
377 unsigned char clearnew= changed& (~irqnew);
397 unsigned char usr_old=
usr;
507 unsigned char irqold=
ucr&usr_old;
508 unsigned char irqnew=
ucr&
usr;
511 unsigned char changed=irqold^irqnew;
512 unsigned char setnew= changed&irqnew;
513 unsigned char clearnew= changed& (~irqnew);
529 unsigned int rx_interrupt,
530 unsigned int udre_interrupt,
531 unsigned int tx_interrupt,
632 if((val &
URSEL) == URSEL) {
633 SetUcsrc(val & 0x7f);
661 HWUart(core, s, tx, rx, vrx, vudre, vtx, instance_id),
663 ucsrc_reg(this,
"UCSRC",
665 ubrrh_reg(this,
"UBRRH",
667 ucsrc_ubrrh_reg(this,
"UCSRC_UBRRH",
Basic AVR device, contains the core functionality.
unsigned char usr
USR register value, also used as UCSRA register value.
IOReg< HWUsart > ubrrh_reg
HWIrqSystem * irqSystem
Connection to interrupt system.
bool writeParity
The write parity flag for usart.
unsigned int vectorRx
Interrupt vector ID for receive interrupt.
void AddToCycleList(Hardware *hw)
void SetUdr(unsigned char val)
unsigned int vectorUdre
Interrupt vector ID for UDR empty interrupt.
unsigned int vectorTx
Interrupt vector ID for sent byte interrupt.
void SetAlternateDdr(bool val)
void SetUseAlternatePort(bool val)
IOReg< HWUart > ubrrhi_reg
IO register "UBRRxH" - baudrate.
virtual unsigned int CpuCycle()
bool readParity
The read parity flag for usart.
void SetUbrr(unsigned char val)
unsigned int CpuCycleTx()
void SetUcr(unsigned char val)
IOReg< HWUart > ubrr_reg
IO register "UBRRxL" - baudrate.
void SetUbrrhi(unsigned char val)
void SetUcsrcUbrrh(unsigned char val)
unsigned char regSeq
Cycle timer for controling read access to UCSRC/UBRRH combined register.
unsigned char udrWrite
Write stage of UDR register value.
Implements the I/O hardware necessary to do USART transfers.
IOReg< HWUart > ucsra_reg
unsigned char GetUcsrcUbrrh()
void SetFrameLengthFromRegister()
void SetAlternatePort(bool val)
Build a register for TraceValue's.
IOReg< HWUart > ucsrb_reg
void SetIrqFlag(Hardware *, unsigned int vector_index)
void SetUsr(unsigned char val)
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.
std::string int2str(int i)
Convert an int into a string.
void ClearIrqFlag(unsigned int)
void SetUseAlternateDdr(bool val)
IOReg< HWUsart > ucsrc_ubrrh_reg
void DebugVerifyInterruptVector(unsigned int vector_index, const Hardware *source)
In datasheets RESET vector is index 1 but we use 0! And not a byte address.
void CheckForNewClearIrq(unsigned char)
unsigned char ucr
UCR register value, also used as UCSRB register value.
unsigned char GetUbrrhi()
void ClearIrqFlag(unsigned int vector_index)
int frameLength
Hold length of UART frame.
Implements the I/O hardware necessary to do UART transfers.
void CheckForNewSetIrq(unsigned char)
unsigned short ubrr
Baud rate register value (UBRR)
unsigned char ucsrc
UCSRC register value.
IOReg< HWUsart > ucsrc_reg
void SetUcsrc(unsigned char val)
unsigned char udrRead
Read stage of UDR register value.
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.
TraceValue * trace_direct(TraceValueRegister *t, const std::string &name, const bool *val)
Register a directly traced bool value.
unsigned int CpuCycleRx()
void releaseTraceValue(void)