serialF0  1.3
Serial stream for HvA-Xmegaboard
serialF0.c File Reference

Serial interface voor HvA-Xmegaboard. More...

#include "serialF0.h"
#include <stdio.h>
#include <stddef.h>
#include <math.h>
#include <avr/io.h>
#include <avr/interrupt.h>

Macros

#define BAUD_115K2   115200UL
 Baud rate 115200.
 
#define BAUD_57K6   57600UL
 Baud rate 57600.
 
#define BAUD_38K4   38000UL
 Baud rate 38400.
 
#define UART_DOUBLE_CLK   1
 Double clock speed true.
 
#define UART_NO_DOUBLE_CLK   0
 Double clock speed false.
 

Functions

void uartF0_putc (uint8_t data)
 Send a byte to UARTF0. More...
 
uint16_t uartF0_getc (void)
 Read a byte from UARTF0. More...
 
void uartF0_puts (char *s)
 Send a string to UARTF0. More...
 
char * getline (char *buf, uint16_t len)
 Get a line from the serial input. More...
 
void init_stream (uint32_t f_cpu)
 Initializes the serial stream for the HvA-Xmegaboard. More...
 

Variables

FILE uartF0_stdinout = FDEV_SETUP_STREAM(uartF0_fputc, uartF0_fgetc, _FDEV_SETUP_RW)
 FILE structure for standard streams.
 

Detailed Description

Serial interface voor HvA-Xmegaboard.

Author
Wim Dolman (w.e.dolman@hva.nl)
Date
16-04-2018
Version
1.8

This serial interface doesn't use the drivers of Atmel The interface uses two non circulair buffers for sending and receiving the data. It is based om md_serial.c from J.D.Bakker.

It is a serial interface for the HvA-Xmegaboard (Version 2) with a Xmega256a3u and Xmega32a4u for programming and the serial interface. You can use the standard printf, putchar, puts, scanf, getchar, ... functions.

The baud rate is 115200

Function Documentation

◆ getline()

char* getline ( char *  buf,
uint16_t  len 
)

Get a line from the serial input.

Parameters
bufpointer to a buffer to store the received line
lenlength of the buffer to store the received line

The line has to be finished with a End-Of-Line. This can be <CR>, <CR><LF> or <LF>

Returns
Received character

◆ init_stream()

void init_stream ( uint32_t  f_cpu)

Initializes the serial stream for the HvA-Xmegaboard.

Parameters
f_cpuclock frequency

The only paramter is the clockfrequency. The default baud rate is 115200. At the moment this match best with the HvA-Xmegaboard. If you want to use another baud rate you can change it in this function.

Returns
void

◆ uartF0_getc()

uint16_t uartF0_getc ( void  )
inline

Read a byte from UARTF0.

Returns
Received byte from buffer or UART_NO_DATA if buffer is empty

◆ uartF0_putc()

void uartF0_putc ( uint8_t  data)
inline

Send a byte to UARTF0.

Parameters
databyte to send
Returns
void

◆ uartF0_puts()

void uartF0_puts ( char *  s)

Send a string to UARTF0.

Parameters
sa pointer to the pointer
Returns
void