Skip to content

Conversation

kyp44
Copy link
Contributor

@kyp44 kyp44 commented Aug 4, 2025

Summary

As part of the clock::v2 effort tracked in Issue #912, this PR updates the nvm to use the clock::v2 API by requiring ownership of its AhbClks and ApbClk. Note that this peripheral is only on thumbv7 targets.

The NVM has three AHB bus clocks: CLK_NVMCTRL_AHB, CLK_NVMCTRL_CACHE, and CLK_NVMCTRL_SMEEPROM. It seems that CLK_NVMCTRL_AHB is needed for basic operation, but the documentation does not talk about exactly what CLK_NVMCTRL_CACHE and CLK_NVMCTRL_SMEEPROM are needed for at all. As the the nvm::Nvm does not seem to do anything with the cache at all, it was assumed that AhbClk<NvmCtrlCache> is not needed. However, it is assumed that AhbClk<NvmCtrlSmeeProm> is needed for SmartEEPROM functionality, and so this is now required when calling nvm::Nvm::smart_eeprom, and the clock can be freed with nvm::smart_eeprom::SmartEeprom::free.

Note that automatic wait states are enabled when clock::v2::clock_system_at_reset is called so that the notes here about wait states should not be an issue.

The following Tier 1 BSP examples are now broken and cannot be fixed until the noted peripherals are also migrated and merged (see the notes about this in Issue #912):

  • feather_m4/nvm_dsu (dsu::Dsu, usb::UsbBus)
  • feather_m4/smart_eeprom (usb::UsbBus)

Checklist

  • All new or modified code is well documented, especially public items
  • No new warnings or clippy suggestions have been introduced - CI will deny clippy warnings by default! You may #[allow] certain lints where reasonable, but ideally justify those with a short comment.

* `nvm::Nvm::new` now requires the `AhbClk<NvmCtrl>` and `ApbClk<NvmCtrl>`.
* Adds the `nvm::Nvm::free` method that returns the PAC controller and bus clocks.
* `nvm::Nvm::smart_eeprom` now requires the `AhbClk<NvmCtrlSmeeProm>`.
* Adds the `nvm::smart_eeprom::SmartEeprom::free` method that returns the bus clock.
* Breaks some Tier 1 BSP examples, which cannot be repaired at the moment due to requiring other peripheral migrations to the `clock::v2` API.
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