mirror of
https://github.com/italicsjenga/rp-hal-boards.git
synced 2025-02-23 23:57:43 +11:00
Adding blocking helper method to setup the XOSC easily.
This commit is contained in:
parent
8f6aea6a31
commit
2a704a73f0
1 changed files with 12 additions and 0 deletions
|
@ -56,6 +56,18 @@ pub enum Error {
|
|||
BadArgument
|
||||
}
|
||||
|
||||
|
||||
/// Blocking helper method to setup the XOSC without going through all the steps.
|
||||
pub fn setup_xosc_blocking(xosc_dev: rp2040_pac::XOSC, frequency: Hertz) -> Result<CrystalOscillator<Stable>, Error> {
|
||||
|
||||
let initialized_xosc = CrystalOscillator::new(xosc_dev).initialize(frequency)?;
|
||||
|
||||
let stable_xosc_token = nb::block!(initialized_xosc.await_stabilization()).unwrap();
|
||||
|
||||
Ok(initialized_xosc.get_stable(stable_xosc_token))
|
||||
}
|
||||
|
||||
|
||||
/// A Crystal Oscillator.
|
||||
pub struct CrystalOscillator<S: State> {
|
||||
device: rp2040_pac::XOSC,
|
||||
|
|
Loading…
Add table
Reference in a new issue