feat(logic): read usb report leds

This commit is contained in:
Miguel Ángel 2021-08-07 11:30:56 -05:00
parent 47109641d8
commit 3cb616a697
3 changed files with 23 additions and 0 deletions

View file

@ -424,6 +424,10 @@ choice CBPRINTF_IMPLEMENTATION
endchoice
config ZMK_USB_REPORT_LEDS
bool "Enable usb report leds"
select ENABLE_HID_INT_OUT_EP
module = ZMK
module-str = zmk
source "subsys/logging/Kconfig.template.log_config"

View file

@ -26,4 +26,7 @@ static inline bool zmk_usb_is_hid_ready() { return zmk_usb_get_conn_state() == Z
#ifdef CONFIG_ZMK_USB
int zmk_usb_hid_send_report(const uint8_t *report, size_t len);
#ifdef CONFIG_ZMK_USB_REPORT_LEDS
int zmk_usb_hid_receive_report(uint8_t *report, size_t len);
#endif /* CONFIG_ZMK_USB_REPORT_LEDS */
#endif /* CONFIG_ZMK_USB */

View file

@ -38,6 +38,22 @@ static const struct hid_ops ops = {
.int_in_ready = in_ready_cb,
};
#ifdef CONFIG_ZMK_USB_REPORT_LEDS
int zmk_usb_hid_receive_report(uint8_t *report, size_t len) {
k_sem_take(&hid_sem, K_MSEC(30));
int err = hid_int_ep_read(hid_dev, report, len, NULL);
if (err) {
k_sem_give(&hid_sem);
LOG_ERR("Error receive report %d", err);
}
return err;
}
#endif /* CONFIG_ZMK_USB_REPORT_LEDS */
int zmk_usb_hid_send_report(const uint8_t *report, size_t len) {
switch (usb_status) {
case USB_DC_SUSPEND: