#include "AD18F06A.h"
#include <stdio.h>
#include "usart.h"
#include "Periph.h"


void usart0_init()
{
    UART0CLKEN = 1;
	RX0_PIN    = 1;
	TX0_PIN    = 0;

	PORTB|=0X06;
	PBPU&=~(1<<1);
	TX0_MAP=(1<<3)|0X02;	//PB2_TX
	RX0_MAP=(1<<3)|0X01;	//PB1_RX
	SPBRG     = DIVIDER0;
	RCSTA     = 0x90;
	TXSTA     = 0x26;//24

}



void putch( char byte)
{
	while(!TXIF)		continue;
	TXREG = byte;
}


unsigned char getch()
{
	/* retrieve one byte */
	while(!RCIF)	/* set when register is not empty */
		continue;
	return RCREG;
}



unsigned char getche(void)
{
	unsigned char c;
	putch(c = getch());
	return c;
}







