aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/rtc
diff options
context:
space:
mode:
authoreZio Pan <[email protected]>2023-12-25 21:29:17 +0800
committereZio Pan <[email protected]>2023-12-25 22:03:32 +0800
commitd90a97aa4c5977e3d071fb4ed94656e6666d965c (patch)
tree04a904e569fb1870817aff3335958ef4e20b56e7 /embassy-stm32/src/rtc
parent8b6c6c7df68088abc4a572a825a03e79c9b8694a (diff)
update metapac after stm32-data PR323
and refactor a few code with cargo clippy
Diffstat (limited to 'embassy-stm32/src/rtc')
-rw-r--r--embassy-stm32/src/rtc/v2.rs8
-rw-r--r--embassy-stm32/src/rtc/v3.rs8
2 files changed, 8 insertions, 8 deletions
diff --git a/embassy-stm32/src/rtc/v2.rs b/embassy-stm32/src/rtc/v2.rs
index 91f08fae4..1eda097a7 100644
--- a/embassy-stm32/src/rtc/v2.rs
+++ b/embassy-stm32/src/rtc/v2.rs
@@ -1,4 +1,4 @@
1use stm32_metapac::rtc::vals::{Init, Osel, Pol}; 1use stm32_metapac::rtc::vals::{Osel, Pol};
2 2
3use super::sealed; 3use super::sealed;
4use crate::pac::rtc::Rtc; 4use crate::pac::rtc::Rtc;
@@ -49,7 +49,7 @@ impl super::Rtc {
49 clock_drift = RTC_CALR_MAX_PPM; 49 clock_drift = RTC_CALR_MAX_PPM;
50 } 50 }
51 51
52 clock_drift = clock_drift / RTC_CALR_RESOLUTION_PPM; 52 clock_drift /= RTC_CALR_RESOLUTION_PPM;
53 53
54 self.write(false, |rtc| { 54 self.write(false, |rtc| {
55 rtc.calr().write(|w| { 55 rtc.calr().write(|w| {
@@ -107,7 +107,7 @@ impl super::Rtc {
107 // true if initf bit indicates RTC peripheral is in init mode 107 // true if initf bit indicates RTC peripheral is in init mode
108 if init_mode && !r.isr().read().initf() { 108 if init_mode && !r.isr().read().initf() {
109 // to update calendar date/time, time format, and prescaler configuration, RTC must be in init mode 109 // to update calendar date/time, time format, and prescaler configuration, RTC must be in init mode
110 r.isr().modify(|w| w.set_init(Init::INITMODE)); 110 r.isr().modify(|w| w.set_init(true));
111 // wait till init state entered 111 // wait till init state entered
112 // ~2 RTCCLK cycles 112 // ~2 RTCCLK cycles
113 while !r.isr().read().initf() {} 113 while !r.isr().read().initf() {}
@@ -116,7 +116,7 @@ impl super::Rtc {
116 let result = f(&r); 116 let result = f(&r);
117 117
118 if init_mode { 118 if init_mode {
119 r.isr().modify(|w| w.set_init(Init::FREERUNNINGMODE)); // Exits init mode 119 r.isr().modify(|w| w.set_init(false)); // Exits init mode
120 } 120 }
121 121
122 // Re-enable write protection. 122 // Re-enable write protection.
diff --git a/embassy-stm32/src/rtc/v3.rs b/embassy-stm32/src/rtc/v3.rs
index d2d0d9309..902776b0a 100644
--- a/embassy-stm32/src/rtc/v3.rs
+++ b/embassy-stm32/src/rtc/v3.rs
@@ -1,4 +1,4 @@
1use stm32_metapac::rtc::vals::{Calp, Calw16, Calw8, Fmt, Init, Key, Osel, Pol, TampalrmPu, TampalrmType}; 1use stm32_metapac::rtc::vals::{Calp, Calw16, Calw8, Fmt, Key, Osel, Pol, TampalrmType};
2 2
3use super::{sealed, RtcCalibrationCyclePeriod}; 3use super::{sealed, RtcCalibrationCyclePeriod};
4use crate::pac::rtc::Rtc; 4use crate::pac::rtc::Rtc;
@@ -26,7 +26,7 @@ impl super::Rtc {
26 rtc.cr().modify(|w| { 26 rtc.cr().modify(|w| {
27 w.set_out2en(false); 27 w.set_out2en(false);
28 w.set_tampalrm_type(TampalrmType::PUSHPULL); 28 w.set_tampalrm_type(TampalrmType::PUSHPULL);
29 w.set_tampalrm_pu(TampalrmPu::NOPULLUP); 29 w.set_tampalrm_pu(false);
30 }); 30 });
31 }); 31 });
32 } 32 }
@@ -106,7 +106,7 @@ impl super::Rtc {
106 r.wpr().write(|w| w.set_key(Key::DEACTIVATE2)); 106 r.wpr().write(|w| w.set_key(Key::DEACTIVATE2));
107 107
108 if init_mode && !r.icsr().read().initf() { 108 if init_mode && !r.icsr().read().initf() {
109 r.icsr().modify(|w| w.set_init(Init::INITMODE)); 109 r.icsr().modify(|w| w.set_init(true));
110 // wait till init state entered 110 // wait till init state entered
111 // ~2 RTCCLK cycles 111 // ~2 RTCCLK cycles
112 while !r.icsr().read().initf() {} 112 while !r.icsr().read().initf() {}
@@ -115,7 +115,7 @@ impl super::Rtc {
115 let result = f(&r); 115 let result = f(&r);
116 116
117 if init_mode { 117 if init_mode {
118 r.icsr().modify(|w| w.set_init(Init::FREERUNNINGMODE)); // Exits init mode 118 r.icsr().modify(|w| w.set_init(false)); // Exits init mode
119 } 119 }
120 120
121 // Re-enable write protection. 121 // Re-enable write protection.