FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
pulse_timer.h File Reference

PulseTimer API. More...

#include "boards/board_traits.h"
#include <avr/interrupt.h>
#include <stddef.h>
#include "interrupts.h"
#include "utilities.h"
#include "timer.h"
#include "gpio.h"
#include "types_traits.h"
Include dependency graph for pulse_timer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  timer::PulseTimer< NTIMER_, PRESCALER_, T >
 Special kind of timer::Timer, specialized in emitting pulses with accurate width, according to a slow frequency. More...
 

Namespaces

namespace  timer
 Defines all API to manipulate AVR Timers.
 

Macros

#define REGISTER_PULSE_TIMER8_AB_ISR(TIMER_NUM, PRESCALER, PIN_A, PIN_B)
 Register all necessary ISR (Tnterrupt Service Routines) for a timer::PulseTimer to work properly, when both its PWM pins are connected. More...
 
#define REGISTER_PULSE_TIMER8_A_ISR(TIMER_NUM, PRESCALER, PIN_A)
 Register all necessary ISR (Tnterrupt Service Routines) for a timer::PulseTimer to work properly, when only its first PWM pins is connected. More...
 
#define REGISTER_PULSE_TIMER8_B_ISR(TIMER_NUM, PRESCALER, PIN_B)
 Register all necessary ISR (Tnterrupt Service Routines) for a timer::PulseTimer to work properly, when only its second PWM pins is connected. More...
 

Detailed Description

PulseTimer API.

Definition in file pulse_timer.h.

Macro Definition Documentation

◆ REGISTER_PULSE_TIMER8_AB_ISR

#define REGISTER_PULSE_TIMER8_AB_ISR (   TIMER_NUM,
  PRESCALER,
  PIN_A,
  PIN_B 
)
Value:
ISR(CAT3(TIMER, TIMER_NUM, _OVF_vect)) \
{ \
timer::isr_handler_pulse::pulse_timer_overflow<TIMER_NUM, PRESCALER, PIN_A, 0, PIN_B, 1>(); \
} \
ISR(CAT3(TIMER, TIMER_NUM, _COMPA_vect)) \
{ \
timer::isr_handler_pulse::pulse_timer_compare<TIMER_NUM, 0, PIN_A>(); \
} \
ISR(CAT3(TIMER, TIMER_NUM, _COMPB_vect)) \
{ \
timer::isr_handler_pulse::pulse_timer_compare<TIMER_NUM, 1, PIN_B>(); \
}

Register all necessary ISR (Tnterrupt Service Routines) for a timer::PulseTimer to work properly, when both its PWM pins are connected.

Note: this is necessary only for PulseTimer based on an 8-bits Timer. If you are using a 16-bits based PulseTimer, then you don't need to use this macro.

Parameters
TIMER_NUMthe timer number (as defined in MCU datasheet)
PRESCALERthe prescaler value used to instantiate the PulseTimer template
PIN_Athe board::PWMPin connected to first PWM pin of the PulseTimer; this is used for control only, to avoid bugs due to code typos.
PIN_Bthe board::PWMPin connected to second PWM pin of the PulseTimer; this is used for control only, to avoid bugs due to code typos.
See also
timer::PulseTimer

Definition at line 51 of file pulse_timer.h.

◆ REGISTER_PULSE_TIMER8_A_ISR

#define REGISTER_PULSE_TIMER8_A_ISR (   TIMER_NUM,
  PRESCALER,
  PIN_A 
)
Value:
ISR(CAT3(TIMER, TIMER_NUM, _OVF_vect)) \
{ \
timer::isr_handler_pulse::pulse_timer_overflow<TIMER_NUM, PRESCALER, PIN_A, 0>(); \
} \
ISR(CAT3(TIMER, TIMER_NUM, _COMPA_vect)) \
{ \
timer::isr_handler_pulse::pulse_timer_compare<TIMER_NUM, 0, PIN_A>(); \
} \
EMPTY_INTERRUPT(CAT3(TIMER, TIMER_NUM, _COMPB_vect))

Register all necessary ISR (Tnterrupt Service Routines) for a timer::PulseTimer to work properly, when only its first PWM pins is connected.

Note: this is necessary only for PulseTimer based on an 8-bits Timer. If you are using a 16-bits based PulseTimer, then you don't need to use this macro.

Parameters
TIMER_NUMthe timer number (as defined in MCU datasheet)
PRESCALERthe prescaler value used to instantiate the PulseTimer template
PIN_Athe board::PWMPin connected to first PWM pin of the PulseTimer; this is used for control only, to avoid bugs due to code typos.
See also
timer::PulseTimer

Definition at line 79 of file pulse_timer.h.

◆ REGISTER_PULSE_TIMER8_B_ISR

#define REGISTER_PULSE_TIMER8_B_ISR (   TIMER_NUM,
  PRESCALER,
  PIN_B 
)
Value:
ISR(CAT3(TIMER, TIMER_NUM, _OVF_vect)) \
{ \
timer::isr_handler_pulse::pulse_timer_overflow<TIMER_NUM, PRESCALER, PIN_B, 1>(); \
} \
ISR(CAT3(TIMER, TIMER_NUM, _COMPB_vect)) \
{ \
timer::isr_handler_pulse::pulse_timer_compare<TIMER_NUM, 1, PIN_B>(); \
} \
EMPTY_INTERRUPT(CAT3(TIMER, TIMER_NUM, _COMPA_vect))

Register all necessary ISR (Tnterrupt Service Routines) for a timer::PulseTimer to work properly, when only its second PWM pins is connected.

Note: this is necessary only for PulseTimer based on an 8-bits Timer. If you are using a 16-bits based PulseTimer, then you don't need to use this macro.

Parameters
TIMER_NUMthe timer number (as defined in MCU datasheet)
PRESCALERthe prescaler value used to instantiate the PulseTimer template
PIN_Bthe board::PWMPin connected to second PWM pin of the PulseTimer; this is used for control only, to avoid bugs due to code typos.
See also
timer::PulseTimer

Definition at line 104 of file pulse_timer.h.