Setup Code

Add these macros to the top of your main application C-file:
/* Use TC Peripheral 0. */
#define TC             TC0
#define TC_PERIPHERAL  0
/* Configure TC0 channel 2 as capture input. */
#define TC_CHANNEL_CAPTURE 2
#define ID_TC_CAPTURE ID_TC2
#define PIN_TC_CAPTURE PIN_TC0_TIOA2
#define PIN_TC_CAPTURE_MUX PIN_TC0_TIOA2_MUX
/* Use TC2_Handler for TC capture interrupt. */
#define TC_Handler  TC2_Handler
#define TC_IRQn     TC2_IRQn
Add this macro and functions to your main application C-file:
#define TC_CAPTURE_TIMER_SELECTION TC_CMR_TCCLKS_TIMER_CLOCK3
static void tc_capture_initialize(void)
{
    /* Configure the PMC to enable the TC module */
    sysclk_enable_peripheral_clock(ID_TC_CAPTURE);
#if SAMG55
    /* Enable PCK output */
    pmc_disable_pck(PMC_PCK_3);
    pmc_switch_pck_to_mck(PMC_PCK_3, PMC_PCK_PRES_CLK_1);
    pmc_enable_pck(PMC_PCK_3);
#endif

    /* Init TC to capture mode. */
    tc_init(TC, TC_CHANNEL_CAPTURE,
            TC_CAPTURE_TIMER_SELECTION /* Clock Selection */
            | TC_CMR_LDRA_RISING /* RA Loading: rising edge of TIOA */
            | TC_CMR_LDRB_FALLING /* RB Loading: falling edge of TIOA */
            | TC_CMR_ABETRG /* External Trigger: TIOA */
            | TC_CMR_ETRGEDG_FALLING /* External Trigger Edge: Falling edge */
    );
}
void TC_Handler(void)
{
}