nRF5 SDK v17.1.0
Data Structures | Macros | Typedefs | Enumerations | Functions
USB Device high level library core module

nRF52840 only: Core module that manages current USB state and process device requests. More...

Data Structures

struct  app_usbd_core_setup_data_handler_desc_t
 Variable type used to register EP0 transfer handler. More...
 
struct  CONCAT_2
 Declare Core instance type. More...
 

Macros

#define APP_USBD_CORE_CLASS_CONFIGURATION   ((0, NRF_DRV_USBD_EPOUT0, NRF_DRV_USBD_EPIN0))
 Core interface configuration. More...
 

Typedefs

typedef ret_code_t(* app_usbd_core_setup_data_handler_t )(nrf_drv_usbd_ep_status_t status, void *p_context)
 EP0 handler function pointer. More...
 
typedef struct CONCAT_2 _data_t
 

Enumerations

enum  app_usbd_state_t {
  APP_USBD_STATE_Disabled,
  APP_USBD_STATE_Unattached,
  APP_USBD_STATE_Powered,
  APP_USBD_STATE_Default,
  APP_USBD_STATE_Addressed,
  APP_USBD_STATE_Configured
}
 USB Device state. More...
 

Functions

union CONCAT_2 (app_usbd_core, _u)
 
 CONCAT_2 (app_usbd_core, _t)
 
static app_usbd_class_inst_t
const * 
app_usbd_core_instance_access (void)
 Access to core instance. More...
 
void app_usbd_core_ep0_enable (void)
 Enable endpoint 0. More...
 
void app_usbd_core_ep0_disable (void)
 Disable endpoint 0. More...
 
ret_code_t app_usbd_core_setup_rsp (app_usbd_setup_t const *p_setup, void const *p_data, size_t size)
 Default simple response to setup command. More...
 
ret_code_t app_usbd_core_setup_data_handler_set (nrf_drv_usbd_ep_t ep, app_usbd_core_setup_data_handler_desc_t const *const p_handler_desc)
 Configure the handler for the nearest setup data endpoint transfer. More...
 
void * app_usbd_core_setup_transfer_buff_get (size_t *p_size)
 Set up a data transfer buffer. More...
 
app_usbd_state_t app_usbd_core_state_get (void)
 Return internal USBD core state. More...
 
bool app_usbd_core_feature_state_get (app_usbd_setup_stdfeature_t feature)
 Check current feature state. More...
 

Detailed Description

nRF52840 only: Core module that manages current USB state and process device requests.

Macro Definition Documentation

#define APP_USBD_CORE_CLASS_CONFIGURATION   ((0, NRF_DRV_USBD_EPOUT0, NRF_DRV_USBD_EPIN0))

Core interface configuration.

Core instance would have 2 endpoints (IN0 and OUT0). The interface number does not matter because it is not used.

Typedef Documentation

typedef ret_code_t(* app_usbd_core_setup_data_handler_t)(nrf_drv_usbd_ep_status_t status, void *p_context)

EP0 handler function pointer.

Type of the variable that would hold the pointer to the handler for endpoint 0 messages processing.

Parameters
p_contexContext variable configured with the transmission request.

Enumeration Type Documentation

USB Device state.

Possible USB Device states according to specification.

Enumerator
APP_USBD_STATE_Disabled 

The whole USBD library is disabled

APP_USBD_STATE_Unattached 

Device is currently not connected to the host

APP_USBD_STATE_Powered 

Device is connected to the host but has not been enumerated

APP_USBD_STATE_Default 

USB Reset condition detected, waiting for the address

APP_USBD_STATE_Addressed 

Device has been addressed but has not been configured

APP_USBD_STATE_Configured 

Device is addressed and configured

Function Documentation

void app_usbd_core_ep0_disable ( void  )

Disable endpoint 0.

Function disables endpoint OUT0 and IN0. This makes the USB ignore SETUP transfers.

void app_usbd_core_ep0_enable ( void  )

Enable endpoint 0.

Function enables endpoint OUT0 and IN0. This makes the USB respond to SETUP transfers.

bool app_usbd_core_feature_state_get ( app_usbd_setup_stdfeature_t  feature)

Check current feature state.

Function checks the state of the selected feature that was configured by the host.

Parameters
featureFeature to check. app_usbd_setup_stdfeature_t Only features related to the device should be checked by this function.
Return values
trueSelected feature is set.
falseSelected feature is cleared.
static app_usbd_class_inst_t const* app_usbd_core_instance_access ( void  )
inlinestatic

Access to core instance.

Function that returns pointer to the USBD core instance.

Returns
pointer to the core instance.
ret_code_t app_usbd_core_setup_data_handler_set ( nrf_drv_usbd_ep_t  ep,
app_usbd_core_setup_data_handler_desc_t const *const  p_handler_desc 
)

Configure the handler for the nearest setup data endpoint transfer.

This function would be called on incomming setup data. The correct place to set the handler for a data is when SETUP command was received.

Parameters
epEndpoint number (only IN0 and OUT0 are supported).
p_handler_descDescriptor of the handler to be called.
Return values
NRF_SUCCESSSuccessfully configured.
NRF_ERROR_INVALID_ADDRLast received setup direction does not match configured endpoint.
ret_code_t app_usbd_core_setup_rsp ( app_usbd_setup_t const *  p_setup,
void const *  p_data,
size_t  size 
)

Default simple response to setup command.

This function generates default simple response. It sends ZLP when required and on takes care on allowing status stage when transfer is finished.

Parameters
p_setupPointer to original setup message.
p_dataPointer to the response. This has to be globaly aviable data.
sizeTotal size of the answer - The function takes care about limiting the size of transfered data to the size required by setup command.
void* app_usbd_core_setup_transfer_buff_get ( size_t *  p_size)

Set up a data transfer buffer.

Returns special internal buffer that can be used in setup transfer.

Returns
Internal buffer pointer.
app_usbd_state_t app_usbd_core_state_get ( void  )

Return internal USBD core state.

Returns
Check app_usbd_state_t to find possible USBD core states.

Documentation feedback | Developer Zone | Subscribe | Updated