STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
diskio.c
Go to the documentation of this file.
1 /*-----------------------------------------------------------------------*/
2 /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2014 */
3 /* */
4 /* Portions COPYRIGHT 2015 STMicroelectronics */
5 /* Portions Copyright (C) 2014, ChaN, all right reserved */
6 /*-----------------------------------------------------------------------*/
7 /* If a working storage control module is available, it should be */
8 /* attached to the FatFs via a glue function rather than modifying it. */
9 /* This is an example of glue functions to attach various exsisting */
10 /* storage control modules to the FatFs module with a defined API. */
11 /*-----------------------------------------------------------------------*/
12 
38 /* Includes ------------------------------------------------------------------*/
39 #include "diskio.h"
40 #include "ff_gen_drv.h"
41 
42 /* Private typedef -----------------------------------------------------------*/
43 /* Private define ------------------------------------------------------------*/
44 /* Private variables ---------------------------------------------------------*/
45 extern Disk_drvTypeDef disk;
46 
47 /* Private function prototypes -----------------------------------------------*/
48 /* Private functions ---------------------------------------------------------*/
49 
56  BYTE pdrv /* Physical drive nmuber to identify the drive */
57 )
58 {
59  DSTATUS stat;
60 
61  stat = disk.drv[pdrv]->disk_status(disk.lun[pdrv]);
62  return stat;
63 }
64 
71  BYTE pdrv /* Physical drive nmuber to identify the drive */
72 )
73 {
74  DSTATUS stat = RES_OK;
75 
76  if(disk.is_initialized[pdrv] == 0)
77  {
78  disk.is_initialized[pdrv] = 1;
79  stat = disk.drv[pdrv]->disk_initialize(disk.lun[pdrv]);
80  }
81  return stat;
82 }
83 
93  BYTE pdrv, /* Physical drive nmuber to identify the drive */
94  BYTE *buff, /* Data buffer to store read data */
95  DWORD sector, /* Sector address in LBA */
96  UINT count /* Number of sectors to read */
97 )
98 {
99  DRESULT res;
100 
101  res = disk.drv[pdrv]->disk_read(disk.lun[pdrv], buff, sector, count);
102  return res;
103 }
104 
113 #if _USE_WRITE == 1
115  BYTE pdrv, /* Physical drive nmuber to identify the drive */
116  const BYTE *buff, /* Data to be written */
117  DWORD sector, /* Sector address in LBA */
118  UINT count /* Number of sectors to write */
119 )
120 {
121  DRESULT res;
122 
123  res = disk.drv[pdrv]->disk_write(disk.lun[pdrv], buff, sector, count);
124  return res;
125 }
126 #endif /* _USE_WRITE == 1 */
127 
135 #if _USE_IOCTL == 1
137  BYTE pdrv, /* Physical drive nmuber (0..) */
138  BYTE cmd, /* Control code */
139  void *buff /* Buffer to send/receive control data */
140 )
141 {
142  DRESULT res;
143 
144  res = disk.drv[pdrv]->disk_ioctl(disk.lun[pdrv], cmd, buff);
145  return res;
146 }
147 #endif /* _USE_IOCTL == 1 */
148 
154 __weak DWORD get_fattime (void)
155 {
156  return 0;
157 }
158 
159 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
160 
Diskio_drvTypeDef * drv[_VOLUMES]
Definition: ff_gen_drv.h:65
__weak DWORD get_fattime(void)
Gets Time from RTC.
Definition: diskio.c:154
DSTATUS(* disk_initialize)(BYTE)
Definition: ff_gen_drv.h:47
uint8_t is_initialized[_VOLUMES]
Definition: ff_gen_drv.h:64
DSTATUS(* disk_status)(BYTE)
Definition: ff_gen_drv.h:48
uint8_t lun[_VOLUMES]
Definition: ff_gen_drv.h:66
Disk_drvTypeDef disk
Definition: ff_gen_drv.c:34
unsigned long DWORD
Definition: integer.h:29
DRESULT disk_write(BYTE pdrv, const BYTE *buff, DWORD sector, UINT count)
Writes Sector(s)
Definition: diskio.c:114
BYTE DSTATUS
Definition: diskio.h:19
DRESULT
Definition: diskio.h:22
unsigned char BYTE
Definition: integer.h:16
DSTATUS disk_status(BYTE pdrv)
Gets Disk Status.
Definition: diskio.c:55
DRESULT(* disk_ioctl)(BYTE, BYTE, void *)
Definition: ff_gen_drv.h:54
DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff)
I/O control operation.
Definition: diskio.c:136
Definition: diskio.h:23
DRESULT(* disk_read)(BYTE, BYTE *, DWORD, UINT)
Definition: ff_gen_drv.h:49
Global Disk IO Drivers structure definition.
Definition: ff_gen_drv.h:62
DRESULT(* disk_write)(BYTE, const BYTE *, DWORD, UINT)
Definition: ff_gen_drv.h:51
DSTATUS disk_initialize(BYTE pdrv)
Initializes a Drive.
Definition: diskio.c:70
unsigned int UINT
Definition: integer.h:25
Header for ff_gen_drv.c module.
DRESULT disk_read(BYTE pdrv, BYTE *buff, DWORD sector, UINT count)
Reads Sector(s)
Definition: diskio.c:92