
#include <at89x52.h>

// recieve status
#define C_OCUPADO       0x00    // busy state
#define C_LIBRE         0x01    // free state    
#define C_INICIANDO     0x02    // starting state
#define C_RECIBIENDO    0x03    // recieving state

// commands for the transmition
#define CMD_INICIAR     0xaa    // start
#define CMD_ACK         0xac    // ack
#define CMD_CANCELAR    0xcc    // cancel
#define CMD_FINALIZAR   0xee    // finish

unsigned char estado;           // channel state
unsigned char direccion_local;  // local addres
unsigned char ind_trama;        // index of the buffer
unsigned char  trama[5];        // buffer
unsigned char  ROk;             // software recieve flag

void cfg_pto_serial(){
	SCON=0x50;          // uart in mode 1 (8 bit), REN=1
	TMOD=TMOD|0x20;     // Timer 1 in mode 2
	TH1=0xFD;           // 9600 Bds at 11.059MHz
	TL1=0xFD; 			// 9600 Bds at 11.059MHz
	TI=0;               // clears TI
    RI=0;               // clears RI
	ES=1; 				// Enable serial interrupt
}

