Class that stores state and functions for interacting with SAMD21 or SAMD51 Timer Counter.
More...
#include <Adafruit_ZeroTimer.h>
|
| Adafruit_ZeroTimer (uint8_t tn) |
| Instantiate a ZeroTimer class. More...
|
|
boolean | PWMout (boolean pwmout, uint8_t channum, uint8_t pin) |
| Use the TC to output a PWM signal on a given pin. Check datasheet to verify what pins can be connected to which TC output and what channel to use. More...
|
|
void | setPeriodMatch (uint32_t period, uint32_t match, uint8_t channum=1) |
| Set up channel 0 of the timer for the 'top' or period setting value, and channel 1 for the 'compare' value. More...
|
|
void | enable (boolean en) |
| Enable or disable the timer. Won't do anything if the status is what we desire already. More...
|
|
void | configure (tc_clock_prescaler prescale, tc_counter_size countersize, tc_wave_generation wavegen, tc_count_direction countdir=TC_COUNT_DIRECTION_UP) |
| Configure how we want to use the timer, based on ASF constants. More...
|
|
void | setCompare (uint8_t channum, uint32_t compare) |
| Set the timer counter's channel compare register to a value. More...
|
|
void | invertWave (uint8_t invert) |
| Whether or not to invert the output PWM. More...
|
|
void | setCallback (boolean enable, tc_callback cb_type, void(*callback_func)(void)=NULL) |
| Have a function called whenever the timer interrupt goes off. More...
|
|
|
static void | timerHandler (uint8_t timerNum) |
| The function we call from within the IRQ function defined in the sketch. We can't have all the IRQ functions in this library because then no other library can use them. So we have a handler that the usercode must call. More...
|
|
Class that stores state and functions for interacting with SAMD21 or SAMD51 Timer Counter.
◆ Adafruit_ZeroTimer()
Adafruit_ZeroTimer::Adafruit_ZeroTimer |
( |
uint8_t |
timernum | ) |
|
Instantiate a ZeroTimer class.
- Parameters
-
timernum | The timer we are wrapping, 3 for TC3, 4 for TC4, etc! |
◆ PWMout()
boolean Adafruit_ZeroTimer::PWMout |
( |
boolean |
pwmout, |
|
|
uint8_t |
channum, |
|
|
uint8_t |
pin |
|
) |
| |
Use the TC to output a PWM signal on a given pin. Check datasheet to verify what pins can be connected to which TC output and what channel to use.
- Parameters
-
pwmout | True to enable the output, False to disable |
channum | Which channel, 0 or 1, we want to output on. |
pin | The Arduino pin name we want to have the PWM output on |
- Returns
- True on success
◆ setPeriodMatch()
void Adafruit_ZeroTimer::setPeriodMatch |
( |
uint32_t |
period, |
|
|
uint32_t |
match, |
|
|
uint8_t |
channum = 1 |
|
) |
| |
Set up channel 0 of the timer for the 'top' or period setting value, and channel 1 for the 'compare' value.
- Parameters
-
period | The period register value to use (you'll need to calculate this from the frequency desired) |
match | The compare value, should be less than the period, determines the duty cycle |
channum | Only for 8-bit counter mod, we can have the period set and two* channel outputs |
◆ enable()
void Adafruit_ZeroTimer::enable |
( |
boolean |
en | ) |
|
Enable or disable the timer. Won't do anything if the status is what we desire already.
- Parameters
-
en | True to enable, False to disable |
◆ configure()
Configure how we want to use the timer, based on ASF constants.
- Parameters
-
◆ setCompare()
void Adafruit_ZeroTimer::setCompare |
( |
uint8_t |
channum, |
|
|
uint32_t |
compare |
|
) |
| |
Set the timer counter's channel compare register to a value.
- Parameters
-
channum | Which channel to use, can be 0 or 1 |
compare | The compare value to set the channel compare value to, will be cast to whatever size the timer is setup for (8/16/32 bit) |
◆ invertWave()
void Adafruit_ZeroTimer::invertWave |
( |
uint8_t |
invert | ) |
|
Whether or not to invert the output PWM.
- Parameters
-
invert | True to invert, False to use default |
◆ setCallback()
void Adafruit_ZeroTimer::setCallback |
( |
boolean |
enable, |
|
|
tc_callback |
cb_type, |
|
|
void(*)(void) |
callback_func = NULL |
|
) |
| |
Have a function called whenever the timer interrupt goes off.
- Parameters
-
enable | True to enable the callback, False to disable |
cb_type | Which channel to use, can be TC_CALLBACK_CC_CHANNEL0 or TC_CALLBACK_CC_CHANNEL1 |
callback_func | A function with no params or return, that will be called |
◆ timerHandler()
void Adafruit_ZeroTimer::timerHandler |
( |
uint8_t |
timerNum | ) |
|
|
static |
The function we call from within the IRQ function defined in the sketch. We can't have all the IRQ functions in this library because then no other library can use them. So we have a handler that the usercode must call.
- Parameters
-
timerNum | The timer we just got an IRQ for, 3 for TC3, 4 for TC4, etc! |
◆ tc_init()
bool Adafruit_ZeroTimer::tc_init |
( |
| ) |
|
|
protected |
Initializer for timer counter object.
- Returns
- True if we were able to init the timer, False on any failure
◆ _counter_8_bit
Stats for when we have the counter configed for 8 bit operation
◆ _counter_16_bit
Stats for when we have the counter configed for 16 bit operation
◆ _counter_32_bit
Stats for when we have the counter configed for 32 bit operation
◆ _pwm_channel
status of the 2 PWM channels per timer
The documentation for this class was generated from the following files: