Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ff_gen_drv.c
00001 /** 00002 ****************************************************************************** 00003 * @file ff_gen_drv.c 00004 * @author MCD Application Team 00005 * @version V1.1.0 00006 * @date 22-April-2014 00007 * @brief FatFs generic low level driver. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2> 00012 * 00013 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 00014 * You may not use this file except in compliance with the License. 00015 * You may obtain a copy of the License at: 00016 * 00017 * http://www.st.com/software_license_agreement_liberty_v2 00018 * 00019 * Unless required by applicable law or agreed to in writing, software 00020 * distributed under the License is distributed on an "AS IS" BASIS, 00021 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00022 * See the License for the specific language governing permissions and 00023 * limitations under the License. 00024 * 00025 ****************************************************************************** 00026 */ 00027 00028 /* Includes ------------------------------------------------------------------*/ 00029 #include "ff_gen_drv.h" 00030 00031 /* Private typedef -----------------------------------------------------------*/ 00032 /* Private define ------------------------------------------------------------*/ 00033 /* Private variables ---------------------------------------------------------*/ 00034 Disk_drvTypeDef disk = {0}; 00035 00036 /* Private function prototypes -----------------------------------------------*/ 00037 /* Private functions ---------------------------------------------------------*/ 00038 00039 /** 00040 * @brief Links a compatible diskio driver and increments the number of active 00041 * linked drivers. 00042 * @note The number of linked drivers (volumes) is up to 10 due to FatFs limits 00043 * @param drv: pointer to the disk IO Driver structure 00044 * @param path: pointer to the logical drive path 00045 * @retval Returns 0 in case of success, otherwise 1. 00046 */ 00047 uint8_t FATFS_LinkDriver(Diskio_drvTypeDef *drv, char *path) 00048 { 00049 uint8_t ret = 1; 00050 uint8_t DiskNum = 0; 00051 if(disk.nbr <= _VOLUMES) 00052 { 00053 disk.is_initialized[disk.nbr] = 0; 00054 disk.drv[disk.nbr] = drv; 00055 DiskNum = disk.nbr++; 00056 path[0] = DiskNum + '0'; 00057 path[1] = ':'; 00058 path[2] = '/'; 00059 path[3] = 0; 00060 ret = 0; 00061 } 00062 return ret; 00063 } 00064 00065 /** 00066 * @brief Unlinks a diskio driver and decrements the number of active linked 00067 * drivers. 00068 * @param path: pointer to the logical drive path 00069 * @retval Returns 0 in case of success, otherwise 1. 00070 */ 00071 uint8_t FATFS_UnLinkDriver(char *path) 00072 { 00073 uint8_t DiskNum = 0; 00074 uint8_t ret = 1; 00075 00076 if(disk.nbr >= 1) 00077 { 00078 DiskNum = path[0] - '0'; 00079 if(DiskNum <= disk.nbr) 00080 { 00081 disk.drv[disk.nbr--] = 0; 00082 ret = 0; 00083 } 00084 } 00085 00086 return ret; 00087 } 00088 00089 /** 00090 * @brief Gets number of linked drivers to the FatFs module. 00091 * @param None 00092 * @retval Number of attached drivers. 00093 */ 00094 uint8_t FATFS_GetAttachedDriversNbr(void) 00095 { 00096 return disk.nbr; 00097 } 00098 00099 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 00100
Generated on Tue Jul 12 2022 20:10:41 by
