/*************************************************************************
Function: init_wyvern()
Purpose:  Runs all initialization functions
		  Enables interrupts
Input:    None
Returns:  None
**************************************************************************/
void init_wyvern(void){
	// Setup Wyvern Systems
	init_uc();		//UC
	init_uart();	// Serial  Communication
	//init_pwm();		// Motor PWM Control
	init_adc();			// ADC
	// Setup Wyvern RF
	RFsetup(local,max(sizeof(packet_com_t),sizeof(packet_inf_t)));
	set(PCICR,PCIE0); // enable pin-change interrupts
	PCMSK0 =0x00;
	set(PCMSK0, PCINT4); // demask PCINT4
	
	//clear(TCCR0B,CS02);
	//set(TCCR0B,CS01);
	//clear(TCCR0B,CS00);	// Timer0 Clock = System Clock/1024
	//set(TIMSK0,TOIE0);	// Enable Timer0 Overflow Interrupt

	// Enable Global Interrupts
	sei();

	// Force RF Interrupt (Pin Change Interrupt Channel 4) to run once
	clear(PORTB,4);
	if(RFRXdataReady()){
     	RFreceive((char*) &incoming);
	}

	incoming.battery = 150;
}
int main ( )
{
	init_uc ( );
	sei ( );

	while ( 1 ) {
		eval_event_flags ( );
	}
	return 0;
}