#include "main.h"
#include "../libs/uartlibrary/uart.h"
Defines | |
#define | UART_RX_BUFFER_SIZE 8 |
#define | UART_TX_BUFFER_SIZE 8 |
Functions | |
void | usart_init (void) |
initialises both USARTs | |
void | usart_off (void) |
switches off both USARTs | |
void | usart_baudrate (int8_t br) |
property: sets baudrate | |
void | usart_setSync (int8_t enable) |
property: enables synchronous communication | |
void | usart_stopBits (int8_t sb) |
property: sets the nr of stop bits | |
void | usart_dataBits (int8_t db) |
property: sets the nr of data bits |
Serial communication.
Peter Fleury's lib?
|
|
|
|
|
|
|
initialises both USARTs
00017 { 00018 //baudrate 00019 // UBRR0H = 0; UBRR0L = 0; 00020 // UBRR1H = 0; UBRR1L = 0; 00021 usart_baudrate(0); 00022 00023 //erase data overflow flag 00024 UCSR0A &= ~(1<<DOR); 00025 UCSR1A &= ~(1<<DOR); 00026 00027 //RXEN, TXEN, INTERRUPT ENABLE 00028 UCSR0B |= (1<<RXEN) | (1<<TXEN) | (1<<RXCIE); 00029 UCSR1B |= (1<<RXEN) | (1<<TXEN) | (1<<RXCIE); 00030 00031 //2 stop bit, 8 data bit, synchronous mode 00032 // UCSR0C = (1<<USBS) | (3<<UCSZ0);// | (1<<UMSEL); 00033 // UCSR1C = (1<<USBS) | (3<<UCSZ0);// | (1<<UMSEL); 00034 usart_stopBits(1); 00035 usart_setSync(0); 00036 usart_dataBits(3); 00037 00038 //activate internal PullUp for RX and XCK(if input) 00039 //DDRE = 255; 00040 PORTE |= (1<<PE0) | (1<<PE2); 00041 PORTD |= (1<<PD2) | (1<<PD5); 00042 00043 uart_init(UART_BAUD_SELECT(9600, 11059200UL)); 00044 uart1_init(UART_BAUD_SELECT(9600, 11059200UL)); 00045 }
|
|
switches off both USARTs
|
|
|