Skip to content

Refactor interface availability code #9

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bugadani
Copy link
Contributor

This PR builds on top of #8 and enables bitbang-dap to set the correct capabilities based on how many pins the user provides to the constructor (in theory, unimplemented atm.).

The SWO changes allow users to:

  • Omit a bunch of boilerplate if they don't need SWO support
  • Correctly set the streaming trace capability. This is a best guess on my part of what this bit means, based on "support for streaming SWO trace is provided via an additional USB endpoint".
  • I'm trying to come up with a way to dynamically make SWO available if there are pins available (e.g. if the probe has 4 pins, allow SWD+SWO or JTAG+no-swo). I may end up not actually doing this, but this PR takes a step in that direction.

@bugadani bugadani marked this pull request as ready for review May 18, 2025 20:36
@bugadani bugadani requested a review from Copilot May 18, 2025 20:36
Copy link

@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 refactors the interface availability code by replacing constant flags with dynamic function calls and a bitflags‑based approach to determine capabilities.

  • Refactors the Swo trait and adds a NoSwo marker struct for cases with no SWO support.
  • Replaces constant AVAILABLE definitions in SWD and JTAG traits with dynamic availability functions.
  • Introduces a bitflags structure in the Dap module to streamline capability reporting and update related logic.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/swo.rs Updated Swo trait to return booleans and added the NoSwo implementation.
src/swd.rs Replaced constant availability with a function-based check.
src/mock_device.rs Updated SWD and JTAG implementations to use function availability.
src/jtag.rs Replaced constant availability with a function-based check.
src/dap.rs Introduced bitflags to represent capabilities and refactored DAP logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant