The pins on the SAMD21 can perform as GPIO or number of different peripheral functions: timer, analog input, serial communications, etc.. , but by default they're GPIO.
Each pin has its own "Pin Configuration" register, that amongst other things can activate the input buffer or set the pull-up resistor. One of the bits however is the PMUXEN (Peripheral Multiplexer Enable) bit. Setting this bit switches the pin from GPIO to one of a number of (yet to be defined) peripherals.
The following line sets the PMUXEN in the Pin Configuration register for digital pin D7:
// Enable the port multiplexer for the digital pin D7
PORT->Group[g_APinDescription[7].ulPort].PINCFG[g_APinDescription[7].ulPin].bit.PMUXEN = 1;
As D7 is actually port pin PA21 on the SAMD21, so you could also write:
// Enable the port multiplexer for the port pin PA21:
PORT->Group[PORTA].PINCFG[21].bit.PMUXEN = 1;
The next step is to select the peripheral for the given pin, using the "Peripheral Multiplexing" registers. Each peripheral is given a letter from A-H. The TCC timers are listed as peripheral F. While there's one "Pin Configuration" register per pin, there's only one "Peripheral Multiplexing" registers for each odd and even pin pair. (So there are only half the number of "Periphal Multiplexing" registers). For example port pin PA21 (D7) is odd, this is paired with PA20 (D6), which is even.
Each "Peripheral Multiplexing" 8-bit register is split into two 4-bit halves, odd and even, with each half specifying the selected peripheral A-H. PORT_PMUX_PMUXO_F is used to set the odd port for peripheral F and PORT_PMUX_PMUXE_F to set the even port. To select a given PMUX register you specify the even pair divided by 2 (>> 1), as there are only half the number of "Peripheral Multiplexing" registers.
// Connect the TCC0 timer to digital output D7 - port pins are paired odd PMUO and even PMUXE
// F & E specify the timers: TCC0, TCC1 and TCC2
PORT->Group[g_APinDescription[6].ulPort].PMUX[g_APinDescription[6].ulPin >> 1].reg = PORT_PMUX_PMUXO_F;
This could also be written as:
// Connect the TCC0 timer to port pin PA21 - port pins are paired odd PMUO and even PMUXE
// F & E specify the timers: TCC0, TCC1 and TCC2
PORT->Group[PORTA].PMUX[20 >> 1].reg = PORT_PMUX_PMUXO_F;
It took me a while to bend my head around port multiplexing.