URL
https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk
Subversion Repositories openrisc_2011-10-31
[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [Common/] [FileSystem/] [FatFs-0.7e/] [doc/] [en/] [forward.html] - Rev 637
Go to most recent revision | Compare with Previous | Blame | View Log
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Style-Type" content="text/css"> <link rel="up" title="FatFs" href="../00index_e.html"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <title>FatFs - f_forward</title> </head> <body> <div class="para"> <h2>f_forward</h2> <p>The f_forward function reads the file data and forward it to the data streaming device.</p> <pre> FRESULT f_forward ( FIL* <em>FileObject</em>, /* File object */ UINT (*<em>Func</em>)(const BYTE*,UINT), /* Data streaming function */ UINT <em>ByteToFwd</em>, /* Number of bytes to forward */ UINT* <em>ByteFwd</em> /* Number of bytes forwarded */ ); </pre> </div> <div class="para"> <h4>Parameters</h4> <dl class="par"> <dt>FileObject</dt> <dd>Pointer to the open file object.</dd> <dt>Func</dt> <dd>Pointer to the user-defined data streaming function. For details, refer to the sample code.</dd> <dt>ByteToFwd</dt> <dd>Number of bytes to forward in range of UINT.</dd> <dt>ByteFwd</dt> <dd>Pointer to the UINT variable to return number of bytes forwarded.</dd> </dl> </div> <div class="para"> <h4>Return Values</h4> <dl class="ret"> <dt>FR_OK (0)</dt> <dd>The function succeeded.</dd> <dt>FR_DENIED</dt> <dd>The function denied due to the file has been opened in non-read mode.</dd> <dt>FR_DISK_ERR</dt> <dd>The function failed due to an error in the disk function.</dd> <dt>FR_INT_ERR</dt> <dd>The function failed due to a wrong FAT structure or an internal error.</dd> <dt>FR_NOT_READY</dt> <dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd> <dt>FR_INVALID_OBJECT</dt> <dd>The file object is invalid.</dd> </dl> </div> <div class="para"> <h4>Description</h4> <p>The f_forward function reads the data from the file and forward it to the outgoing stream without data buffer. This is suitable for small memory system because it does not require any data buffer at application module. The file pointer of the file object increases in number of bytes forwarded. In case of <tt>*ByteFwd < ByteToFwd</tt> without error, it means the requested bytes could not be transferred due to end of file or stream goes busy during data transfer.</p> </div> <div class="para"> <h4>QuickInfo</h4> <p>Available when <tt>_USE_FORWARD == 1</tt> and <tt>_FS_TINY == 1</tt>.</p> </div> <div class="para"> <h4>Example (Audio playback)</h4> <pre> /*-----------------------------------------------------------------------*/ /* Sample code of data transfer function to be called from f_forward */ /*-----------------------------------------------------------------------*/ UINT out_stream ( /* Returns number of bytes sent or stream status */ const BYTE *p, /* Pointer to the data block to be sent */ UINT btf /* >0: Transfer call (Number of bytes to be sent). 0: Sense call */ ) { UINT cnt = 0; if (btf == 0) { /* Sense call */ /* Return stream status (0: Busy, 1: Ready) */ /* When once it returned ready to sense call, it must accept a byte at least */ /* at subsequent transfer call, or f_forward will fail with FR_INT_ERROR. */ if (FIFO_READY) cnt = 1; } else { /* Transfer call */ do { /* Repeat while there is any data to be sent and the stream is ready */ FIFO_PORT = *p++; cnt++; } while (cnt < btf && FIFO_READY); } return cnt; } /*-----------------------------------------------------------------------*/ /* Sample code using f_forward function */ /*-----------------------------------------------------------------------*/ FRESULT play_file ( char *fn /* Pointer to the audio file name to be played */ ) { FRESULT rc; FIL fil; UINT dmy; /* Open the audio file in read only mode */ rc = f_open(&fil, fn, FA_READ); /* Repeat until the file pointer reaches end of the file */ while (rc == FR_OK && fil.fptr < fil.fsize) { /* any other processes... */ /* Fill output stream periodicaly or on-demand */ rc = f_forward(&fil, out_stream, 1000, &dmy); } /* The read-only file object may be discarded without close */ return rc; } </pre> </div> <div class="para"> <h4>See Also</h4> <p><tt><a href="open.html">f_open</a>, <a href="gets.html">fgets</a>, <a href="write.html">f_write</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p> </div> <p class="foot"><a href="../00index_e.html">Return</a></p> </body> </html>
Go to most recent revision | Compare with Previous | Blame | View Log