Implementation of USART Stack. More...
#include <avr/io.h>#include <avr/interrupt.h>#include "uart.h"
Go to the source code of this file.
Defines | |
| #define | _UART_C_ 1 |
Functions | |
| void | uart_init (void) |
| Initialise the USART Module. | |
| void | uart_sendbyte (uint8_t data) |
| Send one Byte. | |
| uint8_t | uart_senddata (uint8_t data) |
| Send one data byte without buffering in the FIFO. | |
| uint8_t | uart_sendid (uint8_t data) |
| Send one id byte without buffering in the FIFO. | |
| uint8_t | uart_getbyte (uint8_t *data) |
| Pull one Byte from RX-Buffer. | |
| int | uart_putchar (char c, FILE *sream) |
| Send one Byte (printf version) | |
| int | uart_getchar (FILE *stream) |
| Pull one Byte from RX-Buffer. | |
| ISR (RXC_vect) | |
| Interrupt-Service-Routine for the RX-Complete Interrupt. | |
| ISR (DRE_vect) | |
| Interrupt-Service-Routine for the Data-Register-Empty Interrupt. | |
Variables | |
| uint8_t | rx_buffer [UART_RX_BUFFER_SIZE] |
| Memory for the Receive FIFO. | |
| uint8_t | tx_buffer [UART_TX_BUFFER_SIZE] |
| Memory for the Transmit FIFO. | |
| volatile uint8_t | rx_head = 0 |
| head index of the Receive FIFO | |
| volatile uint8_t | rx_tail = 0 |
| tail index of the Receive FIFO | |
| volatile uint8_t | tx_head = 0 |
| head index of the Transmit FIFO | |
| volatile uint8_t | tx_tail = 0 |
| tail index of the Transmit FIFO | |
Implementation of USART Stack.
Definition in file uart.c.
| ISR | ( | RXC_vect | ) |
| ISR | ( | DRE_vect | ) |
| uint8_t uart_getbyte | ( | uint8_t * | data ) |
Pull one Byte from RX-Buffer.
If the RX-Fifo is enabled any data receives is automaticaly pusched into the Fifo ba the ISR. This function removes the oldest Byte from the Buffer and copies it into the Memory-Space which is handed over as a parameter.
| data | pointer to a buffer where the received data is copied to |
| int uart_getchar | ( | FILE * | stream ) |
Pull one Byte from RX-Buffer.
If the RX-Fifo is enabled any data receives is automaticaly pusched into the Fifo ba the ISR. This function removes the oldest Byte from the Buffer and copies it into the Memory-Space which is handed over as a parameter.
| void uart_init | ( | void | ) |
| int uart_putchar | ( | char | c, |
| FILE * | sream | ||
| ) |
Send one Byte (printf version)
This fuction sends one byte by copyint the data into the fifo-buffer and enabling the UDRE-Interrupt. The actual transmission is then initiated by the Interrupt-Service-Routine. If the buffer is full this function waits until the next byte has been transmitted, so it is always successful.
This is the printf compatible version ov uart_sendbyte
| data | Data-Byte to send |
Definition at line 101 of file uart.c.

| void uart_sendbyte | ( | uint8_t | data ) |
Send one Byte.
This fuction sends one byte by copying the data into the fifo-buffer and enabling the UDRE-Interrupt. The actual transmission is then initiated by the Interrupt-Service-Routine. If the buffer is full this function waits until the next byte has been transmitted, so it is always successful.
| data | Data-Byte to send |
Definition at line 48 of file uart.c.


| uint8_t uart_senddata | ( | uint8_t | data ) |
| uint8_t uart_sendid | ( | uint8_t | data ) |
1.7.2