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.
3
2
4
3
#[ cfg( feature = "9160" ) ]
5
4
use crate :: pac:: CLOCK_NS as CLOCK ;
@@ -9,27 +8,27 @@ use crate::pac::CLOCK;
9
8
10
9
// ZST Type States
11
10
12
- /// Internal/RC Oscillator
11
+ /// Internal/RC Oscillator.
13
12
pub struct Internal ;
14
13
15
- /// External Crystal Oscillator
14
+ /// External Crystal Oscillator.
16
15
pub struct ExternalOscillator ;
17
16
18
- /// Low Frequency Clock synthesize from High Frequency Clock
17
+ /// Low Frequency Clock synthesize from High Frequency Clock.
19
18
pub struct LfOscSynthesized ;
20
19
21
- /// Low Frequency Clock Started
20
+ /// Low Frequency Clock Started.
22
21
pub struct LfOscStarted ;
23
22
24
- /// Low Frequency Clock Stopped
23
+ /// Low Frequency Clock Stopped.
25
24
pub struct LfOscStopped ;
26
25
27
- /// High Frequency Clock Frequency (in Hz)
26
+ /// High Frequency Clock Frequency (in Hz).
28
27
pub const HFCLK_FREQ : u32 = 64_000_000 ;
29
- /// Low Frequency Clock Frequency (in Hz)
28
+ /// Low Frequency Clock Frequency (in Hz).
30
29
pub const LFCLK_FREQ : u32 = 32_768 ;
31
30
32
- /// A high level abstraction for the CLOCK peripheral
31
+ /// A high level abstraction for the CLOCK peripheral.
33
32
pub struct Clocks < H , L , LSTAT > {
34
33
hfclk : H ,
35
34
lfclk : L ,
@@ -49,7 +48,7 @@ impl Clocks<Internal, Internal, LfOscStopped> {
49
48
}
50
49
51
50
impl < 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.
53
52
pub fn enable_ext_hfosc ( self ) -> Clocks < ExternalOscillator , L , LSTAT > {
54
53
self . periph . tasks_hfclkstart . write ( |w| unsafe { w. bits ( 1 ) } ) ;
55
54
@@ -67,7 +66,7 @@ impl<H, L, LSTAT> Clocks<H, L, LSTAT> {
67
66
}
68
67
}
69
68
70
- /// Use the internal oscillator as the high frequency clock source
69
+ /// Use the internal oscillator as the high frequency clock source.
71
70
pub fn disable_ext_hfosc ( self ) -> Clocks < Internal , L , LSTAT > {
72
71
self . periph . tasks_hfclkstop . write ( |w| unsafe { w. bits ( 1 ) } ) ;
73
72
Clocks {
@@ -78,12 +77,12 @@ impl<H, L, LSTAT> Clocks<H, L, LSTAT> {
78
77
}
79
78
}
80
79
81
- /// Start the Low Frequency clock
80
+ /// Start the Low Frequency clock.
82
81
pub fn start_lfclk ( self ) -> Clocks < H , L , LfOscStarted > {
83
82
self . periph . tasks_lfclkstart . write ( |w| unsafe { w. bits ( 1 ) } ) ;
84
83
85
84
// 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.
87
86
while self . periph . events_lfclkstarted . read ( ) . bits ( ) != 1 { }
88
87
self . periph
89
88
. events_lfclkstarted
@@ -99,15 +98,15 @@ impl<H, L, LSTAT> Clocks<H, L, LSTAT> {
99
98
}
100
99
101
100
/// Allowable configuration options for the low frequency oscillator when
102
- /// driven fron an external crystal
101
+ /// driven fron an external crystal.
103
102
pub enum LfOscConfiguration {
104
103
NoExternalNoBypass ,
105
104
ExternalNoBypass ,
106
105
ExternalAndBypass ,
107
106
}
108
107
109
108
impl < H , L > Clocks < H , L , LfOscStarted > {
110
- /// Stop the Low Frequency clock
109
+ /// Stop the Low Frequency clock.
111
110
pub fn stop_lfclk ( self ) -> Clocks < H , L , LfOscStopped > {
112
111
self . periph . tasks_lfclkstop . write ( |w| unsafe { w. bits ( 1 ) } ) ;
113
112
Clocks {
@@ -120,7 +119,7 @@ impl<H, L> Clocks<H, L, LfOscStarted> {
120
119
}
121
120
122
121
impl < 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.
124
123
#[ cfg( feature = "51" ) ]
125
124
pub fn set_lfclk_src_rc ( self ) -> Clocks < H , Internal , LfOscStopped > {
126
125
self . periph . lfclksrc . write ( |w| w. src ( ) . rc ( ) ) ;
@@ -132,7 +131,7 @@ impl<H, L> Clocks<H, L, LfOscStopped> {
132
131
}
133
132
}
134
133
135
- /// Generate the Low Frequency clock from the high frequency clock source
134
+ /// Generate the Low Frequency clock from the high frequency clock source.
136
135
#[ cfg( feature = "51" ) ]
137
136
pub fn set_lfclk_src_synth ( self ) -> Clocks < H , LfOscSynthesized , LfOscStopped > {
138
137
self . periph . lfclksrc . write ( |w| w. src ( ) . synth ( ) ) ;
@@ -144,7 +143,7 @@ impl<H, L> Clocks<H, L, LfOscStopped> {
144
143
}
145
144
}
146
145
147
- /// Use an external crystal to drive the low frequency clock
146
+ /// Use an external crystal to drive the low frequency clock.
148
147
#[ cfg( feature = "51" ) ]
149
148
pub fn set_lfclk_src_external ( self ) -> Clocks < H , ExternalOscillator , LfOscStopped > {
150
149
self . periph . lfclksrc . write ( move |w| w. src ( ) . xtal ( ) ) ;
@@ -156,7 +155,7 @@ impl<H, L> Clocks<H, L, LfOscStopped> {
156
155
}
157
156
}
158
157
159
- /// Use the internal RC Oscillator for the low frequency clock source
158
+ /// Use the internal RC Oscillator for the low frequency clock source.
160
159
#[ cfg( not( any( feature = "9160" , feature = "51" ) ) ) ]
161
160
pub fn set_lfclk_src_rc ( self ) -> Clocks < H , Internal , LfOscStopped > {
162
161
self . periph
@@ -170,7 +169,7 @@ impl<H, L> Clocks<H, L, LfOscStopped> {
170
169
}
171
170
}
172
171
173
- /// Generate the Low Frequency clock from the high frequency clock source
172
+ /// Generate the Low Frequency clock from the high frequency clock source.
174
173
#[ cfg( not( any( feature = "9160" , feature = "51" ) ) ) ]
175
174
pub fn set_lfclk_src_synth ( self ) -> Clocks < H , LfOscSynthesized , LfOscStopped > {
176
175
self . periph
@@ -184,7 +183,7 @@ impl<H, L> Clocks<H, L, LfOscStopped> {
184
183
}
185
184
}
186
185
187
- /// Use an external crystal to drive the low frequency clock
186
+ /// Use an external crystal to drive the low frequency clock.
188
187
#[ cfg( not( any( feature = "9160" , feature = "51" ) ) ) ]
189
188
pub fn set_lfclk_src_external (
190
189
self ,
0 commit comments