Jump to content
Sign in to follow this  
trossin

Fat12, Fat16 And Fat32 Sd Card Interface Example

Recommended Posts

I finished up adding write support as well as date and time to my SD project this Spring and finally got it on the web recently. With this code, it is possible to read, write and delete files as well as created and remove directories on FAT file systems built on MMC, SD or SDHC cards using long filenames.

 

The project can be found here:

 

http://www.tedrossin.net46.net/Electronics/Pic/Pic.html#SDCardInterface

 

This project uses the large memory model found in BoostC 7.xx. I should also mention that I developed this project with a custom SD card plugin that really helped ease development.

 

I still need to add more detail to the web page but here is a list of the commands that can be used in local mode from a terminal:

 

ls, cd, pwd, cat, new, rm, mkdir, rmdir, date, setdate, df, unmount, mount

 

Here are the functions that the above commands are using:

unsigned char FsMountFileSystem(unsigned char ReadOnly);

void FsUnmountFileSystem(void);

void FsPushCdStack(void);

void FsPopCdStack(void);

unsigned char FsGetFirstDir(char *Name,FsDirInfo *Info);

unsigned char FsGetNextDir(char *Name,FsDirInfo *Info);

unsigned char FsSeek(unsigned char FdIndex,unsigned long Offset,unsigned char Origin);

unsigned char FsClose(unsigned char FdIndex);

unsigned int FsRead(unsigned char FdIndex, unsigned int Count, unsigned char *Data);

unsigned int FsWrite(unsigned char FdIndex, unsigned int Count, unsigned char *Data);

unsigned char FsOpen(unsigned char Mode,char *Name);

unsigned char FsRemove(char *Name);

unsigned char FsMakeDir(char *Name);

unsigned char FsRemoveDir(char *Name);

void FsGetCurrentDirectory(char *Path);

unsigned char FsSetCurrentDirectory(char *Name);

unsigned long FsGetFreeSectors(void);

void FsInit(void);

 

 

Here are the commands that can be used in remote mode:

#define FS_VERSION 1

#define FS_INIT 2

#define FS_READ_SECTOR 3

#define FS_MOUNT 4

#define FS_MOUNT_READ_ONLY 5

#define FS_GET_FIRST_CURRENT_DIR 6

#define FS_GET_FIRST_DIR 7

#define FS_GET_NEXT_DIR 8

#define FS_SET_CURRENT_DIR 9

#define FS_GET_CURRENT_DIR 10

#define FS_OPEN 11

#define FS_READ 12

#define FS_WRITE 13

#define FS_CLOSE 14

#define FS_SEEK 15

#define FS_PUSH_DIR 16

#define FS_POP_DIR 17

#define FS_GET_FREE_SECTORS 18

#define FS_REMOVE 19

#define FS_MAKE_DIR 20

#define FS_REMOVE_DIR 21

#define FS_GET_TIME 22

#define FS_SET_TIME 23

#define FS_UNMOUNT 24

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...