|
3 | 3 | use crate::hal;
|
4 | 4 | use crate::pac::LPTIM;
|
5 | 5 | use crate::rcc::Rcc;
|
| 6 | +use crate::pwr::PWR; |
6 | 7 | use crate::time::{Hertz, MicroSeconds};
|
7 | 8 | use cast::{u32, u64};
|
8 | 9 | use core::marker::PhantomData;
|
@@ -90,22 +91,26 @@ impl LpTimer<Periodic> {
|
90 | 91 | /// Initializes the Low-Power Timer in periodic mode.
|
91 | 92 | ///
|
92 | 93 | /// The timer needs to be started by calling `.start(freq)`.
|
93 |
| - pub fn init_periodic(lptim: LPTIM, rcc: &mut Rcc, clk: ClockSrc) -> Self { |
94 |
| - Self::init(lptim, rcc, clk) |
| 94 | + pub fn init_periodic(lptim: LPTIM, pwr: &mut PWR, rcc: &mut Rcc, clk: ClockSrc) -> Self { |
| 95 | + Self::init(lptim, pwr, rcc, clk) |
95 | 96 | }
|
96 | 97 | }
|
97 | 98 |
|
98 | 99 | impl LpTimer<OneShot> {
|
99 | 100 | /// Initializes the Low-Power Timer in one-shot mode.
|
100 | 101 | ///
|
101 | 102 | /// The timer needs to be started by calling `.start(freq)`.
|
102 |
| - pub fn init_oneshot(lptim: LPTIM, rcc: &mut Rcc, clk: ClockSrc) -> Self { |
103 |
| - Self::init(lptim, rcc, clk) |
| 103 | + pub fn init_oneshot(lptim: LPTIM, pwr: &mut PWR, rcc: &mut Rcc, clk: ClockSrc) -> Self { |
| 104 | + Self::init(lptim, pwr, rcc, clk) |
104 | 105 | }
|
105 | 106 | }
|
106 | 107 |
|
107 | 108 | impl<M: CountMode> LpTimer<M> {
|
108 |
| - fn init(lptim: LPTIM, rcc: &mut Rcc, clk: ClockSrc) -> Self { |
| 109 | + fn init(lptim: LPTIM, pwr: &mut PWR, rcc: &mut Rcc, clk: ClockSrc) -> Self { |
| 110 | + // `pwr` is not used. It is used as a marker that guarantees that `PWR.CR` is set so this |
| 111 | + // function can set the `RCC.LSEON` bit, which is otherwise write protected. |
| 112 | + let _ = pwr; |
| 113 | + |
109 | 114 | // Enable selected clock and determine its frequency
|
110 | 115 | let input_freq = match clk {
|
111 | 116 | ClockSrc::Apb1 => rcc.clocks.apb1_clk(), // always enabled
|
|
0 commit comments