[ell-i-developers] Re: PWM working for TIM2

  • From: Pekka Nikander <pekka.nikander@xxxxxx>
  • To: ell-i-developers@xxxxxxxxxxxxx
  • Date: Fri, 31 Jan 2014 11:45:02 +0200

> What would be your initial guess about it, why it is not considering 
> __GPIO ## port ## _PIN0_MODE
> to be  a constant, even when they are declared as static const.

Looking at your code, the expression is essentially defined as

static const uint32_t __GPIO ## port ## _PIN ## pin ## _MODE = 
GPIO_MODER_MODER0_ ## mode << (pin * 2);

Now, while that is a compile-time constant, IIRC it is not a constant 
expression by C89/C99 or even C11 rules:

http://bytes.com/topic/c/answers/663536-c99-does-const-int-x-5-make-x-constant-expression
http://stackoverflow.com/questions/12343027/const-keyword-and-constant-expressions-in-c99-and-c11

Most probably the easiest way is to rename ellduino_gpio.c to ellduino_gpio.cpp 
and try again.  IIRC C++11 should compile it just fine, but I may be wrong.

--Pekka


Other related posts: