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

Header file app_usbd_cdc_acm.h

Hi everyone,

In the file header "app_usbd_cdc_acm.h" I notice this function:

/**
* @brief Helper function to get class instance from CDC ACM class.
*
* @param[in] p_cdc_acm CDC ACM class instance (defined by @ref APP_USBD_CDC_ACM_GLOBAL_DEF).
*
* @return Base class instance.
*/
static inline app_usbd_class_inst_t const *
app_usbd_cdc_acm_class_inst_get(app_usbd_cdc_acm_t const * p_cdc_acm)
{
return &p_cdc_acm->base;
}

What does it means " Base class instance"? What's a base class instance? I don't understand what the function is defined for.

Can anyone help me?

BR

Parents
  • So if I have not misunderstood the app_usbd_cdc_acm_class_inst_get function is used to pass from a structure containing all the information on the CDC ACM class to an instance pointer which instead contains the pointers to the functions used and information relating to the addresses of the endpoints whose class has access. Is that so?

    Doing this is possible to use for example the app_usbd_class_append regardless of class. Is it right?

    Thanks 

    BR

    Alex

Reply
  • So if I have not misunderstood the app_usbd_cdc_acm_class_inst_get function is used to pass from a structure containing all the information on the CDC ACM class to an instance pointer which instead contains the pointers to the functions used and information relating to the addresses of the endpoints whose class has access. Is that so?

    Doing this is possible to use for example the app_usbd_class_append regardless of class. Is it right?

    Thanks 

    BR

    Alex

Children
  • Hi Alex

    Exactly. It allows the USB driver to treat all the instances the same, even though they might have widely different implementations based on which USB class they are implementing. 

    This is similar to how object oriented languages might have a base class or interface that defines the API of an object, and then you can have various implementations with different functionality that can all be accessed the same way since they share a common API. 

    Best regards
    Torbjørn

Related