6 #include "wiring_private.h" 8 #ifndef _ADAFRUIT_ZEROTIMER_ 9 #define _ADAFRUIT_ZEROTIMER_ 53 #if defined(__SAMD51__) 93 TC_CALLBACK_OVERFLOW = 0,
95 TC_CALLBACK_CC_CHANNEL0,
96 TC_CALLBACK_CC_CHANNEL1,
101 #define NUM_PWM_CHANNELS 2 103 #define NUM_CC_CHANNELS 2 115 boolean PWMout(
boolean pwmout, uint8_t channum, uint8_t pin);
116 void setPeriodMatch(uint32_t period, uint32_t match, uint8_t channum = 1);
122 void setCompare(uint8_t channum, uint32_t compare);
125 void (*callback_func)(
void) = NULL);
counter_8_bit _counter_8_bit
Definition: Adafruit_ZeroTimer.h:151
Definition: Adafruit_ZeroTimer.h:18
uint8_t period
The period/top value for this timer.
Definition: Adafruit_ZeroTimer.h:148
Tc * _hw
Pointer to the timer we're wrappering.
Definition: Adafruit_ZeroTimer.h:132
tc_wave_generation
Definition: Adafruit_ZeroTimer.h:65
tc_counter_size _counter_size
8, 16 or 32 bit counter size?
Definition: Adafruit_ZeroTimer.h:136
Definition: Adafruit_ZeroTimer.h:69
void enable(boolean en)
Enable or disable the timer. Won't do anything if the status is what we desire already.
Definition: Adafruit_ZeroTimer.cpp:673
tc_count_direction _count_direction
Which way the counter goes, up or down.
Definition: Adafruit_ZeroTimer.h:141
#define NUM_CC_CHANNELS
Definition: Adafruit_ZeroTimer.h:103
uint8_t compare_capture_channel[NUM_CC_CHANNELS]
Definition: Adafruit_ZeroTimer.h:145
Definition: Adafruit_ZeroTimer.h:28
uint32_t pin_mux
The direct chip muxing used for this PWM output.
Definition: Adafruit_ZeroTimer.h:176
uint8_t _waveform_invert_output
Should we invert the output?
Definition: Adafruit_ZeroTimer.h:139
uint8_t value
The count value.
Definition: Adafruit_ZeroTimer.h:149
Definition: Adafruit_ZeroTimer.h:26
#define NUM_PWM_CHANNELS
Definition: Adafruit_ZeroTimer.h:101
Definition: Adafruit_ZeroTimer.h:20
void invertWave(uint8_t invert)
Whether or not to invert the output PWM.
Definition: Adafruit_ZeroTimer.cpp:464
Definition: Adafruit_ZeroTimer.h:24
Helper struct to hold state for 8-bit configured TC.
Definition: Adafruit_ZeroTimer.h:143
counter_32_bit _counter_32_bit
Definition: Adafruit_ZeroTimer.h:171
bool enabled
Whether its activated.
Definition: Adafruit_ZeroTimer.h:175
tc_clock_prescaler
Definition: Adafruit_ZeroTimer.h:12
tc_clock_prescaler _clock_prescaler
Prescale divider from timer clock source.
Definition: Adafruit_ZeroTimer.h:135
uint8_t _timernum
Which TC this is, 3 for TC3, 4 for TC4, etc.
Definition: Adafruit_ZeroTimer.h:130
Definition: Adafruit_ZeroTimer.h:14
tc_callback
Definition: Adafruit_ZeroTimer.h:92
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' ...
Definition: Adafruit_ZeroTimer.cpp:534
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.
Definition: Adafruit_ZeroTimer.cpp:482
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 connecte...
Definition: Adafruit_ZeroTimer.cpp:288
Helper struct to hold state for a PWM output channel.
Definition: Adafruit_ZeroTimer.h:174
bool tc_init()
Initializer for timer counter object.
Definition: Adafruit_ZeroTimer.cpp:64
Class that stores state and functions for interacting with SAMD21 or SAMD51 Timer Counter...
Definition: Adafruit_ZeroTimer.h:111
counter_16_bit _counter_16_bit
Definition: Adafruit_ZeroTimer.h:161
Definition: Adafruit_ZeroTimer.h:84
Definition: Adafruit_ZeroTimer.h:74
pwm_channel _pwm_channel[NUM_PWM_CHANNELS]
Definition: Adafruit_ZeroTimer.h:179
tc_wave_generation _wave_generation
What sort of waveform we'll be creating.
Definition: Adafruit_ZeroTimer.h:138
Helper struct to hold state for 32-bit configured TC.
Definition: Adafruit_ZeroTimer.h:164
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 fu...
Definition: Adafruit_ZeroTimer.cpp:731
void setCallback(boolean enable, tc_callback cb_type, void(*callback_func)(void)=NULL)
Have a function called whenever the timer interrupt goes off.
Definition: Adafruit_ZeroTimer.cpp:561
Definition: Adafruit_ZeroTimer.h:36
Definition: Adafruit_ZeroTimer.h:50
tc_count_direction
Definition: Adafruit_ZeroTimer.h:89
Definition: Adafruit_ZeroTimer.h:16
Helper struct to hold state for 16-bit configured TC.
Definition: Adafruit_ZeroTimer.h:154
uint32_t pin_out
The direct chip pad name used for this PWM output.
Definition: Adafruit_ZeroTimer.h:177
Definition: Adafruit_ZeroTimer.h:79
tc_counter_size
Definition: Adafruit_ZeroTimer.h:32
Definition: Adafruit_ZeroTimer.h:43
Adafruit_ZeroTimer(uint8_t tn)
Instantiate a ZeroTimer class.
Definition: Adafruit_ZeroTimer.cpp:54
void setCompare(uint8_t channum, uint32_t compare)
Set the timer counter's channel compare register to a value.
Definition: Adafruit_ZeroTimer.cpp:633
Definition: Adafruit_ZeroTimer.h:22