Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

USB CCID class with nordic nRF52840

I am developing USB CCID driver class for nordic nRF52840. I used USB CDC-ACM class as reference and tried to implement for USB CCID. I have developed the device descriptor for it.

USB CCID class has 1 interface and 3 endpoints(1 for interrupt, 1 for bulk IN and 1 for bulk OUT). Now the windows is detecting as Microsoft Usbccid smart card reader(WUDF)

In modify the app_usbd_ccid_internal.h, i need to know modification to be done in 

1. class instance data (app_usbd_ccid_inst_t)

2. CCID class specific request handled via control endpoint (app_usbd_ccid_req_t)

3.  ccid context (app_usbd_ccid_ctx_t)

I have attached my app_usbd_ccid_internal.h file with tis for refrence.

app_usbd_ccid_internal.h

  • Hi,

     

    Mohammad said:
    <info> usbd_ccid: ccid_event_handler = 5
    <info> usbd_ccid: setup_event_handler
    <info> usbd_ccid: setup_req_std_in
    <info> usbd_ccid: NRF_ERROR_NOT_SUPPORTED

     What is '5' in this case? Is that the p_event->app_evt.type? If yes, then that is the setup APP_USBD_EVT_DRV_SETUP, which should handle class specific requests. I do not have extensive knowledge about CCID, unfortunately, so I cannot state what should be implemented for this specific USB class.

     

    Mohammad said:
    But i have problem that the program stucks in infinte loop at this part

    while (app_usbd_event_queue_process())
    {
    /* Nothing to do */
    }

     Is it stuck inside there, or just not processing any events? It sounds like there's some CCID specific events that are not implemented?

     

    Kind regards,

    Håkon

  • Hi,

    Yes, it is  p_event->app_evt.type.

    NRF_LOG_INFO("ccid_event_handler = %d", p_event->app_evt.type);

     Is it stuck inside there, or just not processing any events? It sounds like there's some CCID specific events that are not implemented?

    Yes, it processes the events.

  • Mohammad said:

     Is it stuck inside there, or just not processing any events? It sounds like there's some CCID specific events that are not implemented?

    Yes, it processes the events.

    Have you checked if the CCID class documentation has specific setup requests? Because it looks like there are unhandled/unimplemented cases in your implementation of the class.

     

    Kind regards,

    Håkon

  • Hi,

    I have a problem with static ret_code_t setup_req_std_in(app_usbd_class_inst_t const * p_inst,
    app_usbd_setup_evt_t const * p_setup_ev)

    static ret_code_t setup_req_std_in(app_usbd_class_inst_t const * p_inst,
    app_usbd_setup_evt_t const * p_setup_ev)
    {
      NRF_LOG_INFO("setup_req_std_in ");

      /* Only Get Descriptor standard IN request is supported by CCID class */
      if ((app_usbd_setup_req_rec(p_setup_ev->setup.bmRequestType) == APP_USBD_SETUP_REQREC_DEVICE) &&
    (p_setup_ev->setup.bRequest == APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR)) 
      {
         NRF_LOG_INFO("Inside setup_req_std_in ");

         size_t dsc_len = 0;
         size_t max_size;

         uint8_t * p_trans_buff = app_usbd_core_setup_transfer_buff_get(&max_size);

         /* Try to find descriptor in class internals*/
         ret_code_t ret = app_usbd_class_descriptor_find(p_inst, p_setup_ev->setup.wValue.hb,
    p_setup_ev->setup.wValue.lb, p_trans_buff, &dsc_len);

          if (ret != NRF_ERROR_NOT_FOUND) 
         {
              ASSERT(dsc_len < NRF_DRV_USBD_EPSIZE);
              return app_usbd_core_setup_rsp(&(p_setup_ev->setup), p_trans_buff, dsc_len);
          }
       }

       NRF_LOG_INFO("NRF_ERROR_NOT_SUPPORTED");
       return NRF_ERROR_NOT_SUPPORTED;
    }

    ret_code_t ret = app_usbd_class_descriptor_find(p_inst,p_setup_ev->setup.wValue.hb,p_setup_ev->setup.wValue.lb,p_trans_buff,&dsc_len);

    It returns ret = NRF_ERROR_NOT_FOUND;

    In the above p_setup_ev->setup.wValue.hb = 6; (desc_type)

    p_setup_ev->setup.wValue.lb = 0;

    p_trans_buff = 26 03 48 00 53 00 49 00 44 00 36 (Here I dont now the actual length of p_trans_buff)

    dsc_len = 0;

    I find the above value by debugging the code.

    Inside the app_usbd_class_descriptor_find() function , the value of type as follows,

    4, 33, 5, 5, 5 (4 for interface, 33 for CCID, 5 for endpoint)

    So if(type == desc_type) condition is not satisfied. 

    t returns ret = NRF_ERROR_NOT_FOUND; from app_usbd_class_descriptor_find

    Help me to solve this issue

  • That can potentially happen (ie: the request wasn't for this specific descriptor), which is the reason why all class implementations forward that to the app_usbd_core.c::app_usbd_core_setup_rsp().

    It is hard to tell what happens here, as I do not have all the details. What is the expected vs. actual behavior that you're seeing?

     

    Kind regards,

    Håkon

Related