aboutsummaryrefslogtreecommitdiff
path: root/embassy-mcxa/src/clocks/config.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-mcxa/src/clocks/config.rs')
-rw-r--r--embassy-mcxa/src/clocks/config.rs66
1 files changed, 66 insertions, 0 deletions
diff --git a/embassy-mcxa/src/clocks/config.rs b/embassy-mcxa/src/clocks/config.rs
index 9f97160ff..0f362ad0a 100644
--- a/embassy-mcxa/src/clocks/config.rs
+++ b/embassy-mcxa/src/clocks/config.rs
@@ -121,8 +121,12 @@ pub struct ClocksConfig {
121 pub fro16k: Option<Fro16KConfig>, 121 pub fro16k: Option<Fro16KConfig>,
122 /// SOSC, clk_in clock source 122 /// SOSC, clk_in clock source
123 pub sosc: Option<SoscConfig>, 123 pub sosc: Option<SoscConfig>,
124 /// SPLL
125 pub spll: Option<SpllConfig>,
124} 126}
125 127
128// SOSC
129
126/// The mode of the external reference clock 130/// The mode of the external reference clock
127#[derive(Copy, Clone)] 131#[derive(Copy, Clone)]
128pub enum SoscMode { 132pub enum SoscMode {
@@ -143,6 +147,67 @@ pub struct SoscConfig {
143 pub power: PoweredClock, 147 pub power: PoweredClock,
144} 148}
145 149
150// SPLL
151
152// Fin: 32kHz to 150MHz
153// Fcco: 275MHz to 550MHz
154// Fout: 4.3MHz to 2x Max CPU Frequency
155
156pub struct SpllConfig {
157 pub source: SpllSource,
158 pub mode: SpllMode,
159 pub power: PoweredClock,
160}
161
162pub enum SpllSource {
163 /// External Oscillator (8-50M)
164 Sosc,
165 /// Fast Internal Oscillator (45M)
166 // NOTE: Figure 69 says "firc_45mhz"/"clk_45m", not "fro_hf_gated",
167 // so this is is always 45MHz.
168 Firc,
169 /// S Internal Oscillator (12M)
170 Sirc,
171
172 // TODO: the reference manual hints that ROSC is possible,
173 // however the minimum input frequency is 32K, but ROSC is 16K.
174 // Some diagrams show this option, and some diagrams omit it.
175 //
176 // /// Realtime Internal Oscillator (16K Osc)
177 // Rosc,
178}
179
180/// N: 1..=255
181/// M: 1..=65535
182/// P: 1..=31
183pub enum SpllMode {
184 /// Fout = M x Fin
185 Mode1a {
186 m_mult: u16,
187 },
188 /// if !bypass_p2_div: Fout = (M / (2 x P)) x Fin
189 /// if bypass_p2_div: Fout = (M / P ) x Fin
190 Mode1b {
191 m_mult: u16,
192 p_div: u8,
193 bypass_p2_div: bool,
194 },
195 /// Fout = (M / N) x Fin
196 Mode1c {
197 m_mult: u16,
198 n_div: u8,
199 },
200 /// if !bypass_p2_div: Fout = (M / (N x 2 x P)) x Fin
201 /// if bypass_p2_div: Fout = (M / ( N x P )) x Fin
202 Mode1d {
203 m_mult: u16,
204 n_div: u8,
205 p_div: u8,
206 bypass_p2_div: bool,
207 }
208}
209
210
146// FIRC/FRO180M 211// FIRC/FRO180M
147 212
148/// ```text 213/// ```text
@@ -222,6 +287,7 @@ impl Default for ClocksConfig {
222 vdd_core_domain_active: true, 287 vdd_core_domain_active: true,
223 }), 288 }),
224 sosc: None, 289 sosc: None,
290 spll: None,
225 } 291 }
226 } 292 }
227} 293}