Skip to content

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

Closed

Description

@linvinus

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)

Activity

  1. fpistm commented on Jul 31, 2019

    @fpistm
    Member

    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.

  2. self-assigned this
    on Jul 31, 2019
  3. linvinus commented on Jul 31, 2019

    @linvinus
    Author

    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

  4. fpistm commented on Jul 31, 2019

    @fpistm
    Member

    OK, thanks for the feedback.

  5. hasenbanck commented on Jul 31, 2019

    @hasenbanck
    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.

  6. linvinus commented on Jul 31, 2019

    @linvinus
    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.

  7. hasenbanck commented on Jul 31, 2019

    @hasenbanck
    Contributor
  8. linvinus commented on Aug 1, 2019

    @linvinus
    Author

    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.

  9. added
    enhancement
    waiting feedback
    on Aug 1, 2019
  10. fpistm commented on Aug 1, 2019

    @fpistm
    Member

    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.

  11. xC0000005 commented on Aug 1, 2019

    @xC0000005
    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.

  12. fpistm commented on Aug 2, 2019

    @fpistm
    Member

    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.

  13. added
    duplicate
    and removed
    enhancement
    waiting feedback
    on Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

duplicate

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions