nRF52840 only: The base for any class instance is defined in this module. More...
Data Structures | |
struct | app_usbd_class_ep_conf_t |
Endpoint configuration. More... | |
struct | app_usbd_class_iface_conf_t |
Interface configuration. More... | |
struct | app_usbd_class_data_t |
Instance variable data. More... | |
struct | app_usbd_class_methods_t |
Class interface function set. More... | |
struct | app_usbd_class_inst_s |
The instance structure itself. More... | |
Macros | |
#define | APP_USBD_CLASS_INSTANCE_TYPE(type_name) CONCAT_2(type_name, _t) |
USBD instance of class mnemonic. More... | |
#define | APP_USBD_CLASS_DATA_TYPE(type_name) CONCAT_2(type_name, _data_t) |
USBD data for instance class mnemonic. More... | |
#define | APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC(type) type class_part; |
Declare class specific member of class instance. More... | |
#define | APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC_NONE |
Used if there is no class specific configuration. More... | |
#define | APP_USBD_CLASS_DATA_SPECIFIC_DEC(type) APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC(type) |
Declare class specific member of class data. More... | |
#define | APP_USBD_CLASS_DATA_SPECIFIC_DEC_NONE APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC_NONE |
Used if there is no class specific data. More... | |
#define | APP_USBD_CLASS_INSTANCE_TYPEDEF(type_name, interfaces_configs, class_config_dec) |
Instance structure declaration. More... | |
#define | APP_USBD_CLASS_DATA_TYPEDEF(type_name, class_data_dec) |
Writable data structure declaration. More... | |
#define | APP_USBD_CLASS_TYPEDEF(type_name, interface_configs, class_config_dec, class_data_dec) |
Declare all data types required by the class instance. More... | |
#define | APP_USBD_CLASS_FORWARD(type_name) union CONCAT_2(type_name, _u) |
Forward declaration of type defined by APP_USBD_CLASS_TYPEDEF. More... | |
#define | APP_USBD_CLASS_INSTANCE_INITVAL(p_ram_data,class_methods,interfaces_configs,class_config_part) |
Generate the initialization data for. More... | |
#define | APP_USBD_CLASS_INST_DEF(instance_name,type_name,class_methods,interfaces_configs,class_config_part) |
Define the base class instance. More... | |
#define | APP_USBD_CLASS_INST_GLOBAL_DEF(instance_name,type_name,class_methods,interfaces_configs,class_config_part) |
Define the base class instance in global scope. More... | |
#define | APP_USBD_CLASS_GET_SPECIFIC_CONFIG(p_inst) (&((p_inst)->specific.class_part)) |
Access class specific configuration. More... | |
#define | APP_USBD_CLASS_GET_SPECIFIC_DATA(p_inst) (&(((p_inst)->specific.p_data)->class_part)) |
Access class specific data. More... | |
#define | APP_USBD_CLASS_BASE_INSTANCE(p_inst) (&((p_inst)->base)) |
Macro to get base instance from class specific instance. More... | |
Functions | |
static uint8_t | app_usbd_class_iface_count_get (app_usbd_class_inst_t const *const p_inst) |
Get total number of interfaces. | |
static app_usbd_class_iface_conf_t const * | app_usbd_class_iface_get (app_usbd_class_inst_t const *const p_inst, uint8_t iface_idx) |
Interface accessing function. More... | |
static uint8_t | app_usbd_class_iface_number_get (app_usbd_class_iface_conf_t const *const p_iface) |
Get interface number. More... | |
static uint8_t | app_usbd_class_iface_ep_count_get (app_usbd_class_iface_conf_t const *const p_iface) |
Get number of endpoints in interface. More... | |
static app_usbd_class_ep_conf_t const * | app_usbd_class_iface_ep_get (app_usbd_class_iface_conf_t const *const p_iface, uint8_t ep_idx) |
Interface Endpoint accessing function. More... | |
static uint8_t | app_usbd_class_iface_ep_idx_get (app_usbd_class_iface_conf_t const *const p_iface, nrf_drv_usbd_ep_t ep_address) |
Translate endpoint address to class index. More... | |
static nrf_drv_usbd_ep_t | app_usbd_class_ep_address_get (app_usbd_class_ep_conf_t const *p_ep) |
Get the selected endpoint address. More... | |
static app_usbd_class_data_t * | app_usbd_class_data_access (app_usbd_class_inst_t const *const p_inst) |
Get the pointer to the writable instance data. More... | |
Internal macros for argument mapping | |
Functions to be used as a mapping macro for MACRO_MAP, MACRO_MAP_FOR or MACRO_MAP_FOR_PARAM | |
#define | APP_USBD_CLASS_CONF_IFACE_EP_COUNT_(iface_config) (NUM_VA_ARGS(BRACKET_EXTRACT(iface_config)) - 1) |
Count the number of endpoints in given configuration. More... | |
#define | APP_USBD_CLASS_CONF_IFACE_EP_PLUS_COUNT_(iface_config) + APP_USBD_CLASS_CONF_IFACE_EP_COUNT_(iface_config) |
Adds the number of endpoints in given config to the current value. More... | |
#define | APP_USBD_CLASS_IFACE_EP_EXTRACT_(iface_config) |
Create variable for endpoint. More... | |
#define | APP_USBD_CLASS_IFACE_EP_EXTRACT_0(iface_nr) |
Auxiliary macro for APP_USBD_CLASS_IFACE_EP_EXTRACT_. More... | |
#define | APP_USBD_CLASS_IFACE_EP_EXTRACT_1(...) APP_USBD_CLASS_IFACE_EP_EXTRACT_1_(__VA_ARGS__) |
Auxiliary macro for APP_USBD_CLASS_IFACE_EP_EXTRACT_. More... | |
#define | APP_USBD_CLASS_IFACE_EP_EXTRACT_1_(iface_nr,...) MACRO_MAP_REC(PARAM_CBRACE, __VA_ARGS__) |
#define | APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_(iface_config, N, iface_configs) |
Generate configuration for single interface. More... | |
#define | APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_x(iface_config, N, iface_configs) [N] = !!!iface_config!!! |
#define | APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_0(N, iface_configs, iface_nr) APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_0_(N, iface_configs, iface_nr) |
Auxiliary macro for APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_. More... | |
#define | APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_0_(N, iface_configs, iface_nr) { .number = iface_nr, .ep_cnt = 0, .ep_offset = 0 }, |
#define | APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_1(N, iface_configs,...) APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_1_(N, iface_configs, __VA_ARGS__) |
Auxiliary macro for APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_. More... | |
#define | APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_1_(N, iface_configs, iface_nr,...) |
Macros that uses mapping macros internally | |
Auxiliary macros that uses mapping macros to make some calculations or realize other functionality. Mapped here for easier unit testing and to hide complex mapping functions calling. | |
#define | APP_USBD_CLASS_CONF_TOTAL_EP_COUNT(iface_configs) (0 MACRO_MAP(APP_USBD_CLASS_CONF_IFACE_EP_PLUS_COUNT_, BRACKET_EXTRACT(iface_configs))) |
Count total number of endpoints. More... | |
#define | APP_USBD_CLASS_CONF_TOTAL_EP_COUNT_N(N, iface_configs) (0 MACRO_MAP_N(N, APP_USBD_CLASS_CONF_IFACE_EP_PLUS_COUNT_, BRACKET_EXTRACT(iface_configs))) |
Count total number of endpoint up-to interface index. More... | |
#define | APP_USBD_CLASS_IFACES_CONFIG_EXTRACT(iface_configs) |
Extract configurations for interfaces. More... | |
#define | APP_USBD_CLASS_IFACES_EP_EXTRACT(iface_configs) MACRO_MAP(APP_USBD_CLASS_IFACE_EP_EXTRACT_, BRACKET_EXTRACT(iface_configs)) |
Extract all endpoints. More... | |
nRF52840 only: The base for any class instance is defined in this module.
Any class instance must start from base class instance structure. This makes them compatible with USBD library independently of the implementation details.
#define APP_USBD_CLASS_BASE_INSTANCE | ( | p_inst | ) | (&((p_inst)->base)) |
Macro to get base instance from class specific instance.
This macro may be used on class specific instance to get base instance that can be processed by base instance access functions. Class specific instance can be just casted to class base instance, but then we would totally lost type safety.
A little more safe is to use pointer to base member of class instance. This would generate an error when used on any variable that has no base member and would generate also error if this base member is wrong type.
#define APP_USBD_CLASS_CONF_IFACE_EP_COUNT_ | ( | iface_config | ) | (NUM_VA_ARGS(BRACKET_EXTRACT(iface_config)) - 1) |
Count the number of endpoints in given configuration.
Config should be given as a interface configuration in a brackets:
Number of endpoints may vary from 0 to a few (technically up to 16, but it seems not to make sense to use more than 4). Interface number is always present.
iface_config | Single interface configuration (in brackets) |
#define APP_USBD_CLASS_CONF_IFACE_EP_PLUS_COUNT_ | ( | iface_config | ) | + APP_USBD_CLASS_CONF_IFACE_EP_COUNT_(iface_config) |
Adds the number of endpoints in given config to the current value.
This is basically APP_USBD_CLASS_CONF_IFACE_EP_COUNT_ with plus sign added.
iface_config | See parameters documentation in APP_USBD_CLASS_CONF_IFACE_EP_COUNT_ |
#define APP_USBD_CLASS_CONF_TOTAL_EP_COUNT | ( | iface_configs | ) | (0 MACRO_MAP(APP_USBD_CLASS_CONF_IFACE_EP_PLUS_COUNT_, BRACKET_EXTRACT(iface_configs))) |
Count total number of endpoints.
iface_configs | List of interface configurations like explained in documentation for APP_USBD_CLASS_INSTANCE_TYPEDEF |
#define APP_USBD_CLASS_CONF_TOTAL_EP_COUNT_N | ( | N, | |
iface_configs | |||
) | (0 MACRO_MAP_N(N, APP_USBD_CLASS_CONF_IFACE_EP_PLUS_COUNT_, BRACKET_EXTRACT(iface_configs))) |
Count total number of endpoint up-to interface index.
The version of APP_USBD_CLASS_CONF_TOTAL_EP_COUNT macro which takes the number of interfaces to analyze.
N | Number of interfaces to analyze |
iface_configs | List of interface configurations like explained in documentation for APP_USBD_CLASS_INSTANCE_TYPEDEF |
#define APP_USBD_CLASS_DATA_SPECIFIC_DEC | ( | type | ) | APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC(type) |
Declare class specific member of class data.
type | Type of the attached class data. |
#define APP_USBD_CLASS_DATA_SPECIFIC_DEC_NONE APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC_NONE |
Used if there is no class specific data.
This constant can be used if there is no specific writable data inside created instance
USBD data for instance class mnemonic.
The mnemonic of the variable type that holds writable part of the class instance.
type_name | The name of the instance without _t postfix |
#define APP_USBD_CLASS_DATA_TYPEDEF | ( | type_name, | |
class_data_dec | |||
) |
Writable data structure declaration.
The macro that declares a variable type that would be used to store given class writable data. Writable data contains base part of the type app_usbd_class_data_t followed by class specific data.
type_name | The name of the type without _t postfix. |
class_data_dec | Result of the macro APP_USBD_CLASS_DATA_SPECIFIC_DEC or APP_USBD_CLASS_DATA_SPECIFIC_DEC_NONE |
#define APP_USBD_CLASS_FORWARD | ( | type_name | ) | union CONCAT_2(type_name, _u) |
Forward declaration of type defined by APP_USBD_CLASS_TYPEDEF.
type_name | The name of the type without _t postfix. |
#define APP_USBD_CLASS_GET_SPECIFIC_CONFIG | ( | p_inst | ) | (&((p_inst)->specific.class_part)) |
Access class specific configuration.
Macro that returns class specific configuration.
[in] | p_inst | Instance pointer |
#define APP_USBD_CLASS_GET_SPECIFIC_DATA | ( | p_inst | ) | (&(((p_inst)->specific.p_data)->class_part)) |
Access class specific data.
[in] | p_inst | Instance pointer |
#define APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_ | ( | iface_config, | |
N, | |||
iface_configs | |||
) |
Generate configuration for single interface.
This macro extract configuration for single interface. The configuration is inside curly brackets and comma is added on the end. This mean it can be directly used to init array of interface configurations.
iface_config | Single interface configuration |
N | Currently processed configuration |
iface_configs | All interfaces configuration in brackets |
#define APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_0 | ( | N, | |
iface_configs, | |||
iface_nr | |||
) | APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_0_(N, iface_configs, iface_nr) |
Auxiliary macro for APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_.
This macro is called when interface has no endpoints
#define APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_1 | ( | N, | |
iface_configs, | |||
... | |||
) | APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_1_(N, iface_configs, __VA_ARGS__) |
Auxiliary macro for APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_.
This macro is called when interface has at last one endpoint
#define APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_1_ | ( | N, | |
iface_configs, | |||
iface_nr, | |||
... | |||
) |
#define APP_USBD_CLASS_IFACE_EP_EXTRACT_ | ( | iface_config | ) |
Create variable for endpoint.
Extract endpoints given interface configuration
This macro gets single endpoint configuration and extracts all the endpoints. It also adds comma on the end of extracted endpoints. This way when this macro is called few times it generates nice list of all endpoints that may be used to array initialization.
iface_config | Single interface configuration in brackets. The format should be similar like described in APP_USBD_CLASS_CONF_IFACE_EP_COUNT_. |
#define APP_USBD_CLASS_IFACE_EP_EXTRACT_0 | ( | iface_nr | ) |
Auxiliary macro for APP_USBD_CLASS_IFACE_EP_EXTRACT_.
This macro is called when interface has no endpoints
#define APP_USBD_CLASS_IFACE_EP_EXTRACT_1 | ( | ... | ) | APP_USBD_CLASS_IFACE_EP_EXTRACT_1_(__VA_ARGS__) |
Auxiliary macro for APP_USBD_CLASS_IFACE_EP_EXTRACT_.
This macro is called when interface has at least one endpoint
#define APP_USBD_CLASS_IFACES_CONFIG_EXTRACT | ( | iface_configs | ) |
Extract configurations for interfaces.
This macro extracts the configurations for every interface. Basically uses the APP_USBD_CLASS_IFACE_CONFIG_EXTRACT_ macro on every configuration found.
This should generate interface configuration initialization data in comma separated initializers in curly braces.
iface_configs | List of interface configurations like explained in documentation for APP_USBD_CLASS_INSTANCE_TYPEDEF |
#define APP_USBD_CLASS_IFACES_EP_EXTRACT | ( | iface_configs | ) | MACRO_MAP(APP_USBD_CLASS_IFACE_EP_EXTRACT_, BRACKET_EXTRACT(iface_configs)) |
Extract all endpoints.
Macro that extracts all endpoints from every interface
iface_configs | List of interface configurations like explained in documentation for APP_USBD_CLASS_INSTANCE_TYPEDEF |
#define APP_USBD_CLASS_INST_DEF | ( | instance_name, | |
type_name, | |||
class_methods, | |||
interfaces_configs, | |||
class_config_part | |||
) |
Define the base class instance.
Macro that defines whole instance variable and fill it with initialization data.
The tricky part is class_config_part
. The configuration data here has to be placed inside brackets. Then any type of values can be used depending on the type used in APP_USBD_CLASS_TYPEDEF. If instance does not has any specyfic data, use just empty bracket here.
If the type of instance configuration is simple type, just provide initialization value:
If the type of instance configuration is structure, provide initialization value for the whole structure:
instance_name | The name of created instance variable. It would be constant variable and its type would be app_usbd_class_inst_t. |
type_name | The name of the variable type. It has to be the same type that was passed to APP_USBD_CLASS_TYPEDEF |
class_methods | Class unified interface. |
interfaces_configs | The same configuration data that the one passed to APP_USBD_CLASS_TYPEDEF |
class_config_part | Configuration data to the type that was declared by class_data_dec when calling APP_USBD_CLASS_TYPEDEF. Configuration data has to be provided in brackets. It would be extracted from brackets and placed in initialization part of configuration structure. See detailed description of this macro for more informations. |
#define APP_USBD_CLASS_INST_GLOBAL_DEF | ( | instance_name, | |
type_name, | |||
class_methods, | |||
interfaces_configs, | |||
class_config_part | |||
) |
Define the base class instance in global scope.
This is the same macro like APP_USBD_CLASS_INST_DEF but it creates the instance without static keyword.
instance_name | See documentation for APP_USBD_CLASS_INST_DEF |
type_name | See documentation for APP_USBD_CLASS_INST_DEF |
class_methods | See documentation for APP_USBD_CLASS_INST_DEF |
interfaces_configs | See documentation for APP_USBD_CLASS_INST_DEF |
class_config_part | See documentation for APP_USBD_CLASS_INST_DEF |
#define APP_USBD_CLASS_INSTANCE_INITVAL | ( | p_ram_data, | |
class_methods, | |||
interfaces_configs, | |||
class_config_part | |||
) |
Generate the initialization data for.
Macro that generates the initialization data for instance.
p_ram_data | Pointer to writable instance data structure |
class_methods | Class methods |
interfaces_configs | Exactly the same interface config data that in APP_USBD_CLASS_INSTANCE_TYPEDEF |
class_config_part | Configuration part. The data should be inside brackets. Any data here would be removed from brackets and then put as an initialization data for class_part member of instance structure. |
#define APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC | ( | type | ) | type class_part; |
Declare class specific member of class instance.
type | Type of the attached class configuration. |
#define APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC_NONE |
Used if there is no class specific configuration.
This constant can be used if there is no specific configuration inside created instance
#define APP_USBD_CLASS_INSTANCE_TYPE | ( | type_name | ) | CONCAT_2(type_name, _t) |
USBD instance of class mnemonic.
Macro that generates mnemonic for the name of the structure that describes instance for selected class.
type_name | The name of the instance without _t postfix |
#define APP_USBD_CLASS_INSTANCE_TYPEDEF | ( | type_name, | |
interfaces_configs, | |||
class_config_dec | |||
) |
Instance structure declaration.
The macro that declares a variable type that would be used to store given class instance. Class instance stores all the data from app_usbd_class_inst_t and overlaid data for specified class.
The structure of interface configuration data:
type_name | The name of the instance without _t postfix. |
interfaces_configs | List of interface configurations like explained above. |
class_config_dec | Result of the macro APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC or APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC_NONE |
#define APP_USBD_CLASS_TYPEDEF | ( | type_name, | |
interface_configs, | |||
class_config_dec, | |||
class_data_dec | |||
) |
Declare all data types required by the class instance.
Macro that declares data type first and then instance type.
type_name | The name of the type without _t postfix. |
interface_configs | List of interface configurations like in APP_USBD_CLASS_INSTANCE_TYPEDEF. |
class_config_dec | Result of the macro APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC or APP_USBD_CLASS_INSTANCE_SPECIFIC_DEC_NONE |
class_data_dec | Result of the macro APP_USBD_CLASS_DATA_SPECIFIC_DEC or APP_USBD_CLASS_DATA_SPECIFIC_DEC_NONE |
|
inlinestatic |
Get the pointer to the writable instance data.
p_inst | Instance pointer |
|
inlinestatic |
Get the selected endpoint address.
p_ep | Endpoint configuration structure |
|
inlinestatic |
Get number of endpoints in interface.
p_iface | Pointer to interface structure |
|
inlinestatic |
Interface Endpoint accessing function.
p_iface | Interface configuration pointer |
ep_idx | Endpoint index |
|
inlinestatic |
Translate endpoint address to class index.
p_iface | Interface configuration pointer |
ep_address | Endpoint address |
|
inlinestatic |
Interface accessing function.
Get interface pointer. Interfaces creates continuous array in the memory so it is possible to get interface with index 0 and the just iterate to the next one.
p_inst | Pointer to the class instance |
iface_idx | Index of the instance to get. This is not the interface identifier. Technically it is the index of the interface in the class description array. |
|
inlinestatic |
Get interface number.
p_iface | Pointer to interface structure |