Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bootloader/libs/fatfs/diskio.c
1476 views
1
/*-----------------------------------------------------------------------*/
2
/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2016 */
3
/*-----------------------------------------------------------------------*/
4
/* If a working storage control module is available, it should be */
5
/* attached to the FatFs via a glue function rather than modifying it. */
6
/* This is an example of glue functions to attach various exsisting */
7
/* storage control modules to the FatFs module with a defined API. */
8
/*-----------------------------------------------------------------------*/
9
10
#include <string.h>
11
12
#include <bdk.h>
13
14
#include <libs/fatfs/diskio.h> /* FatFs lower layer API */
15
16
/*-----------------------------------------------------------------------*/
17
/* Get Drive Status */
18
/*-----------------------------------------------------------------------*/
19
DSTATUS disk_status (
20
BYTE pdrv /* Physical drive nmuber to identify the drive */
21
)
22
{
23
return 0;
24
}
25
26
/*-----------------------------------------------------------------------*/
27
/* Inidialize a Drive */
28
/*-----------------------------------------------------------------------*/
29
DSTATUS disk_initialize (
30
BYTE pdrv /* Physical drive nmuber to identify the drive */
31
)
32
{
33
return 0;
34
}
35
36
/*-----------------------------------------------------------------------*/
37
/* Read Sector(s) */
38
/*-----------------------------------------------------------------------*/
39
DRESULT disk_read (
40
BYTE pdrv, /* Physical drive nmuber to identify the drive */
41
BYTE *buff, /* Data buffer to store read data */
42
DWORD sector, /* Start sector in LBA */
43
UINT count /* Number of sectors to read */
44
)
45
{
46
return sdmmc_storage_read(&sd_storage, sector, count, buff) ? RES_OK : RES_ERROR;
47
}
48
49
/*-----------------------------------------------------------------------*/
50
/* Write Sector(s) */
51
/*-----------------------------------------------------------------------*/
52
DRESULT disk_write (
53
BYTE pdrv, /* Physical drive nmuber to identify the drive */
54
const BYTE *buff, /* Data to be written */
55
DWORD sector, /* Start sector in LBA */
56
UINT count /* Number of sectors to write */
57
)
58
{
59
return sdmmc_storage_write(&sd_storage, sector, count, (void *)buff) ? RES_OK : RES_ERROR;
60
}
61
62
/*-----------------------------------------------------------------------*/
63
/* Miscellaneous Functions */
64
/*-----------------------------------------------------------------------*/
65
DRESULT disk_ioctl (
66
BYTE pdrv, /* Physical drive nmuber (0..) */
67
BYTE cmd, /* Control code */
68
void *buff /* Buffer to send/receive control data */
69
)
70
{
71
return RES_OK;
72
}
73
74