/************************LICENCIA*****************************

Copyright (C) 2003  Jon Latorre Martinez & Fernando Cabrera

Este programa es software libre; usted puede redistribuirlo y/o 
modificarlo bajo los terminos de la Licencia Publica Genereal GNU
tal y como lo publica la Free Software Foundation en su version 2.

Este programa se distribuye con la idea de ser util, pero 
SIN NINGUNA GARANTIA

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
******************************************************************/


#include "at898252.h"
#include "lcd_4bit.h"
//#include "delay.h"
//#include "adc0808.h"
#include "visual.h"
#include "rs232.h"
#include "protocolo.h"

#define  UCHAR unsigned char
#define  UINT unsigned int

//Donde almacenamos los datos
UCHAR idata buffer[8] ; 

UCHAR code * saludo="Espe. Comando";


//Definimos las flags
bit F_COM;
bit F_MASQ;
bit F_FREQ;
bit F_N_SAMPL;
bit F_MANDADO;
bit F_NUEVODATO;
bit F_ARRANCAR;
bit F_TIMER;
bit salir;

UCHAR COM, MASQ, FREQ, N_SAMPL ;
//Necesario para las rutinas de recepcion serie con interrupciones
UCHAR dato_en_serie;
//necesario para la rutina delay
UINT desbordes;
UCHAR temp;
/******programa principal*********/
void main(void)
{

F_COM=1;F_MASQ=F_FREQ=F_N_SAMPL=0;	//Lo primero que esperamos es un comando

//init_serie_int();
ini_serie();

while(1)
	{
	ini_serie();
	init_lcd();
	lcd_clrscr();
	display(saludo);
	poner_linea_2();

	while(F_ARRANCAR==0) //Esperamos ha que hallamos recibido el comando y sus parametros
	{
//		while(F_NUEVODATO==0);
//		F_NUEVODATO=0;
 		dato_en_serie=recibir_serie();
		recibir();
	}
	F_ARRANCAR=0;
//	salir=0;
	mandar();			//Una vez hemos recibido el comando empezamos a mandar

	}
}


