Prusa MINI Firmware overview
diskio.c File Reference
#include "diskio.h"
#include "ff_gen_drv.h"

Functions

DSTATUS disk_status (BYTE pdrv)
 Gets Disk Status. More...
 
DSTATUS disk_initialize (BYTE pdrv)
 Initializes a Drive. More...
 
DRESULT disk_read (BYTE pdrv, BYTE *buff, DWORD sector, UINT count)
 Reads Sector(s) More...
 
DRESULT disk_write (BYTE pdrv, const BYTE *buff, DWORD sector, UINT count)
 Writes Sector(s) More...
 
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void *buff)
 I/O control operation. More...
 
__weak DWORD get_fattime (void)
 Gets Time from RTC. More...
 

Variables

Disk_drvTypeDef disk
 

Function Documentation

◆ disk_status()

DSTATUS disk_status ( BYTE  pdrv)

Gets Disk Status.

Parameters
pdrvPhysical drive number (0..)
Return values
DSTATUSOperation status
79 {
80  DSTATUS stat;
81 
82  stat = disk.drv[pdrv]->disk_status(disk.lun[pdrv]);
83  return stat;
84 }
Here is the caller graph for this function:

◆ disk_initialize()

DSTATUS disk_initialize ( BYTE  pdrv)

Initializes a Drive.

Parameters
pdrvPhysical drive number (0..)
Return values
DSTATUSOperation status
94 {
95  DSTATUS stat = RES_OK;
96 
97  if(disk.is_initialized[pdrv] == 0)
98  {
99  disk.is_initialized[pdrv] = 1;
100  stat = disk.drv[pdrv]->disk_initialize(disk.lun[pdrv]);
101  }
102  return stat;
103 }
Here is the caller graph for this function:

◆ disk_read()

DRESULT disk_read ( BYTE  pdrv,
BYTE buff,
DWORD  sector,
UINT  count 
)

Reads Sector(s)

Parameters
pdrvPhysical drive number (0..)
*buffData buffer to store read data
sectorSector address (LBA)
countNumber of sectors to read (1..128)
Return values
DRESULTOperation result
119 {
120  DRESULT res;
121 
122  res = disk.drv[pdrv]->disk_read(disk.lun[pdrv], buff, sector, count);
123  return res;
124 }
Here is the caller graph for this function:

◆ disk_write()

DRESULT disk_write ( BYTE  pdrv,
const BYTE buff,
DWORD  sector,
UINT  count 
)

Writes Sector(s)

Parameters
pdrvPhysical drive number (0..)
*buffData to be written
sectorSector address (LBA)
countNumber of sectors to write (1..128)
Return values
DRESULTOperation result
141 {
142  DRESULT res;
143 
144  res = disk.drv[pdrv]->disk_write(disk.lun[pdrv], buff, sector, count);
145  return res;
146 }
Here is the caller graph for this function:

◆ disk_ioctl()

DRESULT disk_ioctl ( BYTE  pdrv,
BYTE  cmd,
void buff 
)

I/O control operation.

Parameters
pdrvPhysical drive number (0..)
cmdControl code
*buffBuffer to send/receive control data
Return values
DRESULTOperation result
162 {
163  DRESULT res;
164 
165  res = disk.drv[pdrv]->disk_ioctl(disk.lun[pdrv], cmd, buff);
166  return res;
167 }
Here is the caller graph for this function:

◆ get_fattime()

__weak DWORD get_fattime ( void  )

Gets Time from RTC.

Parameters
None
Return values
Timein DWORD
176 {
177  return 0;
178 }

Variable Documentation

◆ disk

© 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
Disk_drvTypeDef disk
Definition: ff_gen_drv.c:54
Disk_drvTypeDef::is_initialized
uint8_t is_initialized[_VOLUMES]
Definition: ff_gen_drv.h:86
Disk_drvTypeDef::lun
uint8_t lun[_VOLUMES]
Definition: ff_gen_drv.h:88
Diskio_drvTypeDef::disk_status
DSTATUS(* disk_status)(BYTE)
Definition: ff_gen_drv.h:70
Diskio_drvTypeDef::disk_read
DRESULT(* disk_read)(BYTE, BYTE *, DWORD, UINT)
Definition: ff_gen_drv.h:71
Disk_drvTypeDef::drv
const Diskio_drvTypeDef * drv[_VOLUMES]
Definition: ff_gen_drv.h:87
RES_OK
Definition: onboard_sd.h:23
DSTATUS
BYTE DSTATUS
Definition: onboard_sd.h:19
Diskio_drvTypeDef::disk_write
DRESULT(* disk_write)(BYTE, const BYTE *, DWORD, UINT)
Definition: ff_gen_drv.h:73
DRESULT
DRESULT
Definition: onboard_sd.h:22
Diskio_drvTypeDef::disk_initialize
DSTATUS(* disk_initialize)(BYTE)
Definition: ff_gen_drv.h:69
Diskio_drvTypeDef::disk_ioctl
DRESULT(* disk_ioctl)(BYTE, BYTE, void *)
Definition: ff_gen_drv.h:76