|
FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
|
Special kind of timer::Timer, specialized in emitting pulses with accurate width, according to a slow frequency.
More...
#include <fastarduino/pulse_timer.h>


Public Member Functions | |
| PulseTimer (UNUSED uint16_t pulse_frequency) | |
Create a PulseTimer with the provided pulse_frequency. More... | |
Public Member Functions inherited from timer::Timer< NTIMER_ > | |
| Timer (TimerMode timer_mode, PRESCALER prescaler, TimerInterrupt interrupts=TimerInterrupt(0)) | |
| Construct a new Timer handler and initialize its mode. More... | |
| void | set_interrupts (TimerInterrupt interrupts=TimerInterrupt(0)) |
| Set the list of interrupts that must be triggered by this timer. More... | |
| void | enable_interrupts (TimerInterrupt interrupts) |
| Add new interrupts to be enabled to the current list of interrupts that must be triggered by this timer. More... | |
| void | disable_interrupts (TimerInterrupt interrupts) |
| Remove interrupts from the current list of enabled interrupts triggered by this timer. More... | |
| bool | are_interrupts_enabled (TimerInterrupt interrupts) const |
| Test if interrupts are currently enabled for this timers. More... | |
| void | set_input_capture (TimerInputCapture input_capture) |
| Set the input capture mode for this timer. More... | |
| TimerInputCapture | input_capture () const |
Return the current TimerInputCapture used by this timer. More... | |
| void | set_capture_noise_canceller (bool cancel_noise) |
| Set or clear the noise canceller for input capture on this timer. More... | |
| bool | has_capture_noise_canceller () const |
| Tell whether noise canceller for this timer's input capture is active or not. More... | |
| void | set_timer_mode (TimerMode timer_mode) |
| Change timer mode. More... | |
| TimerMode | get_timer_mode () const |
| Get current time mode. More... | |
| void | set_prescaler (PRESCALER prescaler) |
| Change prescaler for this timer. More... | |
| void | begin (TYPE max=0) |
Start this timer in the currently selected mode, with the provided prescaler value and max value. More... | |
| void | begin_ (TYPE max=0) |
Start this timer in the currently selected mode, with the provided prescaler value and max value. More... | |
| void | reset (TYPE ticks=0) |
Reset current counter to ticks . More... | |
| void | reset_ (TYPE ticks=0) |
Reset current counter to ticks . More... | |
| TYPE | ticks () |
| Return the current counter value for this timer. More... | |
| TYPE | ticks_ () |
| Return the current counter value for this timer. More... | |
| void | suspend_interrupts () |
| Temporarily suspend this timer: the timer does not generate any interrupt any longer. More... | |
| void | suspend_interrupts_ () |
| Temporarily suspend this timer: the timer does not generate any interrupt any longer. More... | |
| void | resume_interrupts () |
| Resume this timer if it was previously suspended: the timer's counter is reset and the timer starts generating interrupts again. More... | |
| void | resume_interrupts_ () |
| Resume this timer if it was previously suspended: the timer's counter is reset and the timer starts generating interrupts again. More... | |
| bool | is_interrupt_suspended () |
| Check if this timer interrupts are currently suspended, i.e. More... | |
| void | suspend_timer () |
Suspend this timer, ie stop this timer counting (ticks() will not change then). More... | |
| void | suspend_timer_ () |
Suspend this timer, ie stop this timer counting (ticks() will not change then). More... | |
| void | resume_timer () |
Resume this timer, ie restart counting (ticks() will start changing again). More... | |
| void | resume_timer_ () |
Resume this timer, ie restart counting (ticks() will start changing again). More... | |
| void | end () |
| Completely stop this timer: timer interrupts are disabled and counter is stopped. More... | |
| void | end_ () |
| Completely stop this timer: timer interrupts are disabled and counter is stopped. More... | |
| template<uint8_t COM> | |
| void | set_output_mode (TimerOutputMode mode) |
| Change the output mode for this timer; this enables connection between this timer to one of its associated digital output pins. More... | |
| template<uint8_t COM> | |
| void | set_max (TYPE max) |
| Change the maximum value for this timer, in relation to one of its associated digital output pins. More... | |
Additional Inherited Members | |
Public Types inherited from timer::Timer< NTIMER_ > | |
| using | TYPE = typename TRAIT::TYPE |
The type of this timer's counter (either uint8_t or uint16_t). More... | |
| using | CALCULATOR = Calculator< NTIMER > |
| The Calculator type for this Timer. More... | |
| using | PRESCALER = typename PRESCALERS_TRAIT::TYPE |
| The enum type listing all available precaler values for this timer. More... | |
Static Public Attributes inherited from timer::Timer< NTIMER_ > | |
| static constexpr const board::Timer | NTIMER = NTIMER_ |
| The Board timer used by this Timer. More... | |
| static constexpr const TYPE | TIMER_MAX = TRAIT::MAX_COUNTER - 1 |
| The maximum value that can be set to this timer's counter. More... | |
| static constexpr const TYPE | PWM_MAX = TRAIT::MAX_PWM |
| The maximum value that can be set to this timer's counter in PWM mode. More... | |
| static constexpr const board::DigitalPin | ICP_PIN = TRAIT::ICP_PIN |
The pin that is used for Input Capture feature, if supported by this timer, or board::DigitalPin::NONE if not. More... | |
Special kind of timer::Timer, specialized in emitting pulses with accurate width, according to a slow frequency.
This is typically useful for controlling servos, which need a pulse with a width range from ~1000us to ~2000us, send every 20ms, ie with a 50Hz frequency. This implementation ensures a good pulse width precision for both 16-bits and 8-bits timers.
Note: if NTIMER_ is an 8-bits Timer, then one of the following macros must be used to register the necessary ISR for the PulseTimer to work correctly:
For concrete usage, you can check the following examples, provided with FastArduino source:
| NTIMER_ | the board::Timer to use for this PulseTimer |
| PRESCALER_ | the prescaler value to use for this PulseTimer; it shall be calculated with timer::Calculator::PulseTimer_prescaler() |
| T | the type (uint8_t or uint16_t) of the Timer determined by NTIMER_; you should not specify it yourself, as its default value alwayy matches NTIMER_. |
Definition at line 245 of file pulse_timer.h.
|
inlineexplicit |
Create a PulseTimer with the provided pulse_frequency.
| pulse_frequency | the frequency, in Hz, at which pulses will be generated; this frequency must match the PRESCALER_ template parameter. |
Definition at line 255 of file pulse_timer.h.