I'm having a hard time understanding how the Arduino libraries are defining the address for accessing the registers of the USART modules.
I cant find definition for udr(pointer)
as used in the delegated constructor for Hardware Serial. So how does the class gets the underlying address? And what type of declaration is this?
HardwareSerial::HardwareSerial(
volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
volatile uint8_t *ucsrc, volatile uint8_t *udr) :
_ubrrh(ubrrh), _ubrrl(ubrrl),
_ucsra(ucsra), _ucsrb(ucsrb), _ucsrc(ucsrc),
_udr(udr),
_rx_buffer_head(0), _rx_buffer_tail(0),
_tx_buffer_head(0), _tx_buffer_tail(0)
{
}
1 Answer 1
It is handed the addresses when the object is constrcted:
HardwareSerial Serial(&UBRRH, &UBRRL, &UCSRA, &UCSRB, &UCSRC, &UDR);
&UDR
is passed as *udr
. That is then assigned to _udr
in the initialiser list.