| Wheelchair Control MCU firmware

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Enumerations Groups Pages
UART.c
Go to the documentation of this file.
1
11 //Includes
12 #include "UART.h"
13
14 //Functions
15 void UART_Init(void) //initializes UART
16 {
17 UBRRH=0x00;
18 UBRRL=0x33; //set baudrate to 19200
19
20 UCSRB=(1<<RXCIE | 1<<RXEN | 1<<TXEN); //enable Rx, Tx, Rx interrupt
21 UCSRC=(1<<URSEL | 1<<UCSZ1 | 1<<UCSZ0); //asynchronous mode, no parity, 1 stop bit, 8 data bits
22 }
23
24 void UART_SendByte(uint8_t data) //sends byte via UART
25 {
26 while (!(UCSRA & (1<<UDRE))); //wait until data register is empty
27
28 UDR = data; //transmit data
29 }