LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
USBD_MSC_INIT_PARAM_T Struct Reference

Detailed Description

Mass Storage class function driver initilization parameter data structure.

This data structure is used to pass initialization parameters to the Mass Storage class function driver's init function.

Definition at line 110 of file usbd_api.h.

#include "usbd_api.h"

Data Fields

uint32_t mem_base
 
uint32_t mem_size
 
uint8_t * InquiryStr
 
uint32_t BlockCount
 
uint32_t BlockSize
 
uint32_t MemorySize
 
uint8_t * intf_desc
 
void(* MSC_Write )(uint32_t offset, uint8_t **src, uint32_t length)
 
void(* MSC_Read )(uint32_t offset, uint8_t **dst, uint32_t length)
 
ErrorCode_t(* MSC_Verify )(uint32_t offset, uint8_t dst[], uint32_t length)
 
void(* MSC_GetWriteBuf )(uint32_t offset, uint8_t **buff_adr, uint32_t length)
 
ErrorCode_t(* MSC_Ep0_Hdlr )(USBD_HANDLE_T hUsb, void *data, uint32_t event)
 

Field Documentation

uint32_t BlockCount

Number of blocks present in the mass storage device

Definition at line 117 of file usbd_api.h.

uint32_t BlockSize

Block size in number of bytes

Definition at line 118 of file usbd_api.h.

uint8_t * InquiryStr

Pointer to the 28 character string. This string is sent in response to the SCSI Inquiry command.

Note
The data pointed by the pointer should be of global scope.

Pointer to the 28 character string. This string is sent in response to the SCSI Inquiry command.

Note
The data pointed by the pointer should be of global scope.

Definition at line 116 of file usbd_api.h.

uint8_t * intf_desc

Pointer to the interface descriptor within the descriptor array (high_speed_desc) passed to Init() through USB_CORE_DESCS_T structure. The stack assumes both HS and FS use same BULK endpoints.

Pointer to the interface descriptor within the descriptor array (high_speed_desc) passed to Init() through USB_CORE_DESCS_T structure. The stack assumes both HS and FS use same BULK endpoints.

Definition at line 126 of file usbd_api.h.

uint32_t mem_base

Base memory location from where the stack can allocate data and buffers.

Note
The memory address set in this field should be accessible by USB DMA controller. Also this value should be aligned on 4 byte boundary.

Base memory location from where the stack can allocate data and buffers.

Note
The memory address set in this field should be accessible by USB DMA controller. Also this value should be aligned on 4 byte boundary.

Definition at line 113 of file usbd_api.h.

uint32_t mem_size

The size of memory buffer which stack can use.

Note
The mem_size should be greater than the size returned by USBD_MSC_API::GetMemSize() routine.

The size of memory buffer which stack can use.

Note
The mem_size should be greater than the size returned by USBD_MSC_API::GetMemSize() routine.

Definition at line 114 of file usbd_api.h.

uint32_t MemorySize

Memory size in number of bytes

Definition at line 119 of file usbd_api.h.

ErrorCode_t(* MSC_Ep0_Hdlr)(USBD_HANDLE_T hUsb, void *data, uint32_t event)

Optional user overridable function to replace the default MSC class handler.

The application software could override the default EP0 class handler with their own by providing the handler function address as this data member of the parameter structure. Application which like the default handler should set this data member to zero before calling the USBD_MSC_API::Init().

Note
Parameters
[in]hUsbHandle to the USB device stack.
[in]dataPointer to the data which will be passed when callback function is called by the stack.
[in]eventType of endpoint event. See USBD_EVENT_T for more details.
Returns
The call back should returns ErrorCode_t type to indicate success or error condition.
Return values
LPC_OKOn success.
ERR_USBD_UNHANDLEDEvent is not handled hence pass the event to next in line.
ERR_USBD_xxxFor other error conditions.

Optional user overridable function to replace the default MSC class handler.

The application software could override the default EP0 class handler with their own by providing the handler function address as this data member of the parameter structure. Application which like the default handler should set this data member to zero before calling the USBD_MSC_API::Init().

Note
Parameters
hUsbHandle to the USB device stack.
dataPointer to the data which will be passed when callback function is called by the stack.
eventType of endpoint event. See USBD_EVENT_T for more details.
Returns
The call back should returns ErrorCode_t type to indicate success or error condition.
Return values
LPC_OKOn success.
ERR_USBD_UNHANDLEDEvent is not handled hence pass the event to next in line.
ERR_USBD_xxxFor other error conditions.

Definition at line 134 of file usbd_api.h.

void(* MSC_GetWriteBuf)(uint32_t offset, uint8_t **buff_adr, uint32_t length)

Optional callback function to optimize MSC_Write buffer transfer.

This function is provided by the application software. This function gets called when host sends SCSI_WRITE10/SCSI_WRITE12 command. The callback function should update the buff_adr pointer so that the stack transfers the data directly to the target buffer. /note The updated buffer address should be accessable by USB DMA master. If user doesn't want to use zero-copy model, then the user should not update the buffer pointer.

Parameters
[in]offsetDestination start address.
[in,out]bufBuffer containing the data sent by the host.
[in]lengthNumber of bytes to write.
Returns
Nothing.

Optional callback function to optimize MSC_Write buffer transfer.

This function is provided by the application software. This function gets called when host sends SCSI_WRITE10/SCSI_WRITE12 command. The callback function should update the buff_adr pointer so that the stack transfers the data directly to the target buffer. /note The updated buffer address should be accessable by USB DMA master. If user doesn't want to use zero-copy model, then the user should not update the buffer pointer.

Parameters
offsetDestination start address.
[in,out]bufBuffer containing the data sent by the host.
lengthNumber of bytes to write.
Returns
Nothing.

Definition at line 132 of file usbd_api.h.

void(* MSC_Read)(uint32_t offset, uint8_t **dst, uint32_t length)

MSC Read callback function.

This function is provided by the application software. This function gets called when host sends a read command.

Parameters
[in]offsetSource start address.
[in,out]dstPointer to a pointer to the source of data. The MSC function drivers implemented in stack are written with zero-copy model. Meaning the stack doesn't make an extra copy of buffer before writing/reading data from USB hardware FIFO. Hence the parameter is pointer to a pointer containing address buffer (uint8_t** dst). So that the user application can update the buffer pointer instead of copying data to address pointed by the parameter. /note The updated buffer address should be accessable by USB DMA master. If user doesn't want to use zero-copy model, then the user should copy data to the address pointed by the passed buffer pointer parameter and shouldn't change the address value.
[in]lengthNumber of bytes to be read.
Returns
Nothing.

MSC Read callback function.

This function is provided by the application software. This function gets called when host sends a read command.

Parameters
offsetSource start address.
dstPointer to a pointer to the source of data. The MSC function drivers implemented in stack are written with zero-copy model. Meaning the stack doesn't make an extra copy of buffer before writing/reading data from USB hardware FIFO. Hence the parameter is pointer to a pointer containing address buffer (uint8_t** dst). So that the user application can update the buffer pointer instead of copying data to address pointed by the parameter. /note The updated buffer address should be accessable by USB DMA master. If user doesn't want to use zero-copy model, then the user should copy data to the address pointed by the passed buffer pointer parameter and shouldn't change the address value.
lengthNumber of bytes to be read.
Returns
Nothing.

Definition at line 129 of file usbd_api.h.

ErrorCode_t(* MSC_Verify)(uint32_t offset, uint8_t buf[], uint32_t length)

MSC Verify callback function.

This function is provided by the application software. This function gets called when host sends a verify command. The callback function should compare the buffer with the destination memory at the requested offset and

Parameters
[in]offsetDestination start address.
[in]bufBuffer containing the data sent by the host.
[in]lengthNumber of bytes to verify.
Returns
Returns ErrorCode_t type to indicate success or error condition.
Return values
LPC_OKIf data in the buffer matches the data at destination
ERR_FAILEDAtleast one byte is different.

MSC Verify callback function.

This function is provided by the application software. This function gets called when host sends a verify command. The callback function should compare the buffer with the destination memory at the requested offset and

Parameters
offsetDestination start address.
bufBuffer containing the data sent by the host.
lengthNumber of bytes to verify.
Returns
Returns ErrorCode_t type to indicate success or error condition.
Return values
LPC_OKIf data in the buffer matches the data at destination
ERR_FAILEDAtleast one byte is different.

Definition at line 130 of file usbd_api.h.

void(* MSC_Write)(uint32_t offset, uint8_t **src, uint32_t length)

MSC Write callback function.

This function is provided by the application software. This function gets called when host sends a write command.

Parameters
[in]offsetDestination start address.
[in,out]srcPointer to a pointer to the source of data. Pointer-to-pointer is used to implement zero-copy buffers.
[in]lengthNumber of bytes to be written.
Returns
Nothing.

MSC Write callback function.

This function is provided by the application software. This function gets called when host sends a write command.

Parameters
offsetDestination start address.
srcPointer to a pointer to the source of data. Pointer-to-pointer is used to implement zero-copy buffers.
lengthNumber of bytes to be written.
Returns
Nothing.

Definition at line 128 of file usbd_api.h.


The documentation for this struct was generated from the following files: