Skip to content

Refactor #30 #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 8, 2019
Merged

Refactor #30 #33

merged 3 commits into from
Feb 8, 2019

Conversation

MabezDev
Copy link
Member

@MabezDev MabezDev commented Feb 1, 2019

Based on the comments from @nickray and my own thoughts:

  • Remove stm32l47x feature, replaced by a more generic stm32l4x6, due to regressions, see cannot find type CRRCR in module rcc #32
  • hsi48 will always be available in Clocks, but for stm32l4x6 devices the method to set it is not available
  • remove duplicate freezes, opting to instead conditionally compile the specific code
  • remove usb_rng, Clocks is used to detect if a peripheral has the right clocks or not* see rng.rs.

@mathk this will introduce some breaking changes for you, but nothing too severe I hope.

* The clock selection still needs to be implemented properly.

@nickray
Copy link
Member

nickray commented Feb 2, 2019

Looks like an improvement to me, thanks!

Maybe remove hsi48 completely for devices where it does not exist? And get rid of the || in checking if RNG clock is enabled? https://gist.github.com/nickray/e660f293c26ad34207aa86d51e9b578e

@MabezDev
Copy link
Member Author

MabezDev commented Feb 2, 2019

And get rid of the || in checking if RNG clock is enabled?

The || will still be required as AFAIK all l4 devices have the MSI, and all can use the msi as the 48mhz rng/usb clock.

Maybe remove hsi48 completely for devices where it does not exist

This can be done but then requires a bit more awkward cfg feature gating.

How about this instead? Doesn't look quite as weird.

let msi = match clocks.msi() {
    Some(msi) => msi == crate::rcc::MsiFreq::RANGE48M,
    None => false,
};
let hsi = clocks.hsi48();
assert!(msi || hsi);

@nickray
Copy link
Member

nickray commented Feb 2, 2019

Fine :) I was mistakenly under the impression that RNG and USB both needed HSI48 on the L432.

Not sure what happens if a device without HSI48 configures it to be turned on, plus it's wasting space on those devices, but I guess we can revisit minimalism when we're more feature complete, and the stm32-rs has come to a consensus on how best to organize multi-device HALs anyway.

@mathk
Copy link
Contributor

mathk commented Feb 3, 2019

@MabezDev Ok I see the stm32-rs/stm32-rs#141 has not been merge yet. If merged #32 should disappear. Do you still want to erfactor that ? Becasue the CRRCR is available on some 4x6 chip. I have double check all reference manual only the 47x does not have the CRRCR.

@mathk
Copy link
Contributor

mathk commented Feb 3, 2019

I still think that is interesting to have the usb_rng flags. as it is an independent clock line.

@MabezDev
Copy link
Member Author

MabezDev commented Feb 3, 2019

Do you still want to erfactor that ? Becasue the CRRCR is available on some 4x6 chip. I have double check all reference manual only the 47x does not have the CRRCR

At this point I time I think it's best to feature gate specific chips. e.g 476 475 471 instead of 47x. I also think it would be best to accept feature gate PR's as a full package where all/most peripherals are features gated for the device.

I'll try to feature gate a chip at some point as a reference PR for adding more devices.

Hopefully we can tick all the items of of this #29 not too far in the future :)

…ve the hsi, instead we should feature gate devices per chip
@MabezDev
Copy link
Member Author

MabezDev commented Feb 3, 2019

Fine :) I was mistakenly under the impression that RNG and USB both needed HSI48 on the L432.

Not sure what happens if a device without HSI48 configures it to be turned on, plus it's wasting space on those devices, but I guess we can revisit minimalism when we're more feature complete, and the stm32-rs has come to a consensus on how best to organize multi-device HALs anyway.

It shouldn't be able to turn it on once feature gated properly, the hsi(bool) is hidden. Not sure the byte for hsi matters to much but you are right there is probably a more efficient way to do this.

@MabezDev MabezDev merged commit 8190e54 into master Feb 8, 2019
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.

3 participants