teemuatlut / TMC2130Stepper

Arduino library for Trinamic TMC2130 Stepper driver
MIT License
159 stars 50 forks source link

Prefix macros to avoid name clashing with STM32 Arduino Core #30

Closed ktand closed 6 years ago

ktand commented 6 years ago

When building for STM32 there is a name clashing between macros (WRITE_REG, READ_REGetc.) defined in the TMC2130 library and the STM32 Arduino core. This PR will prefix macros in this library with TMC_.

teemuatlut commented 6 years ago

Seems to build fine for Generic STM32F103C target. What am I missing?

ktand commented 6 years ago

WRITE_REG is defined in CMSIS STM32F1xx Device Peripheral Access Layer Header File, stm32f1xx.h. The same goes for all STM32Fx devices. In these files, WRITE_REG is defined like this:

#define WRITE_REG(REG, VAL) ((REG) = (VAL))

When building the Marlin bugfix-2.0.x branch for STM32F4 I get the following error when compiling TMC2130Stepper.cpp:

.. stm32f4xx_ll_spi.h:357:57: error: macro "WRITE_REG" passed 2 arguments, but takes just 1

stm32f4xx_ll_spi.h is included from the SPI.h file which is included from TMC2130Stepper.cpp.

ktand commented 6 years ago

Any chance this can get merged?

Regards, Karl

teemuatlut commented 6 years ago

Released now in version 2.3.0.