Skip to content

cpu/stm32/periph_gpio: reset PU/PD for ADC channels #19574

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

Conversation

gschorcht
Copy link
Contributor

Contribution description

This PR provides a small fix that is relevant when a GPIO has been used as input/output with a pull resistor before it is initialized as an ADC channel.

The PU/PD configuration has to be 0b00 for analog outputs which is corresponds to the reset state. However, if the GPIO is not in the reset state but was used digital input/output with any pull resistor, the PU/PD configuration has also to be reset to use it as ADC channel.

Testing procedure

  • Green CI
  • The periph_adc test application should still work for any board that supports the periph_adc feature.

Issues/PRs references

PU/PD configuration has to be `0b00` for analog outputs which is corresponds to the reset state. However, if the GPIO is not in reset state but was used digital input/output with any pull resistor, the PU/PD configuration has also to be reset to work as ADC channel.
@github-actions github-actions bot added Area: cpu Area: CPU/MCU ports Platform: ARM Platform: This PR/issue effects ARM-based platforms labels May 10, 2023
@gschorcht gschorcht 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 10, 2023
@riot-ci
Copy link

riot-ci commented May 10, 2023

Murdock results

✔️ PASSED

ddb95e7 cpu/stm32/periph_gpio: reset PU/PD for ADC channels

Success Failures Total Runtime
6931 0 6931 08m:32s

Artifacts

@maribu
Copy link
Member

maribu commented May 10, 2023

bors merge

bors bot added a commit that referenced this pull request May 10, 2023
19568: tests: move remaining driver related applications to tests/drivers r=aabadie a=aabadie



19574: cpu/stm32/periph_gpio: reset PU/PD for ADC channels r=maribu a=gschorcht

### Contribution description

This PR provides a small fix that is relevant when a GPIO has been used as input/output with a pull resistor before it is initialized as an ADC channel.

The PU/PD configuration has to be `0b00` for analog outputs which is corresponds to the reset state. However, if the GPIO is not in the reset state but was used digital input/output with any pull resistor, the PU/PD configuration has also to be reset to use it as ADC channel.

### Testing procedure

- Green CI
- The `periph_adc` test application should still work for any board that supports the `periph_adc` feature.

### Issues/PRs references



Co-authored-by: Alexandre Abadie <alexandre.abadie@inria.fr>
Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
@bors
Copy link
Contributor

bors bot commented May 10, 2023

Build failed (retrying...):

bors bot added a commit that referenced this pull request May 10, 2023
19574: cpu/stm32/periph_gpio: reset PU/PD for ADC channels r=maribu a=gschorcht

### Contribution description

This PR provides a small fix that is relevant when a GPIO has been used as input/output with a pull resistor before it is initialized as an ADC channel.

The PU/PD configuration has to be `0b00` for analog outputs which is corresponds to the reset state. However, if the GPIO is not in the reset state but was used digital input/output with any pull resistor, the PU/PD configuration has also to be reset to use it as ADC channel.

### Testing procedure

- Green CI
- The `periph_adc` test application should still work for any board that supports the `periph_adc` feature.

### Issues/PRs references



Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
@bors
Copy link
Contributor

bors bot commented May 10, 2023

Build failed:

@maribu
Copy link
Member

maribu commented May 11, 2023

What?

esp_eth_netdev.c:96:11: error: format '%d' expects argument of type 'int', but argument 4 has type 'uint32_t' {aka 'long unsigned int'} [-Werror=format=]
   96 |     DEBUG("%s: buf=%p len=%d priv=%p\n", __func__, buffer, len, priv);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~                    ~~~
      |                                                            |
      |                                                            uint32_t {aka long unsigned int}
../../../core/lib/include/debug.h:59:33: note: in definition of macro 'DEBUG_PRINT'
   59 | #define DEBUG_PRINT(...) printf(__VA_ARGS__)
      |                                 ^~~~~~~~~~~
esp_eth_netdev.c:96:5: note: in expansion of macro 'DEBUG'
   96 |     DEBUG("%s: buf=%p len=%d priv=%p\n", __func__, buffer, len, priv);
      |     ^~~~~
esp_eth_netdev.c:96:28: note: format string is defined here
   96 |     DEBUG("%s: buf=%p len=%d priv=%p\n", __func__, buffer, len, priv);
      |                           ~^
      |                            |
      |                            int
      |                           %ld
esp_eth_netdev.c: In function '_esp_eth_event_handler':
esp_eth_netdev.c:148:19: error: format '%d' expects argument of type 'int', but argument 3 has type 'int32_t' {aka 'long int'} [-Werror=format=]
  148 |             DEBUG("%s: event=%d\n", __func__, event_id);
      |                   ^~~~~~~~~~~~~~~~            ~~~~~~~~
      |                                               |
      |                                               int32_t {aka long int}
../../../core/lib/include/debug.h:59:33: note: in definition of macro 'DEBUG_PRINT'
   59 | #define DEBUG_PRINT(...) printf(__VA_ARGS__)
      |                                 ^~~~~~~~~~~
esp_eth_netdev.c:148:13: note: in expansion of macro 'DEBUG'
  148 |             DEBUG("%s: event=%d\n", __func__, event_id);
      |             ^~~~~
esp_eth_netdev.c:148:31: note: format string is defined here
  148 |             DEBUG("%s: event=%d\n", __func__, event_id);
      |                              ~^
      |                               |
      |                               int
      |                              %ld
cc1: all warnings being treated as errors

Was there a toolchain update and build in master is now broken?

@maribu
Copy link
Member

maribu commented May 11, 2023

Ah, yes. And the fix is already there: #19577

@maribu
Copy link
Member

maribu commented May 11, 2023

bors merge

@bors
Copy link
Contributor

bors bot commented May 11, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit d362a8d into RIOT-OS:master May 11, 2023
@gschorcht
Copy link
Contributor Author

Thanks.

@gschorcht gschorcht deleted the cpu/stm32/periph/gpio_reset_pupd_register_for_analog branch May 15, 2023 12:37
@benpicco benpicco added this to the Release 2023.07 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms 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.

4 participants