1- //! Configuration and control of the High and Low Frequency Clock
2- //! sources
1+ //! Configuration and control of the High and Low Frequency Clock sources.
32
43#[ cfg( feature = "9160" ) ]
54use crate :: pac:: CLOCK_NS as CLOCK ;
@@ -9,27 +8,27 @@ use crate::pac::CLOCK;
98
109// ZST Type States
1110
12- /// Internal/RC Oscillator
11+ /// Internal/RC Oscillator.
1312pub struct Internal ;
1413
15- /// External Crystal Oscillator
14+ /// External Crystal Oscillator.
1615pub struct ExternalOscillator ;
1716
18- /// Low Frequency Clock synthesize from High Frequency Clock
17+ /// Low Frequency Clock synthesize from High Frequency Clock.
1918pub struct LfOscSynthesized ;
2019
21- /// Low Frequency Clock Started
20+ /// Low Frequency Clock Started.
2221pub struct LfOscStarted ;
2322
24- /// Low Frequency Clock Stopped
23+ /// Low Frequency Clock Stopped.
2524pub struct LfOscStopped ;
2625
27- /// High Frequency Clock Frequency (in Hz)
26+ /// High Frequency Clock Frequency (in Hz).
2827pub const HFCLK_FREQ : u32 = 64_000_000 ;
29- /// Low Frequency Clock Frequency (in Hz)
28+ /// Low Frequency Clock Frequency (in Hz).
3029pub const LFCLK_FREQ : u32 = 32_768 ;
3130
32- /// A high level abstraction for the CLOCK peripheral
31+ /// A high level abstraction for the CLOCK peripheral.
3332pub struct Clocks < H , L , LSTAT > {
3433 hfclk : H ,
3534 lfclk : L ,
@@ -49,7 +48,7 @@ impl Clocks<Internal, Internal, LfOscStopped> {
4948}
5049
5150impl < H , L , LSTAT > Clocks < H , L , LSTAT > {
52- /// Use an external oscillator as the high frequency clock source
51+ /// Use an external oscillator as the high frequency clock source.
5352 pub fn enable_ext_hfosc ( self ) -> Clocks < ExternalOscillator , L , LSTAT > {
5453 self . periph . tasks_hfclkstart . write ( |w| unsafe { w. bits ( 1 ) } ) ;
5554
@@ -67,7 +66,7 @@ impl<H, L, LSTAT> Clocks<H, L, LSTAT> {
6766 }
6867 }
6968
70- /// Use the internal oscillator as the high frequency clock source
69+ /// Use the internal oscillator as the high frequency clock source.
7170 pub fn disable_ext_hfosc ( self ) -> Clocks < Internal , L , LSTAT > {
7271 self . periph . tasks_hfclkstop . write ( |w| unsafe { w. bits ( 1 ) } ) ;
7372 Clocks {
@@ -78,12 +77,12 @@ impl<H, L, LSTAT> Clocks<H, L, LSTAT> {
7877 }
7978 }
8079
81- /// Start the Low Frequency clock
80+ /// Start the Low Frequency clock.
8281 pub fn start_lfclk ( self ) -> Clocks < H , L , LfOscStarted > {
8382 self . periph . tasks_lfclkstart . write ( |w| unsafe { w. bits ( 1 ) } ) ;
8483
8584 // Datasheet says this could take 100us from synth source
86- // 600us from rc source, 0.25s from an external source
85+ // 600us from rc source, 0.25s from an external source.
8786 while self . periph . events_lfclkstarted . read ( ) . bits ( ) != 1 { }
8887 self . periph
8988 . events_lfclkstarted
@@ -99,15 +98,15 @@ impl<H, L, LSTAT> Clocks<H, L, LSTAT> {
9998}
10099
101100/// Allowable configuration options for the low frequency oscillator when
102- /// driven fron an external crystal
101+ /// driven fron an external crystal.
103102pub enum LfOscConfiguration {
104103 NoExternalNoBypass ,
105104 ExternalNoBypass ,
106105 ExternalAndBypass ,
107106}
108107
109108impl < H , L > Clocks < H , L , LfOscStarted > {
110- /// Stop the Low Frequency clock
109+ /// Stop the Low Frequency clock.
111110 pub fn stop_lfclk ( self ) -> Clocks < H , L , LfOscStopped > {
112111 self . periph . tasks_lfclkstop . write ( |w| unsafe { w. bits ( 1 ) } ) ;
113112 Clocks {
@@ -120,7 +119,7 @@ impl<H, L> Clocks<H, L, LfOscStarted> {
120119}
121120
122121impl < H , L > Clocks < H , L , LfOscStopped > {
123- /// Use the internal RC Oscillator for the low frequency clock source
122+ /// Use the internal RC Oscillator for the low frequency clock source.
124123 #[ cfg( feature = "51" ) ]
125124 pub fn set_lfclk_src_rc ( self ) -> Clocks < H , Internal , LfOscStopped > {
126125 self . periph . lfclksrc . write ( |w| w. src ( ) . rc ( ) ) ;
@@ -132,7 +131,7 @@ impl<H, L> Clocks<H, L, LfOscStopped> {
132131 }
133132 }
134133
135- /// Generate the Low Frequency clock from the high frequency clock source
134+ /// Generate the Low Frequency clock from the high frequency clock source.
136135 #[ cfg( feature = "51" ) ]
137136 pub fn set_lfclk_src_synth ( self ) -> Clocks < H , LfOscSynthesized , LfOscStopped > {
138137 self . periph . lfclksrc . write ( |w| w. src ( ) . synth ( ) ) ;
@@ -144,7 +143,7 @@ impl<H, L> Clocks<H, L, LfOscStopped> {
144143 }
145144 }
146145
147- /// Use an external crystal to drive the low frequency clock
146+ /// Use an external crystal to drive the low frequency clock.
148147 #[ cfg( feature = "51" ) ]
149148 pub fn set_lfclk_src_external ( self ) -> Clocks < H , ExternalOscillator , LfOscStopped > {
150149 self . periph . lfclksrc . write ( move |w| w. src ( ) . xtal ( ) ) ;
@@ -156,7 +155,7 @@ impl<H, L> Clocks<H, L, LfOscStopped> {
156155 }
157156 }
158157
159- /// Use the internal RC Oscillator for the low frequency clock source
158+ /// Use the internal RC Oscillator for the low frequency clock source.
160159 #[ cfg( not( any( feature = "9160" , feature = "51" ) ) ) ]
161160 pub fn set_lfclk_src_rc ( self ) -> Clocks < H , Internal , LfOscStopped > {
162161 self . periph
@@ -170,7 +169,7 @@ impl<H, L> Clocks<H, L, LfOscStopped> {
170169 }
171170 }
172171
173- /// Generate the Low Frequency clock from the high frequency clock source
172+ /// Generate the Low Frequency clock from the high frequency clock source.
174173 #[ cfg( not( any( feature = "9160" , feature = "51" ) ) ) ]
175174 pub fn set_lfclk_src_synth ( self ) -> Clocks < H , LfOscSynthesized , LfOscStopped > {
176175 self . periph
@@ -184,7 +183,7 @@ impl<H, L> Clocks<H, L, LfOscStopped> {
184183 }
185184 }
186185
187- /// Use an external crystal to drive the low frequency clock
186+ /// Use an external crystal to drive the low frequency clock.
188187 #[ cfg( not( any( feature = "9160" , feature = "51" ) ) ) ]
189188 pub fn set_lfclk_src_external (
190189 self ,
0 commit comments