Updated get_fattime to use rtc and provide a date/time. This has been an annoying missing feature.

Dependents:   IoTGateway_Basic y_XBeeTest_5_read CameraC1098_picture LifeCam ... more

Committer:
SomeRandomBloke
Date:
Mon Apr 02 22:06:35 2012 +0000
Revision:
1:5baba5d5b728
Parent:
0:93acdd9f65f4

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
SomeRandomBloke 0:93acdd9f65f4 1 /*-----------------------------------------------------------------------*/
SomeRandomBloke 0:93acdd9f65f4 2 /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2007 */
SomeRandomBloke 0:93acdd9f65f4 3 /*-----------------------------------------------------------------------*/
SomeRandomBloke 0:93acdd9f65f4 4 /* This is a stub disk I/O module that acts as front end of the existing */
SomeRandomBloke 0:93acdd9f65f4 5 /* disk I/O modules and attach it to FatFs module with common interface. */
SomeRandomBloke 0:93acdd9f65f4 6 /*-----------------------------------------------------------------------*/
SomeRandomBloke 0:93acdd9f65f4 7
SomeRandomBloke 0:93acdd9f65f4 8 #include "diskio.h"
SomeRandomBloke 0:93acdd9f65f4 9 #include <stdio.h>
SomeRandomBloke 0:93acdd9f65f4 10 #include <string.h>
SomeRandomBloke 0:93acdd9f65f4 11 #include "FATFileSystem.h"
SomeRandomBloke 0:93acdd9f65f4 12
SomeRandomBloke 0:93acdd9f65f4 13 #include "mbed.h"
SomeRandomBloke 0:93acdd9f65f4 14
SomeRandomBloke 0:93acdd9f65f4 15 DSTATUS disk_initialize (
SomeRandomBloke 0:93acdd9f65f4 16 BYTE drv /* Physical drive nmuber (0..) */
SomeRandomBloke 0:93acdd9f65f4 17 )
SomeRandomBloke 0:93acdd9f65f4 18 {
SomeRandomBloke 0:93acdd9f65f4 19 FFSDEBUG("disk_initialize on drv [%d]\n", drv);
SomeRandomBloke 0:93acdd9f65f4 20 return (DSTATUS)FATFileSystem::_ffs[drv]->disk_initialize();
SomeRandomBloke 0:93acdd9f65f4 21 }
SomeRandomBloke 0:93acdd9f65f4 22
SomeRandomBloke 0:93acdd9f65f4 23 DSTATUS disk_status (
SomeRandomBloke 0:93acdd9f65f4 24 BYTE drv /* Physical drive nmuber (0..) */
SomeRandomBloke 0:93acdd9f65f4 25 )
SomeRandomBloke 0:93acdd9f65f4 26 {
SomeRandomBloke 0:93acdd9f65f4 27 FFSDEBUG("disk_status on drv [%d]\n", drv);
SomeRandomBloke 0:93acdd9f65f4 28 return (DSTATUS)FATFileSystem::_ffs[drv]->disk_status();
SomeRandomBloke 0:93acdd9f65f4 29 }
SomeRandomBloke 0:93acdd9f65f4 30
SomeRandomBloke 0:93acdd9f65f4 31 DRESULT disk_read (
SomeRandomBloke 0:93acdd9f65f4 32 BYTE drv, /* Physical drive nmuber (0..) */
SomeRandomBloke 0:93acdd9f65f4 33 BYTE *buff, /* Data buffer to store read data */
SomeRandomBloke 0:93acdd9f65f4 34 DWORD sector, /* Sector address (LBA) */
SomeRandomBloke 0:93acdd9f65f4 35 BYTE count /* Number of sectors to read (1..255) */
SomeRandomBloke 0:93acdd9f65f4 36 )
SomeRandomBloke 0:93acdd9f65f4 37 {
SomeRandomBloke 0:93acdd9f65f4 38 FFSDEBUG("disk_read(sector %d, count %d) on drv [%d]\n", sector, count, drv);
SomeRandomBloke 0:93acdd9f65f4 39 for(DWORD s=sector; s<sector+count; s++) {
SomeRandomBloke 0:93acdd9f65f4 40 FFSDEBUG(" disk_read(sector %d)\n", s);
SomeRandomBloke 0:93acdd9f65f4 41 int res = FATFileSystem::_ffs[drv]->disk_read((char*)buff, s);
SomeRandomBloke 0:93acdd9f65f4 42 if(res) {
SomeRandomBloke 0:93acdd9f65f4 43 return RES_PARERR;
SomeRandomBloke 0:93acdd9f65f4 44 }
SomeRandomBloke 0:93acdd9f65f4 45 buff += 512;
SomeRandomBloke 0:93acdd9f65f4 46 }
SomeRandomBloke 0:93acdd9f65f4 47 return RES_OK;
SomeRandomBloke 0:93acdd9f65f4 48 }
SomeRandomBloke 0:93acdd9f65f4 49
SomeRandomBloke 0:93acdd9f65f4 50 #if _READONLY == 0
SomeRandomBloke 0:93acdd9f65f4 51 DRESULT disk_write (
SomeRandomBloke 0:93acdd9f65f4 52 BYTE drv, /* Physical drive nmuber (0..) */
SomeRandomBloke 0:93acdd9f65f4 53 const BYTE *buff, /* Data to be written */
SomeRandomBloke 0:93acdd9f65f4 54 DWORD sector, /* Sector address (LBA) */
SomeRandomBloke 0:93acdd9f65f4 55 BYTE count /* Number of sectors to write (1..255) */
SomeRandomBloke 0:93acdd9f65f4 56 )
SomeRandomBloke 0:93acdd9f65f4 57 {
SomeRandomBloke 0:93acdd9f65f4 58 FFSDEBUG("disk_write(sector %d, count %d) on drv [%d]\n", sector, count, drv);
SomeRandomBloke 0:93acdd9f65f4 59 for(DWORD s=sector; s<sector+count; s++) {
SomeRandomBloke 0:93acdd9f65f4 60 FFSDEBUG(" disk_write(sector %d)\n", s);
SomeRandomBloke 0:93acdd9f65f4 61 int res = FATFileSystem::_ffs[drv]->disk_write((char*)buff, s);
SomeRandomBloke 0:93acdd9f65f4 62 if(res) {
SomeRandomBloke 0:93acdd9f65f4 63 return RES_PARERR;
SomeRandomBloke 0:93acdd9f65f4 64 }
SomeRandomBloke 0:93acdd9f65f4 65 buff += 512;
SomeRandomBloke 0:93acdd9f65f4 66 }
SomeRandomBloke 0:93acdd9f65f4 67 return RES_OK;
SomeRandomBloke 0:93acdd9f65f4 68 }
SomeRandomBloke 0:93acdd9f65f4 69 #endif /* _READONLY */
SomeRandomBloke 0:93acdd9f65f4 70
SomeRandomBloke 0:93acdd9f65f4 71 DRESULT disk_ioctl (
SomeRandomBloke 0:93acdd9f65f4 72 BYTE drv, /* Physical drive nmuber (0..) */
SomeRandomBloke 0:93acdd9f65f4 73 BYTE ctrl, /* Control code */
SomeRandomBloke 0:93acdd9f65f4 74 void *buff /* Buffer to send/receive control data */
SomeRandomBloke 0:93acdd9f65f4 75 )
SomeRandomBloke 0:93acdd9f65f4 76 {
SomeRandomBloke 0:93acdd9f65f4 77 FFSDEBUG("disk_ioctl(%d)\n", ctrl);
SomeRandomBloke 0:93acdd9f65f4 78 switch(ctrl) {
SomeRandomBloke 0:93acdd9f65f4 79 case CTRL_SYNC:
SomeRandomBloke 0:93acdd9f65f4 80 if(FATFileSystem::_ffs[drv] == NULL) {
SomeRandomBloke 0:93acdd9f65f4 81 return RES_NOTRDY;
SomeRandomBloke 0:93acdd9f65f4 82 } else if(FATFileSystem::_ffs[drv]->disk_sync()) {
SomeRandomBloke 0:93acdd9f65f4 83 return RES_ERROR;
SomeRandomBloke 0:93acdd9f65f4 84 }
SomeRandomBloke 0:93acdd9f65f4 85 return RES_OK;
SomeRandomBloke 0:93acdd9f65f4 86 case GET_SECTOR_COUNT:
SomeRandomBloke 0:93acdd9f65f4 87 if(FATFileSystem::_ffs[drv] == NULL) {
SomeRandomBloke 0:93acdd9f65f4 88 return RES_NOTRDY;
SomeRandomBloke 0:93acdd9f65f4 89 } else {
SomeRandomBloke 0:93acdd9f65f4 90 int res = FATFileSystem::_ffs[drv]->disk_sectors();
SomeRandomBloke 0:93acdd9f65f4 91 if(res > 0) {
SomeRandomBloke 0:93acdd9f65f4 92 *((DWORD*)buff) = res; // minimum allowed
SomeRandomBloke 0:93acdd9f65f4 93 return RES_OK;
SomeRandomBloke 0:93acdd9f65f4 94 } else {
SomeRandomBloke 0:93acdd9f65f4 95 return RES_ERROR;
SomeRandomBloke 0:93acdd9f65f4 96 }
SomeRandomBloke 0:93acdd9f65f4 97 }
SomeRandomBloke 0:93acdd9f65f4 98 case GET_BLOCK_SIZE:
SomeRandomBloke 0:93acdd9f65f4 99 *((DWORD*)buff) = 1; // default when not known
SomeRandomBloke 0:93acdd9f65f4 100 return RES_OK;
SomeRandomBloke 0:93acdd9f65f4 101
SomeRandomBloke 0:93acdd9f65f4 102 }
SomeRandomBloke 0:93acdd9f65f4 103 return RES_PARERR;
SomeRandomBloke 0:93acdd9f65f4 104 }
SomeRandomBloke 0:93acdd9f65f4 105