ZeroTC45 - a timer library for SAMD21 Arduinos

I have updated my simple timer library for SAMD21 Arduinos.

It provides access to timer/counters 4 & 5 with second or millisecond resolution (roughly).

You set an interval for either timer/counter and give it a callback function that will be called when the timer goes off.

You can set a timer to be a single shot.

Both TC4 & TC5 will use the same resolution, and can be used at the same time with different intervals, and either can be single shot.

It does not interfere with RTCZero, or the Arduino core as far as I can tell. It does not use any other libraries.

See GitHub - dajtxx/ZeroTC45: An Arduino library providing simple access to the SAMD TC4 and TC5 counters for periodic callbacks.

An example:

#include <ZeroTC45.h>

// Create the timer instance.
ZeroTC45 timer;

volatile bool tc4IsrTriggered = false;

void tc4Callback() {
    tc4IsrTriggered = true;
}

void setup() {
    timer.begin(ZeroTC45::MILLISECONDS);

    // Start TC4 and have it call tc4Callback every 1.5 seconds.
    timer.setTc4Callback(tc4Callback);
    timer.startTc4(1500);
}

void loop() {
    if (tc4IsrTriggered) {
        ...
    }
}