Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/flipperzero-firmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Kharisov <ah@bright-box.com>2021-11-03 20:22:49 +0300
committerGitHub <noreply@github.com>2021-11-03 20:22:49 +0300
commit0c1bcf144b33889244b946115d001675f61260dd (patch)
tree83428d51077c3189e74e9b1158bae44105e5f47d /firmware
parent6d548637f25e8ebdd689d609a40fbccb398619a3 (diff)
[FL-1994] Add Saved Struct (#804)
Co-authored-by: あく <alleteam@gmail.com>
Diffstat (limited to 'firmware')
-rw-r--r--firmware/targets/f6/furi-hal/furi-hal-lock.c17
-rw-r--r--firmware/targets/f7/furi-hal/furi-hal-lock.c17
-rw-r--r--firmware/targets/furi-hal-include/furi-hal-lock.h5
3 files changed, 39 insertions, 0 deletions
diff --git a/firmware/targets/f6/furi-hal/furi-hal-lock.c b/firmware/targets/f6/furi-hal/furi-hal-lock.c
new file mode 100644
index 00000000..0f519380
--- /dev/null
+++ b/firmware/targets/f6/furi-hal/furi-hal-lock.c
@@ -0,0 +1,17 @@
+#include "furi-hal-lock.h"
+#include <stm32wbxx_ll_rtc.h>
+
+#define FLIPPER_LOCKED_VALUE 0x5432FAFA
+
+bool furi_hal_lock_get() {
+ return FLIPPER_LOCKED_VALUE == LL_RTC_BAK_GetRegister(RTC, LL_RTC_BKP_DR3);
+}
+
+void furi_hal_lock_set(bool locked) {
+ if (locked) {
+ LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR3, FLIPPER_LOCKED_VALUE);
+ } else {
+ LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR3, 0);
+ }
+}
+
diff --git a/firmware/targets/f7/furi-hal/furi-hal-lock.c b/firmware/targets/f7/furi-hal/furi-hal-lock.c
new file mode 100644
index 00000000..0f519380
--- /dev/null
+++ b/firmware/targets/f7/furi-hal/furi-hal-lock.c
@@ -0,0 +1,17 @@
+#include "furi-hal-lock.h"
+#include <stm32wbxx_ll_rtc.h>
+
+#define FLIPPER_LOCKED_VALUE 0x5432FAFA
+
+bool furi_hal_lock_get() {
+ return FLIPPER_LOCKED_VALUE == LL_RTC_BAK_GetRegister(RTC, LL_RTC_BKP_DR3);
+}
+
+void furi_hal_lock_set(bool locked) {
+ if (locked) {
+ LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR3, FLIPPER_LOCKED_VALUE);
+ } else {
+ LL_RTC_BAK_SetRegister(RTC, LL_RTC_BKP_DR3, 0);
+ }
+}
+
diff --git a/firmware/targets/furi-hal-include/furi-hal-lock.h b/firmware/targets/furi-hal-include/furi-hal-lock.h
new file mode 100644
index 00000000..d07ce571
--- /dev/null
+++ b/firmware/targets/furi-hal-include/furi-hal-lock.h
@@ -0,0 +1,5 @@
+#pragma once
+#include <stdbool.h>
+
+bool furi_hal_lock_get();
+void furi_hal_lock_set(bool locked);