Skip to content

fix(examples): align OTG usage with datasheet; update API; fix stm32g4 build - #1

Merged
IvanLi-CN merged 8 commits into
mainfrom
refactor/api-remove-vbus-ratio-param
Oct 12, 2025
Merged

IvanLi-CN merged 8 commits into
mainfrom
refactor/api-remove-vbus-ratio-param

Conversation

@IvanLi-CN

Copy link
Copy Markdown
Owner

Summary

  • Remove VINREG from OTG paths; ignored in discharging mode per docs.
  • Use set_vbus_internal_voltage() for OTG output voltage; clarify OTG vs charging.
  • Update examples/stm32g0-otg README: wording & current limits.
  • Fix examples/stm32g4 build: add missing vbus_ratio (E0063).

Build & Verify

  • Built lib + examples: thumbv6m-none-eabi (g0-otg, g0-charging), thumbv7em-none-eabihf (g4).

Changes

  • examples/stm32g0-otg/README.md
  • examples/stm32g0-otg/src/main.rs
  • examples/stm32g4/src/main.rs
  • src/lib.rs

Update bits [7:6] for VBUSREF_[IE]_SET2 and preserve [5:0].
Add FeedbackMode enum and set_feedback_mode()/get_feedback_mode() to control FB_SEL independently.
Program RATIO.VBUS_RATIO in configure_device and update ADC config; add VbusRatio type.
Use driver-configured VBUS_RATIO and adc_config.vbus_ratio.

Do not write RATIO in setter; only program reference.
Use cached adc_config.vbus_ratio; align with set_vbus_internal_voltage API simplification.
Voltage reads now rely on cached ADC ratio config for both VBUS and VBAT.
VINREG is charge-path only; honor project policy to not touch VINREG for discharging/OTG.
Remove VINREG config from OTG paths (ignored in discharging mode).

Use set_vbus_internal_voltage() for OTG output voltage.

Add notes to avoid confusion between OTG and charging.

docs(otg): clarify output voltage and current limits in example README.

docs(lib): update OTG example in src/lib.rs.

build(stm32g4): add missing vbus_ratio to fix E0063 on thumbv7em-none-eabihf.

Verification: built lib and examples for thumbv6m and thumbv7em targets.
@IvanLi-CN
IvanLi-CN merged commit da3bb22 into main Oct 12, 2025
1 check passed
@IvanLi-CN
IvanLi-CN deleted the refactor/api-remove-vbus-ratio-param branch October 12, 2025 10:31
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