Expand description
RTC oscillator
This module provides a representation of the RTC oscillator, which
can be selected from one of four possible options. The RtcOsc
type
represents proof that the RTC oscillator has been properly configured and
that its clock source has been locked and cannot be modified.
For the moment, the RtcOsc
is not used anywhere else in the HAL. A
future change to the rtc
module should either take ownership
of the RtcOsc
at creation of the Rtc
or replace the RtcOsc
entirely with an integrated Rtc
API.
Example
To create the RtcOsc
let’s start by using clock_system_at_reset
to
access the HAL clocking structs.
use atsamd_hal::{
pac::Peripherals,
thumbv7em::clock::v2::{clock_system_at_reset, osculp32k::OscUlp32k, rtcosc::RtcOsc},
};
let mut pac = Peripherals::take().unwrap();
let (buses, clocks, tokens) = clock_system_at_reset(
pac.OSCCTRL,
pac.OSC32KCTRL,
pac.GCLK,
pac.MCLK,
&mut pac.NVMCTRL,
);
Next, let’s enable the 32 kHz output of the internal, ultra-low power oscillator.
let (osculp32k, base) = OscUlp32k::enable(tokens.osculp32k.osculp32k, clocks.osculp32k_base);
Finally, we can use the EnabledOscUlp32k
to enabled the RtcOsc
.
let (rtc_osc, osculp32k) = RtcOsc::enable(tokens.rtcosc, osculp32k);
The entire example is provided below.
use atsamd_hal::{
pac::Peripherals,
thumbv7em::clock::v2::{clock_system_at_reset, osculp32k::OscUlp32k, rtcosc::RtcOsc},
};
let mut pac = Peripherals::take().unwrap();
let (buses, clocks, tokens) = clock_system_at_reset(
pac.OSCCTRL,
pac.OSC32KCTRL,
pac.GCLK,
pac.MCLK,
&mut pac.NVMCTRL,
);
let (osculp32k, base) = OscUlp32k::enable(tokens.osculp32k.osculp32k, clocks.osculp32k_base);
let (rtc_osc, osculp32k) = RtcOsc::enable(tokens.rtcosc, osculp32k);
Structs
RtcOsc
Enums
RtcOsc
Traits
enum
for the RTC oscillator clock source