USBD ROM Stack  2.0
ROM based USB device stack
mw_usbd_mscuser.h
Go to the documentation of this file.
1 /***********************************************************************
2  * $Id:: mw_usbd_mscuser.h 2219 2015-12-08 22:18:38Z usb00423 $
3  *
4  * Project: USB device ROM Stack
5  *
6  * Description:
7  * Mass Storage Class Custom User Module definitions.
8  *
9  ***********************************************************************
10  * Copyright(C) 2011, NXP Semiconductor
11  * All rights reserved.
12  *
13  * Software that is described herein is for illustrative purposes only
14  * which provides customers with programming information regarding the
15  * products. This software is supplied "AS IS" without any warranties.
16  * NXP Semiconductors assumes no responsibility or liability for the
17  * use of the software, conveys no license or title under any patent,
18  * copyright, or mask work right to the product. NXP Semiconductors
19  * reserves the right to make changes in the software without
20  * notification. NXP Semiconductors also make no representation or
21  * warranty that such application will be suitable for the specified
22  * use without further testing or modification.
23  **********************************************************************/
24 #ifndef __MSCUSER_H__
25 #define __MSCUSER_H__
26 
27 #include "error.h"
28 #include "mw_usbd.h"
29 #include "mw_usbd_msc.h"
30 #include "mw_usbd_core.h"
31 
57 typedef struct USBD_MSC_INIT_PARAM {
58  /* memory allocation params */
59  uint32_t mem_base;
64  uint32_t mem_size;
67  /* mass storage params */
68  uint8_t *InquiryStr;
72  uint32_t BlockCount;
73  uint32_t BlockSize;
74  uint32_t MemorySize;
80  uint8_t *intf_desc;
81  /* user defined functions */
82 
98  void (*MSC_Write)(uint32_t offset, uint8_t * *src, uint32_t length, uint32_t high_offset);
120  void (*MSC_Read)(uint32_t offset, uint8_t * *dst, uint32_t length, uint32_t high_offset);
137  ErrorCode_t (*MSC_Verify)(uint32_t offset, uint8_t buf[], uint32_t length, uint32_t high_offset);
156  void (*MSC_GetWriteBuf)(uint32_t offset, uint8_t * *buff_adr, uint32_t length, uint32_t high_offset);
157 
177  ErrorCode_t (*MSC_Ep0_Hdlr)(USBD_HANDLE_T hUsb, void *data, uint32_t event);
178 
179  uint64_t MemorySize64;
180 
182 
189 typedef struct USBD_MSC_API {
201  uint32_t (*GetMemSize)(USBD_MSC_INIT_PARAM_T *param);
202 
220 
222 
223 /*-----------------------------------------------------------------------------
224  * Private functions & structures prototypes
225  *-----------------------------------------------------------------------------*/
228 typedef struct _MSC_CTRL_T {
229  /* If it's a USB HS, the max packet is 512, if it's USB FS,
230  the max packet is 64. Use 512 for both HS and FS. */
231  /*ALIGNED(4)*/ uint8_t BulkBuf[USB_HS_MAX_BULK_PACKET];/* Bulk In/Out Buffer */
232  /*ALIGNED(4)*/ MSC_CBW CBW; /* Command Block Wrapper */
233  /*ALIGNED(4)*/ MSC_CSW CSW; /* Command Status Wrapper */
234 
235  USB_CORE_CTRL_T *pUsbCtrl;
236 
237  uint64_t Offset; /* R/W Offset */
238  uint32_t Length; /* R/W Length */
239  uint32_t BulkLen; /* Bulk In/Out Length */
240  uint8_t *rx_buf;
241 
242  uint8_t BulkStage; /* Bulk Stage */
243  uint8_t if_num; /* interface number */
244  uint8_t epin_num; /* BULK IN endpoint number */
245  uint8_t epout_num; /* BULK OUT endpoint number */
246  uint32_t MemOK; /* Memory OK */
247 
248  uint8_t *InquiryStr;
249  uint32_t BlockCount;
250  uint32_t BlockSize;
251  uint64_t MemorySize;
252  /* user defined functions */
253  void (*MSC_Write)(uint32_t offset, uint8_t * *src, uint32_t length, uint32_t high_offset);
254  void (*MSC_Read)(uint32_t offset, uint8_t * *dst, uint32_t length, uint32_t high_offset);
255  ErrorCode_t (*MSC_Verify)(uint32_t offset, uint8_t src[], uint32_t length, uint32_t high_offset);
256  /* optional call back for MSC_Write optimization */
257  void (*MSC_GetWriteBuf)(uint32_t offset, uint8_t * *buff_adr, uint32_t length, uint32_t high_offset);
258 
259 } USB_MSC_CTRL_T;
260 
262 extern uint32_t mwMSC_GetMemSize(USBD_MSC_INIT_PARAM_T *param);
263 
264 extern ErrorCode_t mwMSC_init(USBD_HANDLE_T hUsb, USBD_MSC_INIT_PARAM_T *param);
265 
270 #endif /* __MSCUSER_H__ */
ErrorCode_t
Definition: error.h:38
ROM API for USB device stack.
uint8_t * intf_desc
Definition: mw_usbd_mscuser.h:80
Mass Storage class (MSC) descriptors.
uint8_t * InquiryStr
Definition: mw_usbd_mscuser.h:68
uint32_t BlockCount
Definition: mw_usbd_mscuser.h:72
uint32_t BlockSize
Definition: mw_usbd_mscuser.h:73
Error code returned by Boot ROM drivers/library functions.This file contains unified error codes to b...
MSC class API functions structure.This module exposes functions which interact directly with USB devi...
Definition: mw_usbd_mscuser.h:189
uint32_t MemorySize
Definition: mw_usbd_mscuser.h:74
uint32_t mem_size
Definition: mw_usbd_mscuser.h:64
uint32_t mem_base
Definition: mw_usbd_mscuser.h:59
Common definitions and declarations for the USB stack.
Mass Storage class function driver initialization parameter data structure.
Definition: mw_usbd_mscuser.h:57
void * USBD_HANDLE_T
Definition: mw_usbd.h:704