You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
			
		
		
		
		
			
		
			
				
	
	
		
			38 lines
		
	
	
		
			676 B
		
	
	
	
		
			C
		
	
			
		
		
	
	
			38 lines
		
	
	
		
			676 B
		
	
	
	
		
			C
		
	
| #ifndef _UART_H_
 | |
| #define _UART_H_
 | |
| 
 | |
| #include <stdio.h>
 | |
| 
 | |
| #define BAUD 9600 
 | |
| #define BAUDRATE ((F_CPU)/(BAUD*16UL)-1)
 | |
| 
 | |
| #define UART_BAUD_REGH UBRR0H
 | |
| #define UART_BAUD_REGL UBRR0L
 | |
| 
 | |
| #define UART_CTRL_REGA UCSR0A
 | |
| #define UART_CTRL_REGB UCSR0B
 | |
| #define UART_CTRL_REGC UCSR0C
 | |
| 
 | |
| // UCSRA
 | |
| #define UART_UDRE_BM UDRE0
 | |
| #define UART_RXC_BM RXC0
 | |
| 
 | |
| // UCSRB
 | |
| #define UART_TXEN_BM TXEN0
 | |
| #define UART_RXEN_BM RXEN0
 | |
| #define UART_RXCIE_BM RXCIE0
 | |
| 
 | |
| // UCSRC
 | |
| #define UART_URSEL_BM 0 /* only for old atmega */
 | |
| #define UART_UCSZ0_BM UCSZ00
 | |
| #define UART_UCSZ1_BM UCSZ01
 | |
| 
 | |
| #define UART_DATA_REG UDR0
 | |
| 
 | |
| void uart_init (void);
 | |
| void read_sync(char buffer[], uint8_t buffersize, uint8_t * bufferindex);
 | |
| 
 | |
| #endif
 | |
| 
 | |
| 
 |