Open
Description
I'm trying to implement a USART setup function I had from C:
void uart_init(void) {
UBRR0H = UBRRH_VALUE;
UBRR0L = UBRRL_VALUE;
#if USE_2X
// Double transmission speed.
UCSR0A |= _BV(U2X0);
#else
// Not double transmission speed.
UCSR0A &= ~(_BV(U2X0));
#endif
// 8-bit data.
UCSR0C = _BV(UCSZ01) | _BV(UCSZ00);
// Enable RX and TX.
UCSR0B = _BV(RXEN0) | _BV(TXEN0);
// The UART io.
static FILE uart_io = FDEV_SETUP_STREAM(uart_put, uart_get, _FDEV_SETUP_RW);
// Set this UART as stdout and stdin.
stdout = &uart_io;
stdin = &uart_io;
}
Seems like I need UBRRH_VALUE
, UBRRL_VALUE
from util/setbaud.h
, which seems blacklisted to avoid preprocessor stuff.
Line 21 in 22322e0
It would be great if we could use things like cfg(USE_2X)
(or something) to control this. Or is this possible somehow already?
Additionally, the IO hook fdev_setup_stream
creates a stream I have set to STDIN and STDOUT, which would be nice to replicate. But the *io
also seems blacklisted.
Line 139 in 22322e0
I'm not sure how the Rust AVR library organization is being planned, so this may be in the wrong place.
Thanks.
Metadata
Metadata
Assignees
Labels
No labels
Activity