34 lines
No EOL
802 B
C
Executable file
34 lines
No EOL
802 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, COM1A1 ? 1 pour desactiver /OC1A
|
|
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 a 1 pour desactiver /OC1A
|
|
OCR1B=16; //d'apres retroingenieurie OCR1B=16
|
|
TCCR1|=(1<<CS10); //on active la clock avec CS10 = 1, pas de prediv (plus precis pour haute freq)
|
|
}
|
|
|
|
void led1_stop(void)
|
|
{
|
|
TCCR1 &= ~(1<<COM1A0);
|
|
}
|
|
|
|
void led2_stop(void)
|
|
{
|
|
GTCCR &= ~(1<<COM1B0);
|
|
} |