uart  1.4
Serial stream for Xmega/Wrapper for UART-driver Xmega
 All Files Functions Variables Macros
stream.c File Reference

Stream for the communcation mode of HvA-Xmegaboard. More...

#include <avr/io.h>
#include "stream.h"
#include "uart.h"

Macros

#define ENABLE_UART_F0   1
 UART0 from PORTF.
 
#define BAUD   115200
 baud rate
 
#define CLK2X   0
 no double clock speed
 

Functions

int uart_fputc (char c, FILE *stream)
 Write a byte to the circular transmit buffer. This function is necessary for a standard stream. More...
 
int uart_fgetc (FILE *stream)
 Get a byte from the circular receive buffer This function is necessary for a standard stream. More...
 
void init_stream (uint32_t fcpu)
 Initialize a standard in/out stream It uses USART0 of port F, the baud rate is BAUD, doubleclockspeed is CLK2X and the interruptlevel is low The global interrupt is not yet set. More...
 

Variables

FILE uart_stdinout = FDEV_SETUP_STREAM(uart_fputc, uart_fgetc, _FDEV_SETUP_RW)
 FILE structure for standard streams.
 

Detailed Description

Stream for the communcation mode of HvA-Xmegaboard.

Author
Wim Dolman (w.e.dolman@hva.nl)
Date
03-10-2016
Version
1.4

Makes a standard stream for the HvA-Xmegaboard. It is build on the wrapper. With these you can use printf and scanf to write to and read from the UART F0. The baud rate is 115200 and the protocol is 8N1.

Version 1.3 : Modified uart_fputc changed. With a full TX-buffer it doesn't skips characters anymore. It now waits until there is free space in the buffer.

Version 1.4 : The baud rate is changed toe 115200

Function Documentation

void init_stream ( uint32_t  fcpu)

Initialize a standard in/out stream It uses USART0 of port F, the baud rate is BAUD, doubleclockspeed is CLK2X and the interruptlevel is low The global interrupt is not yet set.

Parameters
fcputhe clock frequency
Returns
void
int uart_fgetc ( FILE *  stream)

Get a byte from the circular receive buffer This function is necessary for a standard stream.

Parameters
streamfile pointer
Returns
received byte from circulair buffer (low byte) or UART_NO_DATA if buffer is empty
int uart_fputc ( char  c,
FILE *  stream 
)

Write a byte to the circular transmit buffer. This function is necessary for a standard stream.

Parameters
ccharacter to be written
streamfile pointer
Returns
always zero