40 #define FLAG_FILE_CLOSED 0
41 #define FLAG_FILE_OPEN 1
42 eeprom_addr_t fileptr;
43 eeprom_addr_t filesize;
46 static struct filestate file;
48 #ifdef CFS_EEPROM_CONF_OFFSET
49 #define CFS_EEPROM_OFFSET CFS_EEPROM_CONF_OFFSET
51 #define CFS_EEPROM_OFFSET 0
58 if(file.flag == FLAG_FILE_CLOSED) {
59 file.flag = FLAG_FILE_OPEN;
65 file.fileptr = file.filesize;
80 file.flag = FLAG_FILE_CLOSED;
84 cfs_read(
int f,
void *buf,
unsigned int len)
87 eeprom_read(CFS_EEPROM_OFFSET + file.fileptr, buf, len);
96 cfs_write(
int f,
const void *buf,
unsigned int len)
99 eeprom_write(CFS_EEPROM_OFFSET + file.fileptr, (
unsigned char *)buf, len);
void eeprom_read(eeprom_addr_t addr, unsigned char *buf, int size)
Read data from the EEPROM.
int cfs_open(const char *name, int flags)
Open a file.
cfs_offset_t cfs_seek(int fd, cfs_offset_t offset, int whence)
Seek to a specified position in an open file.
#define CFS_WRITE
Specify that cfs_open() should open a file for writing.
#define CFS_READ
Specify that cfs_open() should open a file for reading.
int cfs_readdir(struct cfs_dir *dir, struct cfs_dirent *record)
Read a directory entry.
void eeprom_write(eeprom_addr_t addr, unsigned char *buf, int size)
Write a buffer into EEPROM.
#define CFS_APPEND
Specify that cfs_open() should append written data to the file rather than overwriting it...
int cfs_remove(const char *name)
Remove a file.
void cfs_closedir(struct cfs_dir *dir)
Close a directory opened with cfs_opendir().
int cfs_opendir(struct cfs_dir *dir, const char *name)
Open a directory for reading directory entries.
#define CFS_SEEK_SET
Specify that cfs_seek() should compute the offset from the beginning of the file. ...
void cfs_close(int fd)
Close an open file.