typedef unsigned char u8;
typedef unsigned int u16;
typedef unsigned long u32;


#define F_CPU 16000000UL
#define	FOSC	16000000	//Clock speed
#define	BAUD	38400 //57600	//115200
#define MYUBRR	FOSC/16/BAUD-1		//8

#define TX_buffer_length	32
#define TX_buffer_mask		31				//Xrhsimopoieitai gia na mhn ginetai out of bounds  buffer
#define RX_buffer_length 	32
#define RX_buffer_mask		31				//Xrhsimopoieitai gia na mhn ginetai out of bounds  buffer

// ADC Masks (sel 216)	Ayta tha ginontai Bit -and me ton ADMUX gia thn epilogh tou channel
#define ADC0_and 	0b11100000
#define ADC0_or 	0
#define ADC1_and 	0b11100001
#define ADC1_or 	1
#define ADC2_and 	0b11100010
#define ADC2_or 	2
#define ADC3_and 	0b11100011
#define ADC3_or 	3
#define ADC4_and 	0b11100100
#define ADC4_or 	4
#define ADC5_and 	0b11100101
#define ADC5_or 	5

#define special_char		'$'
#define	start_of_frame		's'				// An exoume thn akolou8ia 255 1 tote start of frame
#define mhden_code			'0'				// An exoume thn akolou8ia 255 2 tote no=0
#define	special_char_code	'^'				// An exoume thn akolou8ia 255 3 tote no=255

//June 2008
static	u8	previous_char=23;					// Xrhsimopoeitai gia na kwdikopoihsh ton previous character.
static	u8	previous_tx_char=23;				// Xrhsimopoeitai gia na kwdikopoihsh ton previous character.
static	u8	previous_tx_code=23;				// Xrhsimopoeitai gia na kwdikopoihsh ton previous character.
static	u8	tx_temp;

// Wheel Encoders 
static  unsigned int wheel_big_counter=0;				// Metraei ta 1024*128us=131072us
static	unsigned int front_left_ticks=0;				
static	unsigned int front_right_ticks=0;	
static	unsigned int rear_left_ticks=0;				
static	unsigned int rear_right_ticks=0;
static	unsigned int rpm_ticks=0;	
static 	unsigned int previous_state=0;					// Xrhsimopoieitai gia na ypodhlwsei thn prohgoumenh katastash,high h low

static	unsigned int front_left_speed=0;				
static	unsigned int front_right_speed=0;	
static	unsigned int rear_left_speed=0;				
static	unsigned int rear_right_speed=0;
static	unsigned int rpm_speed=0;

static u8 	buffer[5];
//Front left
static u8	fl_1=1;	
static u8	fl_2=1;
static u8	fl_3=1;
//Front right
static u8	fr_1=1;	
static u8	fr_2=1;
static u8	fr_3=1;
//Rear left
static u8	rl_1=1;	
static u8	rl_2=1;
static u8	rl_3=1;
//Rear right
static u8	rr_1=1;	
static u8	rr_2=1;
static u8	rr_3=1;


//RPM
static  unsigned int rpm_big_counter=0;
static u8	rpm_1=1;	
static u8	rpm_2=1;
static u8	rpm_3=1;


static u8 servo_0=0;



