//-----------------------------------------------------------------------------
// TITLE	:Car Application code
// REVISION	:00.01
// AUTHOR	:Chengfj
// COMPANY	:Radioway Co.,Ltd..
// DATE		:2016/05/23
// CHIP		:RW1600

//--------------Include files Segment-----------------------------------------
#include	<8PE531A.H>
#include    "timer.h"
#include    "carapp.h"
#include    "rw1620drv.h"
//----------------------------------------------------------

//----------------------------------------------------------
void SWCKto8MHz(void)
{
	OSCCONbits.CPUS=0;
	NOP();					//Switch CLK Required
	OSCCONbits.IRCF0=0;
	OSCCONbits.IRCF1=0;
	OSCCONbits.IRCF2=0;		//4MHz
	NOP();					//Switch CLK Required
	OSCCONbits.CPUS=1;
	NOP();					//Switch CLK Required
}

void WDT_Init(void)
{
}

void WDT_Feed(void)
{
}


//--------------Program segment------------------------------------------------
void main(void)@0x0095
{
	LVDTCON=0x60;			    //RDPORT=Reg, IOB3EN=IOB3, LVDT=2.6V
					            //(if IOB3 need set to output low, IOB3EN bit must be set first!!!)
	
	OSCCONbits.WDTEN=0;			//Disable WDT
	SWCKto8MHz();				//Switch CLK to 4MHz
	NOP(); 
	
	rf_SPI_init();
	init_rf();
	
	timer1init();      
	
	INTFLAG=0xFE;				//Clear pervious flag(Not recommed INTFLAGbits.T1IF=0;)
	INTEN=0x81;				    //Enable TMR1 INT & Global INT
	T1CONbits.T1EN=1;			//Enable TMR1
	
	rf_send_data_test();
	rf_recive_data_test();

}


