FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
|
Timer API. More...
#include "boards/board_traits.h"
#include <avr/interrupt.h>
#include <stddef.h>
#include "interrupts.h"
#include "utilities.h"
Go to the source code of this file.
Classes | |
struct | timer::Calculator< NTIMER_ > |
Defines a set of calculation methods for the given NTIMER_ The behavior of these methods is specific to each AVR Timer are there can be many important differences between 2 timers on AVR. More... | |
class | timer::Timer< NTIMER_ > |
General API to handle an AVR timer. More... | |
Namespaces | |
namespace | timer |
Defines all API to manipulate AVR Timers. | |
Macros | |
#define | REGISTER_TIMER_COMPARE_ISR_METHOD(TIMER_NUM, HANDLER, CALLBACK) |
Register the necessary ISR (Interrupt Service Routine) for a timer::Timer with a callback method in CTC mode. More... | |
#define | REGISTER_TIMER_COMPARE_ISR_FUNCTION(TIMER_NUM, CALLBACK) |
Register the necessary ISR (Interrupt Service Routine) for a timer::Timer with a callback function in CTC mode. More... | |
#define | REGISTER_TIMER_COMPARE_ISR_EMPTY(TIMER_NUM) |
Register an empty ISR (Interrupt Service Routine) for a timer::Timer. More... | |
#define | REGISTER_TIMER_OVERFLOW_ISR_METHOD(TIMER_NUM, HANDLER, CALLBACK) |
Register the necessary ISR (Interrupt Service Routine) for the Counter Overflow of a timer::Timer. More... | |
#define | REGISTER_TIMER_OVERFLOW_ISR_FUNCTION(TIMER_NUM, CALLBACK) |
Register the necessary ISR (Interrupt Service Routine) for the Counter Overflow of a timer::Timer. More... | |
#define | REGISTER_TIMER_OVERFLOW_ISR_EMPTY(TIMER_NUM) |
Register an empty ISR (Interrupt Service Routine) for the Counter Overflow of a timer::Timer. More... | |
#define | REGISTER_TIMER_CAPTURE_ISR_METHOD(TIMER_NUM, HANDLER, CALLBACK) |
Register the necessary ISR (Interrupt Service Routine) for the Input Capture of a timer::Timer. More... | |
#define | REGISTER_TIMER_CAPTURE_ISR_FUNCTION(TIMER_NUM, CALLBACK) |
Register the necessary ISR (Interrupt Service Routine) for the Input Capture of a timer::Timer. More... | |
#define | REGISTER_TIMER_CAPTURE_ISR_EMPTY(TIMER_NUM) |
Register an empty ISR (Interrupt Service Routine) for the Input Capture of a timer::Timer. More... | |
#define | DECL_TIMER_ISR_HANDLERS_FRIEND |
This macro shall be used in a class containing a private callback method, registered by REGISTER_TIMER_COMPARE_ISR_METHOD , REGISTER_TIMER_OVERFLOW_ISR_METHOD or REGISTER_TIMER_CAPTURE_ISR_METHOD . More... | |
Enumerations | |
enum class | timer::TimerMode : uint8_t { timer::NORMAL , timer::CTC , timer::FAST_PWM , timer::PHASE_CORRECT_PWM } |
Defines the mode of operation of a timer. More... | |
enum class | timer::TimerInterrupt : uint8_t { timer::OVERFLOW = board_traits::TimerInterrupt::OVERFLOW , timer::OUTPUT_COMPARE_A = board_traits::TimerInterrupt::OUTPUT_COMPARE_A , timer::OUTPUT_COMPARE_B = board_traits::TimerInterrupt::OUTPUT_COMPARE_B , timer::OUTPUT_COMPARE_C = board_traits::TimerInterrupt::OUTPUT_COMPARE_C , timer::INPUT_CAPTURE = board_traits::TimerInterrupt::INPUT_CAPTURE } |
Defines the interrupts that can be handled by a timer. More... | |
enum class | timer::TimerOutputMode : uint8_t { timer::DISCONNECTED , timer::TOGGLE , timer::NON_INVERTING , timer::INVERTING } |
Defines the "connection" between this timer and specific PWM output pins. More... | |
enum class | timer::TimerInputCapture : uint8_t { timer::RISING_EDGE , timer::FALLING_EDGE } |
Defines the type of input capture we want for a timer. More... | |
Functions | |
constexpr TimerInterrupt | timer::operator| (TimerInterrupt i1, TimerInterrupt i2) |
Combine 2 timer interrupts for use with Timer.set_interrupts() . More... | |
Timer API.
Definition in file timer.h.
#define REGISTER_TIMER_COMPARE_ISR_METHOD | ( | TIMER_NUM, | |
HANDLER, | |||
CALLBACK | |||
) |
Register the necessary ISR (Interrupt Service Routine) for a timer::Timer with a callback method in CTC mode.
TIMER_NUM | the number of the TIMER feature for the target MCU |
HANDLER | the class holding the callback method |
CALLBACK | the method of HANDLER that will be called when the interrupt is triggered; this must be a proper PTMF (pointer to member function). |
#define REGISTER_TIMER_COMPARE_ISR_FUNCTION | ( | TIMER_NUM, | |
CALLBACK | |||
) |
Register the necessary ISR (Interrupt Service Routine) for a timer::Timer with a callback function in CTC mode.
TIMER_NUM | the number of the TIMER feature for the target MCU |
CALLBACK | the function that will be called when the interrupt is triggered |
#define REGISTER_TIMER_COMPARE_ISR_EMPTY | ( | TIMER_NUM | ) |
Register an empty ISR (Interrupt Service Routine) for a timer::Timer.
This may be needed when using timer CTC mode but when you don't need any callback.
TIMER_NUM | the number of the TIMER feature for the target MCU |
#define REGISTER_TIMER_OVERFLOW_ISR_METHOD | ( | TIMER_NUM, | |
HANDLER, | |||
CALLBACK | |||
) |
Register the necessary ISR (Interrupt Service Routine) for the Counter Overflow of a timer::Timer.
TIMER_NUM | the number of the TIMER feature for the target MCU |
HANDLER | the class holding the callback method |
CALLBACK | the method of HANDLER that will be called when the interrupt is triggered; this must be a proper PTMF (pointer to member function). |
#define REGISTER_TIMER_OVERFLOW_ISR_FUNCTION | ( | TIMER_NUM, | |
CALLBACK | |||
) |
Register the necessary ISR (Interrupt Service Routine) for the Counter Overflow of a timer::Timer.
TIMER_NUM | the number of the TIMER feature for the target MCU |
CALLBACK | the function that will be called when the interrupt is triggered |
#define REGISTER_TIMER_OVERFLOW_ISR_EMPTY | ( | TIMER_NUM | ) |
Register an empty ISR (Interrupt Service Routine) for the Counter Overflow of a timer::Timer.
This would normally not be needed.
TIMER_NUM | the number of the TIMER feature for the target MCU |
#define REGISTER_TIMER_CAPTURE_ISR_METHOD | ( | TIMER_NUM, | |
HANDLER, | |||
CALLBACK | |||
) |
Register the necessary ISR (Interrupt Service Routine) for the Input Capture of a timer::Timer.
TIMER_NUM | the number of the TIMER feature for the target MCU |
HANDLER | the class holding the callback method |
CALLBACK | the method of HANDLER that will be called when the interrupt is triggered; this must be a proper PTMF (pointer to member function). |
#define REGISTER_TIMER_CAPTURE_ISR_FUNCTION | ( | TIMER_NUM, | |
CALLBACK | |||
) |
Register the necessary ISR (Interrupt Service Routine) for the Input Capture of a timer::Timer.
TIMER_NUM | the number of the TIMER feature for the target MCU |
CALLBACK | the function that will be called when the interrupt is triggered |
#define REGISTER_TIMER_CAPTURE_ISR_EMPTY | ( | TIMER_NUM | ) |
Register an empty ISR (Interrupt Service Routine) for the Input Capture of a timer::Timer.
This would normally not be needed.
TIMER_NUM | the number of the TIMER feature for the target MCU |
#define DECL_TIMER_ISR_HANDLERS_FRIEND |
This macro shall be used in a class containing a private callback method, registered by REGISTER_TIMER_COMPARE_ISR_METHOD
, REGISTER_TIMER_OVERFLOW_ISR_METHOD
or REGISTER_TIMER_CAPTURE_ISR_METHOD
.
It declares the class where it is used as a friend of all necessary functions so that the private callback method can be called properly.