usart.c File Reference

Serial interface functions. More...

#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
Include dependency graph for usart.c:

Go to the source code of this file.

Defines

#define USART_UBBR_CALC(baud)   (F_CPU / ((baud << 4)) - 1u)
#define USART0_BAUD_RATE   (19200ul)
#define USART_PRINTF_BUF_SIZE   (128)

Functions

void USART0_init (void)
 Initialize UART.
unsigned char USART0_getc (void)
 Read one byte from serial port.
void USART0_putc (unsigned char data)
 Write one byte to the serial port.
void USART0_puts (const char *data)
 Write a null-terminated string to the serial port.
void USART0_printf (const char *fmt,...)
 Printf function which uses UART interface to send.

Detailed Description

Serial interface functions.

Author:
Copyright (C) Peter Ivanov, 2010

Created 2010-08-07 11:48:53 Last modify: 2010-08-07 11:51:36 ivanovp {Time-stamp} Licence: GPL

Definition in file usart.c.


Define Documentation

#define USART0_BAUD_RATE   (19200ul)

Definition at line 18 of file usart.c.

#define USART_PRINTF_BUF_SIZE   (128)

Definition at line 19 of file usart.c.

#define USART_UBBR_CALC ( baud   )     (F_CPU / ((baud << 4)) - 1u)

Definition at line 17 of file usart.c.


Function Documentation

unsigned char USART0_getc ( void   ) 

Read one byte from serial port.

It waits for the data.

Returns:
The received character.

Definition at line 43 of file usart.c.

void USART0_init ( void   ) 

Initialize UART.

Baud rate is in USART0_BAUD_RATE.

See also:
USART0_BAUD_RATE

Definition at line 25 of file usart.c.

void USART0_printf ( const char *  fmt,
  ... 
)

Printf function which uses UART interface to send.

Example:

UART_printf ("Number: %02i\r\n", number);
Parameters:
fmt Printf format string. Example: "Value: %02i\r\n"

Definition at line 89 of file usart.c.

void USART0_putc ( unsigned char  data  ) 

Write one byte to the serial port.

Parameters:
data Byte to send.

Definition at line 57 of file usart.c.

void USART0_puts ( const char *  data  ) 

Write a null-terminated string to the serial port.

Parameters:
data String to send.

Definition at line 71 of file usart.c.

Generated on Sat Oct 9 20:10:52 2010 for Sonar with ATMEGA88P by  doxygen 1.6.3