#include "SPORT_AS_UART.h"
#include "def21364.h"
#include "Cdef21364.h"

void Write_UART(int data)
{

	int temp;
	
	temp=pack_tx_data(data);
		
	while((*pSPCTL0&BIT_31)!=0);
		
		*pTXSP0A=temp;
			
}



int Read_UART()
{
		
	int temp1, temp2;
	
	while((*pSPCTL1&(BIT_31))!=0x80000000);
		
	temp1=*pRXSP1A;
		
	temp2=unpack_rx_data(temp1);
	
	return temp2;
		
}

void Init_UART()
{
	
	*pDIV0=CLKDIV0<<1;
	
	*pDIV1=CLKDIV1<<1;
	
	*pSPCTL0=SPTRAN|LSBF|ICLK|IFS|LFS|FSR|LAFS|SLEN11|SPEN_A;
	
	*pSPCTL1=LFS|FSR|ICLK|SLEN29|SPEN_A|CKRE;

		
		
}
