Pin Attributes in variant.cpp

This file describes the properties of each pin.
(ArduinoCore-samd/variant.cpp at master · Seeed-Studio/ArduinoCore-samd · GitHub)

according to this typedef

typedef struct _PinDescription
{
  EPortType       ulPort ;
  uint32_t        ulPin ;
  EPioType        ulPinType ;
  uint32_t        ulPinAttribute ;
  EAnalogChannel  ulADCChannelNumber ; /* ADC Channel number in the SAM device */
  EPWMChannel     ulPWMChannel ;
  ETCChannel      ulTCChannel ;
  EExt_Interrupts ulExtInt ;
} PinDescription ;

Here is an example of a description from varient.cpp
{ PORTA, 4, PIO_ANALOG, (PIN_ATTR_PWM|PIN_ATTR_TIMER), ADC_Channel4, PWM0_CH0, TCC0_CH0, EXTERNAL_INT_4 }, // ADC/AIN[4]

Everything after PORTA, 4 is a mystery to me. Where can I find out more information on how to set these variables and what effect they have?

IMHO, _PinDescription is moderately broken; it doesn't do the things I want it to, and it does the other things poorly and inefficiently.

However:
PORTA: pin is on PortA
4: pin is bit 4. (PA4)
EPioType: PIO_ANALOG: The Arduino primary function is an analog pin. (This field is the biggest problem. It doesn't allow for a pin having more than one possible function.)
ulPinAttribute: PIN_ATTR_PWM|PIN_ATTR_TIMER: The pin can also do PWM, using a TIMER pinmux (as opposed to a TIMER_ALT pinmux setting.)
ADC_Channel_4: which ADC channel to use, when used as analog
PWM0_CH0: which PWM channel to use.
TCC0_CH0: which timer that PWM channel is on.
EXTERNAL_INT_4: for attachInterrupt(), which external interrupt does this pin tie to.

Most of this can be gleaned from the WVariant.h file, and searching the source for use of the individual structure members.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.