/******************************************************************************
 * FileName:   usart.h
 * Overview:   Macros y prototipos de funciones para el USART0 en modo Asíncrono
 * Processor:  ATmel AVR con USART0
 * Compiler:   IAR-C y AVR-GCC (WinAVR)
 * Author:     Shawn Johnson. http://www.cursomicros.com.
 *
 * Copyright (C) 2008 - 2012 Shawn Johnson. All rights reserved.
 *
 * License:    Se permiten el uso y la redistribución de este código con 
 *             modificaciones o sin ellas, siempre que se mantengan esta 
 *             licencia y las notas de autor y copyright de arriba.
 *****************************************************************************/

#include "avr_compiler.h"

/* Define la velocidad de transmisión del USART (en bits/segundo), si aún no 
 * ha sido definida.
 */
#ifndef USART_BAUD
#define USART_BAUD  9600UL
#endif

/* Usar kbhit para ver si hay algún dato en el buffer de recepción antes de
 * llamar directamente a la función getchar para evitar esperas innecesarias.
 */
#define  kbhit()     (UCSR0A & (1<<RXC0))

/* Descomentar el siguiente #define para que la funcion 'getchar' haga eco de
 * los caracteres recibidos.
 */
//#define __GETCHAR_ECHO__

/* Macros para AVR GCC */
#if defined( __GNUC__ )
#ifdef putchar
#undef putchar
#endif
#ifdef getchar
#undef getchar
#endif
#endif

/* Definiciones de funciones */
void usart_init(void);
int putchar(int);
int getchar(void);
