/* Copyright 2022, Savanni D'Gerinel This file is part of Savanni's AVR library. This AVR library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This AVR library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Lumeto. If not, see . */ #ifndef __TIMER_H__ #define __TIMER_H__ #include // ATmega16U4/32U4 Datasheet, table 14.4, page 133 typedef enum { normal, pwm_phasecorrect_8bit, pwm_phasecorrect_9bit, pwm_phasecorrect_10bit, ctc, fast_pwm_8bit, fast_pwm_9bit, fast_pwm_10bit, pwm_phase_and_frequency_correct_icrtop, pwm_phase_and_frequency_correct_ocrtop, pwm_phase_correct_icrtop, pwm_phase_correct_ocrtop, ctc_icr, fast_pwm_icrtop, fast_pwm_ocrtop, } timer_mode_t; // Clock prescaler selector, ATmega16U4/32U4 Datasheet, table 14.5, page 1354p typedef enum { none, clk_1, clk_8, clk_64, clk_256, clk_1024, external_falling_edge, external_rising_edge, } clock_select_t; typedef struct { volatile uint8_t count_msb; volatile uint8_t count_lsb; volatile uint8_t top_msb; volatile uint8_t top_lsb; } timer_16bit_t; #endif