[drivers, stm32wb, pic32cz] Remove nested driver calls. Handle dependencies externally in Board_Init#17
Conversation
…encies externally in Board_Init
There was a problem hiding this comment.
Pull request overview
This PR refactors wolfHAL register-level drivers (STM32WB + PIC32CZ) to remove cross-driver calls (e.g., UART/SPI enabling clocks, clock driver setting flash latency) and moves those dependency steps into Board_Init / Board_Deinit, aligning code with the updated driver-writing guidance.
Changes:
- Remove clock/supply/flash cross-driver interactions from several peripheral drivers and their config structs.
- Update board initialization code to explicitly enable peripheral clocks, enable PLL supply (PIC32CZ), and set/reduce flash wait states (STM32WB).
- Update documentation to formalize the “no cross-driver calls” rule and adjust examples accordingly.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| wolfHAL/uart/stm32wb_uart.h | Drops clock refs from UART cfg; adds BRR helper macros; removes LPUART driver extern. |
| wolfHAL/uart/pic32cz_uart.h | Drops clock refs from PIC32CZ UART cfg. |
| wolfHAL/spi/stm32wb_spi.h | Replaces clock controller refs with pclk frequency in SPI cfg. |
| wolfHAL/rng/stm32wb_rng.h | Drops clock refs from RNG cfg. |
| wolfHAL/platform/st/stm32wb55xx.h | Maps LPUART device to the common STM32WB UART driver. |
| wolfHAL/gpio/stm32wb_gpio.h | Drops GPIO clock enable fields from GPIO cfg. |
| wolfHAL/flash/stm32wb_flash.h | Drops clock refs from flash cfg. |
| wolfHAL/flash/pic32cz_flash.h | Removes clock include (no longer needed). |
| wolfHAL/crypto/stm32wb_aes.h | Drops clock refs from AES cfg. |
| wolfHAL/clock/stm32wb_rcc.h | Removes flash-latency dependency fields from RCC cfg. |
| wolfHAL/clock/pic32cz_clock.h | Removes PLL supply dependency fields from clock PLL cfg. |
| src/uart/stm32wb_uart.c | Removes clock enable/rate query; uses cfg-provided BRR; removes separate LPUART init/driver. |
| src/uart/pic32cz_uart.c | Removes peripheral clock enable/disable calls. |
| src/spi/stm32wb_spi.c | Removes clock enable/disable and rate query; uses cfg pclk for prescaler calc. |
| src/rng/stm32wb_rng.c | Removes peripheral clock enable/disable calls. |
| src/gpio/stm32wb_gpio.c | Removes GPIO clock enable/disable from init/deinit (board-managed). |
| src/flash/stm32wb_flash.c | Removes flash interface clock enable/disable from init/deinit (board-managed). |
| src/crypto/stm32wb_aes.c | Removes AES clock enable/disable calls. |
| src/clock/stm32wb_rcc.c | Removes flash latency adjustments from clock init/deinit (board-managed). |
| src/clock/pic32cz_clock.c | Removes PLL supply enable from clock init (board-managed). |
| docs/writing_a_driver.md | Adds explicit “No Cross-Driver Calls” rule; updates init/deinit guidance for multiple drivers. |
| docs/getting_started.md | Updates examples to show board-managed clocks and precomputed register values (e.g., UART BRR). |
| docs/adding_a_board.md | Updates board template to enable/disable peripheral clocks in board init/deinit. |
| boards/stm32wb55xx_nucleo/board.c | Enables peripheral clocks in board; sets/reduces flash latency around clock changes. |
| boards/pic32cz_curiosity_ultra/board.c | Enables PLL supply before clock init and enables/disables peripheral clocks in board. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
This PR updates STM32WB and PIC32CZ drivers to remove nested (cross-driver) calls (e.g., peripheral drivers enabling clocks internally), shifting all dependency handling (clocks, supplies, flash latency) into Board_Init/Deinit and documenting the pattern.
Changes:
- Remove clock/supply/flash-latency dependencies from multiple register-level driver config structs and implementations.
- Update STM32WB UART/SPI to use board-provided precomputed values (e.g., UART BRR, SPI pclk) instead of querying the clock driver at runtime.
- Update board examples and documentation to explicitly manage cross-peripheral prerequisites in board bring-up.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| wolfHAL/uart/stm32wb_uart.h | Replace clock-derived UART config with board-provided BRR helpers and brr config field. |
| wolfHAL/uart/pic32cz_uart.h | Remove clock-controller references from PIC32CZ UART config. |
| wolfHAL/spi/stm32wb_spi.h | Replace clock descriptor with explicit pclk frequency for SPI baud computations. |
| wolfHAL/rng/stm32wb_rng.h | Remove clock-controller references from RNG config. |
| wolfHAL/platform/st/stm32wb55xx.h | Point LPUART device to the unified STM32WB UART driver. |
| wolfHAL/gpio/stm32wb_gpio.h | Remove GPIO clock control fields from STM32WB GPIO config. |
| wolfHAL/flash/stm32wb_flash.h | Remove flash clock control fields from STM32WB flash config. |
| wolfHAL/flash/pic32cz_flash.h | Remove clock include from PIC32CZ flash header (consistent with no nested calls). |
| wolfHAL/crypto/stm32wb_aes.h | Remove clock-controller references from STM32WB AES config. |
| wolfHAL/clock/stm32wb_rcc.h | Remove flash-latency dependency fields from RCC config. |
| wolfHAL/clock/pic32cz_clock.h | Remove supply dependency fields from PLL config. |
| src/uart/stm32wb_uart.c | Stop enabling/querying clocks; use cfg->brr and add argument validation. |
| src/uart/pic32cz_uart.c | Stop enabling/disabling clocks internally; tighten argument validation. |
| src/spi/stm32wb_spi.c | Stop querying/enabling clocks; compute prescaler from cfg->pclk. |
| src/rng/stm32wb_rng.c | Stop enabling/disabling clocks internally; keep init/deinit as pure register-level. |
| src/gpio/stm32wb_gpio.c | Remove GPIO port clock gating from driver; Deinit becomes a no-op. |
| src/gpio/pic32cz_gpio.c | Add cfg/pin bounds validation for safer GPIO Get/Set. |
| src/flash/stm32wb_flash.c | Remove flash clock gating from driver; Init/Deinit become no-ops; add some argument validation elsewhere. |
| src/flash/pic32cz_flash.c | Tighten argument validation around cfg usage. |
| src/crypto/stm32wb_aes.c | Remove clock gating from AES Init/Deinit. |
| src/clock/stm32wb_rcc.c | Remove flash-latency cross-driver calls from RCC init/deinit. |
| src/clock/pic32cz_clock.c | Remove supply enable from clock init; require board to handle supply prerequisite. |
| docs/writing_a_driver.md | Document “No Cross-Driver Calls” rule and board responsibility for dependencies. |
| docs/getting_started.md | Update examples to show board-managed clock enable and precomputed UART BRR. |
| docs/adding_a_board.md | Update board template to enable/disable peripheral clocks in Board_Init/Deinit. |
| boards/stm32wb55xx_nucleo/board.c | Move flash latency, HSI48, and peripheral clock enables into Board_Init/Deinit. |
| boards/pic32cz_curiosity_ultra/board.c | Move PLL supply enable and peripheral clock enable into Board_Init/Deinit. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… board init/deinit
There was a problem hiding this comment.
Pull request overview
This PR enforces a register-level driver rule across STM32WB and PIC32CZ: peripheral drivers no longer call other wolfHAL drivers (clock/flash/supply) internally, and board code is updated to handle cross-peripheral dependencies explicitly in Board_Init/Board_Deinit.
Changes:
- Removed nested cross-driver calls from multiple STM32WB and PIC32CZ drivers (clock enable/disable, flash latency, PLL supply).
- Updated driver configuration structs to remove
clkCtrl/clkreferences and shift required inputs to board-provided values (e.g., STM32WB UART uses precomputedbrr, STM32WB SPI takespclk). - Updated documentation and board examples to show explicit dependency sequencing and peripheral clock enable/disable in board code.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| wolfHAL/uart/stm32wb_uart.h | Removes clock dependency from UART config; introduces BRR helper macros; drops LPUART driver extern. |
| wolfHAL/uart/pic32cz_uart.h | Removes clock controller fields from PIC32CZ UART config. |
| wolfHAL/spi/stm32wb_spi.h | Replaces clock controller fields with pclk frequency input. |
| wolfHAL/rng/stm32wb_rng.h | Removes clock controller fields from RNG config. |
| wolfHAL/platform/st/stm32wb55xx.h | Switches LPUART device macro to use the unified STM32WB UART driver. |
| wolfHAL/gpio/stm32wb_gpio.h | Removes clock controller fields from GPIO config. |
| wolfHAL/flash/stm32wb_flash.h | Removes clock controller fields from flash config. |
| wolfHAL/flash/pic32cz_flash.h | Removes clock include (clock no longer required by header). |
| wolfHAL/crypto/stm32wb_aes.h | Removes clock controller fields from AES config. |
| wolfHAL/clock/stm32wb_rcc.h | Removes flash dependency from RCC config. |
| wolfHAL/clock/pic32cz_clock.h | Removes supply dependency from PLL oscillator control config. |
| src/uart/stm32wb_uart.c | Stops enabling/querying clocks; uses precomputed brr; removes separate LPUART init/driver. |
| src/uart/pic32cz_uart.c | Stops enabling/disabling peripheral clocks in UART init/deinit. |
| src/spi/stm32wb_spi.c | Computes prescaler from cfg->pclk instead of querying the clock driver; removes clock gating. |
| src/rng/stm32wb_rng.c | Removes clock gating; tightens argument validation placement. |
| src/gpio/stm32wb_gpio.c | Removes GPIO port clock gating from init/deinit. |
| src/gpio/pic32cz_gpio.c | Tightens argument validation and adds pin bounds checks in Get/Set paths. |
| src/flash/stm32wb_flash.c | Removes flash clock gating; adds some null checks in lock/unlock/write helper paths. |
| src/flash/pic32cz_flash.c | Tightens argument validation and cfg access order. |
| src/crypto/stm32wb_aes.c | Removes AES peripheral clock gating. |
| src/clock/stm32wb_rcc.c | Removes flash latency adjustments from clock init/deinit routines. |
| src/clock/pic32cz_clock.c | Removes supply enable from PLL init (board now handles). |
| docs/writing_a_driver.md | Documents “No Cross-Driver Calls” rule and updates peripheral init guidance accordingly. |
| docs/getting_started.md | Updates examples to precompute BRR and to enable peripheral clocks in Board_Init. |
| docs/adding_a_board.md | Updates board template to enable/disable peripheral clocks explicitly in board code. |
| boards/stm32wb55xx_nucleo/board.c | Moves flash latency and clock enables into board init/deinit; updates configs for new driver structs. |
| boards/pic32cz_curiosity_ultra/board.c | Moves PLL supply enable and peripheral clock enables into board init/deinit; updates UART config. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.