Go Down

Topic: digitalPinHasPWM(P) (Read 281 times) previous topic - next topic


Does anyone know why...

In the variant.h files for the SAMD products, there is a macro defined:

Code: [Select]
#define digitalPinHasPWM(P) (g_APinDescription[P].ulPWMChannel != NOT_ON_PWM || g_APinDescription[P].ulTCChannel != NOT_ON_TIMER)

However, the only code in the SAMD code or libraries that checks for PWM being allowed is in wiring_analog.c, and IT uses:

Code: [Select]
  if ((attr & PIN_ATTR_PWM) == PIN_ATTR_PWM)

(which seems like a better method...)

Is there some reason that the macro doesn't check the attribute?  Seems simpler and less error prone (especially as chips add different timer types.)

Go Up