Adafruit ZeroTimer Library
Classes | Macros | Enumerations
Adafruit_ZeroTimer.h File Reference
#include "Arduino.h"
#include "wiring_private.h"

Go to the source code of this file.

Classes

class  Adafruit_ZeroTimer
 Class that stores state and functions for interacting with SAMD21 or SAMD51 Timer Counter. More...
 
struct  Adafruit_ZeroTimer::counter_8_bit
 Helper struct to hold state for 8-bit configured TC. More...
 
struct  Adafruit_ZeroTimer::counter_16_bit
 Helper struct to hold state for 16-bit configured TC. More...
 
struct  Adafruit_ZeroTimer::counter_32_bit
 Helper struct to hold state for 32-bit configured TC. More...
 
struct  Adafruit_ZeroTimer::pwm_channel
 Helper struct to hold state for a PWM output channel. More...
 

Macros

#define NUM_PWM_CHANNELS   2
 
#define NUM_CC_CHANNELS   2
 

Enumerations

enum  tc_clock_prescaler {
  TC_CLOCK_PRESCALER_DIV1 = TC_CTRLA_PRESCALER(0), TC_CLOCK_PRESCALER_DIV2 = TC_CTRLA_PRESCALER(1), TC_CLOCK_PRESCALER_DIV4 = TC_CTRLA_PRESCALER(2), TC_CLOCK_PRESCALER_DIV8 = TC_CTRLA_PRESCALER(3),
  TC_CLOCK_PRESCALER_DIV16 = TC_CTRLA_PRESCALER(4), TC_CLOCK_PRESCALER_DIV64 = TC_CTRLA_PRESCALER(5), TC_CLOCK_PRESCALER_DIV256 = TC_CTRLA_PRESCALER(6), TC_CLOCK_PRESCALER_DIV1024 = TC_CTRLA_PRESCALER(7)
}
 
enum  tc_counter_size { TC_COUNTER_SIZE_8BIT = TC_CTRLA_MODE_COUNT8, TC_COUNTER_SIZE_16BIT = TC_CTRLA_MODE_COUNT16, TC_COUNTER_SIZE_32BIT = TC_CTRLA_MODE_COUNT32 }
 
enum  tc_wave_generation { TC_WAVE_GENERATION_NORMAL_FREQ = TC_CTRLA_WAVEGEN_NFRQ, TC_WAVE_GENERATION_MATCH_FREQ = TC_CTRLA_WAVEGEN_MFRQ, TC_WAVE_GENERATION_NORMAL_PWM = TC_CTRLA_WAVEGEN_NPWM, TC_WAVE_GENERATION_MATCH_PWM = TC_CTRLA_WAVEGEN_MPWM }
 
enum  tc_count_direction { TC_COUNT_DIRECTION_UP = 0, TC_COUNT_DIRECTION_DOWN }
 
enum  tc_callback {
  TC_CALLBACK_OVERFLOW = 0, TC_CALLBACK_ERROR, TC_CALLBACK_CC_CHANNEL0, TC_CALLBACK_CC_CHANNEL1,
  TC_CALLBACK_N
}
 

Macro Definition Documentation

◆ NUM_PWM_CHANNELS

#define NUM_PWM_CHANNELS   2

! How many PWM channels per TC

◆ NUM_CC_CHANNELS

#define NUM_CC_CHANNELS   2

! How many CC channels per TC

Enumeration Type Documentation

◆ tc_clock_prescaler

! Prescale from the peripheral clock

Enumerator
TC_CLOCK_PRESCALER_DIV1 

Divide clock by 1

TC_CLOCK_PRESCALER_DIV2 

Divide clock by 2

TC_CLOCK_PRESCALER_DIV4 

Divide clock by 4

TC_CLOCK_PRESCALER_DIV8 

Divide clock by 8

TC_CLOCK_PRESCALER_DIV16 

Divide clock by 16

TC_CLOCK_PRESCALER_DIV64 

Divide clock by 64

TC_CLOCK_PRESCALER_DIV256 

Divide clock by 256

TC_CLOCK_PRESCALER_DIV1024 

Divide clock by 1024

◆ tc_counter_size

! The counter size for this TC

Enumerator
TC_COUNTER_SIZE_8BIT 

! The counter's maximum value is 0xFF, the period register is available to be used as top value

TC_COUNTER_SIZE_16BIT 

! The counter's maximum value is 0xFFFF. There is no separate period register, to modify top one of the capture compare registers has to be used. This limits the amount of available channels.

TC_COUNTER_SIZE_32BIT 

! The counter's maximum value is 0xFFFFFFFF. There is no separate period register, to modify top one of the capture compare registers has to be used. This limits the amount of available channels.

◆ tc_wave_generation

! The output pin PWM style

Enumerator
TC_WAVE_GENERATION_NORMAL_FREQ 

! Top is maximum, except in 8-bit counter size where it is the PER register

TC_WAVE_GENERATION_MATCH_FREQ 

! Top is CC0, except in 8-bit counter size where it is the PER register

TC_WAVE_GENERATION_NORMAL_PWM 

! Top is maximum, except in 8-bit counter size where it is the PER register

TC_WAVE_GENERATION_MATCH_PWM 

! Top is CC0, except in 8-bit counter size where it is the PER register

◆ tc_count_direction

! Which way the counter goes

◆ tc_callback

! What event triggers a callback