Exemplo n.º 1
0
void toggle(void)
{
	led1 = !led1;
	
	// Relaunch alarm in 10 sec
	clock.alarm(10, &toggle);
}
Exemplo n.º 2
0
/****MAIN****/
int main(void)
{
	PORTINIT();
	/***INICIALIZE OBJECTS***/
	FUNC function = FUNCenable();
	LCD0 lcd0 = LCD0enable(&DDRA,&PINA,&PORTA);
	ANALOG analog = ANALOGenable(1, 128, 1, 0); // channel 0 for position
	TIMER_COUNTER0 timer0 = TIMER_COUNTER0enable(2,2); // for clock
	TIMER_COUNTER1 timer1 = TIMER_COUNTER1enable(9,0); // PWM positioning
	relogio=CLOCKenable(12,0,0);
	LFSM lfsm=LFSMenable(memory,128);
	//lfsm.input_inic(&lfsm,PINB);
	/******/
	lfsm.inic(&lfsm,PINB,0);
	int adcvalue;
	uint8_t alarm;
	char value[9];
	/***Parameters timers***/
	timer0.compare(249);
	timer1.compoutmodeB(2);
	timer1.compareA(20000);
	timer1.start(8);
	timer0.start(64);
	/**********/
	while(TRUE){
		//PREAMBLE
		lcd0.reboot();
		//TODO:: Please write your application code
		lcd0.gotoxy(0,0);
		lcd0.string(relogio.show());
		lcd0.gotoxy(9,0);
		alarm=relogio.alarm(12,1,0);
		function.itoa(alarm,value);
		lcd0.string(value);
		lcd0.gotoxy(12,0);
		function.itoa(PINB,value);
		lcd0.string(value);
		if(!alarm){
			lcd0.gotoxy(0,1);
			lcd0.string(relogio.show());
		}else{
			lcd0.gotoxy(0,1);
			lcd0.string("Alarm");
		}
		lcd0.gotoxy(9,1);
		function.itoa(lfsm.read(&lfsm,PINB),value);
		lcd0.string(value);
		lcd0.gotoxy(12,1);
		function.itoa(lfsm.read_input(&lfsm),value);
		lcd0.string(value);
		
	}
}
Exemplo n.º 3
0
int main(void)
{	
	Systick_Init();
	
	time.hours = 10;
	time.minutes = 30;
	time.seconds = 0;
	
	clock.set(time);
	
	// Alarm set to 10 sec
	clock.alarm(10, &toggle);
	
  while (1)
  {
		clock.get(&time);
  }
}