1 /*
2  * The Clear BSD License
3  * Copyright (c) 2015, Freescale Semiconductor, Inc.
4  * Copyright 2016 NXP
5  * All rights reserved.
6  *
7  *
8  * Redistribution and use in source and binary forms, with or without modification,
9  * are permitted (subject to the limitations in the disclaimer below) provided
10  *  that the following conditions are met:
11  *
12  * o Redistributions of source code must retain the above copyright notice, this list
13  *   of conditions and the following disclaimer.
14  *
15  * o Redistributions in binary form must reproduce the above copyright notice, this
16  *   list of conditions and the following disclaimer in the documentation and/or
17  *   other materials provided with the distribution.
18  *
19  * o Neither the name of the copyright holder nor the names of its
20  *   contributors may be used to endorse or promote products derived from this
21  *   software without specific prior written permission.
22  *
23  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
28  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
31  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #ifndef _MSD_DISKIO_H_
37 #define _MSD_DISKIO_H_
38 
39 #include "usb_host_config.h"
40 #include "usb_host.h"
41 #include "usb_host_msd.h"
42 #include "diskio.h"
43 
44 /*******************************************************************************
45  * Definitions
46  ******************************************************************************/
47 
48 /*! @brief mass storage read/write retry time */
49 #define USB_HOST_FATFS_RW_RETRY_TIMES                   (2U)
50 
51 /*******************************************************************************
52  * API
53  ******************************************************************************/
54 
55 /*!
56  * @brief fatfs call this function to initialize physical disk.
57  *
58  * @param pdrv   Physical drive number.
59  *
60  * @retval 0x00    success.
61  */
62 extern DSTATUS USB_HostMsdInitializeDisk(BYTE pdrv);
63 
64 /*!
65  * @brief fatfs call this function to get physical disk status.
66  *
67  * @param pdrv           Physical drive number.
68  *
69  * @retval 0x00    OK.
70  */
71 extern DSTATUS USB_HostMsdGetDiskStatus(BYTE pdrv);
72 
73 /*!
74  * @brief fatfs call this function to write data to physical disk.
75  *
76  * @param pdrv           Physical drive number.
77  * @param buff           Pointer to the data buffer to store read data.
78  * @param sector         Start sector number.
79  * @param count          Number of sectors to read.
80  *
81  * @retval RES_PARERR    parameter error.
82  * @retval RES_ERROR     usb stack driver error.
83  * @retval RES_NOTRDY    read disk error.
84  */
85 extern DRESULT USB_HostMsdReadDisk(BYTE pdrv, BYTE *buff, DWORD sector, UINT count);
86 
87 /*!
88  * @brief fatfs call this function to write data to physical disk.
89  *
90  * @param pdrv           Physical drive number.
91  * @param buff           Pointer to the data buffer to be written.
92  * @param sector         Start sector number.
93  * @param count          Number of sectors to read.
94  *
95  * @retval RES_PARERR    parameter error.
96  * @retval RES_ERROR     usb stack driver error.
97  * @retval RES_NOTRDY    write disk error.
98  */
99 extern DRESULT USB_HostMsdWriteDisk(BYTE pdrv, const BYTE *buff, DWORD sector, UINT count);
100 
101 /*!
102  * @brief fatfs call this function to write data to physical disk.
103  *
104  * @param pdrv           Physical drive number.
105  * @param cmd            ioctl command, please reference to diskio.h
106  * @param buff           Parameter or data buffer.
107  *
108  * @retval RES_PARERR    parameter error.
109  * @retval RES_ERROR     usb stack driver error.
110  * @retval RES_NOTRDY    write disk error.
111  */
112 extern DRESULT USB_HostMsdIoctlDisk(BYTE pdrv, BYTE cmd, void *buff);
113 
114 #endif /* _MSD_DISKIO_H_ */
115 
116