summaryrefslogtreecommitdiff
path: root/rtc/stm32_rtc.h
diff options
context:
space:
mode:
authorKarl Palsson <karlp@tweak.net.au>2022-01-12 18:30:15 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2022-01-26 23:41:04 +0100
commit1155f57710a068efbdc7fdd167ac4e44dd54ec7f (patch)
tree198ee24c33f4c697f039b32e50b0ecea109d3bbe /rtc/stm32_rtc.h
parent39a5d7c632ec25bcaaa6f296effe719bbc62a6ed (diff)
stm32wb: rtc: initial registers
Backup registers are just hardcoded to 32, which is the max seen. Note that the STM32WB only has 20! I've captured that in the platform yaml, even though it's not used anywhere (yet?) Signed-off-by: Karl Palsson <karlp@tweak.net.au>
Diffstat (limited to 'rtc/stm32_rtc.h')
-rw-r--r--rtc/stm32_rtc.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/rtc/stm32_rtc.h b/rtc/stm32_rtc.h
new file mode 100644
index 0000000..bc78128
--- /dev/null
+++ b/rtc/stm32_rtc.h
@@ -0,0 +1,44 @@
+#pragma once
+
+#include <mmio/mmio.h>
+
+struct STM32_RTC_reg_v2ss_t {
+ volatile uint32_t TR;
+ volatile uint32_t DR;
+ volatile uint32_t CR;
+ volatile uint32_t ISR;
+ volatile uint32_t PRER;
+ volatile uint32_t WUTR;
+ uint32_t _reserved1;
+ volatile uint32_t ALRMAR;
+ volatile uint32_t ALRMBR;
+ volatile uint32_t WPR;
+ volatile uint32_t SSR;
+ volatile uint32_t SHIFTR;
+ volatile uint32_t TSTR;
+ volatile uint32_t TSDR;
+ volatile uint32_t TSSSR;
+ volatile uint32_t CALR;
+ volatile uint32_t TAMPCR;
+ volatile uint32_t ALRMASSR;
+ volatile uint32_t ALRMBSSR;
+ volatile uint32_t OR;
+ volatile uint32_t BKP[32]; /* max known 32, might be less, check DS */
+};
+
+template <typename T>
+class STM32_RTC_t : public mmio_ptr<T> {
+ public:
+ using mmio_ptr<T>::ptr;
+
+ void lock(void) const {
+ ptr()->WPR = 0x99; // Doesn't matter...
+ }
+
+ void unlock(void) const {
+ ptr()->WPR = 0xCA;
+ ptr()->WPR = 0x53;
+ }
+
+};
+