![]() |
ATmega64M1 AVR UART, ADC and DAC
v2.0
UART, ADC and DAC libraries for the ATmega16M1, ATmega32M1 and ATmega64M1.
|
Header file for UART communication. More...
#include <avr/io.h>
#include <stdio.h>
Go to the source code of this file.
Macros | |
#define | UART_LBT 8 |
#define | BAUD_CALC(baud) ((F_CPU / 4 / baud - 1) / 2) |
Functions | |
void | uart_init (uint8_t brr_value) |
UART initialization function. More... | |
int | uart_transmit (char byte_data, FILE *stream) |
Function to transmit characters. More... | |
int | uart_receive (FILE *stream) |
Function to read characters. More... | |
int | uart_getline (char line[], int max) |
Function to read line. More... | |
Header file for UART communication.
This library is released under the GNU General Public License v3.0.
#define BAUD_CALC | ( | baud | ) | ((F_CPU / 4 / baud - 1) / 2) |
Calculation of LINBRR value for UART initialization.
#define UART_LBT 8 |
Numbers of samples per bit.
int uart_getline | ( | char | line[], |
int | max | ||
) |
Function to read line.
Call this function to read a string until newline termination. Example call:
line | Is the buffer for the read line. |
max | Maximum number of receiving characters. |
void uart_init | ( | uint8_t | brr_value | ) |
UART initialization function.
To initialize the UART connection call this function with the desired LINBRR value, which can be calculated wit the following command:
Call the initialization function as follow:
int uart_receive | ( | FILE * | stream | ) |
Function to read characters.
Call this function to read a character from the UART buffer. Example call:
stream | Is an optional parameter for the FDEV_SETUP_STREAM. |
int uart_transmit | ( | char | byte_data, |
FILE * | stream | ||
) |
Function to transmit characters.
Call this function with a character or character array to transmit data via the UART connection. Example call:
byte_data | Is the to transmitted data e.g. a character. |
stream | Is an optional parameter for the FDEV_SETUP_STREAM. |