Prusa MINI Firmware overview
ff_gen_drv.c File Reference

FatFs generic low level driver. More...

#include "ff_gen_drv.h"

Functions

uint8_t FATFS_LinkDriverEx (const Diskio_drvTypeDef *drv, char *path, uint8_t lun)
 Links a compatible diskio driver/lun id and increments the number of active linked drivers. More...
 
uint8_t FATFS_LinkDriver (const Diskio_drvTypeDef *drv, char *path)
 Links a compatible diskio driver and increments the number of active linked drivers. More...
 
uint8_t FATFS_UnLinkDriverEx (char *path, uint8_t lun)
 Unlinks a diskio driver and decrements the number of active linked drivers. More...
 
uint8_t FATFS_UnLinkDriver (char *path)
 Unlinks a diskio driver and decrements the number of active linked drivers. More...
 
uint8_t FATFS_GetAttachedDriversNbr (void)
 Gets number of linked drivers to the FatFs module. More...
 

Variables

Disk_drvTypeDef disk = {{0},{0},{0},0}
 

Detailed Description

FatFs generic low level driver.

Author
MCD Application Team
Version
V2.0.2
Date
10-November-2017
Attention

© Copyright (c) 2017 STMicroelectronics International N.V. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted, provided that the following conditions are met:

  1. Redistribution of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of other contributors to this software may be used to endorse or promote products derived from this software without specific written permission.
  4. This software, including modifications and/or derivative works of this software, must execute solely and exclusively on microcontroller or microprocessor devices manufactured by or for STMicroelectronics.
  5. Redistribution and use of this software other than as permitted under this license is void and will automatically terminate your rights under this license.

THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ FATFS_LinkDriverEx()

uint8_t FATFS_LinkDriverEx ( const Diskio_drvTypeDef drv,
char *  path,
uint8_t  lun 
)

Links a compatible diskio driver/lun id and increments the number of active linked drivers.

Note
The number of linked drivers (volumes) is up to 10 due to FatFs limits.
Parameters
drvpointer to the disk IO Driver structure
pathpointer to the logical drive path
lun: only used for USB Key Disk to add multi-lun management else the parameter must be equal to 0
Return values
Returns0 in case of success, otherwise 1.
70 {
71  uint8_t ret = 1;
72  uint8_t DiskNum = 0;
73 
74  if(disk.nbr < _VOLUMES)
75  {
77  disk.drv[disk.nbr] = drv;
78  disk.lun[disk.nbr] = lun;
79  DiskNum = disk.nbr++;
80  path[0] = DiskNum + '0';
81  path[1] = ':';
82  path[2] = '/';
83  path[3] = 0;
84  ret = 0;
85  }
86 
87  return ret;
88 }
Here is the caller graph for this function:

◆ FATFS_LinkDriver()

uint8_t FATFS_LinkDriver ( const Diskio_drvTypeDef drv,
char *  path 
)

Links a compatible diskio driver and increments the number of active linked drivers.

Note
The number of linked drivers (volumes) is up to 10 due to FatFs limits
Parameters
drvpointer to the disk IO Driver structure
pathpointer to the logical drive path
Return values
Returns0 in case of success, otherwise 1.
99 {
100  return FATFS_LinkDriverEx(drv, path, 0);
101 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FATFS_UnLinkDriverEx()

uint8_t FATFS_UnLinkDriverEx ( char *  path,
uint8_t  lun 
)

Unlinks a diskio driver and decrements the number of active linked drivers.

Parameters
pathpointer to the logical drive path
lun: not used
Return values
Returns0 in case of success, otherwise 1.
111 {
112  uint8_t DiskNum = 0;
113  uint8_t ret = 1;
114 
115  if(disk.nbr >= 1)
116  {
117  DiskNum = path[0] - '0';
118  if(disk.drv[DiskNum] != 0)
119  {
120  disk.drv[DiskNum] = 0;
121  disk.lun[DiskNum] = 0;
122  disk.nbr--;
123  ret = 0;
124  }
125  }
126 
127  return ret;
128 }
Here is the caller graph for this function:

◆ FATFS_UnLinkDriver()

uint8_t FATFS_UnLinkDriver ( char *  path)

Unlinks a diskio driver and decrements the number of active linked drivers.

Parameters
pathpointer to the logical drive path
Return values
Returns0 in case of success, otherwise 1.
137 {
138  return FATFS_UnLinkDriverEx(path, 0);
139 }
Here is the call graph for this function:

◆ FATFS_GetAttachedDriversNbr()

uint8_t FATFS_GetAttachedDriversNbr ( void  )

Gets number of linked drivers to the FatFs module.

Parameters
None
Return values
Numberof attached drivers.
147 {
148  return disk.nbr;
149 }

Variable Documentation

◆ disk

Disk_drvTypeDef disk = {{0},{0},{0},0}

© Copyright (c) 2017 STMicroelectronics International N.V. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted, provided that the following conditions are met:

  1. Redistribution of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of other contributors to this software may be used to endorse or promote products derived from this software without specific written permission.
  4. This software, including modifications and/or derivative works of this software, must execute solely and exclusively on microcontroller or microprocessor devices manufactured by or for STMicroelectronics.
  5. Redistribution and use of this software other than as permitted under this license is void and will automatically terminate your rights under this license.

THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Disk_drvTypeDef::is_initialized
uint8_t is_initialized[_VOLUMES]
Definition: ff_gen_drv.h:86
FATFS_LinkDriverEx
uint8_t FATFS_LinkDriverEx(const Diskio_drvTypeDef *drv, char *path, uint8_t lun)
Links a compatible diskio driver/lun id and increments the number of active linked drivers.
Definition: ff_gen_drv.c:69
Disk_drvTypeDef::lun
uint8_t lun[_VOLUMES]
Definition: ff_gen_drv.h:88
_VOLUMES
#define _VOLUMES
Definition: ffconf.h:194
FATFS_UnLinkDriverEx
uint8_t FATFS_UnLinkDriverEx(char *path, uint8_t lun)
Unlinks a diskio driver and decrements the number of active linked drivers.
Definition: ff_gen_drv.c:110
disk
Disk_drvTypeDef disk
Definition: ff_gen_drv.c:54
Disk_drvTypeDef::drv
const Diskio_drvTypeDef * drv[_VOLUMES]
Definition: ff_gen_drv.h:87
uint8_t
const uint8_t[]
Definition: 404_html.c:3
Disk_drvTypeDef::nbr
volatile uint8_t nbr
Definition: ff_gen_drv.h:89