// // Created by kirillius on 09.04.2022. // #include "FanController.h" #include #include #include FanController::FanController() { pinmode_output(DDRC, PORTC0); TCCR0A = 0; TCCR0B = 0; TCCR0A |= (1 << WGM01);// Режим CTC (сброс по совпадению) TCCR0B |= (1 << CS01);// Тактирование от CLK CLK/8 OCR0A = 64; TIMSK0 |= (1 << OCIE0A);// Прерывание по совпадению } uint8_t FanController::PWM, FanController::PWMCounter = 0; ISR(TIMER0_COMPA_vect) { if (FanController::PWM == 0) { PORTC &= ~(1 << PORTC0); return; } if (++FanController::PWMCounter == 0) { PORTC |= (1 << PORTC0); return; } if (FanController::PWMCounter == FanController::PWM) { PORTC &= ~(1 << PORTC0); } }