aboutsummaryrefslogtreecommitdiff
path: root/src/clocks
diff options
context:
space:
mode:
authorJames Munns <[email protected]>2025-11-14 17:29:31 +0100
committerJames Munns <[email protected]>2025-11-14 17:29:31 +0100
commite799d6c8956ed3ea5ced65d58c3065a22927ad10 (patch)
tree05db757ce7d739c9f7a92905406bae08e3a281e1 /src/clocks
parent9b91d886e6a5067d6a553715a053db653af55ca6 (diff)
More work on examples
Diffstat (limited to 'src/clocks')
-rw-r--r--src/clocks/mod.rs12
-rw-r--r--src/clocks/periph_helpers.rs8
2 files changed, 18 insertions, 2 deletions
diff --git a/src/clocks/mod.rs b/src/clocks/mod.rs
index 24e118e38..e04f63b8e 100644
--- a/src/clocks/mod.rs
+++ b/src/clocks/mod.rs
@@ -79,6 +79,11 @@ pub unsafe fn assert_reset<G: Gate>() {
79 G::assert_reset(); 79 G::assert_reset();
80} 80}
81 81
82#[inline]
83pub unsafe fn is_reset_released<G: Gate>() -> bool {
84 G::is_reset_released()
85}
86
82/// Pulse a reset line (assert then release) with a short delay. 87/// Pulse a reset line (assert then release) with a short delay.
83#[inline] 88#[inline]
84pub unsafe fn pulse_reset<G: Gate>() { 89pub unsafe fn pulse_reset<G: Gate>() {
@@ -150,12 +155,15 @@ pub mod gate {
150 use super::periph_helpers::{AdcConfig, LpuartConfig, OsTimerConfig}; 155 use super::periph_helpers::{AdcConfig, LpuartConfig, OsTimerConfig};
151 use super::*; 156 use super::*;
152 157
158 // These peripherals have no additional upstream clocks or configuration required
159 // other than enabling through the MRCC gate.
153 impl_cc_gate!(PORT1, mrcc_glb_cc1, port1, NoConfig); 160 impl_cc_gate!(PORT1, mrcc_glb_cc1, port1, NoConfig);
154 impl_cc_gate!(PORT2, mrcc_glb_cc1, port2, NoConfig); 161 impl_cc_gate!(PORT2, mrcc_glb_cc1, port2, NoConfig);
155 impl_cc_gate!(PORT3, mrcc_glb_cc1, port3, NoConfig); 162 impl_cc_gate!(PORT3, mrcc_glb_cc1, port3, NoConfig);
163 impl_cc_gate!(GPIO3, mrcc_glb_cc2, gpio3, NoConfig);
164
156 impl_cc_gate!(OSTIMER0, mrcc_glb_cc1, ostimer0, OsTimerConfig); 165 impl_cc_gate!(OSTIMER0, mrcc_glb_cc1, ostimer0, OsTimerConfig);
157 impl_cc_gate!(LPUART2, mrcc_glb_cc0, lpuart2, LpuartConfig); 166 impl_cc_gate!(LPUART2, mrcc_glb_cc0, lpuart2, LpuartConfig);
158 impl_cc_gate!(GPIO3, mrcc_glb_cc2, gpio3, NoConfig);
159 impl_cc_gate!(ADC1, mrcc_glb_cc1, adc1, AdcConfig); 167 impl_cc_gate!(ADC1, mrcc_glb_cc1, adc1, AdcConfig);
160} 168}
161 169
@@ -276,7 +284,7 @@ pub struct Clock {
276 pub power: PoweredClock, 284 pub power: PoweredClock,
277} 285}
278 286
279#[derive(Debug, Clone, Copy)] 287#[derive(Debug, Clone, Copy, PartialEq, Eq)]
280pub enum PoweredClock { 288pub enum PoweredClock {
281 NormalEnabledDeepSleepDisabled, 289 NormalEnabledDeepSleepDisabled,
282 AlwaysEnabled, 290 AlwaysEnabled,
diff --git a/src/clocks/periph_helpers.rs b/src/clocks/periph_helpers.rs
index de767ef87..1657bd7eb 100644
--- a/src/clocks/periph_helpers.rs
+++ b/src/clocks/periph_helpers.rs
@@ -18,6 +18,11 @@ pub trait SPConfHelper {
18pub struct Div4(pub(super) u8); 18pub struct Div4(pub(super) u8);
19 19
20impl Div4 { 20impl Div4 {
21 /// Divide by one, or no division
22 pub const fn no_div() -> Self {
23 Self(0)
24 }
25
21 /// Store a "raw" divisor value that will divide the source by 26 /// Store a "raw" divisor value that will divide the source by
22 /// `(n + 1)`, e.g. `Div4::from_raw(0)` will divide the source 27 /// `(n + 1)`, e.g. `Div4::from_raw(0)` will divide the source
23 /// by 1, and `Div4::from_raw(15)` will divide the source by 28 /// by 1, and `Div4::from_raw(15)` will divide the source by
@@ -81,6 +86,7 @@ pub enum LpuartClockSel {
81 None, 86 None,
82} 87}
83 88
89#[derive(Copy, Clone, Debug, PartialEq, Eq)]
84pub enum LpuartInstance { 90pub enum LpuartInstance {
85 Lpuart0, 91 Lpuart0,
86 Lpuart1, 92 Lpuart1,
@@ -102,6 +108,7 @@ pub struct LpuartConfig {
102 pub(crate) instance: LpuartInstance, 108 pub(crate) instance: LpuartInstance,
103} 109}
104 110
111#[derive(Copy, Clone, Debug, PartialEq, Eq)]
105pub enum OstimerClockSel { 112pub enum OstimerClockSel {
106 /// 16k clock, sourced from FRO16K (Vdd Core) 113 /// 16k clock, sourced from FRO16K (Vdd Core)
107 Clk16kVddCore, 114 Clk16kVddCore,
@@ -116,6 +123,7 @@ pub struct OsTimerConfig {
116 pub source: OstimerClockSel, 123 pub source: OstimerClockSel,
117} 124}
118 125
126#[derive(Copy, Clone, Debug, PartialEq, Eq)]
119pub enum AdcClockSel { 127pub enum AdcClockSel {
120 FroLfDiv, 128 FroLfDiv,
121 FroHf, 129 FroHf,