Hi Guys,
I want to implement a Vendor-defined USB HID device,But encountered the following problems:
1.When the PC sends data via USB HID , the slave(52840) cannot enter the response Event (APP_USBD_HID_USER_EVT_OUT_REPORT_READY) in main.c , i can not use app_usbd_hid_generic_out_report_get fuction to receive data in hid_user_ev_handler。
2. The received data and data length are incorrect ,Data is all zero( hid_generic_ep_transfer_out function in app_usbd_hid_generic.c)
static ret_code_t hid_generic_ep_transfer_out(app_usbd_class_inst_t const * p_inst)
{
app_usbd_hid_generic_t const * p_generic = hid_generic_get(p_inst);
nrf_drv_usbd_ep_t ep_addr = app_usbd_hid_epout_addr_get(p_inst);
/*Request setup data*/
app_usbd_hid_report_buffer_t const * p_rep_buff;
p_rep_buff = app_usbd_hid_rep_buff_out_get(&p_generic->specific.inst.hid_inst);
NRF_DRV_USBD_TRANSFER_OUT(transfer, p_rep_buff->p_buff, p_rep_buff->size);
bsp_board_led_on(3);
NRF_LOG_INFO("p_rep_buff->size :%d , data:", p_rep_buff->size);
NRF_LOG_HEXDUMP_INFO( p_rep_buff->p_buff, p_rep_buff->size);
return app_usbd_ep_transfer(ep_addr, &transfer);
}
LOG:
0> <info> app: p_rep_buff->size :32 , data:
0> <info> app: 00 00 00 00 00 00 00 00|........
0> <info> app: 00 00 00 00 00 00 00 00|........
0> <info> app: 00 00 00 00 00 00 00 00|........
0> <info> app: 00 00 00 00 00 00 00 00|........
I want to where code is wrong,Below is my code:
#define HID_VENDOR_OUT_INTERFACE 4
#define HID_VENDOR_OUT_EPIN NRFX_USBD_EPOUT4
#define VENDOR_OUT_ENDPOINT_LIST() \
( \
HID_VENDOR_OUT_EPIN \
)
#define APP_USBD_VENDOR_OUT_REPORT_DSC() { \
0x06, 0x00, 0xff, /* Usage Page (Vendor Defined 0xFF00) */ \
0x09,0x01, \
0xA1, 0x01, /* Collection (Application) */\
0x0A, 0x01, 0xff, /* Usage (0xFF01) */ \
0x15, 0x00, /* Logical Minimum (0) */ \
0x26, 0xff, 0x00, /* Logical Maximum (255) */ \
0x75, 0x08, /* Report Size (8) */ \
0x95, 29, /* Report Count */ \
0x91, 0x02, /* Feature (Data, Variable, Absolute) */ \
0xC0,\
}
APP_USBD_HID_GENERIC_SUBCLASS_REPORT_DESC(vendor_out,APP_USBD_VENDOR_OUT_REPORT_DSC());
static const app_usbd_hid_subclass_desc_t * vendor_out_reps[] = {&vendor_out};
APP_USBD_HID_GENERIC_GLOBAL_DEF(m_app_hid_vendor_out,
HID_VENDOR_OUT_INTERFACE,
hid_user_ev_handler,
VENDOR_OUT_ENDPOINT_LIST(),
vendor_out_reps,
REPORT_IN_QUEUE_SIZE,
REPORT_OUT_MAXSIZE,
REPORT_FEATURE_MAXSIZE,
APP_USBD_HID_SUBCLASS_BOOT,
APP_USBD_HID_PROTO_KEYBOARD);
app_usbd_class_inst_t const * class_inst_generic5;
class_inst_generic5 = app_usbd_hid_generic_class_inst_get(&m_app_hid_vendor_out);
ret = hid_generic_idle_handler_set(class_inst_generic5, idle_handle);
APP_ERROR_CHECK(ret);
ret = app_usbd_class_append(class_inst_generic5);
APP_ERROR_CHECK(ret);
Looking forward to your reply。
