nRF52840 only: Module for easy support for any USB device configuration. More...
Modules | |
USBD Class Base module | |
nRF52840 only: The base for any class instance is defined in this module. | |
USB Device high level library core module | |
nRF52840 only: Core module that manages current USB state and process device requests. | |
USB standard descriptors | |
nRF52840 only: Module with types definitions used for standard descriptors. | |
USB Device library configuration | |
USB standard requests | |
nRF52840 only: Module with types definitions used for standard requests processing. | |
USBD string descriptors | |
nRF52840 only: USBD string descriptors management. | |
USB Device high level library variable types definition | |
nRF52840 only: All types used by USB Device high level library are defined here. This helps to avoid cross referencing into types in different files. | |
USB AUDIO class | |
nRF52840 only: Module with types, definitions, and API used by USB Audio class. | |
USB CDC ACM class | |
nRF52840 only: Module with types, definitions and API used by CDC ACM class. | |
USB HID class | |
nRF52840 only: Module with generic HID event data processing. | |
USB MSC class | |
nRF52840 only: Module with types, definitions, and API used by the USB MSC class. | |
Functions | |
ret_code_t | app_usbd_init (void) |
USB library initialization. More... | |
ret_code_t | app_usbd_uninit (void) |
USB library un-initialization. More... | |
void | app_usbd_enable (void) |
Enable USBD. More... | |
void | app_usbd_disable (void) |
Disable USBD. More... | |
void | app_usbd_start (void) |
Start USB to work. More... | |
void | app_usbd_stop (void) |
Stop USB to work. More... | |
ret_code_t | app_usbd_class_append (app_usbd_class_inst_t const *p_cinst) |
Add class instance. More... | |
ret_code_t | app_usbd_class_remove (app_usbd_class_inst_t const *p_cinst) |
Remove class instance. More... | |
ret_code_t | app_usbd_class_remove_all (void) |
Remove all class instances. More... | |
ret_code_t | app_usbd_ep_handler_set (app_usbd_class_inst_t const *p_cinst, nrf_drv_usbd_ep_t ep, app_usbd_ep_event_handler_t handler) |
Change endpoint handler. More... | |
ret_code_t | app_usbd_class_sof_register (app_usbd_class_inst_t const *p_cinst) |
Register class instance as the one that requires SOF events. More... | |
ret_code_t | app_usbd_class_sof_unregister (app_usbd_class_inst_t const *p_cinst) |
Unregister class instance from SOF processing instances list. More... | |
const void * | app_usbd_class_descriptor_find (app_usbd_class_inst_t const *const p_cinst, uint8_t desc_type, uint8_t desc_index, size_t *p_desc_len) |
Function finds a given descriptor type in class descriptors payload. More... | |
ret_code_t | app_usbd_interface_std_req_handle (app_usbd_class_inst_t const *p_cinst, app_usbd_setup_evt_t const *p_setup_ev) |
Standard interface request handle. More... | |
ret_code_t | app_usbd_endpoint_std_req_handle (app_usbd_class_inst_t const *p_cinst, app_usbd_setup_evt_t const *p_setup_ev) |
Standard endpoint request handle. More... | |
ret_code_t | app_usbd_req_std_set_interface (app_usbd_class_inst_t const *const p_cinst, app_usbd_setup_evt_t const *const p_setup_ev) |
Standard interface set request handle. More... | |
Iterate through classes lists | |
Functions that helps to iterate through internally chained classes. | |
app_usbd_class_inst_t const * | app_usbd_class_first_get (void) |
Get first class instance in the list. More... | |
static app_usbd_class_inst_t const * | app_usbd_class_next_get (app_usbd_class_inst_t const *const p_cinst) |
Get next instance in the list. More... | |
app_usbd_class_inst_t const * | app_usbd_class_sof_first_get (void) |
Get first instance in SOF list. More... | |
static app_usbd_class_inst_t const * | app_usbd_class_sof_next_get (app_usbd_class_inst_t const *const p_cinst) |
Get next instance in the SOF list. More... | |
Communicate with interfaces, endpoints and instances inside usbd library | |
ret_code_t | app_usbd_iface_call (uint8_t iface, app_usbd_complex_evt_t const *const p_event) |
Call interface event handler. More... | |
ret_code_t | app_usbd_ep_call (nrf_drv_usbd_ep_t ep, app_usbd_complex_evt_t const *const p_event) |
Call endpoint event handler. More... | |
void | app_usbd_all_call (app_usbd_complex_evt_t const *const p_event) |
Auxiliary function that process event by every instance in the list. More... | |
ret_code_t | app_usbd_all_until_served_call (app_usbd_complex_evt_t const *const p_event) |
Call interface event handlers and stop when served. More... | |
nRF52840 only: Module for easy support for any USB device configuration.
This module manages class instances that would create the USB device, manages endpoints and interfaces transactions.
void app_usbd_all_call | ( | app_usbd_complex_evt_t const *const | p_event | ) |
Auxiliary function that process event by every instance in the list.
This function ignores the result of called handler.
p_event | Event to pass to every instance |
ret_code_t app_usbd_all_until_served_call | ( | app_usbd_complex_evt_t const *const | p_event | ) |
Call interface event handlers and stop when served.
Call event handlers from instances as long as we get result different than NRF_ERROR_NOT_SUPPORTED
[in] | p_event | Event structure to send |
ret_code_t app_usbd_class_append | ( | app_usbd_class_inst_t const * | p_cinst | ) |
Add class instance.
This function connects given instance into internal class instance chain and into all required endpoints. The instance event handler would be connected into endpoint by default, but this can be overwritten by app_usbd_ep_handler_set.
After successful attachment APP_USBD_EVT_INST_APPEND would be passed to class instance.
[in,out] | p_cinst | Instance to connect. Chain data would be written into writable instance data. |
const void* app_usbd_class_descriptor_find | ( | app_usbd_class_inst_t const *const | p_cinst, |
uint8_t | desc_type, | ||
uint8_t | desc_index, | ||
size_t * | p_desc_len | ||
) |
Function finds a given descriptor type in class descriptors payload.
[in] | p_cinst | Instance of a class |
[in] | desc_type | Descriptor type (APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR) |
[in] | desc_index | Descriptor index (APP_USBD_SETUP_STDREQ_GET_DESCRIPTOR) |
[out] | p_desc_len | Descriptor length |
app_usbd_class_inst_t const* app_usbd_class_first_get | ( | void | ) |
Get first class instance in the list.
Get first instance from the list of active class instances. That instance may be used then in app_usbd_class_next_get function.
|
inlinestatic |
Get next instance in the list.
Get the next instance from the list of active instances. Used to iterate through all instances.
[in] | p_cinst | The current instance from with next one is required. |
ret_code_t app_usbd_class_remove | ( | app_usbd_class_inst_t const * | p_cinst | ) |
Remove class instance.
Instance is removed from instance chain. Instance and event handlers are removed also from endpoints. Endpoints used by by the class instance are left disabled.
p_cinst | Instance pointer to remove. |
NRF_SUCCESS | Instance successfully removed. |
NRF_ERROR_NOT_FOUND | Instance not found in the instance chain. |
ret_code_t app_usbd_class_remove_all | ( | void | ) |
Remove all class instances.
This function basically calls app_usbd_class_remove on instances chain as long as there is any element left.
app_usbd_class_inst_t const* app_usbd_class_sof_first_get | ( | void | ) |
Get first instance in SOF list.
Start iteration through the list of instances that requires SOF event processing.
|
inlinestatic |
Get next instance in the SOF list.
Get the next instance from the list of instances requiring SOF event processing. Used to iterate through all SOF instances.
p_cinst | The current instance from with next one is required. |
ret_code_t app_usbd_class_sof_register | ( | app_usbd_class_inst_t const * | p_cinst | ) |
Register class instance as the one that requires SOF events.
This function should be called in reaction on APP_USBD_EVT_INST_APPEND event. Connect the class instance to the list of instances that requires SOF processing. If none of the appended instances requires SOF event - it is disabled.
p_cinst | Instance that requires SOF event. |
NRF_SUCCESS | Instance linked into SOF processing list. |
ret_code_t app_usbd_class_sof_unregister | ( | app_usbd_class_inst_t const * | p_cinst | ) |
Unregister class instance from SOF processing instances list.
Every class that calls app_usbd_class_sof_register have to call also unregistering function in reaction to APP_USBD_EVT_INST_REMOVE event.
p_cinst | Instance to be unregistered from SOF event processing list. |
NRF_SUCCESS | Instance linked into SOF processing list. |
NRF_ERROR_NOT_FOUND | Instance not found in the SOF processing list. |
void app_usbd_disable | ( | void | ) |
Disable USBD.
Disabled USDB peripheral cannot be accessed but also stops requesting High Frequency clock and releases power regulator.
void app_usbd_enable | ( | void | ) |
Enable USBD.
USBD is enabled and starts requiring High Frequency Clock and power regulator.
ret_code_t app_usbd_endpoint_std_req_handle | ( | app_usbd_class_inst_t const * | p_cinst, |
app_usbd_setup_evt_t const * | p_setup_ev | ||
) |
Standard endpoint request handle.
[in] | p_cinst | Instance of a class |
[in] | p_setup_ev | Setup event |
ret_code_t app_usbd_ep_call | ( | nrf_drv_usbd_ep_t | ep, |
app_usbd_complex_evt_t const *const | p_event | ||
) |
Call endpoint event handler.
Call event handler for the selected endpoint.
[in] | ep | Endpoint number |
[in] | p_event | Event structure to send |
ret_code_t app_usbd_ep_handler_set | ( | app_usbd_class_inst_t const * | p_cinst, |
nrf_drv_usbd_ep_t | ep, | ||
app_usbd_ep_event_handler_t | handler | ||
) |
Change endpoint handler.
This function may be called for the endpoint only if the class instance is already properly attached by the app_usbd_class_append function.
The endpoint event handler function can be only overwritten by the class instance that was connected into the endpoint.
[in] | p_cinst | Instance of a class that wish to set new event handler. It has to match currently configured instance for the selected endpoint. In other situation error would be returned. |
[in] | ep | Endpoint address to configure. |
[in] | handler | Event handler function to set. |
NRF_SUCCESS | New handler successfully set |
NRF_ERROR_INVALID_PARAM | p_cinst is not the same as currently set for the endpoint |
ret_code_t app_usbd_iface_call | ( | uint8_t | iface, |
app_usbd_complex_evt_t const *const | p_event | ||
) |
Call interface event handler.
Call event handler for selected interface.
[in] | iface | Target interface number |
[in] | p_event | Event structure to send |
ret_code_t app_usbd_init | ( | void | ) |
USB library initialization.
Call this function before any configuration or class attachment. USBD peripheral would be ready to accept commands, and library would be ready, but it would not be connected to the bus. Call app_usbd_enable to enable USBD communication with the host.
ret_code_t app_usbd_interface_std_req_handle | ( | app_usbd_class_inst_t const * | p_cinst, |
app_usbd_setup_evt_t const * | p_setup_ev | ||
) |
Standard interface request handle.
[in] | p_cinst | Instance of a class |
[in] | p_setup_ev | Setup event |
ret_code_t app_usbd_req_std_set_interface | ( | app_usbd_class_inst_t const *const | p_cinst, |
app_usbd_setup_evt_t const *const | p_setup_ev | ||
) |
Standard interface set request handle.
[in] | p_cinst | Instance of a class |
[in] | p_setup_ev | Setup event |
void app_usbd_start | ( | void | ) |
Start USB to work.
Start library to work. Enable interrupts. Enable USB pull-ups. After calling this function USB device is visible to a HOST.
void app_usbd_stop | ( | void | ) |
Stop USB to work.
This function disables interrupts and USB pull-ups. The peripheral itself is left enabled so it can be programmed, but it a HOST sees it as a peripheral disconnection.
ret_code_t app_usbd_uninit | ( | void | ) |
USB library un-initialization.