LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
usbd_mscuser.h
Go to the documentation of this file.
1 /*
2  * @brief Definition of functions exported by ROM based MSC function driver
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2012
6  * All rights reserved.
7  *
8  * @par
9  * Software that is described herein is for illustrative purposes only
10  * which provides customers with programming information regarding the
11  * LPC products. This software is supplied "AS IS" without any warranties of
12  * any kind, and NXP Semiconductors and its licensor disclaim any and
13  * all warranties, express or implied, including all implied warranties of
14  * merchantability, fitness for a particular purpose and non-infringement of
15  * intellectual property rights. NXP Semiconductors assumes no responsibility
16  * or liability for the use of the software, conveys no license or rights under any
17  * patent, copyright, mask work right, or any other intellectual property rights in
18  * or to any products. NXP Semiconductors reserves the right to make changes
19  * in the software without notification. NXP Semiconductors also makes no
20  * representation or warranty that such application will be suitable for the
21  * specified use without further testing or modification.
22  *
23  * @par
24  * Permission to use, copy, modify, and distribute this software and its
25  * documentation is hereby granted, under NXP Semiconductors' and its
26  * licensor's relevant copyrights in the software, without fee, provided that it
27  * is used in conjunction with NXP Semiconductors microcontrollers. This
28  * copyright, permission, and disclaimer notice must appear in all copies of
29  * this code.
30  */
31 
32 #include "error.h"
33 #include "usbd.h"
34 #include "usbd_msc.h"
35 #include "usbd_core.h"
36 
37 #ifndef __MSCUSER_H__
38 #define __MSCUSER_H__
39 
40 
59 typedef struct USBD_MSC_INIT_PARAM
60 {
61  /* memory allocation params */
62  uint32_t mem_base;
67  uint32_t mem_size;
70  /* mass storage paramas */
71  uint8_t* InquiryStr;
82  uint8_t* intf_desc;
83  /* user defined functions */
84 
99  void (*MSC_Write)( uint32_t offset, uint8_t** src, uint32_t length);
120  void (*MSC_Read)( uint32_t offset, uint8_t** dst, uint32_t length);
136  ErrorCode_t (*MSC_Verify)( uint32_t offset, uint8_t buf[], uint32_t length);
154  void (*MSC_GetWriteBuf)( uint32_t offset, uint8_t** buff_adr, uint32_t length);
155 
175  ErrorCode_t (*MSC_Ep0_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
176 
178 
185 typedef struct USBD_MSC_API
186 {
198  uint32_t (*GetMemSize)(USBD_MSC_INIT_PARAM_T* param);
199 
217 
219 
220 /*-----------------------------------------------------------------------------
221  * Private functions & structures prototypes
222  *-----------------------------------------------------------------------------*/
225 typedef struct _MSC_CTRL_T
226 {
227  /* If it's a USB HS, the max packet is 512, if it's USB FS,
228  the max packet is 64. Use 512 for both HS and FS. */
229  /*ALIGNED(4)*/ uint8_t BulkBuf[512]; /* Bulk In/Out Buffer */
230  /*ALIGNED(4)*/MSC_CBW CBW; /* Command Block Wrapper */
231  /*ALIGNED(4)*/MSC_CSW CSW; /* Command Status Wrapper */
232 
233  USB_CORE_CTRL_T* pUsbCtrl;
234 
235  uint32_t Offset; /* R/W Offset */
236  uint32_t Length; /* R/W Length */
237  uint32_t BulkLen; /* Bulk In/Out Length */
238  uint8_t* rx_buf;
239 
240  uint8_t BulkStage; /* Bulk Stage */
241  uint8_t if_num; /* interface number */
242  uint8_t epin_num; /* BULK IN endpoint number */
243  uint8_t epout_num; /* BULK OUT endpoint number */
244  uint32_t MemOK; /* Memory OK */
245 
246  uint8_t* InquiryStr;
247  uint32_t BlockCount;
248  uint32_t BlockSize;
249  uint32_t MemorySize;
250  /* user defined functions */
251  void (*MSC_Write)( uint32_t offset, uint8_t** src, uint32_t length);
252  void (*MSC_Read)( uint32_t offset, uint8_t** dst, uint32_t length);
253  ErrorCode_t (*MSC_Verify)( uint32_t offset, uint8_t src[], uint32_t length);
254  /* optional call back for MSC_Write optimization */
255  void (*MSC_GetWriteBuf)( uint32_t offset, uint8_t** buff_adr, uint32_t length);
256 
257 
258 }USB_MSC_CTRL_T;
259 
260 
264 #endif /* __MSCUSER_H__ */