sparkfun / SparkFun_Apollo3_AmbiqSuite_BSPs

One-stop-shop for all your AmbiqSuite SDK board support package needs.
27 stars 21 forks source link

Cannot compile pdm_fft example on Artemis ATP #27

Closed Gyoorey closed 4 years ago

Gyoorey commented 4 years ago

Ambiq SDK version R2.3.2

Error messages: Compiling gcc ../../../../common/examples/pdm_fft/main.c In file included from ../../../../../CMSIS/ARM/Include/arm_math.h:322, from ../../../../common/examples/pdm_fft/main.c:56: ../../../../../CMSIS/AmbiqMicro/Include/apollo3.h:3126:22: error: expected identifier or '(' before numeric constant 3126 | IOM uint32_t OVERFLOW : 1; /!< [8..8] COUNTER over flowed from 0xFFFFFFFF back to 0x00000000. / | ^~~~ ../../../../../CMSIS/AmbiqMicro/Include/apollo3.h:3154:22: error: expected identifier or '(' before numeric constant 3154 | __IOM uint32_t OVERFLOW : 1; /!< [8..8] COUNTER over flowed from 0xFFFFFFFF back to 0x00000000. / | ^~~~ ../../../../../CMSIS/AmbiqMicro/Include/apollo3.h:3182:22: error: expected identifier or '(' before numeric constant 3182 | IOM uint32_t OVERFLOW : 1; /!< [8..8] COUNTER over flowed from 0xFFFFFFFF back to 0x00000000. / | ^~~~ ../../../../../CMSIS/AmbiqMicro/Include/apollo3.h:3210:22: error: expected identifier or '(' before numeric constant 3210 | __IOM uint32_t OVERFLOW : 1; /!< [8..8] COUNTER over flowed from 0xFFFFFFFF back to 0x00000000. / | ^~~~ make: *** [Makefile:333: bin/main.o] Error 1

oclyke commented 4 years ago

The use of OVERFLOW in Apollo3.h gets munged by a macro defining OVERFLOW in <arm_math.h>. I think a suitable fix is to undefine OVERFLOW at the top of Apollo3.h.

This would be a good thing for Ambiq to fix.

For now see if this branch / PR helps out: Upgrade SDK to 2.3.2

The specific commit that fixes the issue: Undefine OVERFLOW in Apollo3.h

Gyoorey commented 4 years ago

Thank you @oclyke . I've seen that the Arduino core implements something similar by temporarily saving the value of the OVERFLOWconstant and reconstructs its value after the includes. I could fix the mentioned example.