This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

USBD keyboard doesn't receive status led change. (Capslock, Numlock ...)

Hi Everybody,

I am working on USBD keyboard.

I used USBD example for implementation.

I changed mouse profile to keyboard profile.

And it's recognized well without problem in device manager.

But it doesn't get status change from PC. (capslock, numlock, ...)

When I test it using "usbd_hid_composite" example it receive well.  But that example is too complex to extend devices.

So I choosed USBD example.

SDK version: 17.0.2

Used example: USBD

Changes : mouse to keyboard

Parents
  • Hi

    What do you mean by the "usbd_hid_composite" example is too complex to extend devices? By default the USBD_HID_composite example uses a keyboard interface, so I would suggest using that for reference instead of modifying the entire USBD example.

    Getting an error from the usbd_setup points to your SETUP packet not being correct according to the USB specification, so I would double check how you've set up the keyboard on your end. 

    Best regards,

    Simon

  • Hi Simonr,

    Thank you for follow up.

    I meant "complex" is read to hard because of many macros. (I think these macro is only good for designers )

    Actually, I implemented many devices to USBC without problem.  The only problem is that I asked.

    From the example of "usbd_hid_composite". It looks some response using NRF_DRV_USBD_EPOUT0 is needed to get status change.

    I've tried "nrf_drv_usbd_ep_transfer(NRF_DRV_USBD_EPOUT0 , transfer)" in usbd_setup_SetConfig. but in vain.

    static ret_code_t hid_kbd_on_set_report(app_usbd_class_inst_t const * p_inst,
                                            app_usbd_setup_evt_t const  * p_setup_ev)
    {
        app_usbd_hid_kbd_t const * p_kbd = hid_kbd_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_kbd->specific.inst.hid_inst);
    
        p_rep_buff->p_buff[0] = 0;
        NRF_DRV_USBD_TRANSFER_OUT(transfer, p_rep_buff->p_buff + 1, p_rep_buff->size - 1);
    
        ret_code_t ret;
        CRITICAL_REGION_ENTER();
        ret = app_usbd_ep_transfer(NRF_DRV_USBD_EPOUT0, &transfer);
        if (ret == NRF_SUCCESS)
        {
            app_usbd_core_setup_data_handler_desc_t desc = {
                .handler   = hid_kbd_on_set_report_data_cb,
                .p_context = (app_usbd_hid_kbd_t *)p_kbd
            };
    
            ret = app_usbd_core_setup_data_handler_set(NRF_DRV_USBD_EPOUT0, &desc);
        }
        CRITICAL_REGION_EXIT();
    
        return ret;
    }

    I will check "usbd_hid_composite" also according to your suggestion.

    But It would be good if the problem is solved in UBBD example.

    Best Regards,

    Steven

Reply
  • Hi Simonr,

    Thank you for follow up.

    I meant "complex" is read to hard because of many macros. (I think these macro is only good for designers )

    Actually, I implemented many devices to USBC without problem.  The only problem is that I asked.

    From the example of "usbd_hid_composite". It looks some response using NRF_DRV_USBD_EPOUT0 is needed to get status change.

    I've tried "nrf_drv_usbd_ep_transfer(NRF_DRV_USBD_EPOUT0 , transfer)" in usbd_setup_SetConfig. but in vain.

    static ret_code_t hid_kbd_on_set_report(app_usbd_class_inst_t const * p_inst,
                                            app_usbd_setup_evt_t const  * p_setup_ev)
    {
        app_usbd_hid_kbd_t const * p_kbd = hid_kbd_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_kbd->specific.inst.hid_inst);
    
        p_rep_buff->p_buff[0] = 0;
        NRF_DRV_USBD_TRANSFER_OUT(transfer, p_rep_buff->p_buff + 1, p_rep_buff->size - 1);
    
        ret_code_t ret;
        CRITICAL_REGION_ENTER();
        ret = app_usbd_ep_transfer(NRF_DRV_USBD_EPOUT0, &transfer);
        if (ret == NRF_SUCCESS)
        {
            app_usbd_core_setup_data_handler_desc_t desc = {
                .handler   = hid_kbd_on_set_report_data_cb,
                .p_context = (app_usbd_hid_kbd_t *)p_kbd
            };
    
            ret = app_usbd_core_setup_data_handler_set(NRF_DRV_USBD_EPOUT0, &desc);
        }
        CRITICAL_REGION_EXIT();
    
        return ret;
    }

    I will check "usbd_hid_composite" also according to your suggestion.

    But It would be good if the problem is solved in UBBD example.

    Best Regards,

    Steven

Children
No Data
Related