SD Card Interface class. Log raw data bytes to memory addresses of your choice, or format the card and use the FAT file system to write files.

Dependencies:   mbed

Committer:
Blaze513
Date:
Mon Aug 23 07:12:13 2010 +0000
Revision:
3:210eb67b260c
Parent:
1:94c648931f84
Child:
4:9a5878d316d5

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Blaze513 1:94c648931f84 1 /* mbed Microcontroller Library - FATDirHandle
Blaze513 1:94c648931f84 2 Copyright (c) 2008, sford */
Blaze513 3:210eb67b260c 3
Blaze513 3:210eb67b260c 4 //Modified by Thomas Hamilton, Copyright 2010
Blaze513 1:94c648931f84 5
Blaze513 1:94c648931f84 6 #include "FATDirHandle.h"
Blaze513 1:94c648931f84 7
Blaze513 1:94c648931f84 8 FATDirHandle::FATDirHandle(FAT_DIR InputDirStr)
Blaze513 1:94c648931f84 9 {
Blaze513 1:94c648931f84 10 DirectoryObject = InputDirStr;
Blaze513 1:94c648931f84 11 }
Blaze513 1:94c648931f84 12
Blaze513 1:94c648931f84 13 int FATDirHandle::closedir()
Blaze513 1:94c648931f84 14 {
Blaze513 1:94c648931f84 15 delete this;
Blaze513 1:94c648931f84 16 return 0;
Blaze513 1:94c648931f84 17 }
Blaze513 1:94c648931f84 18
Blaze513 1:94c648931f84 19 struct dirent* FATDirHandle::readdir()
Blaze513 1:94c648931f84 20 {
Blaze513 1:94c648931f84 21 FILINFO FileInfo;
Blaze513 1:94c648931f84 22 FRESULT Result = f_readdir(&DirectoryObject, &FileInfo);
Blaze513 1:94c648931f84 23 if (Result || !FileInfo.fname[0])
Blaze513 1:94c648931f84 24 {
Blaze513 1:94c648931f84 25 return NULL;
Blaze513 1:94c648931f84 26 }
Blaze513 1:94c648931f84 27 else
Blaze513 1:94c648931f84 28 {
Blaze513 1:94c648931f84 29 for (unsigned char i = 0; i < 13; i++)
Blaze513 1:94c648931f84 30 {
Blaze513 1:94c648931f84 31 CurrentEntry.d_name[i] = ((char*)FileInfo.fname)[i];
Blaze513 1:94c648931f84 32 }
Blaze513 1:94c648931f84 33 return &CurrentEntry;
Blaze513 1:94c648931f84 34 }
Blaze513 1:94c648931f84 35 }
Blaze513 1:94c648931f84 36
Blaze513 1:94c648931f84 37 void FATDirHandle::rewinddir()
Blaze513 1:94c648931f84 38 {
Blaze513 1:94c648931f84 39 DirectoryObject.index = 0;
Blaze513 1:94c648931f84 40 }
Blaze513 1:94c648931f84 41
Blaze513 1:94c648931f84 42 off_t FATDirHandle::telldir()
Blaze513 1:94c648931f84 43 {
Blaze513 1:94c648931f84 44 return (off_t)DirectoryObject.index;
Blaze513 1:94c648931f84 45 }
Blaze513 1:94c648931f84 46
Blaze513 1:94c648931f84 47 void FATDirHandle::seekdir(off_t location)
Blaze513 1:94c648931f84 48 {
Blaze513 1:94c648931f84 49 DirectoryObject.index = (WORD)location;
Blaze513 1:94c648931f84 50 }