Click here to Skip to main content
15,897,187 members
Articles / Mobile Apps

TCP/IP Stack, FAT16 System on a Microcontroller

Rate me:
Please Sign up or sign in to vote.
4.53/5 (10 votes)
31 Jul 2011GPL35 min read 43.5K   2.1K   36  
TCP/IP Stack, FAT16 System on a Microcontroller
/*
 * myfile.h
 *
 *  Created on: 29/07/2011
 *      Author: lyl
 */

#ifndef MYFILE_H_
#define MYFILE_H_

#define FATFS_MAX_OPEN_FILES 1

#define FAT_SFN_SIZE_FULL						 11			

struct _FILE;

struct cluster_lookup
{
	DWORD ClusterIdx;
	DWORD CurrentCluster;
};

typedef struct _FILE
{
	DWORD			parentcluster;
	DWORD			startcluster;
	DWORD			bytenum;
	DWORD			filelength;
	int				filelength_changed;
	char			path[FATFS_MAX_LONG_FILENAME];
	char			filename[FATFS_MAX_LONG_FILENAME];
	BYTE			shortfilename[11];

	// Cluster Lookup
	struct cluster_lookup	last_fat_lookup;

	// Read/Write sector buffer
	SECTOR_BUFFER	file_data;

	// File fopen flags
	BYTE			flags;
#define FILE_READ	(1 << 0)
#define FILE_WRITE	(1 << 1)
#define FILE_APPEND	(1 << 2)
#define FILE_BINARY	(1 << 3)
#define FILE_ERASE	(1 << 4)
#define FILE_CREATE	(1 << 5)

	struct _FILE			*next;
} FILE;


#endif /* MYFILE_H_ */

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions