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

Error adding USBD project

  • I want to add USBD function in other projects, but there is an error:“..\..\..\..\..\..\components\libraries\usbd\class\hid\generic\app_usbd_hid_generic.c(257): error:  #20: identifier "ret" is undefined”

Parents Reply
  • Those CRITICAL_REGION macros contain a "{" and a "}" character each, thus "ret" is outside scope at the return statement.

    Fix is really simple, just declare it early:

    ret_code_t ret;
    
    CRITICAL_REGION_ENTER();
    
    ret = app_usbd_ep_transfer(ep_addr, &transfer);
    if (ret == NRF_SUCCESS)
    {
    app_usbd_hid_state_flag_set(&p_generic_ctx->hid_ctx,
    APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS);
    }
    
    CRITICAL_REGION_EXIT();
    
    return ret;

Children
Related