Skip to content

Conversation

@sunyanmeng963
Copy link
Contributor

@sunyanmeng963 sunyanmeng963 commented Jan 5, 2026

PR Type

Bug fix


Description

This description is generated by an AI tool. It may have inaccuracies

  • Fixed AT32F43x LED toggle logic using correct register operations

  • Replaced incorrect bit-shifting approach with proper clr and scr registers

  • Added missing braces for proper conditional statement structure


Diagram Walkthrough

flowchart LR
  A["AT32F43x IOToggle"] --> B["Check odt register bit"]
  B --> C["Bit set: use clr register"]
  B --> D["Bit clear: use scr register"]
  C --> E["Toggle LED correctly"]
  D --> E
Loading

File Walkthrough

Relevant files
Bug fix
io.c
Correct AT32F43x GPIO toggle register operations                 

src/main/drivers/io.c

  • Fixed AT32F43x GPIO toggle implementation in IOToggle() function
  • Replaced incorrect bit-shifting logic with proper register writes
    using clr and scr
  • Added missing braces to conditional block for code clarity
  • Corrected register field name from odt to match proper AT32 HAL usage
+5/-4     

@github-actions
Copy link

github-actions bot commented Jan 5, 2026

Branch Targeting Suggestion

You've targeted the master branch with this PR. Please consider if a version branch might be more appropriate:

  • maintenance-9.x - If your change is backward-compatible and won't create compatibility issues between INAV firmware and Configurator 9.x versions. This will allow your PR to be included in the next 9.x release.

  • maintenance-10.x - If your change introduces compatibility requirements between firmware and configurator that would break 9.x compatibility. This is for PRs which will be included in INAV 10.x

If master is the correct target for this change, no action is needed.


This is an automated suggestion to help route contributions to the appropriate branch.

@qodo-code-review
Copy link
Contributor

PR Compliance Guide 🔍

All compliance sections have been disabled in the configurations.

Comment on lines +247 to +251
if (IO_GPIO(io)->odt & mask) {
IO_GPIO(io)->clr = mask;
} else {
IO_GPIO(io)->scr = mask;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Refactor the AT32F43x GPIO toggle logic to use the scr register for both setting and clearing pins in a single atomic write, which improves efficiency by removing the if/else branch. [general, importance: 6]

Suggested change
if (IO_GPIO(io)->odt & mask) {
IO_GPIO(io)->clr = mask;
} else {
IO_GPIO(io)->scr = mask;
}
#elif defined(AT32F43x)
uint32_t toggleMask = mask;
if (IO_GPIO(io)->odt & mask) {
toggleMask <<= 16;
}
IO_GPIO(io)->scr = toggleMask;

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