Subversion Repositories Code-Repo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
248 Kevin 1
/*-----------------------------------------------------------------------*/
2
/* Low level disk I/O module skeleton for Petit FatFs (C)ChaN, 2009      */
3
/*-----------------------------------------------------------------------*/
4
 
5
#include "diskio.h"
6
#include "mmc.h"
7
 
8
 
9
/*-----------------------------------------------------------------------*/
10
/* Initialize Disk Drive                                                 */
11
/*-----------------------------------------------------------------------*/
12
 
13
DSTATUS disk_initialize (void)
14
{
15
    int i;
16
 
17
    // Try the initialization sequence up to four times
18
    for (i = 0; i < 4; i++) {
19
        if (mmcInit() == MMC_SUCCESS)
20
            return STA_OK;
21
    }
22
 
23
    return STA_NOINIT;
24
}
25
 
26
 
27
 
28
/*-----------------------------------------------------------------------*/
29
/* Read Partial Sector                                                   */
30
/*-----------------------------------------------------------------------*/
31
 
32
DRESULT disk_readp (
33
    BYTE* dest,         /* Pointer to the destination object */
34
    DWORD sector,       /* Sector number (LBA) */
35
    WORD sofs,          /* Offset in the sector */
36
    WORD count          /* Byte count (bit15:destination) */
37
)
38
{
39
    DRESULT res;
40
    DWORD address = (sector * MMC_SECTOR_SIZE) + sofs;
41
 
42
    if (mmcReadBlock(address, count, dest) == MMC_SUCCESS) {
43
        res = RES_OK;
44
    } else {
45
        res = RES_ERROR;
46
    }
47
 
48
    return res;
49
}
50
 
51
 
52
 
53
/*-----------------------------------------------------------------------*/
54
/* Write Partial Sector                                                  */
55
/*-----------------------------------------------------------------------*/
56
 
57
//DRESULT disk_writep (
58
//  BYTE* buff,     /* Pointer to the data to be written, NULL:Initiate/Finalize write operation */
59
//  DWORD sc        /* Sector number (LBA) or Number of bytes to send */
60
//)
61
//{
62
//  DRESULT res;
63
//
64
//
65
//  if (!buff) {
66
//      if (sc) {
67
//
68
//          // Initiate write process
69
//
70
//      } else {
71
//
72
//          // Finalize write process
73
//
74
//      }
75
//  } else {
76
//
77
//      // Send data to the disk
78
//
79
//  }
80
//
81
//  return res;
82
//}
83