/************************************************************************/
/*                                                                      */
/*                      Motorpotiplatine Steuerung                      */
/*                                                                      */
/*              Author : Frank Link                                     */
/*                       franklink61@aol.com                            */
/*              Version: 1.0                                            */
/************************************************************************/
#include <avr/io.h>
#include <avr/eeprom.h>
#include <avr/interrupt.h>
#include <stdlib.h>

#define uchar unsigned char
#define uint unsigned int



/* 9600 baud */
#define BAUD_RATE      9600      

/************************************************************************/
/*                                                                      */
/*                      RC5 Remote Receiver                             */
/*                                                                      */
/*              Author: Peter Dannegger                                 */
/*                      danni@specs.de                                  */
/*                                                                      */
/************************************************************************/

#define	xRC5_IN		PIND
#define	xRC5		PD7			// IR input low active
#define XTAL		4000000
#define RC5TIME 	1.778e-3		// 1.778msec
#define PULSE_MIN	(uchar)(XTAL / 512 * RC5TIME * 0.4 + 0.5)
#define PULSE_1_2	(uchar)(XTAL / 512 * RC5TIME * 0.8 + 0.5)
#define PULSE_MAX	(uchar)(XTAL / 512 * RC5TIME * 1.2 + 0.5)

uchar	rc5_bit;				// bit value
uchar	rc5_time;				// count bit time
uint	rc5_tmp;				// shift bits in
uint	rc5_data;				// store result

uchar f_timer_tick;

// UART
#define	BAUD	19200

#define UART_BAUDRATE   ((unsigned int)((unsigned long)XTAL/((unsigned long)BAUD_RATE*16)-1))	// calculate baud rate value for UBBR
#define bauddivider (uint)(XTAL / BAUD / 16 - 0.5)

extern uint	rc5_data;				// store result
