Adding blocking helper method to setup the XOSC easily.

This commit is contained in:
Nic0w 2021-04-25 16:34:48 +02:00
parent 8f6aea6a31
commit 2a704a73f0

View file

@ -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,