#ifndef _SERIAL_H_
#define _SERIAL_H_

#include <p24FJ128GA006.h>
#include "types.h"

#define MAX_SIO_COUNT		32

#define Fcy			16000000
#define BAUD			57600

typedef struct _UARTHANDLER
{
	char (*uart_get_handler)(void);
	void (*uart_put_handler)(char);
}UARTHANDLER;

/*
********************************************************************************
Function Prototype Definition Part
********************************************************************************
*/
void _ISR _U1RXInterrupt(void);

void uart_init(void);		/* Initialize the UART  */

u_int uart_keyhit(u_char uart);	/* Check if there is Rx */

void uart0_putchar(char c);	/* Send a character through UART */
char uart0_getchar(void);	/* Get a character from UART */

int write (int handle, void *buffer, unsigned int len);
int read(int handle, void *buffer, unsigned int len);

void uart_puts(u_char uart, char * str);	/* Send a string to UART */
int uart_gets(u_char uart, char * str,char bpasswordtype, int max_len);	/* Get a string from UART */

void uart_flush_rx(void);	/* Flush RX Buffer */


#endif		/* _SERIAL_H_ */

