#include<hc11.h>
#include<stdio.h>
#include <string.h>
#include <math.h>

#include"lcd.c"
#include"clavier.c"



/* pour essai interrupt real time */
void start(void)
{
	PACTL &= 0xFC; /* selection de la vitesse */
	TMSK2 |= 0x40;	/* declenche le timer */
	asm("cli");	/* autorise les interruptions */
}

/********************************************/
	
void beep( int cnt)
	{
		do
		{
		PORTG ^=01;
		wait(7);
		PORTG ^=01;
		wait(4);
		}
		while(--cnt);
	}

/********************************************/
	
void wait(int cnt)
{
	int i;
	for(;cnt;cnt--)
	for(i=0;i<1000;i++);
}	

/********************************************/

	
void main(void)
	{

	/* initialisations */


	int bcl=2; /* clignotement */
	DDRA = 0x80; /* port A en sortie sur le bit 7 */
	PORTA = 0x7F; /* silence ! */
	DDRG = 0xFF;
	PORTG = 0;
//	CSCTL = 0xE5;	/* pour autoriser CSIO1 */
//	CSGSIZ = 0x0A;	/* le prévoir dans crt11.s si ça ne marchait pas ici */

	/* init afficheur */
	
	lcdinit();
	wait(10);

	start();	/* demarrage timer */

	lcd_on();
	printf("* Centrale    *\n*   D'alarme  *");
	beep(2);
	wait(100);
	printf("\x04* WATCH_DOG   *\n*  MILLENIUM  *");
	wait(200);
	/* clignotement de watch_dog millenium */
		do
		{
		lcd_off();wait(20);
		lcd_on();wait(20);
		bcl--;
		}while(bcl);

	printf("\x04 COPYRIGHT (c)\n     2000");wait(100);
	printf("\x04 gerald.festou@\n worldonline.fr");wait(300);
	
}	