1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use crate::iomuxc;

/// Frequency (Hz) of the crystal oscillator.
pub const XTAL_OSCILLATOR_HZ: u32 = 24_000_000;

/// A CCM clock output pin.
///
/// This adapter configures the IOMUXC pad, and protects the pad
/// from accidentally being used for anything else. It does not
/// enable / disable anything in the CCM to enable the output. Use the functions
/// in the [`output_source`](crate::ccm::output_source) module
/// to the CLKO settings.
pub struct Output<P> {
    pin: P,
}

impl<P, const N: u8> Output<P>
where
    P: iomuxc::ccm::Pin<Function = iomuxc::ccm::Observable<N>>,
{
    /// Create the output pin.
    #[inline]
    pub fn new(mut pin: P) -> Self {
        iomuxc::ccm::prepare(&mut pin);
        Self { pin }
    }

    /// Release the output pin.
    #[inline]
    pub fn release(self) -> P {
        self.pin
    }
}