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

cpu/stm32/periph_adc: fix register access #20360

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

maribu
Copy link
Member

@maribu maribu commented Feb 8, 2024

Contribution description

The register access to SMPR1/SMPR2 was incorrect in three aspects:

  1. For channels < 10, SMPR1 was cleared but SMPR2 should have been cleared
  2. The code was not thread-safe
  3. An unneeded write was issued. (The compiler won't combine the in-place bitwise operations into a single read-modify-write sequence on volatile memory.)

Testing procedure

  • Using ADC lines < 10 should no longer corrupt settings on ADC lines >= 10.
  • Using line x and y with x!=y concurrently should no longer result in race conditions

Issues/PRs references

Fixes #20261

The register access to SMPR1/SMPR2 was incorrect in three aspects:

1. For channels < 10, SMPR1 was cleared but SMPR2 should have been
   cleared
2. The code was not thread-safe
3. An unneeded write was issued. (The compiler won't combine the
   in-place bitwise operations into a single read-modify-write
   sequence on `volatile` memory.)

Fixes RIOT-OS#20261
@maribu maribu 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 Feb 8, 2024
@github-actions github-actions bot added Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: cpu Area: CPU/MCU ports labels Feb 8, 2024
@maribu maribu enabled auto-merge February 8, 2024 14:19
@riot-ci
Copy link

riot-ci commented Feb 8, 2024

Murdock results

✔️ PASSED

4ed287c cpu/stm32/periph_adc: fix register access

Success Failures Total Runtime
10016 0 10016 10m:58s

Artifacts

@maribu maribu added this pull request to the merge queue Feb 8, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 8, 2024
@maribu maribu added this pull request to the merge queue Feb 8, 2024
Merged via the queue into RIOT-OS:master with commit 26946a7 Feb 8, 2024
28 checks passed
@maribu maribu deleted the stm32-adc-typo branch April 23, 2024 08:55
@MrKevinWeiss MrKevinWeiss added this to the Release 2024.04 milestone Apr 30, 2024
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.

STM32 f4_f7 ADC sample time register configuration
4 participants