/*! \file 
*	\details This file contains function for UART handling.
*
*	\ingroup WheelchairControl
*	@{
*
	\ingroup UART
*	@{
*/

//Includes
#include "UART.h"

//Functions
void UART_Init(void)	//initializes UART
{
	UBRRH=0x00;
	UBRRL=0x33;	//set baudrate to 19200

	UCSRB=(1<<RXCIE | 1<<RXEN | 1<<TXEN);	//enable Rx, Tx, Rx interrupt
	UCSRC=(1<<URSEL | 1<<UCSZ1 | 1<<UCSZ0);	//asynchronous mode, no parity, 1 stop bit, 8 data bits
}

void UART_SendByte(uint8_t data)	//sends byte via UART
{
	while (!(UCSRA & (1<<UDRE))); //wait until data register is empty

	UDR = data;	//transmit data
}
