diff options
Diffstat (limited to 'floppyMusic/uart.c')
-rw-r--r-- | floppyMusic/uart.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/floppyMusic/uart.c b/floppyMusic/uart.c index d4d5ccf..aed8acd 100644 --- a/floppyMusic/uart.c +++ b/floppyMusic/uart.c @@ -9,32 +9,40 @@ void uart_init(uint32_t _baud) { - unsigned int ubrr = _GET_UBBR(_baud); + unsigned int ubrr = _GET_UBBR(_baud); - UBRRH = (ubrr<<8); - UBRRL = ubrr; + UBRRH = (ubrr<<8); + UBRRL = ubrr; + + /* Enable receiver and transmitter */ + UCSRB = (1<<RXEN)|(1<<TXEN); + + /* Set frame format: 8data, 2stop bit */ + UCSRC = (1<<URSEL)|(1<<USBS)|(3<<UCSZ0); } void uart_send(char _data) { - while(!(UCSRA & (1<<UDRE))); - UDR = _data; + while(!(UCSRA & (1<<UDRE))); + UDR = _data; } void uart_send_string(char *_data) { - char *data = _data; + char *data = _data; - while(*data != '\0') - { - uart_send(*data); - data++; - } + while(*data != '\0') + { + uart_send(*data); + data++; + } } char uart_recieve() { - while(!(UCSRA & (1<<RXC))); + while(!(UCSRA & (1<<RXC))); + + return UDR; + } + - return UDR; - }
\ No newline at end of file |