nRF5 SDK v17.1.0
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
USB MSC internals

nRF52840 only: Internals of the USB MSC class. More...

Data Structures

struct  app_usbd_msc_inst_t
 MSC part of class instance data. More...
 
struct  app_usbd_msc_ctx_t
 MSC context. More...
 

Macros

#define APP_USBD_MSC_MINIMAL_SERIAL_STRING_SIZE   (12 + 1)
 Minimal serial string descriptor length.
 
#define APP_USBD_MSC_BUFFER_CNT   2
 Number of block buffers. More...
 
#define APP_USBD_MSC_BUFFER_NAME(instance_name)   CONCAT_2(instance_name, _block)
 Create the name of the block buffer. More...
 
#define APP_USBD_MSC_BLKDEVS_NAME(instance_name)   CONCAT_2(instance_name, _blkdevs)
 Create the name of the block device list. More...
 
#define APP_USBD_MSC_CONFIG(iface, endpoints)   ((iface, BRACKET_EXTRACT(endpoints)))
 MSC configuration macro. More...
 
#define APP_USBD_MSC_INSTANCE_SPECIFIC_DEC   app_usbd_msc_inst_t inst;
 Specific class constant data for MSC. More...
 
#define APP_USBD_MSC_INST_CONFIG(p_devs,devs_cnt,p_buff,block_size,block_cnt,user_event_handler)
 Configures MSC instance. More...
 
#define APP_USBD_MSC_DATA_SPECIFIC_DEC   app_usbd_msc_ctx_t ctx;
 Specific class data for MSC. More...
 
#define APP_USBD_MSC_DSC_CONFIG(interface_number,...)
 MSC descriptors config macro. More...
 
#define APP_USBD_MSC_GLOBAL_DEF_INTERNAL(instance_name,interface_number,user_ev_handler,endpoint_list,blockdev_list,workbuffer_size)
 Global definition of mass storage class instance. More...
 

Typedefs

typedef void(* app_usbd_msc_user_ev_handler_t )(app_usbd_class_inst_t const *p_inst, enum app_usbd_msc_user_event_e event)
 User event handler. More...
 

Enumerations

enum  app_usbd_msc_state_t {
  APP_USBD_MSC_STATE_DISABLED,
  APP_USBD_MSC_STATE_IDLE,
  APP_USBD_MSC_STATE_CBW,
  APP_USBD_MSC_STATE_CMD_IN,
  APP_USBD_MSC_STATE_DATA_IN,
  APP_USBD_MSC_STATE_DATA_OUT,
  APP_USBD_MSC_STATE_CSW,
  APP_USBD_MSC_STATE_UNSUPPORTED,
  APP_USBD_MSC_STATE_CBW_INVALID,
  APP_USBD_MSC_STATE_DEVICE_ERROR
}
 Internal module state. More...
 

Functions

 APP_USBD_CLASS_FORWARD (app_usbd_msc)
 Forward declaration of Mass Storage Class type.
 

Variables

const app_usbd_class_methods_t app_usbd_msc_class_methods
 Public MSC class interface.
 

Detailed Description

nRF52840 only: Internals of the USB MSC class.

Macro Definition Documentation

#define APP_USBD_MSC_BLKDEVS_NAME (   instance_name)    CONCAT_2(instance_name, _blkdevs)

Create the name of the block device list.

Parameters
instance_nameThe name of the MSC instance
Returns
The name of the block device list
#define APP_USBD_MSC_BUFFER_CNT   2

Number of block buffers.

Number of buffers used for the transfer. The library is designed to work with double buffering. Not tested with other configuration.

#define APP_USBD_MSC_BUFFER_NAME (   instance_name)    CONCAT_2(instance_name, _block)

Create the name of the block buffer.

Parameters
instance_nameThe name of the MSC instance
Returns
The name of the block buffer used with the instance
#define APP_USBD_MSC_CONFIG (   iface,
  endpoints 
)    ((iface, BRACKET_EXTRACT(endpoints)))

MSC configuration macro.

Used by APP_USBD_MSC_GLOBAL_DEF

Parameters
ifaceInterface number.
endpointsEndpoint list.
#define APP_USBD_MSC_DATA_SPECIFIC_DEC   app_usbd_msc_ctx_t ctx;

Specific class data for MSC.

app_usbd_msc_ctx_t

#define APP_USBD_MSC_DSC_CONFIG (   interface_number,
  ... 
)
Value:
{ \
APP_USBD_MSC_INTERFACE_DSC(interface_number, \
APP_USBD_MSC_EP_DSC(GET_VA_ARG_1(__VA_ARGS__), \
GET_VA_ARG_1(GET_ARGS_AFTER_1(__VA_ARGS__)), \
64) \
}

MSC descriptors config macro.

Parameters
interface_numberInterface number.
...Extracted endpoint list.
#define APP_USBD_MSC_GLOBAL_DEF_INTERNAL (   instance_name,
  interface_number,
  user_ev_handler,
  endpoint_list,
  blockdev_list,
  workbuffer_size 
)
Value:
static const nrf_block_dev_t * APP_USBD_MSC_BLKDEVS_NAME(instance_name)[] = \
{ BRACKET_EXTRACT(blockdev_list) }; \
static uint32_t APP_USBD_MSC_BUFFER_NAME(instance_name) \
[APP_USBD_MSC_BUFFER_CNT * CEIL_DIV(workbuffer_size, sizeof(uint32_t))]; \
APP_USBD_CLASS_INST_GLOBAL_DEF( \
instance_name, \
app_usbd_msc, \
APP_USBD_MSC_CONFIG(interface_number, endpoint_list), \
ARRAY_SIZE(APP_USBD_MSC_BLKDEVS_NAME(instance_name)), \
APP_USBD_MSC_BUFFER_NAME (instance_name), \
sizeof(APP_USBD_MSC_BUFFER_NAME(instance_name)) \
user_ev_handler)) \
)

Global definition of mass storage class instance.

#define APP_USBD_MSC_INST_CONFIG (   p_devs,
  devs_cnt,
  p_buff,
  block_size,
  block_cnt,
  user_event_handler 
)
Value:
.inst = { \
.pp_block_devs = (p_devs), \
.block_devs_count = (devs_cnt), \
.p_block_buff = (p_buff), \
.block_buff_size = (block_size), \
.block_buff_count = (block_cnt), \
.user_ev_handler = (user_event_handler), \
}

Configures MSC instance.

Parameters
p_devsBlock devices list that is array of pointers of nrf_block_dev_t type.
devs_cntNumber of block devices connected.
p_buffBlock buffer.
block_sizeTotal size of the single block in the buffer.
block_cntNumber of available block buffers.
user_event_handlerUser event handler.
#define APP_USBD_MSC_INSTANCE_SPECIFIC_DEC   app_usbd_msc_inst_t inst;

Specific class constant data for MSC.

app_usbd_msc_inst_t

Typedef Documentation

typedef void(* app_usbd_msc_user_ev_handler_t)(app_usbd_class_inst_t const *p_inst, enum app_usbd_msc_user_event_e event)

User event handler.

Parameters
[in]p_instClass instance.
[in]eventUser event.

Enumeration Type Documentation

Internal module state.

Enumerator
APP_USBD_MSC_STATE_DISABLED 

Internal module state DISABLED

APP_USBD_MSC_STATE_IDLE 

Internal module state IDLE

APP_USBD_MSC_STATE_CBW 

Internal module state CBW

APP_USBD_MSC_STATE_CMD_IN 

Internal module state CMD_IN

APP_USBD_MSC_STATE_DATA_IN 

Internal module state DATA_IN

APP_USBD_MSC_STATE_DATA_OUT 

Internal module state DATA_OUT

APP_USBD_MSC_STATE_CSW 

Internal module state CSW

APP_USBD_MSC_STATE_UNSUPPORTED 

Internal module state UNSUPPORTED

APP_USBD_MSC_STATE_CBW_INVALID 

Endpoint is stalled until the command APP_USBD_MSC_REQ_BULK_RESET

APP_USBD_MSC_STATE_DEVICE_ERROR 

Endpoint is stalled and it is required to send PE error when clearing


Documentation feedback | Developer Zone | Subscribe | Updated