Skip to content

Conversation

dpproto
Copy link
Contributor

@dpproto dpproto commented May 4, 2025

Add guard around macro definition to allow the user to redefine it to use the SPI module

Contribution description

  • Disable BUTTON0 if SPI is used because this pin conflicts with the SPI MISO line.
  • Don't define GPIO5 as a PWM line any more since it is used as chip select in the default SPI configuration.

Testing procedure

Issues/PRs references

Fixes #21462

@dpproto dpproto requested a review from jia200x as a code owner May 4, 2025 21:16
@github-actions github-actions bot added Area: doc Area: Documentation Area: boards Area: Board ports labels May 4, 2025
@dpproto dpproto force-pushed the 21462-seeedstudio-xiao-esp32c3-fix-pin-conflict branch 2 times, most recently from b5479f0 to 867f1c6 Compare May 5, 2025 08:27
@benpicco benpicco requested a review from gschorcht May 5, 2025 09:01
Copy link
Contributor

@gschorcht gschorcht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't use URLs for references inside the documentation. Furthermore, ESP32 documentation includes its own section on application specific configurations. Using CFLAGS at command line or in the Makefile of the application should be much more easier than to override board.h.

@crasbe crasbe added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels May 6, 2025
@riot-ci
Copy link

riot-ci commented May 6, 2025

Murdock results

✔️ PASSED

12cc737 boards/seeedstudio-xiao-esp32c3: fix Arduino pins

Success Failures Total Runtime
10346 0 10346 12m:54s

Artifacts

@dpproto dpproto force-pushed the 21462-seeedstudio-xiao-esp32c3-fix-pin-conflict branch from 867f1c6 to bf76aa1 Compare May 9, 2025 09:36
@crasbe
Copy link
Contributor

crasbe commented May 9, 2025

Wouldn't a similar approach to #21338 work here as well? The Nucleo64 boards have the same issue with a conflicting pin between the LED and SPI bus.

@dpproto dpproto force-pushed the 21462-seeedstudio-xiao-esp32c3-fix-pin-conflict branch from bf76aa1 to 55eea4e Compare May 10, 2025 17:58
@dpproto
Copy link
Contributor Author

dpproto commented May 10, 2025

Wouldn't a similar approach to #21338 work here as well? The Nucleo64 boards have the same issue with a conflicting pin between the LED and SPI bus.

Yes, indeed. I tried to mimic this behavior. What do you think?

@dpproto dpproto force-pushed the 21462-seeedstudio-xiao-esp32c3-fix-pin-conflict branch from 55eea4e to 3d2540a Compare May 12, 2025 16:50
@github-actions github-actions bot added the Area: drivers Area: Device drivers label May 12, 2025
@crasbe
Copy link
Contributor

crasbe commented May 12, 2025

The drivers/max31865: implement LUT generator script commit does not really belong to this PR, does it? 😅

@dpproto dpproto force-pushed the 21462-seeedstudio-xiao-esp32c3-fix-pin-conflict branch from 3d2540a to d4d5ee9 Compare May 13, 2025 07:00
@github-actions github-actions bot removed the Area: drivers Area: Device drivers label May 13, 2025
@dpproto dpproto force-pushed the 21462-seeedstudio-xiao-esp32c3-fix-pin-conflict branch from d4d5ee9 to b5990c4 Compare May 14, 2025 11:53
Copy link
Contributor

@crasbe crasbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for sticking through, even though the approach was changed and there were a lot of suggestions :)

@crasbe
Copy link
Contributor

crasbe commented May 14, 2025

@gschorcht you still have your "changes requested" review open that prevents merging.

@dpproto
Copy link
Contributor Author

dpproto commented May 14, 2025

Thank you for sticking through, even though the approach was changed and there were a lot of suggestions :)

You're welcome. I learned a new RIOT trick 😄

@dpproto
Copy link
Contributor Author

dpproto commented May 16, 2025

You shouldn't use URLs for references inside the documentation. Furthermore, ESP32 documentation includes its own section on application specific configurations. Using CFLAGS at command line or in the Makefile of the application should be much more easier than to override board.h.

@gschorcht The changes you request here are not relevant any more, due to the solution suggested by @crasbe, which differs substantially from my initial proposition.

Comment on lines 5 to 6
MSG="Warning: Using periph_spi on Seeed Studio Xiao ESP32C3 board will disable BUTTON0 due to pin conflict."
$(shell $(COLOR_ECHO) "$(COLOR_RED)$(MSG)$(COLOR_RESET)" 1>&2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is only a warning, the message should be coloured yellow as usual, IMHO. It is confusing when you get the red message and the compilation works afterwards.

Remove GPIO5 from the PWM pin list because it is used by default
as SPI chip select pin.
@dpproto dpproto force-pushed the 21462-seeedstudio-xiao-esp32c3-fix-pin-conflict branch from b5990c4 to 30b382e Compare May 19, 2025 08:35
@github-actions github-actions bot added the Area: build system Area: Build system label May 19, 2025
@gschorcht
Copy link
Contributor

@dpproto Please use fixups the next time and wait until a maintainer asks you to squash the PR. This helps to track the requested changes.

@gschorcht
Copy link
Contributor

gschorcht commented May 19, 2025

Sorry for being a bit nitpicky. It might be that doxygen is not happy with this kind of macro guards having a doc but not the define. Why don't you just embed all the definitions related to the button in the directive, including all the documentation? It makes no sense to define BTN0_MODE or BTN0_INT_FLANK if the button is not defined. The easiest way would be:

#if MODULE_PERIPH_INIT_BUTTONS || DOXYGEN
/**
 * @name    Button pin definitions
 * @{
 */
...
/** @} */
#endif

With this approach you have only one #ifdef ... #endif and doxygen is happy.

@dpproto dpproto force-pushed the 21462-seeedstudio-xiao-esp32c3-fix-pin-conflict branch from 1fe097d to 8510d3e Compare May 19, 2025 11:53
@dpproto
Copy link
Contributor Author

dpproto commented May 19, 2025

Sorry for being a bit nitpicky. It might be that doxygen is not happy with this kind of macro guards having a doc but not the define. Why don't you just embed all the definitions related to the button in the directive, including all the documentation? It makes no sense to define BTN0_MODE or BTN0_INT_FLANK if the button is not defined. The easiest way would be:

#if MODULE_PERIPH_INIT_BUTTONS || DOXYGEN
/**
 * @name    Button pin definitions
 * @{
 */
...
/** @} */
#endif

With this approach you have only one #ifdef ... #endif and doxygen is happy.

I also found Doxygen warning for undocumented items in include/arduino_iomap.h and made a 3rd commit for that.

Add a uard around macro BTN0_PIN definition to allow the user to redefine
it in order to use the SPI module.
Add a guard around SAUL parameters that use BTN0_PIN to avoid error when
it is redefined.
@dpproto dpproto force-pushed the 21462-seeedstudio-xiao-esp32c3-fix-pin-conflict branch from 8510d3e to c8dea01 Compare May 19, 2025 11:57
@gschorcht
Copy link
Contributor

I also found Doxygen warning for undocumented items in include/arduino_iomap.h and made a 3rd commit for that.

👍 But again, please use fixups for existing commits 😉

@dpproto
Copy link
Contributor Author

dpproto commented May 19, 2025

I also found Doxygen warning for undocumented items in include/arduino_iomap.h and made a 3rd commit for that.

👍 But again, please use fixups for existing commits 😉

So, git commit --amend won't do if I fix the last commit?

@gschorcht
Copy link
Contributor

So, git commit --amend won't do if I fix the last commit?

With git commit --amend you can add or replace files of an existing commit, but it replaces the commit instead of creating a new commit with the differences to the existing commit. The right command would be git commit --fixup.

@dpproto dpproto force-pushed the 21462-seeedstudio-xiao-esp32c3-fix-pin-conflict branch from c8dea01 to 12cc737 Compare May 19, 2025 12:55
@gschorcht gschorcht enabled auto-merge May 19, 2025 13:41
@gschorcht gschorcht added this pull request to the merge queue May 19, 2025
Merged via the queue into RIOT-OS:master with commit 99b4dd5 May 19, 2025
29 checks passed
@dpproto dpproto deleted the 21462-seeedstudio-xiao-esp32c3-fix-pin-conflict branch May 20, 2025 07:12
@Teufelchen1 Teufelchen1 added this to the Release 2025.07 milestone Jul 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports Area: build system Area: Build system Area: doc Area: Documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

boards/seeedstudio-xiao-esp32c3: fix pin conflict
5 participants