/*
 * led_gen.c
 *
 * Created: 03/12/2021 14:25:05
 *  Author: 40008304
 */

#include "led_gen.h"

volatile unsigned char led1_state=0;
volatile unsigned char led2_state=0;

void led1_init(void)
{
	TCCR1|=(1<<CTC1)|(1<<COM1A0);		//on active le mode CTC en comparant OCR1C, COM1A0 : mode toggle
	OCR1C=35;							//d'apres retroingenieurie OCR1C=35
	TCCR1|=(1<<CS10)|(1<<CS11);			//on active la clock, prediv de 4
	DDRB |= (1<<PB1);
	led1_state=1;
}

void led2_init(void)
{
	GTCCR|=(1<<COM1B0);					//COM1B0 : mode toggle
	OCR1C=35;							//d'apres retroingenieurie OCR1C=35
	TCCR1|=(1<<CS10)|(1<<CS11);			//on active la clock, prediv de 4
	DDRB |= (1<<PB4);
	led2_state=1;
}

void led1_stop(void)
{
	DDRB &= ~(1<<PB1);
	TCCR1 &= ~(1<<COM1A0);
	led1_state=0;
}

void led2_stop(void)
{
	DDRB &= ~(1<<PB4);
	GTCCR &= ~(1<<COM1B0);
	led2_state=0;
}

void timer0_init(void)
{
	 TCCR0A=0x00;			//Mode normal
	 TCCR0B=0x00;
	 TCCR0B |= (1<<CS01);   //divise par 8
	 TCNT0=0;
	 TIMSK|=(1<<TOIE0);		//Interruptions autorisees
}






