ASF docs  3.1.3
Some important library documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
file.h File Reference
#include "fs_com.h"
#include "fat.h"
+ Include dependency graph for file.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Fs_file_segment

Macros

options for file_seek() routine
#define FS_SEEK_SET   0x00
 start at the beginning
#define FS_SEEK_END   0x01
 start at the end of file and rewind
#define FS_SEEK_CUR_RE   0x02
 start at the current position and rewind
#define FS_SEEK_CUR_FW   0x03
 start at the current position and foward

Functions

bool file_ispresent (void)
 This function checks if a file is selected.
bool file_open (uint8_t fopen_mode)
 This function opens the selected file.
bool file_read (Fs_file_segment _MEM_TYPE_SLOW_ *segment)
 This function returns a segment (position & size) in a physical memory corresponding at the file.
uint16_t file_read_buf (uint8_t _MEM_TYPE_SLOW_ *buffer, uint16_t u16_buf_size)
 This function copys in a buffer the file data corresponding at the current position.
uint16_t file_getc (void)
 This function returns the next byte of file.
bool file_write (Fs_file_segment _MEM_TYPE_SLOW_ *segment)
 This function allocs and returns a segment (position & size) in a physical memory corresponding at the file.
bool file_set_eof (void)
 This function sets the end of file at the current position.
uint16_t file_write_buf (uint8_t _MEM_TYPE_SLOW_ *buffer, uint16_t u16_buf_size)
 This function transfer a buffer to a file at the current file position.
bool file_putc (uint8_t u8_byte)
 This function writes a byte in the file.
uint32_t file_getpos (void)
 This function returns the position in the file.
bool file_seek (uint32_t u32_pos, uint8_t u8_whence)
 This function changes the position in the file.
uint8_t file_bof (void)
 This function checks the beginning of file.
uint8_t file_eof (void)
 This function checks the end of file.
void file_flush (void)
 This function flushs the internal cache (file datas and file information)
void file_close (void)
 This function closes the file.

Data Structure Documentation

struct Fs_file_segment

Definition at line 65 of file file.h.

Data Fields
uint16_t u16_size
uint32_t u32_addr
uint8_t u8_lun

Macro Definition Documentation

#define FS_SEEK_CUR_FW   0x03

Definition at line 60 of file file.h.

#define FS_SEEK_CUR_RE   0x02

Definition at line 59 of file file.h.

#define FS_SEEK_END   0x01

Definition at line 58 of file file.h.

#define FS_SEEK_SET   0x00

Definition at line 57 of file file.h.


Function Documentation

uint8_t file_bof ( void  )
Returns:
1 the position is at the beginning of file
0 the position isn't at the beginning of file
FFh error

Definition at line 714 of file file.c.

void file_close ( void  )

Definition at line 750 of file file.c.

uint8_t file_eof ( void  )
Returns:
1 the position is at the end of file
0 the position isn't at the end of file
FFh error

Definition at line 729 of file file.c.

void file_flush ( void  )

Definition at line 739 of file file.c.

uint16_t file_getc ( void  )
Returns:
The byte readed
EOF, in case of error or end of file

Definition at line 366 of file file.c.

uint32_t file_getpos ( void  )
Returns:
Position in file

Definition at line 635 of file file.c.

bool file_ispresent ( void  )
Returns:
true, a file is selected
false, otherwise

Definition at line 75 of file file.c.

bool file_open ( uint8_t  fopen_mode)
Parameters:
fopen_modeoption to open the file :
FOPEN_MODE_R R access, flux pointer = 0, size not modify
FOPEN_MODE_R_PLUS R/W access, flux pointer = 0, size not modify
FOPEN_MODE_W W access, flux pointer = 0, size = 0
FOPEN_MODE_W_PLUS R/W access, flux pointer = 0, size = 0
FOPEN_MODE_APPEND W access, flux pointer = at the end, size not modify
Returns:
false in case of error, see global value "fs_g_status" for more detail
true otherwise

Definition at line 95 of file file.c.

bool file_putc ( uint8_t  u8_byte)
Parameters:
u8_bytebyte to write
Returns:
false in case of error, see global value "fs_g_status" for more detail
true otherwise
bool file_read ( Fs_file_segment _MEM_TYPE_SLOW_ *  segment)
Parameters:
segmentPointer on the segment structure:
->u32_size_or_pos IN, shall contains maximum number of sector to read in file (0 = unlimited)
->u32_size_or_pos OUT, containt the segment size (unit sector)
->other IN, ignored
->other OUT, contains the segment position
Returns:
false in case of error, see global value "fs_g_status" for more detail
true otherwise
//! This routine is interesting to read a file via a DMA and avoid the file system decode
//! because this routine returns a physical memory segment without File System information.
//! Note: the file can be fragmented and you must call file_read() for each fragments.
//! 

Definition at line 175 of file file.c.

uint16_t file_read_buf ( uint8_t _MEM_TYPE_SLOW_ *  buffer,
uint16_t  u16_buf_size 
)
Parameters:
bufferbuffer to fill
u16_buf_sizebuffer size
Returns:
number of byte read
0, in case of error

Definition at line 252 of file file.c.

bool file_seek ( uint32_t  u32_pos,
uint8_t  u8_whence 
)
Parameters:
u32_posnumber of byte to seek
u8_whencedirection of seek
FS_SEEK_SET , start at the beginning and foward
FS_SEEK_END , start at the end of file and rewind
FS_SEEK_CUR_RE, start at the current position and rewind
FS_SEEK_CUR_FW, start at the current position and foward
Returns:
false in case of error, see global value "fs_g_status" for more detail
true otherwise

Definition at line 656 of file file.c.

bool file_set_eof ( void  )
Returns:
false in case of error, see global value "fs_g_status" for more detail
true otherwise
//! This routine is usualy used after the last file_write() call.
//! The file_write() routine uses the sector unit (512B),
//! and you can set a specific byte size with a file_seek() call and fiel_set_eof() call.
//! 
bool file_write ( Fs_file_segment _MEM_TYPE_SLOW_ *  segment)
Parameters:
segmentPointer on the segment structure:
->u32_size_or_pos IN, shall contains the maximum number of sector to write in file
->u32_size_or_pos OUT, contains the segment size (unit sector)
->other IN, ignored
->other OUT, contains the segment position
Returns:
false in case of error, see global value "fs_g_status" for more detail
true otherwise
//! This routine is interesting to write a file via a DMA and avoid the file system decode
//! because this routine returns a physical memory segment without File System information.
//! Note: the file can be fragmented and you must call file_write() for each fragments.
//! 
uint16_t file_write_buf ( uint8_t _MEM_TYPE_SLOW_ *  buffer,
uint16_t  u16_buf_size 
)
Parameters:
bufferdata buffer
u16_buf_sizedata size
Returns:
number of byte write
0, in case of error