summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2021-10-28 22:31:59 +0100
committerGitHub <noreply@github.com>2021-10-28 22:31:59 +0100
commitdcfffa7b67a072f7d9e37bd8c0029c53b61aeb0f (patch)
tree65491c3878ee76f50c4b46a318503cc27fdb4a6b /quantum
parent0c87e2e7025140ca6105b7fec2639c78c3cd8109 (diff)
Relocate protocol files within tmk_core/common/ (#14972)
* Relocate non platform files within tmk_core/common/ * clang
Diffstat (limited to 'quantum')
-rw-r--r--quantum/keyboard.c3
-rw-r--r--quantum/raw_hid.h5
-rw-r--r--quantum/sync_timer.c58
-rw-r--r--quantum/sync_timer.h54
-rw-r--r--quantum/usb_device_state.c51
-rw-r--r--quantum/usb_device_state.h39
-rw-r--r--quantum/virtser.h9
7 files changed, 129 insertions, 90 deletions
diff --git a/quantum/keyboard.c b/quantum/keyboard.c
index 030fec2d3e..806e4ef7e8 100644
--- a/quantum/keyboard.c
+++ b/quantum/keyboard.c
@@ -94,6 +94,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef DIGITIZER_ENABLE
# include "digitizer.h"
#endif
+#ifdef VIRTSER_ENABLE
+# include "virtser.h"
+#endif
static uint32_t last_input_modification_time = 0;
uint32_t last_input_activity_time(void) { return last_input_modification_time; }
diff --git a/quantum/raw_hid.h b/quantum/raw_hid.h
new file mode 100644
index 0000000000..6d60ab2bff
--- /dev/null
+++ b/quantum/raw_hid.h
@@ -0,0 +1,5 @@
+#pragma once
+
+void raw_hid_receive(uint8_t *data, uint8_t length);
+
+void raw_hid_send(uint8_t *data, uint8_t length);
diff --git a/quantum/sync_timer.c b/quantum/sync_timer.c
new file mode 100644
index 0000000000..de24b463b6
--- /dev/null
+++ b/quantum/sync_timer.c
@@ -0,0 +1,58 @@
+/*
+Copyright (C) 2020 Ryan Caltabiano <https://github.com/XScorpion2>
+
+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.
+
+If you happen to meet one of the copyright holders in a bar you are obligated
+to buy them one pint of beer.
+
+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.
+*/
+
+#include "sync_timer.h"
+#include "keyboard.h"
+
+#if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER)
+volatile int32_t sync_timer_ms;
+
+void sync_timer_init(void) { sync_timer_ms = 0; }
+
+void sync_timer_update(uint32_t time) {
+ if (is_keyboard_master()) return;
+ sync_timer_ms = time - timer_read32();
+}
+
+uint16_t sync_timer_read(void) {
+ if (is_keyboard_master()) return timer_read();
+ return sync_timer_read32();
+}
+
+uint32_t sync_timer_read32(void) {
+ if (is_keyboard_master()) return timer_read32();
+ return sync_timer_ms + timer_read32();
+}
+
+uint16_t sync_timer_elapsed(uint16_t last) {
+ if (is_keyboard_master()) return timer_elapsed(last);
+ return TIMER_DIFF_16(sync_timer_read(), last);
+}
+
+uint32_t sync_timer_elapsed32(uint32_t last) {
+ if (is_keyboard_master()) return timer_elapsed32(last);
+ return TIMER_DIFF_32(sync_timer_read32(), last);
+}
+#endif
diff --git a/quantum/sync_timer.h b/quantum/sync_timer.h
new file mode 100644
index 0000000000..9ddef45bb2
--- /dev/null
+++ b/quantum/sync_timer.h
@@ -0,0 +1,54 @@
+/*
+Copyright (C) 2020 Ryan Caltabiano <https://github.com/XScorpion2>
+
+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.
+
+If you happen to meet one of the copyright holders in a bar you are obligated
+to buy them one pint of beer.
+
+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
+
+#include <stdint.h>
+#include "timer.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(SPLIT_KEYBOARD) && !defined(DISABLE_SYNC_TIMER)
+void sync_timer_init(void);
+void sync_timer_update(uint32_t time);
+uint16_t sync_timer_read(void);
+uint32_t sync_timer_read32(void);
+uint16_t sync_timer_elapsed(uint16_t last);
+uint32_t sync_timer_elapsed32(uint32_t last);
+#else
+# define sync_timer_init()
+# define sync_timer_clear()
+# define sync_timer_update(t)
+# define sync_timer_read() timer_read()
+# define sync_timer_read32() timer_read32()
+# define sync_timer_elapsed(t) timer_elapsed(t)
+# define sync_timer_elapsed32(t) timer_elapsed32(t)
+#endif
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/quantum/usb_device_state.c b/quantum/usb_device_state.c
deleted file mode 100644
index 5ccd309ec2..0000000000
--- a/quantum/usb_device_state.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2021 Andrei Purdea <andrei@purdea.ro>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "usb_device_state.h"
-
-enum usb_device_state usb_device_state = USB_DEVICE_STATE_NO_INIT;
-
-__attribute__((weak)) void notify_usb_device_state_change_kb(enum usb_device_state usb_device_state) { notify_usb_device_state_change_user(usb_device_state); }
-
-__attribute__((weak)) void notify_usb_device_state_change_user(enum usb_device_state usb_device_state) {}
-
-static void notify_usb_device_state_change(enum usb_device_state usb_device_state) { notify_usb_device_state_change_kb(usb_device_state); }
-
-void usb_device_state_set_configuration(bool isConfigured, uint8_t configurationNumber) {
- usb_device_state = isConfigured ? USB_DEVICE_STATE_CONFIGURED : USB_DEVICE_STATE_INIT;
- notify_usb_device_state_change(usb_device_state);
-}
-
-void usb_device_state_set_suspend(bool isConfigured, uint8_t configurationNumber) {
- usb_device_state = USB_DEVICE_STATE_SUSPEND;
- notify_usb_device_state_change(usb_device_state);
-}
-
-void usb_device_state_set_resume(bool isConfigured, uint8_t configurationNumber) {
- usb_device_state = isConfigured ? USB_DEVICE_STATE_CONFIGURED : USB_DEVICE_STATE_INIT;
- notify_usb_device_state_change(usb_device_state);
-}
-
-void usb_device_state_set_reset(void) {
- usb_device_state = USB_DEVICE_STATE_INIT;
- notify_usb_device_state_change(usb_device_state);
-}
-
-void usb_device_state_init(void) {
- usb_device_state = USB_DEVICE_STATE_INIT;
- notify_usb_device_state_change(usb_device_state);
-}
diff --git a/quantum/usb_device_state.h b/quantum/usb_device_state.h
deleted file mode 100644
index c229311d46..0000000000
--- a/quantum/usb_device_state.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2021 Andrei Purdea <andrei@purdea.ro>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-#include <stdbool.h>
-#include <stdint.h>
-
-void usb_device_state_set_configuration(bool isConfigured, uint8_t configurationNumber);
-void usb_device_state_set_suspend(bool isConfigured, uint8_t configurationNumber);
-void usb_device_state_set_resume(bool isConfigured, uint8_t configurationNumber);
-void usb_device_state_set_reset(void);
-void usb_device_state_init(void);
-
-enum usb_device_state {
- USB_DEVICE_STATE_NO_INIT = 0, // We're in this state before calling usb_device_state_init()
- USB_DEVICE_STATE_INIT = 1, // Can consume up to 100mA
- USB_DEVICE_STATE_CONFIGURED = 2, // Can consume up to what is specified in configuration descriptor, typically 500mA
- USB_DEVICE_STATE_SUSPEND = 3 // Can consume only suspend current
-};
-
-extern enum usb_device_state usb_device_state;
-
-void notify_usb_device_state_change_kb(enum usb_device_state usb_device_state);
-void notify_usb_device_state_change_user(enum usb_device_state usb_device_state);
diff --git a/quantum/virtser.h b/quantum/virtser.h
new file mode 100644
index 0000000000..df7e87984c
--- /dev/null
+++ b/quantum/virtser.h
@@ -0,0 +1,9 @@
+#pragma once
+
+void virtser_init(void);
+
+/* Define this function in your code to process incoming bytes */
+void virtser_recv(const uint8_t ch);
+
+/* Call this to send a character over the Virtual Serial Device */
+void virtser_send(const uint8_t byte);