summaryrefslogtreecommitdiff
path: root/tmk_core/protocol/arm_atsam
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2022-10-07 13:35:01 +1100
committerGitHub <noreply@github.com>2022-10-06 19:35:01 -0700
commit6dbbeea46a0ac7527235982cb6406802df846805 (patch)
tree55b2a71430ad3726ab098a53b581a69efdd1602d /tmk_core/protocol/arm_atsam
parentcbe1c22d468d64d7a3274061ce9c2073ecb208a4 (diff)
Refactor `send_extra` (#18615)
Diffstat (limited to 'tmk_core/protocol/arm_atsam')
-rw-r--r--tmk_core/protocol/arm_atsam/main_arm_atsam.c9
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_device_conf.h14
-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
4 files changed, 11 insertions, 42 deletions
diff --git a/tmk_core/protocol/arm_atsam/main_arm_atsam.c b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
index 0537e3937d..1ccfbfb54a 100644
--- a/tmk_core/protocol/arm_atsam/main_arm_atsam.c
+++ b/tmk_core/protocol/arm_atsam/main_arm_atsam.c
@@ -37,7 +37,7 @@ void main_subtasks(void);
uint8_t keyboard_leds(void);
void send_keyboard(report_keyboard_t *report);
void send_mouse(report_mouse_t *report);
-void send_extra(uint8_t report_id, uint16_t data);
+void send_extra(report_extra_t *report);
#ifdef DEFERRED_EXEC_ENABLE
void deferred_exec_task(void);
@@ -113,7 +113,7 @@ void send_mouse(report_mouse_t *report) {
#endif // MOUSEKEY_ENABLE
}
-void send_extra(uint8_t report_id, uint16_t data) {
+void send_extra(report_extra_t *report) {
#ifdef EXTRAKEY_ENABLE
uint32_t irqflags;
@@ -121,9 +121,8 @@ void send_extra(uint8_t report_id, uint16_t data) {
__disable_irq();
__DMB();
- udi_hid_exk_report.desc.report_id = report_id;
- udi_hid_exk_report.desc.report_data = data;
- udi_hid_exk_b_report_valid = 1;
+ memcpy(udi_hid_exk_report, report, UDI_HID_EXK_REPORT_SIZE);
+ udi_hid_exk_b_report_valid = 1;
udi_hid_exk_send_report();
__DMB();
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h b/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h
index eeed196275..a3c6f1c397 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h
+++ b/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h
@@ -352,21 +352,9 @@ typedef struct {
// clang-format on
-// set report buffer (from host)
-extern uint8_t udi_hid_exk_report_set;
-
// report buffer
# define UDI_HID_EXK_REPORT_SIZE 3
-
-typedef union {
- struct {
- uint8_t report_id;
- uint16_t report_data;
- } desc;
- uint8_t raw[UDI_HID_EXK_REPORT_SIZE];
-} udi_hid_exk_report_t;
-
-extern udi_hid_exk_report_t udi_hid_exk_report;
+extern uint8_t udi_hid_exk_report[UDI_HID_EXK_REPORT_SIZE];
COMPILER_PACK_RESET()
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 be4f2bb0c9..5d681a8b71 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c
+++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c
@@ -371,13 +371,13 @@ static uint8_t udi_hid_exk_rate;
COMPILER_WORD_ALIGNED
static uint8_t udi_hid_exk_protocol;
-COMPILER_WORD_ALIGNED
-uint8_t udi_hid_exk_report_set;
+// COMPILER_WORD_ALIGNED
+// uint8_t udi_hid_exk_report_set;
bool udi_hid_exk_b_report_valid;
COMPILER_WORD_ALIGNED
-udi_hid_exk_report_t udi_hid_exk_report;
+uint8_t udi_hid_exk_report[UDI_HID_EXK_REPORT_SIZE];
static bool udi_hid_exk_b_report_trans_ongoing;
@@ -415,39 +415,24 @@ UDC_DESC_STORAGE udi_hid_exk_report_desc_t udi_hid_exk_report_desc = {{
//clang-format on
}};
-static bool udi_hid_exk_setreport(void);
-
static void udi_hid_exk_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep);
-static void udi_hid_exk_setreport_valid(void);
-
bool udi_hid_exk_enable(void) {
// Initialize internal values
udi_hid_exk_rate = 0;
udi_hid_exk_protocol = 0;
udi_hid_exk_b_report_trans_ongoing = false;
- memset(udi_hid_exk_report.raw, 0, UDI_HID_EXK_REPORT_SIZE);
+ memset(udi_hid_exk_report, 0, UDI_HID_EXK_REPORT_SIZE);
udi_hid_exk_b_report_valid = false;
return UDI_HID_EXK_ENABLE_EXT();
}
void udi_hid_exk_disable(void) { UDI_HID_EXK_DISABLE_EXT(); }
-bool udi_hid_exk_setup(void) { return udi_hid_setup(&udi_hid_exk_rate, &udi_hid_exk_protocol, (uint8_t *)&udi_hid_exk_report_desc, udi_hid_exk_setreport); }
+bool udi_hid_exk_setup(void) { return udi_hid_setup(&udi_hid_exk_rate, &udi_hid_exk_protocol, (uint8_t *)&udi_hid_exk_report_desc, NULL); }
uint8_t udi_hid_exk_getsetting(void) { return 0; }
-static bool udi_hid_exk_setreport(void) {
- if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8)) && (0 == (0xFF & udd_g_ctrlreq.req.wValue)) && (1 == udd_g_ctrlreq.req.wLength)) {
- // Report OUT type on report ID 0 from USB Host
- udd_g_ctrlreq.payload = &udi_hid_exk_report_set;
- udd_g_ctrlreq.callback = udi_hid_exk_setreport_valid;
- udd_g_ctrlreq.payload_size = 1;
- return true;
- }
- return false;
-}
-
bool udi_hid_exk_send_report(void) {
if (!main_b_exk_enable) {
return false;
@@ -457,7 +442,7 @@ bool udi_hid_exk_send_report(void) {
return false;
}
- memcpy(udi_hid_exk_report_trans, udi_hid_exk_report.raw, UDI_HID_EXK_REPORT_SIZE);
+ memcpy(udi_hid_exk_report_trans, udi_hid_exk_report, UDI_HID_EXK_REPORT_SIZE);
udi_hid_exk_b_report_valid = false;
udi_hid_exk_b_report_trans_ongoing = udd_ep_run(UDI_HID_EXK_EP_IN | USB_EP_DIR_IN, false, udi_hid_exk_report_trans, UDI_HID_EXK_REPORT_SIZE, udi_hid_exk_report_sent);
@@ -474,8 +459,6 @@ static void udi_hid_exk_report_sent(udd_ep_status_t status, iram_size_t nb_sent,
}
}
-static void udi_hid_exk_setreport_valid(void) {}
-
#endif // EXTRAKEY_ENABLE
//********************************************************************************************
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 a330014498..e17538fa70 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h
+++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h
@@ -79,7 +79,6 @@ bool udi_hid_nkro_send_report(void);
#ifdef EXTRAKEY_ENABLE
extern UDC_DESC_STORAGE udi_api_t udi_api_hid_exk;
extern bool udi_hid_exk_b_report_valid;
-extern uint8_t udi_hid_exk_report_set;
bool udi_hid_exk_send_report(void);
#endif // EXTRAKEY_ENABLE