42 lines
834 B
C
Executable file
42 lines
834 B
C
Executable file
/*
|
|
* led_gen.c
|
|
*
|
|
* Created: 03/12/2021 14:25:05
|
|
* Author: 40008304
|
|
*/
|
|
|
|
#include "led_gen.h"
|
|
|
|
void led1_init(void)
|
|
{
|
|
DDRB |= (1<<PB1);
|
|
TCCR1|=(1<<CTC1)|(1<<COM1A0); //on active le mode CTC en comparant OCR1C, COM1A0 : mode toggle
|
|
OCR1C=16; //d'apres retroingenieurie OCR1C=16
|
|
TCCR1|=(1<<CS10); //on active la clock avec CS10 = 1, pas de prediv (plus precis pour haute freq)
|
|
}
|
|
|
|
void led2_init(void)
|
|
{
|
|
DDRB |= (1<<PB4);
|
|
GTCCR|=(1<<COM1B0); //COM1B0 : mode toggle
|
|
OCR1C=16; //d'apres retroingenieurie OCR1C=16
|
|
TCCR1|=(1<<CS10); //on active la clock avec CS10 = 1, pas de prediv (plus precis pour haute freq)
|
|
}
|
|
|
|
void led1_stop(void)
|
|
{
|
|
DDRB &= ~(1<<PB1);
|
|
TCCR1 &= ~(1<<COM1A0);
|
|
}
|
|
|
|
void led2_stop(void)
|
|
{
|
|
DDRB &= ~(1<<PB4);
|
|
GTCCR &= ~(1<<COM1B0);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|