1
0
Fork 0
lego_sensor_i2c/i2c_test_attiny85/led_gen.c

42 lines
758 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=34; //d'apres retroingenieurie OCR1C=16
TCCR1|=(1<<CS10)|(1<<CS11); //on active la clock, prediv de 4
}
void led2_init(void)
{
DDRB |= (1<<PB4);
GTCCR|=(1<<COM1B0); //COM1B0 : mode toggle
OCR1C=34; //d'apres retroingenieurie OCR1C=16
TCCR1|=(1<<CS10)|(1<<CS11); //on active la clock, prediv de 4
}
void led1_stop(void)
{
DDRB &= ~(1<<PB1);
TCCR1 &= ~(1<<COM1A0);
}
void led2_stop(void)
{
DDRB &= ~(1<<PB4);
GTCCR &= ~(1<<COM1B0);
}