summaryrefslogtreecommitdiff
path: root/supervisor
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2020-11-23 22:44:53 -0500
committerDan Halbert <halbert@halwitz.org>2020-11-23 22:44:53 -0500
commit7a45afc54919162df342fab421ed113ff1771d01 (patch)
tree4d351d45751f40c096c89d0ea773a09a279d6b52 /supervisor
parent3abee9b2563f0203f3d9521631499008708bb407 (diff)
working, but need to avoid deep sleeping too fast before USB ready
Diffstat (limited to 'supervisor')
-rw-r--r--supervisor/shared/workflow.c26
-rw-r--r--supervisor/shared/workflow.h8
2 files changed, 33 insertions, 1 deletions
diff --git a/supervisor/shared/workflow.c b/supervisor/shared/workflow.c
index 41af22eb7..67d191172 100644
--- a/supervisor/shared/workflow.c
+++ b/supervisor/shared/workflow.c
@@ -25,10 +25,36 @@
*/
#include <stdbool.h>
+#include "py/mpconfig.h"
#include "tusb.h"
+STATIC bool _allow_deep_sleep_when_connected;
+STATIC bool _allow_deep_sleep_on_error;
+
+
+void supervisor_workflow_reset(void) {
+ _allow_deep_sleep_when_connected = false;
+ _allow_deep_sleep_on_error = false;
+}
+
bool supervisor_workflow_active(void) {
// Eventually there might be other non-USB workflows, such as BLE.
// tud_ready() checks for usb mounted and not suspended.
return tud_ready();
}
+
+bool supervisor_workflow_get_allow_deep_sleep_when_connected(void) {
+ return _allow_deep_sleep_when_connected;
+}
+
+void supervisor_workflow_set_allow_deep_sleep_when_connected(bool allow) {
+ _allow_deep_sleep_when_connected = allow;
+}
+
+bool supervisor_workflow_get_allow_deep_sleep_on_error(void) {
+ return _allow_deep_sleep_on_error;
+}
+
+void supervisor_workflow_set_allow_deep_sleep_on_error(bool allow) {
+ _allow_deep_sleep_on_error = allow;
+}
diff --git a/supervisor/shared/workflow.h b/supervisor/shared/workflow.h
index 2968961f4..97584a1f4 100644
--- a/supervisor/shared/workflow.h
+++ b/supervisor/shared/workflow.h
@@ -26,6 +26,12 @@
#pragma once
-extern volatile bool _workflow_active;
+extern void supervisor_workflow_reset(void);
extern bool supervisor_workflow_active(void);
+
+extern bool supervisor_workflow_get_allow_deep_sleep_when_connected(void);
+extern void supervisor_workflow_set_allow_deep_sleep_when_connected(bool allow);
+
+extern bool supervisor_workflow_get_allow_deep_sleep_on_error(void);
+extern void supervisor_workflow_set_allow_deep_sleep_on_error(bool allow);