Prusa MINI Firmware overview
ff_gen_drv.h
Go to the documentation of this file.
1 /**
2  ******************************************************************************
3  * @file ff_gen_drv.h
4  * @author MCD Application Team
5  * @version V2.0.2
6  * @date 10-November-2017
7  * @brief Header for ff_gen_drv.c module.
8  ******************************************************************************
9  * @attention
10  *
11  * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics International N.V.
12  * All rights reserved.</center></h2>
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted, provided that the following conditions are met:
16  *
17  * 1. Redistribution of source code must retain the above copyright notice,
18  * this list of conditions and the following disclaimer.
19  * 2. Redistributions in binary form must reproduce the above copyright notice,
20  * this list of conditions and the following disclaimer in the documentation
21  * and/or other materials provided with the distribution.
22  * 3. Neither the name of STMicroelectronics nor the names of other
23  * contributors to this software may be used to endorse or promote products
24  * derived from this software without specific written permission.
25  * 4. This software, including modifications and/or derivative works of this
26  * software, must execute solely and exclusively on microcontroller or
27  * microprocessor devices manufactured by or for STMicroelectronics.
28  * 5. Redistribution and use of this software other than as permitted under
29  * this license is void and will automatically terminate your rights under
30  * this license.
31  *
32  * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
33  * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
34  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
35  * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
36  * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
37  * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
38  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
39  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
40  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
41  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
42  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
43  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44  *
45  ******************************************************************************
46  */
47 
48 /* Define to prevent recursive inclusion -------------------------------------*/
49 #ifndef __FF_GEN_DRV_H
50 #define __FF_GEN_DRV_H
51 
52 #ifdef __cplusplus
53  extern "C" {
54 #endif
55 
56 /* Includes ------------------------------------------------------------------*/
57 #include "diskio.h"
58 #include "ff.h"
59 #include "stdint.h"
60 
61 
62 /* Exported types ------------------------------------------------------------*/
63 
64 /**
65  * @brief Disk IO Driver structure definition
66  */
67 typedef struct
68 {
69  DSTATUS (*disk_initialize) (BYTE); /*!< Initialize Disk Drive */
70  DSTATUS (*disk_status) (BYTE); /*!< Get Disk Status */
71  DRESULT (*disk_read) (BYTE, BYTE*, DWORD, UINT); /*!< Read Sector(s) */
72 #if _USE_WRITE == 1
73  DRESULT (*disk_write) (BYTE, const BYTE*, DWORD, UINT); /*!< Write Sector(s) when _USE_WRITE = 0 */
74 #endif /* _USE_WRITE == 1 */
75 #if _USE_IOCTL == 1
76  DRESULT (*disk_ioctl) (BYTE, BYTE, void*); /*!< I/O control operation when _USE_IOCTL = 1 */
77 #endif /* _USE_IOCTL == 1 */
78 
80 
81 /**
82  * @brief Global Disk IO Drivers structure definition
83  */
84 typedef struct
85 {
86  uint8_t is_initialized[_VOLUMES];
89  volatile uint8_t nbr;
90 
92 
93 /* Exported constants --------------------------------------------------------*/
94 /* Exported macro ------------------------------------------------------------*/
95 /* Exported functions ------------------------------------------------------- */
96 uint8_t FATFS_LinkDriver(const Diskio_drvTypeDef *drv, char *path);
97 uint8_t FATFS_UnLinkDriver(char *path);
98 uint8_t FATFS_LinkDriverEx(const Diskio_drvTypeDef *drv, char *path, BYTE lun);
99 uint8_t FATFS_UnLinkDriverEx(char *path, BYTE lun);
101 
102 #ifdef __cplusplus
103 }
104 #endif
105 
106 #endif /* __FF_GEN_DRV_H */
107 
108 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
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.
Definition: ff_gen_drv.c:98
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, BYTE lun)
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.
Definition: ff_gen_drv.c:98
disk_initialize
DSTATUS disk_initialize(BYTE pdrv)
Initializes a Drive.
Definition: diskio.c:91
Disk_drvTypeDef
Global Disk IO Drivers structure definition.
Definition: ff_gen_drv.h:84
disk_read
DRESULT disk_read(BYTE pdrv, BYTE *buff, DWORD sector, UINT count)
Reads Sector(s)
Definition: diskio.c:113
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
FATFS_GetAttachedDriversNbr
uint8_t FATFS_GetAttachedDriversNbr(void)
Gets number of linked drivers to the FatFs module.
Definition: ff_gen_drv.c:146
Disk_drvTypeDef::lun
uint8_t lun[_VOLUMES]
Definition: ff_gen_drv.h:88
_VOLUMES
#define _VOLUMES
Definition: ffconf.h:194
FATFS_UnLinkDriver
uint8_t FATFS_UnLinkDriver(char *path)
Unlinks a diskio driver and decrements the number of active linked drivers.
Definition: ff_gen_drv.c:136
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
BYTE
#define BYTE
Definition: MarlinSerial.h:142
disk
Disk_drvTypeDef disk
Definition: ff_gen_drv.c:54
ff_gen_drv.h
Header for ff_gen_drv.c module.
Disk_drvTypeDef::drv
const Diskio_drvTypeDef * drv[_VOLUMES]
Definition: ff_gen_drv.h:87
FATFS_UnLinkDriver
uint8_t FATFS_UnLinkDriver(char *path)
Unlinks a diskio driver and decrements the number of active linked drivers.
Definition: ff_gen_drv.c:136
disk_status
DSTATUS disk_status(BYTE pdrv)
Gets Disk Status.
Definition: diskio.c:76
diskio.h
ff.h
DSTATUS
BYTE DSTATUS
Definition: onboard_sd.h:19
disk_write
DRESULT disk_write(BYTE pdrv, const BYTE *buff, DWORD sector, UINT count)
Writes Sector(s)
Definition: diskio.c:135
uint8_t
const uint8_t[]
Definition: 404_html.c:3
disk_ioctl
DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff)
I/O control operation.
Definition: diskio.c:157
DWORD
unsigned long DWORD
Definition: onboard_sd.h:15
Disk_drvTypeDef::nbr
volatile uint8_t nbr
Definition: ff_gen_drv.h:89
BYTE
unsigned char BYTE
Definition: onboard_sd.h:13
DRESULT
DRESULT
Definition: onboard_sd.h:22
Diskio_drvTypeDef
Disk IO Driver structure definition.
Definition: ff_gen_drv.h:67
FATFS_GetAttachedDriversNbr
uint8_t FATFS_GetAttachedDriversNbr(void)
Gets number of linked drivers to the FatFs module.
Definition: ff_gen_drv.c:146
FATFS_UnLinkDriverEx
uint8_t FATFS_UnLinkDriverEx(char *path, BYTE lun)
UINT
unsigned int UINT
Definition: onboard_sd.h:16