summaryrefslogtreecommitdiff
path: root/supervisor/shared
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2020-11-19 17:47:12 -0500
committerDan Halbert <halbert@halwitz.org>2020-11-19 17:47:12 -0500
commit39e1f52e28c620db65d59f16a29d5476c4868901 (patch)
tree7d6995457ce336464a41b96ebbfce603d3ba313c /supervisor/shared
parentcd436bad1ae9b8b448219979fe98e29ddbb2e953 (diff)
wip; not compiling yet
Diffstat (limited to 'supervisor/shared')
-rw-r--r--supervisor/shared/rgb_led_status.c1
-rw-r--r--supervisor/shared/serial.c4
-rw-r--r--supervisor/shared/serial.h29
-rw-r--r--supervisor/shared/usb/usb.c4
-rw-r--r--supervisor/shared/workflow.c4
-rw-r--r--supervisor/shared/workflow.h2
6 files changed, 8 insertions, 36 deletions
diff --git a/supervisor/shared/rgb_led_status.c b/supervisor/shared/rgb_led_status.c
index c3d33ad3e..006bb1b34 100644
--- a/supervisor/shared/rgb_led_status.c
+++ b/supervisor/shared/rgb_led_status.c
@@ -483,4 +483,5 @@ bool tick_rgb_status_animation(rgb_status_animation_t* status) {
}
}
#endif
+ return false; // Animation is not finished.
}
diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c
index 7383cc228..303f89e75 100644
--- a/supervisor/shared/serial.c
+++ b/supervisor/shared/serial.c
@@ -69,9 +69,7 @@ bool serial_connected(void) {
#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
return true;
#else
- // True if DTR is asserted, and the USB connection is up.
- // tud_cdc_get_line_state(): bit 0 is DTR, bit 1 is RTS
- return (tud_cdc_get_line_state() & 1) && tud_ready();
+ return tud_cdc_connected();
#endif
}
diff --git a/supervisor/shared/serial.h b/supervisor/shared/serial.h
deleted file mode 100644
index 84f92c337..000000000
--- a/supervisor/shared/serial.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#pragma once
-
-extern volatile bool _serial_connected;
diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c
index 8a425c990..3d76e7000 100644
--- a/supervisor/shared/usb/usb.c
+++ b/supervisor/shared/usb/usb.c
@@ -31,6 +31,7 @@
#include "supervisor/port.h"
#include "supervisor/serial.h"
#include "supervisor/usb.h"
+#include "supervisor/shared/workflow.h"
#include "lib/utils/interrupt_char.h"
#include "lib/mp-readline/readline.h"
@@ -118,7 +119,6 @@ void tud_umount_cb(void) {
// remote_wakeup_en : if host allows us to perform remote wakeup
// USB Specs: Within 7ms, device must draw an average current less than 2.5 mA from bus
void tud_suspend_cb(bool remote_wakeup_en) {
- _serial_connected = false;
_workflow_active = false;
}
@@ -132,8 +132,6 @@ void tud_resume_cb(void) {
void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) {
(void) itf; // interface ID, not used
- _serial_connected = dtr;
-
// DTR = false is counted as disconnected
if ( !dtr )
{
diff --git a/supervisor/shared/workflow.c b/supervisor/shared/workflow.c
index adcffb319..cd19d3aa2 100644
--- a/supervisor/shared/workflow.c
+++ b/supervisor/shared/workflow.c
@@ -24,9 +24,11 @@
* THE SOFTWARE.
*/
+#include <stdbool.h>
+
// Set by the shared USB code.
volatile bool _workflow_active;
-bool workflow_active(void) {
+bool supervisor_workflow_active(void) {
return _workflow_active;
}
diff --git a/supervisor/shared/workflow.h b/supervisor/shared/workflow.h
index 4a138332a..2968961f4 100644
--- a/supervisor/shared/workflow.h
+++ b/supervisor/shared/workflow.h
@@ -27,3 +27,5 @@
#pragma once
extern volatile bool _workflow_active;
+
+extern bool supervisor_workflow_active(void);