Skip to content

Conversation

finger563
Copy link
Contributor

Description

  • Mark the base_mutex as mutable to allow locking in const methods.
  • Update all read methods as const to reflect their non-modifying nature.
  • Rework the read_register methods to directly use the underlying config methods for accessing the peripherals, enabling const correctness.
  • Move the const Config &config() const; and uint8_t address() const; methods to the public section for better accessibility in subclasses.

Motivation and Context

Allows read methods to be called on const instances of the class, improving code safety and clarity. This makes subclasses that implement read methods more flexible and easier to use in const contexts.

How has this been tested?

  • Building all the examples to ensure they still build.

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Hardware (schematic, board, system design) change
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added / updated the documentation related to this change via either README or WIKI

Software

  • I have added tests to cover my changes.
  • I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • All new and existing tests passed.
  • My code follows the code style of this project.

@Copilot Copilot AI review requested due to automatic review settings October 12, 2025 21:05
@finger563 finger563 self-assigned this Oct 12, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the BasePeripheral class to support const correctness for read operations by making the mutex mutable and converting all read methods to const. The changes improve code safety and usability in const contexts while maintaining thread safety.

Key changes:

  • Made mutex mutable to enable locking within const methods
  • Converted all read-related methods to const
  • Refactored read_register methods to use direct config access instead of delegating to non-const methods

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions
Copy link

✅Static analysis result - no issues found! ✅

@finger563 finger563 merged commit e9296b5 into main Oct 13, 2025
98 of 99 checks passed
@finger563 finger563 deleted the feat/base-peripheral-mutable-mutex-const-reads branch October 13, 2025 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant