summaryrefslogtreecommitdiff
path: root/tmk_core/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol')
-rw-r--r--tmk_core/protocol/arm_atsam/main_arm_atsam.c7
-rw-r--r--tmk_core/protocol/arm_atsam/usb/conf_usb.h1
-rw-r--r--tmk_core/protocol/arm_atsam/usb/main_usb.c5
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c29
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h1
-rw-r--r--tmk_core/protocol/arm_atsam/usb/usb_main.h1
6 files changed, 43 insertions, 1 deletions
diff --git a/tmk_core/protocol/arm_atsam/main_arm_atsam.c b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
index e952a427ef..e4e79d3510 100644
--- a/tmk_core/protocol/arm_atsam/main_arm_atsam.c
+++ b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
@@ -206,10 +206,17 @@ void main_subtask_usb_extra_device(void) {
}
}
+#ifdef RAW_ENABLE
+void main_subtask_raw(void) { udi_hid_raw_receive_report(); }
+#endif
+
void main_subtasks(void) {
main_subtask_usb_state();
main_subtask_power_check();
main_subtask_usb_extra_device();
+#ifdef RAW_ENABLE
+ main_subtask_raw();
+#endif
}
int main(void) {
diff --git a/tmk_core/protocol/arm_atsam/usb/conf_usb.h b/tmk_core/protocol/arm_atsam/usb/conf_usb.h
index f23c2a80dd..f236427ca1 100644
--- a/tmk_core/protocol/arm_atsam/usb/conf_usb.h
+++ b/tmk_core/protocol/arm_atsam/usb/conf_usb.h
@@ -146,6 +146,7 @@
#ifdef RAW
# define UDI_HID_RAW_ENABLE_EXT() main_raw_enable()
# define UDI_HID_RAW_DISABLE_EXT() main_raw_disable()
+# define UDI_HID_RAW_RECEIVE(buffer, len) main_raw_receive(buffer, len)
#endif
//@}
diff --git a/tmk_core/protocol/arm_atsam/usb/main_usb.c b/tmk_core/protocol/arm_atsam/usb/main_usb.c
index 82ab123fd0..3809e1fd02 100644
--- a/tmk_core/protocol/arm_atsam/usb/main_usb.c
+++ b/tmk_core/protocol/arm_atsam/usb/main_usb.c
@@ -18,6 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "samd51j18a.h"
#include "conf_usb.h"
#include "udd.h"
+#ifdef RAW
+# include "raw_hid.h"
+#endif
uint8_t keyboard_protocol = 1;
@@ -89,4 +92,6 @@ bool main_raw_enable(void) {
}
void main_raw_disable(void) { main_b_raw_enable = false; }
+
+void main_raw_receive(uint8_t *buffer, uint8_t len) { raw_hid_receive(buffer, len); }
#endif
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c
index 5b32954071..e94beb1254 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c
+++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c
@@ -647,6 +647,9 @@ COMPILER_WORD_ALIGNED
static uint8_t udi_hid_raw_report_trans[UDI_HID_RAW_REPORT_SIZE];
COMPILER_WORD_ALIGNED
+static uint8_t udi_hid_raw_report_recv[UDI_HID_RAW_REPORT_SIZE];
+
+COMPILER_WORD_ALIGNED
UDC_DESC_STORAGE udi_hid_raw_report_desc_t udi_hid_raw_report_desc = {{
0x06, 0x60, 0xFF, // Usage Page (Vendor Defined)
0x09, 0x61, // Usage (Vendor Defined)
@@ -669,6 +672,7 @@ static bool udi_hid_raw_setreport(void);
static void udi_hid_raw_setreport_valid(void);
static void udi_hid_raw_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep);
+static void udi_hid_raw_report_rcvd(udd_ep_status_t status, iram_size_t nb_rcvd, udd_ep_id_t ep);
bool udi_hid_raw_enable(void) {
// Initialize internal values
@@ -725,7 +729,30 @@ static void udi_hid_raw_report_sent(udd_ep_status_t status, iram_size_t nb_sent,
static void udi_hid_raw_setreport_valid(void) {}
-#endif // RAW
+void raw_hid_send(uint8_t *data, uint8_t length) {
+ if (main_b_raw_enable && !udi_hid_raw_b_report_trans_ongoing && length == UDI_HID_RAW_REPORT_SIZE) {
+ memcpy(udi_hid_raw_report, data, UDI_HID_RAW_REPORT_SIZE);
+ udi_hid_raw_send_report();
+ }
+}
+
+bool udi_hid_raw_receive_report(void) {
+ if (!main_b_raw_enable) {
+ return false;
+ }
+
+ return udd_ep_run(UDI_HID_RAW_EP_OUT | USB_EP_DIR_OUT, false, udi_hid_raw_report_recv, UDI_HID_RAW_REPORT_SIZE, udi_hid_raw_report_rcvd);
+}
+
+static void udi_hid_raw_report_rcvd(udd_ep_status_t status, iram_size_t nb_rcvd, udd_ep_id_t ep) {
+ UNUSED(ep);
+
+ if (status == UDD_EP_TRANSFER_OK && nb_rcvd == UDI_HID_RAW_REPORT_SIZE) {
+ UDI_HID_RAW_RECEIVE(udi_hid_raw_report_recv, UDI_HID_RAW_REPORT_SIZE);
+ }
+}
+
+#endif //RAW
//********************************************************************************************
// CON
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h
index 82b1cbfe07..6dc1fed3ef 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h
+++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h
@@ -111,6 +111,7 @@ bool udi_hid_mou_send_report(void);
#ifdef RAW
extern UDC_DESC_STORAGE udi_api_t udi_api_hid_raw;
bool udi_hid_raw_send_report(void);
+bool udi_hid_raw_receive_report(void);
#endif // RAW
//@}
diff --git a/tmk_core/protocol/arm_atsam/usb/usb_main.h b/tmk_core/protocol/arm_atsam/usb/usb_main.h
index e1ffa3e184..3191b2fc13 100644
--- a/tmk_core/protocol/arm_atsam/usb/usb_main.h
+++ b/tmk_core/protocol/arm_atsam/usb/usb_main.h
@@ -97,6 +97,7 @@ void main_mou_disable(void);
extern volatile bool main_b_raw_enable;
bool main_raw_enable(void);
void main_raw_disable(void);
+void main_raw_receive(uint8_t *buffer, uint8_t len);
#endif // RAW
#endif // _MAIN_H_