Skip to content

Jtag single bit #48

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

Merged
merged 3 commits into from
Apr 7, 2025
Merged

Conversation

HalfSweet
Copy link
Collaborator

@HalfSweet HalfSweet commented Apr 7, 2025

Summary by CodeRabbit

This update introduces a new option in device settings that allows you to enable a dedicated JTAG Single-Bit Mode for enhanced hardware interface control and flexibility.

  • New Features
    • Added a "JTAG Single-Bit Mode" setting in the device configuration for improved interfacing.
    • Enhanced JSON handling for settings, including the new jtag_single_bit_mode.
    • Introduced JTAG_SHIFT acceleration feature for SPI output mode.
  • Bug Fixes
    • Improved type safety in conditional checks related to settings.
  • Style
    • Standardized formatting of function declarations for better readability.

Copy link

coderabbitai bot commented Apr 7, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request updates several modules to enforce a consistent formatting style. Function declarations are modified to place opening curly braces on a new line. A new lambda, get_value_bool, is introduced in the settings function to read a boolean from JSON, which is then used to update HSLink_Setting.jtag_single_bit_mode. Additionally, the JTAG interface code now conditionally configures GPIO settings based on the new flag, and type safety improvements have been made by casting to size_t where appropriate.

Changes

File(s) Change Summary
…/HID_COMM/hid_comm.cpp Reformatted function declaration style; added lambda get_value_bool in settings for JSON boolean parsing; applied size_t casts for type safety comparisons.
…/JTAG_DP/JTAG_DP_SPI.c Updated function signature formatting; integrated conditional logic to configure JTAG GPIO pins based on jtag_single_bit_mode; removed USE_GPIO_1_BIT macro.
…/setting.cpp, …/setting.h Enhanced settings handling by adding the new key jtag_single_bit_mode in JSON serialization/parsing; updated function signatures and added a new struct field.
…/docs/src/projects/HSLink Pro.md Added documentation for the "JTAG_SHIFT 加速" feature, explaining its behavior based on the JTAG output mode setting.

Sequence Diagram(s)

sequenceDiagram
    participant JSON as JSON Input
    participant Parser as parse_settings
    participant Lambda as get_value_bool
    participant Settings as HSLink_Setting
    JSON->>Parser: Provide JSON string
    Parser->>Lambda: Check for "jtag_single_bit_mode"
    Lambda-->>Parser: Return boolean value
    Parser->>Settings: Set jtag_single_bit_mode
Loading
sequenceDiagram
    participant JTAG as SPI_PORT_JTAG_SETUP
    participant Setting as HSLink_Setting
    participant GPIO as GPIO Configurator
    JTAG->>Setting: Check jtag_single_bit_mode
    alt Single Bit Mode Enabled
        JTAG->>GPIO: Configure TCK, TDI, TDO for alternate function
    else Standard Mode
        JTAG->>GPIO: Apply standard configuration
    end
Loading

Poem

I'm just a rabbit, hopping through code,
Leaping over bugs on this bright digital road.
New lambdas and modes now set the pace,
With toggled settings and refactored grace.
Carrots of clean code, oh what a delight!
Happy hops in the code garden, day and night!
🥕🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 06cf0a8 and f5e5cd0.

📒 Files selected for processing (1)
  • docs/src/projects/HSLink Pro.md (1 hunks)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (5)
projects/HSLink-Pro/src/JTAG_DP/JTAG_DP_SPI.c (5)

65-66: Fix the typo in the function name.
The function name jtag_spi_sequece is misspelled. Consider renaming it to jtag_spi_sequence for clarity and consistency.

-static void jtag_spi_sequece(uint32_t info, const uint8_t *tdi, uint8_t *tdo);
+static void jtag_spi_sequence(uint32_t info, const uint8_t *tdi, uint8_t *tdo);

96-98: Validate pull configuration on TDI pin.
Pull enable (PE_SET(1)) combined with pull select set to 0 might add an internal pull-down on the TDI line. If TDI is driven externally, ensure this internal pull is desired.


100-105: Consider refactoring repeated PAD_CTL assignments.
Both SRST and TRST have very similar PAD_CTL configurations. Extracting them into a helper or struct could improve maintainability.


123-125: Minor localized comment style note.
The inline comment is in Chinese. If code comments are typically English in this project, consider adding or switching to an English equivalent for consistency.


410-414: Eliminate unnecessary casts for clarity.
If tdi and tdo are already uint8_t*, casting to (uint8_t *) is redundant.

-        JTAG_SPI_BASE->DATA = *(uint8_t *)(tdi);
+        JTAG_SPI_BASE->DATA = *tdi;

...

-            *(uint8_t *)(tdo) = JTAG_SPI_BASE->DATA;
+            *tdo = JTAG_SPI_BASE->DATA;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e5ac440 and 06cf0a8.

📒 Files selected for processing (4)
  • projects/HSLink-Pro/src/HID_COMM/hid_comm.cpp (25 hunks)
  • projects/HSLink-Pro/src/JTAG_DP/JTAG_DP_SPI.c (23 hunks)
  • projects/HSLink-Pro/src/setting.cpp (5 hunks)
  • projects/HSLink-Pro/src/setting.h (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • projects/HSLink-Pro/src/setting.h
  • projects/HSLink-Pro/src/setting.cpp
  • projects/HSLink-Pro/src/HID_COMM/hid_comm.cpp
🧰 Additional context used
🧬 Code Definitions (1)
projects/HSLink-Pro/src/JTAG_DP/JTAG_DP_SPI.c (3)
projects/HSLink-Pro/src/DAP_config.h (1)
  • gpiom_configure_pin_control_setting (368-368)
projects/HSLink-Pro/src/JTAG_DP/JTAG_DP.h (5)
  • SPI_JTAG_Sequence (17-17)
  • SPI_JTAG_ReadIDCode (18-18)
  • SPI_JTAG_WriteAbort (19-19)
  • SPI_JTAG_IR (20-20)
  • SPI_JTAG_Transfer (21-21)
projects/HSLink-Pro/common/hslinkpro/board.h (1)
  • board_write_spi_cs (335-335)
🔇 Additional comments (13)
projects/HSLink-Pro/src/JTAG_DP/JTAG_DP_SPI.c (13)

33-41: No issues with the added include statements and spacing.
They appear necessary for clock configuration and do not introduce any apparent conflicts.


69-70: Formatting change looks consistent.
Splitting the return type onto a separate line is stylistically acceptable, and there are no functional issues.


86-87: Confirm the need for loopback mode.
IOC_PAD_FUNC_CTL_LOOP_BACK_SET(1) is enabled here. Verify this is intended for diagnostic or functional purposes, as loopback can introduce unexpected behavior if not strictly required.


120-122: No issues found.
Switching the TMS pin to output here is consistent with JTAG usage.


126-135: Single-bit mode GPIO setup looks logically sound.
TCK and TDI are configured as outputs, and TDO is set as input. Confirm that the rest of the flow properly reverts pins if single-bit mode is later disabled or changed.


144-145: Reformatted function signature is acceptable.
No functionality changes observed.


180-181: Function declaration reformat is benign.
No functional changes introduced.


190-191: No concerns with function declaration rewrite.
Everything else appears consistent.


202-208: Conditional call to fast vs. slow IR update is correct.
Implementation aligns well with the existing JTAG_IR_Fast/Slow pattern.


216-222: Conditional call to fast vs. slow transfer is correct.
Matches the approach used for IR handling.


481-482: Signature reformat is fine.
No functional changes noted.


489-490: GPIO write additions look consistent.
Pin transitions in error-handling and setup blocks appear logically correct.

Also applies to: 492-492, 494-494, 519-520, 521-521


576-576: No issues with updated inline comment.
It clarifies the code’s intention during the write transfer block.

@HalfSweet HalfSweet merged commit fd72478 into cherry-embedded:master Apr 7, 2025
2 of 4 checks passed
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