#ifndef	REMOTE_CONTROL_PHILIPS_H
#define	REMOTE_CONTROL_PHILIPS_H

#define	PHILIPS_RC5

#define	ERROR			-1
#define	OFF				0
#define	ON				1
#define	TOGGLE			2

#define	OSC_FREQ		48000000		// 48 MHz
#define	FREQUENCY		OSC_FREQ / 4	// 12 MHz
#define	BUTTON_INPUT	TRISB = TRISB | 0x01
#define	BUTTON_PRESSED	(~PORTB & 0x01)


#ifdef PHILIPS_RC5
	#define	TOGGLE_PERIOD	83		// (Fin / 4) / 36 000; Fin = 48MHz / 4 = 12MHz --> 83.(3)
	#define	HALF_PERIOD		41		// 83/2 = 41;
	#define	PERIOD_US		868
	#define	BASIC_DELAY		480		// 480
	#define	SAMPLE_DELAY	1020	// 1020
	
	struct Philips_Code
	{
		unsigned char Start:2;
		unsigned char Toggle:1;
		unsigned char Address:5;
		unsigned char Data:6;
	};
#endif

extern unsigned char Sample_Buffer[28], New_Flag, Toggle;
extern volatile int counter;
extern struct Philips_Code Signal;

void DelayMs (volatile unsigned int Ms);

void IrDA_Init (void);

void GPIO_Init (void);

void Clock_Init (void);

void Receiver_Init (void);

#endif