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 _FSL_MMC_DISK_H_ 37 #define _FSL_MMC_DISK_H_ 38 39 #include <stdint.h> 40 #include "diskio.h" 41 42 /*! 43 * @addtogroup MMC Disk 44 * @{ 45 */ 46 47 /******************************************************************************* 48 * Definitions 49 ******************************************************************************/ 50 51 #define CD_USING_GPIO 52 53 /************************************************************************************************* 54 * API 55 ************************************************************************************************/ 56 57 #if defined(__cplusplus) 58 extern "C" { 59 #endif 60 61 /*! 62 * @name MMC Disk Function 63 * @{ 64 */ 65 66 /*! 67 * @brief Initializes MMC disk. 68 * 69 * @param physicalDrive Physical drive number. 70 * @retval STA_NOINIT Failed. 71 * @retval RES_OK Success. 72 */ 73 DSTATUS mmc_disk_initialize(uint8_t physicalDrive); 74 75 /*! 76 * @brief Gets MMC disk status 77 * 78 * @param physicalDrive Physical drive number. 79 * @retval STA_NOINIT Failed. 80 * @retval RES_OK Success. 81 */ 82 DSTATUS mmc_disk_status(uint8_t physicalDrive); 83 84 /*! 85 * @brief Reads MMC disk. 86 * 87 * @param physicalDrive Physical drive number. 88 * @param buffer The data buffer pointer to store read content. 89 * @param sector The start sector number to be read. 90 * @param count The sector count to be read. 91 * @retval RES_PARERR Failed. 92 * @retval RES_OK Success. 93 */ 94 DRESULT mmc_disk_read(uint8_t physicalDrive, uint8_t *buffer, uint32_t sector, uint8_t count); 95 96 /*! 97 * @brief Writes MMC disk. 98 * 99 * @param physicalDrive Physical drive number. 100 * @param buffer The data buffer pointer to store write content. 101 * @param sector The start sector number to be written. 102 * @param count The sector count to be written. 103 * @retval RES_PARERR Failed. 104 * @retval RES_OK Success. 105 */ 106 DRESULT mmc_disk_write(uint8_t physicalDrive, const uint8_t *buffer, uint32_t sector, uint8_t count); 107 108 /*! 109 * @brief MMC disk IO operation. 110 * 111 * @param physicalDrive Physical drive number. 112 * @param command The command to be set. 113 * @param buffer The buffer to store command result. 114 * @retval RES_PARERR Failed. 115 * @retval RES_OK Success. 116 */ 117 DRESULT mmc_disk_ioctl(uint8_t physicalDrive, uint8_t command, void *buffer); 118 119 /* @} */ 120 121 #if defined(__cplusplus) 122 } 123 #endif 124 125 #endif /* _FSL_MMC_DISK_H_ */ 126