source: ctrl/firmware/Main/CubeMX/Middlewares/Third_Party/FatFs/src/diskio.c

Last change on this file was 74, checked in by Zed, 3 months ago

FatFs? with DMA were implemented.

File size: 4.1 KB
Line 
1/*-----------------------------------------------------------------------*/
2/* Low level disk I/O module skeleton for FatFs     (C)ChaN, 2017        */
3/*                                                                       */
4/*   Portions COPYRIGHT 2017 STMicroelectronics                          */
5/*   Portions Copyright (C) 2017, 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 existing      */
10/* storage control modules to the FatFs module with a defined API.       */
11/*-----------------------------------------------------------------------*/
12
13/* Includes ------------------------------------------------------------------*/
14#include "diskio.h"
15#include "ff_gen_drv.h"
16
17#if defined ( __GNUC__ )
18#ifndef __weak
19#define __weak __attribute__((weak))
20#endif
21#endif
22
23/* Private typedef -----------------------------------------------------------*/
24/* Private define ------------------------------------------------------------*/
25/* Private variables ---------------------------------------------------------*/
26extern Disk_drvTypeDef  disk;
27
28/* Private function prototypes -----------------------------------------------*/
29/* Private functions ---------------------------------------------------------*/
30
31/**
32  * @brief  Gets Disk Status
33  * @param  pdrv: Physical drive number (0..)
34  * @retval DSTATUS: Operation status
35  */
36DSTATUS disk_status (
37        BYTE pdrv               /* Physical drive number to identify the drive */
38)
39{
40  DSTATUS stat;
41
42  stat = disk.drv[pdrv]->disk_status(disk.lun[pdrv]);
43  return stat;
44}
45
46/**
47  * @brief  Initializes a Drive
48  * @param  pdrv: Physical drive number (0..)
49  * @retval DSTATUS: Operation status
50  */
51DSTATUS disk_initialize (
52        BYTE pdrv                               /* Physical drive nmuber to identify the drive */
53)
54{
55  DSTATUS stat = RES_OK;
56
57  if(disk.is_initialized[pdrv] == 0)
58  {
59    stat = disk.drv[pdrv]->disk_initialize(disk.lun[pdrv]);
60    if(stat == RES_OK)
61    {
62      disk.is_initialized[pdrv] = 1;
63    }
64  }
65  return stat;
66}
67
68/**
69  * @brief  Reads Sector(s)
70  * @param  pdrv: Physical drive number (0..)
71  * @param  *buff: Data buffer to store read data
72  * @param  sector: Sector address (LBA)
73  * @param  count: Number of sectors to read (1..128)
74  * @retval DRESULT: Operation result
75  */
76DRESULT disk_read (
77        BYTE pdrv,              /* Physical drive nmuber to identify the drive */
78        BYTE *buff,             /* Data buffer to store read data */
79        DWORD sector,           /* Sector address in LBA */
80        UINT count              /* Number of sectors to read */
81)
82{
83  DRESULT res;
84
85  res = disk.drv[pdrv]->disk_read(disk.lun[pdrv], buff, sector, count);
86  return res;
87}
88
89/**
90  * @brief  Writes Sector(s)
91  * @param  pdrv: Physical drive number (0..)
92  * @param  *buff: Data to be written
93  * @param  sector: Sector address (LBA)
94  * @param  count: Number of sectors to write (1..128)
95  * @retval DRESULT: Operation result
96  */
97#if _USE_WRITE == 1
98DRESULT disk_write (
99        BYTE pdrv,              /* Physical drive nmuber to identify the drive */
100        const BYTE *buff,       /* Data to be written */
101        DWORD sector,           /* Sector address in LBA */
102        UINT count              /* Number of sectors to write */
103)
104{
105  DRESULT res;
106
107  res = disk.drv[pdrv]->disk_write(disk.lun[pdrv], buff, sector, count);
108  return res;
109}
110#endif /* _USE_WRITE == 1 */
111
112/**
113  * @brief  I/O control operation
114  * @param  pdrv: Physical drive number (0..)
115  * @param  cmd: Control code
116  * @param  *buff: Buffer to send/receive control data
117  * @retval DRESULT: Operation result
118  */
119#if _USE_IOCTL == 1
120DRESULT disk_ioctl (
121        BYTE pdrv,              /* Physical drive nmuber (0..) */
122        BYTE cmd,               /* Control code */
123        void *buff              /* Buffer to send/receive control data */
124)
125{
126  DRESULT res;
127
128  res = disk.drv[pdrv]->disk_ioctl(disk.lun[pdrv], cmd, buff);
129  return res;
130}
131#endif /* _USE_IOCTL == 1 */
132
133/**
134  * @brief  Gets Time from RTC
135  * @param  None
136  * @retval Time in DWORD
137  */
138__weak DWORD get_fattime (void)
139{
140  return 0;
141}
142
143/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
144
Note: See TracBrowser for help on using the repository browser.