Implement regulator firmware per NLSpec v0.1.2d, CubeMX-regeneration safe#5
Draft
Implement regulator firmware per NLSpec v0.1.2d, CubeMX-regeneration safe#5
Conversation
…power_stage.c; fix state_machine.c; expand PDO table; wire USBPD callbacks Co-authored-by: electricalhog <15219301+electricalhog@users.noreply.github.com>
… comment, clean HRTIM constant names Co-authored-by: electricalhog <15219301+electricalhog@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement code for NLSPEC compatibility with CubeMX
Implement regulator firmware per NLSpec v0.1.2d, CubeMX-regeneration safe
Mar 10, 2026
TG-Techie
reviewed
Mar 11, 2026
Comment on lines
+204
to
+208
| HAL_NVIC_SetPriority(TIM6_DAC_IRQn, NVIC_PRIO_SLOPE_COMP, 0u); | ||
| HAL_NVIC_SetPriority(TIM7_IRQn, NVIC_PRIO_PID, 0u); | ||
| HAL_NVIC_SetPriority(HRTIM1_TIMA_IRQn, NVIC_PRIO_HRTIM, 0u); | ||
| HAL_NVIC_SetPriority(HRTIM1_TIMB_IRQn, NVIC_PRIO_HRTIM, 0u); | ||
| HAL_NVIC_SetPriority(HRTIM1_FLT_IRQn, NVIC_PRIO_HRTIM, 0u); |
Collaborator
There was a problem hiding this comment.
unclear of priority order; RTOS priority should be ≥ 5 to allow for full indexing of IRQs
Owner
There was a problem hiding this comment.
unclear of priority order; RTOS priority should be ≥ 5 to allow for full indexing of IRQs
Updated CubeMX to add overhead in NVIC priority change commit to allow for discrete IRQ interrupt priorities.
TG-Techie
reviewed
Mar 11, 2026
Comment on lines
+255
to
+261
| if (mode == PS_MODE_BUCK) { | ||
| ps_configure_hrtim_buck(); | ||
| ps_configure_static_leg_buck(); | ||
| } else { | ||
| ps_configure_hrtim_boost(); | ||
| ps_configure_static_leg_boost(); | ||
| } |
Collaborator
There was a problem hiding this comment.
should be switch for future proofing with buck-boost
fresh build
Copilot stopped work on behalf of
electricalhog due to an error
March 11, 2026 15:39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the full buck-boost regulator control firmware as specified in
buck-boost-nlspec-v0_1_2d.md. All application code lives in new files or existing/* USER CODE */sections — CubeMX regeneration cannot overwrite any of it.New files
regulator_config.h— Single source of truth for all hardware constants (§2.1). Pin mappings, HRTIM timing, ADC/DAC scaling, PID limits, OVP/UVP thresholds, NVIC priorities — each with units, derivation, and valid-range_Static_assert.power_stage.h— Public API:PS_State_t(INIT/IDLE/RUNNING/FAULT),PS_Mode_t(BUCK/BOOST), §9.1 shared state (target_voltage_mv,regulator_ready,regulator_fault), and the §9.2 PD↔Regulator function API.power_stage.c— Full regulator engine:__weakHAL callback overrides — no changes tostm32g4xx_it.crequiredModified files (USER CODE sections only)
state_machine.c— Replaced broken C++PID.calculate()stub with delegation topower_stage; now a thin application coordinator.usbpd_pdo_defs.h— Expanded from 1 stub PDO to 5 SPR PDOs: 5 V/9 V/12 V/15 V @ 3 A, 20 V @ 5 A (§9.4).usbpd_pwr_user.c— WiredVBUSOn,VBUSOff,VBUSSetVoltage_Fixed,VBUSIsOn,VBUSGetVoltagetopower_stage.usbpd_dpm_user.c— EnabledUSBPD_NOTIFY_POWER_EXPLICIT_CONTRACThandler; addedpower_stage.hinclude.main.c— Added#include "power_stage.h"in USER CODE section.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.