##// END OF EJS Templates
sync
sync

File last commit:

r16:194f637a2640 default
r31:74dca42d580c default
Show More
streamdevices.tex
49 lines | 1.5 KiB | application/x-tex | TexLexer
\chapter{Stream devices}
\paragraph{Introduction}
This familly is composed of all the devices that threat data as an unaddressed stream. For example SPI and UART are both streams devices, a sofware or hardware FIFO is olso a stream device.
\section{The stream device representation}
The stream device is represented by a standard structure.
\begin{lstlisting}
struct streamDev
{
int (*write)(stream* _this,void* data,int sz,int n);
int (*read)(stream* _this,void* data,int size,int n);
int (*setpos)(stream* _this,int pos);
int streamPt;
void* dev;
}
\end{lstlisting}
\subsection{Details}
\subsubsection{\textbf{Writing on a stream device}}
int \textbf{write}(stream* \_this,void* data,int sz,int n) \\
This function should write the given data on the stream device. The data pointer is a table of n elements of size sz.
The write function should return the number of bytes writen.
\subsubsection{\textbf{Reading form a stream device}}
int \textbf{read}(stream* \_this,void* data,int sz,int n) \\
This function should read data from the stream device to the data pointer. The data pointer is a table of n elements of size sz.
The read function should return the number of read bytes. \\
Note: writing -1 for n should just return the availiable data.