Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the enum constants is not possible to use in preprocessor conditions #587

Closed
linvinus opened this issue Jul 31, 2019 · 10 comments
Closed

the enum constants is not possible to use in preprocessor conditions #587

linvinus opened this issue Jul 31, 2019 · 10 comments
Assignees
Labels
duplicate This issue or pull request already exists

Comments

@linvinus
Copy link

linvinus commented Jul 31, 2019

Because of most constants (like pins Px[0-16], AFIO_, STM_PIN_ ) defined as enum, it is not possible to use them in preprocessor conditions.

Because of that Marlin port for STM32 have unpredictable behavior
MarlinFirmware/Marlin#14777
MarlinFirmware/Marlin#14711
MarlinFirmware/Marlin#14732

In contrast the arduino port for LPC176x, where pins and other constants is defined as macro definitions https://github.com/p3p/pio-framework-arduino-lpc176x/blob/b3635e53cbd2b6481b207eda668e47dbe712f1e7/cores/arduino/pinmapping.h

Marlin developers has make workaround to resolve this problem https://github.com/MarlinFirmware/Marlin/pull/14785/files

But i believe that problem must be resolved on stm32duino side, i think implementation similar to LPC176x port will be nice.

Similar problem already was discussed earlier, for example here #140 (comment)

@fpistm
Copy link
Member

fpistm commented Jul 31, 2019

Hi @linvinus
I already think about that and have some private request about that.
What is the status of the STM32 porting in Marlin?
If I'm not wrong this core is integrated in the 2.x version?
Originally this is @hasenbanck who start some action in this repo about that.

@fpistm fpistm self-assigned this Jul 31, 2019
@linvinus
Copy link
Author

linvinus commented Jul 31, 2019

What is the status of the STM32 porting in Marlin?

In this year several new the electronic board,based on SMT32 , for 3D printers was released.

For example:
SKR E3 DIP V1.0 (STM32F103)
SKR E3 mini (STM32F103)
FYSETC Cheetah Board (STM32F103)

So marlin port for STM32 will be more and more popular.

If I'm not wrong this core is integrated in the 2.x version?

Yes marlin 2.0 (bugfix-2.0.x branch) is already supporting STM32F1 and STM32F4 based electronic boards, but currently it in alpha state, mostly working but have some problems, not all of them may reveal at compiling time.

Official status is here MarlinFirmware/Marlin#14345

@fpistm
Copy link
Member

fpistm commented Jul 31, 2019

OK, thanks for the feedback.

@hasenbanck
Copy link
Contributor

@linvinus The issues you have linked seem to affect the STM32F1 HAL (HAL_STM32F1), which uses another Arduino Core. Are you sure that it also affects the STM32 HAL? (HAL_STM32) Marlin right now has THREE STM32 HALs. I and some other developers added a generalized STM32 HAL, but not all boards made the switch yet.

@linvinus
Copy link
Author

@hasenbanck Oopse, you are right!

marlin use platformio which have ststm32 module,
According to platformio documentation https://docs.platformio.org/en/latest/platforms/ststm32.html
by default stm32duino is used, so i decide to report here.

I'm sorry, my mistake!

But any way the same problem is present here.

@hasenbanck
Copy link
Contributor

hasenbanck commented Jul 31, 2019 via email

@linvinus
Copy link
Author

linvinus commented Aug 1, 2019

Do you simply assume that the problem is there (when using this core) or
did you test it?

As I said above, I did not know that Marlin uses three different HALs, so no, I have not tested stm32duino as a core yet.

@fpistm fpistm added enhancement New feature or request Request waiting feedback Further information is required labels Aug 1, 2019
@fpistm
Copy link
Member

fpistm commented Aug 1, 2019

Well, until a clear the status.
I will wait.

@hasenbanck IIRW you told me Marlin waited for a Hardware Timer library, FYI the PR was submitted.

@xC0000005
Copy link
Contributor

I think this has already been fixed. Most boards add a set of #defines similar to this:

And that hardware timer library should make it possible to support most ST boards from one HAL. Good stuff.

@fpistm
Copy link
Member

fpistm commented Aug 2, 2019

Ok, looking deeply in issues referenced by @linvinus.
Pins PXn are already a define not enum.
This was covered by #309 thanks @ghent360 for Marlin and merged thanks #356.
This new issue is probably linked to @rogerclarkmelbourne core: Arduino_STM32
ex:
https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/a3a56866505eeca4b49fc435700dcd4bd5540c8c/STM32F1/variants/generic_stm32f103c/board/board.h#L79-L83

So I close this one as already solved.
Thanks all for your feedback.

@fpistm fpistm closed this as completed Aug 2, 2019
@fpistm fpistm added duplicate This issue or pull request already exists and removed enhancement New feature or request Request waiting feedback Further information is required labels Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants