chore(macros/ex02): used homebrew BV macro and fixed ex02 to use timer interupt
This commit is contained in:
parent
508ba6e857
commit
29b0d72ff9
17 changed files with 191 additions and 200 deletions
|
|
@ -14,27 +14,27 @@ void uart_init(void) {
|
|||
UBRR0H = (uint8_t)(UBRR_VALUE >> 8);
|
||||
UBRR0L = (uint8_t)(UBRR_VALUE);
|
||||
|
||||
UCSR0A |= _BV(U2X0);
|
||||
UCSR0A |= BV(U2X0);
|
||||
// Enable transmitter
|
||||
UCSR0B = _BV(TXEN0) | _BV(RXEN0);
|
||||
UCSR0B = BV(TXEN0) | BV(RXEN0);
|
||||
|
||||
// Set frame format: 8 data bits, no parity, 1 stop bit
|
||||
UCSR0C = _BV(UCSZ01) | _BV(UCSZ00);
|
||||
UCSR0C = BV(UCSZ01) | BV(UCSZ00);
|
||||
|
||||
// Set TX (PD1) as output
|
||||
DDRD |= _BV(PD1);
|
||||
DDRD |= BV(PD1);
|
||||
}
|
||||
|
||||
void uart_tx(char data) {
|
||||
// wait for transmit buffer to be empty
|
||||
while (!(UCSR0A & _BV(UDRE0)))
|
||||
while (!(UCSR0A & BV(UDRE0)))
|
||||
;
|
||||
// load data into transmit register
|
||||
UDR0 = data;
|
||||
}
|
||||
|
||||
char uart_rx(void) {
|
||||
while (!(UCSR0A & _BV(RXC0)))
|
||||
while (!(UCSR0A & BV(RXC0)))
|
||||
;
|
||||
return UDR0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue