\section{aversive\_\-10-03-12/modules/base/cirbuf/cirbuf.h File Reference}
\label{cirbuf_8h}\index{aversive\_\-10-03-12/modules/base/cirbuf/cirbuf.h@{aversive\_\-10-03-12/modules/base/cirbuf/cirbuf.h}}
{\tt \#include $<$aversive.h$>$}\par
{\tt \#include $<$stdio.h$>$}\par
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct {\bf cirbuf}
\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define {\bf dprintf}(args...)~do \{\} while(0)
\item 
\#define {\bf CIRBUF\_\-IS\_\-FULL}({\bf cirbuf})~(({\bf cirbuf}) $\rightarrow$ maxlen == ({\bf cirbuf}) $\rightarrow$ len)
\item 
\#define {\bf CIRBUF\_\-IS\_\-EMPTY}({\bf cirbuf})~(({\bf cirbuf}) $\rightarrow$ len == 0)
\item 
\#define {\bf CIRBUF\_\-GET\_\-LEN}({\bf cirbuf})~(({\bf cirbuf}) $\rightarrow$ len)
\item 
\#define {\bf CIRBUF\_\-GET\_\-MAXLEN}({\bf cirbuf})~(({\bf cirbuf}) $\rightarrow$ maxlen)
\item 
\#define {\bf CIRBUF\_\-GET\_\-FREELEN}({\bf cirbuf})~(({\bf cirbuf}) $\rightarrow$ maxlen - ({\bf cirbuf}) $\rightarrow$ len)
\item 
\#define {\bf CIRBUF\_\-FOREACH}(c, {\bf i}, e)
\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
typedef signed char {\bf cirbuf\_\-int}
\item 
typedef unsigned char {\bf cirbuf\_\-uint}
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void {\bf cirbuf\_\-init} (struct {\bf cirbuf} $\ast$cbuf, char $\ast$buf, {\bf cirbuf\_\-uint} start, {\bf cirbuf\_\-uint} maxlen)
\item 
{\bf cirbuf\_\-int} {\bf cirbuf\_\-add\_\-head\_\-safe} (struct {\bf cirbuf} $\ast$cbuf, char c)
\item 
void {\bf cirbuf\_\-add\_\-head} (struct {\bf cirbuf} $\ast$cbuf, char c)
\item 
{\bf cirbuf\_\-int} {\bf cirbuf\_\-add\_\-tail\_\-safe} (struct {\bf cirbuf} $\ast$cbuf, char c)
\item 
void {\bf cirbuf\_\-add\_\-tail} (struct {\bf cirbuf} $\ast$cbuf, char c)
\item 
{\bf cirbuf\_\-int} {\bf cirbuf\_\-del\_\-head\_\-safe} (struct {\bf cirbuf} $\ast$cbuf)
\item 
void {\bf cirbuf\_\-del\_\-head} (struct {\bf cirbuf} $\ast$cbuf)
\item 
{\bf cirbuf\_\-int} {\bf cirbuf\_\-del\_\-tail\_\-safe} (struct {\bf cirbuf} $\ast$cbuf)
\item 
void {\bf cirbuf\_\-del\_\-tail} (struct {\bf cirbuf} $\ast$cbuf)
\item 
char {\bf cirbuf\_\-get\_\-head} (struct {\bf cirbuf} $\ast$cbuf)
\item 
char {\bf cirbuf\_\-get\_\-tail} (struct {\bf cirbuf} $\ast$cbuf)
\item 
{\bf cirbuf\_\-int} {\bf cirbuf\_\-add\_\-buf\_\-head} (struct {\bf cirbuf} $\ast$cbuf, const char $\ast$c, {\bf cirbuf\_\-uint} n)
\item 
{\bf cirbuf\_\-int} {\bf cirbuf\_\-add\_\-buf\_\-tail} (struct {\bf cirbuf} $\ast$cbuf, const char $\ast$c, {\bf cirbuf\_\-uint} n)
\item 
{\bf cirbuf\_\-int} {\bf cirbuf\_\-del\_\-buf\_\-head} (struct {\bf cirbuf} $\ast$cbuf, {\bf cirbuf\_\-uint} size)
\item 
{\bf cirbuf\_\-int} {\bf cirbuf\_\-del\_\-buf\_\-tail} (struct {\bf cirbuf} $\ast$cbuf, {\bf cirbuf\_\-uint} size)
\item 
{\bf cirbuf\_\-int} {\bf cirbuf\_\-get\_\-buf\_\-head} (struct {\bf cirbuf} $\ast$cbuf, char $\ast$c, {\bf cirbuf\_\-uint} size)
\item 
{\bf cirbuf\_\-int} {\bf cirbuf\_\-get\_\-buf\_\-tail} (struct {\bf cirbuf} $\ast$cbuf, char $\ast$c, {\bf cirbuf\_\-uint} size)
\item 
void {\bf cirbuf\_\-align\_\-left} (struct {\bf cirbuf} $\ast$cbuf)
\item 
void {\bf cirbuf\_\-align\_\-right} (struct {\bf cirbuf} $\ast$cbuf)
\end{CompactItemize}


\subsection{Define Documentation}
\index{cirbuf.h@{cirbuf.h}!CIRBUF\_\-FOREACH@{CIRBUF\_\-FOREACH}}
\index{CIRBUF\_\-FOREACH@{CIRBUF\_\-FOREACH}!cirbuf.h@{cirbuf.h}}
\subsubsection[CIRBUF\_\-FOREACH]{\setlength{\rightskip}{0pt plus 5cm}\#define CIRBUF\_\-FOREACH(c, \/  {\bf i}, \/  e)}\label{cirbuf_8h_e71037392d0ab09ada6e0f32de60485c}


\textbf{Value:}

\begin{Code}\begin{verbatim}for ( i=0, e=(c)->buf[(c)->start] ;                     \
              i<((c)->len) ;                                    \
              i ++,  e=(c)->buf[((c)->start+i)%((c)->maxlen)])
\end{verbatim}
\end{Code}
Iterator for a circular buffer c: struct \doxyref{cirbuf}{p.}{structcirbuf} pointer i: an integer type (cirbuf\_\-uint is enough) internally used in the macro e: char that takes the value for each iteration 

Definition at line 104 of file cirbuf.h.

Referenced by rdline\_\-redisplay().\index{cirbuf.h@{cirbuf.h}!CIRBUF\_\-GET\_\-FREELEN@{CIRBUF\_\-GET\_\-FREELEN}}
\index{CIRBUF\_\-GET\_\-FREELEN@{CIRBUF\_\-GET\_\-FREELEN}!cirbuf.h@{cirbuf.h}}
\subsubsection[CIRBUF\_\-GET\_\-FREELEN]{\setlength{\rightskip}{0pt plus 5cm}\#define CIRBUF\_\-GET\_\-FREELEN({\bf cirbuf})~(({\bf cirbuf}) $\rightarrow$ maxlen - ({\bf cirbuf}) $\rightarrow$ len)}\label{cirbuf_8h_1b0430cf34b39c03c514389726bb2269}


return the number of free elts 

Definition at line 96 of file cirbuf.h.

Referenced by cirbuf\_\-add\_\-buf\_\-head(), cirbuf\_\-add\_\-buf\_\-tail(), and uart\_\-send\_\-9bits\_\-nowait().\index{cirbuf.h@{cirbuf.h}!CIRBUF\_\-GET\_\-LEN@{CIRBUF\_\-GET\_\-LEN}}
\index{CIRBUF\_\-GET\_\-LEN@{CIRBUF\_\-GET\_\-LEN}!cirbuf.h@{cirbuf.h}}
\subsubsection[CIRBUF\_\-GET\_\-LEN]{\setlength{\rightskip}{0pt plus 5cm}\#define CIRBUF\_\-GET\_\-LEN({\bf cirbuf})~(({\bf cirbuf}) $\rightarrow$ len)}\label{cirbuf_8h_6f8af31a60103bdd5f3102d0f63c1cc9}


return current size of the circular buffer (number of used elements) 

Definition at line 86 of file cirbuf.h.

Referenced by cirbuf\_\-del\_\-buf\_\-head(), cirbuf\_\-del\_\-buf\_\-tail(), cirbuf\_\-get\_\-buf\_\-head(), cirbuf\_\-get\_\-buf\_\-tail(), rdline\_\-char\_\-in(), rdline\_\-get\_\-buffer(), uart\_\-9bits\_\-recv\_\-nowait(), and uart\_\-send\_\-next\_\-char().\index{cirbuf.h@{cirbuf.h}!CIRBUF\_\-GET\_\-MAXLEN@{CIRBUF\_\-GET\_\-MAXLEN}}
\index{CIRBUF\_\-GET\_\-MAXLEN@{CIRBUF\_\-GET\_\-MAXLEN}!cirbuf.h@{cirbuf.h}}
\subsubsection[CIRBUF\_\-GET\_\-MAXLEN]{\setlength{\rightskip}{0pt plus 5cm}\#define CIRBUF\_\-GET\_\-MAXLEN({\bf cirbuf})~(({\bf cirbuf}) $\rightarrow$ maxlen)}\label{cirbuf_8h_974973f169f269a66ead97940442870c}


return size of the circular buffer (used + free elements) 

Definition at line 91 of file cirbuf.h.\index{cirbuf.h@{cirbuf.h}!CIRBUF\_\-IS\_\-EMPTY@{CIRBUF\_\-IS\_\-EMPTY}}
\index{CIRBUF\_\-IS\_\-EMPTY@{CIRBUF\_\-IS\_\-EMPTY}!cirbuf.h@{cirbuf.h}}
\subsubsection[CIRBUF\_\-IS\_\-EMPTY]{\setlength{\rightskip}{0pt plus 5cm}\#define CIRBUF\_\-IS\_\-EMPTY({\bf cirbuf})~(({\bf cirbuf}) $\rightarrow$ len == 0)}\label{cirbuf_8h_86f0099a8c07b1e19a822be4ea34496e}


Return 1 if the circular buffer is empty 

Definition at line 81 of file cirbuf.h.

Referenced by cirbuf\_\-add\_\-buf\_\-head(), cirbuf\_\-add\_\-buf\_\-tail(), cirbuf\_\-del\_\-buf\_\-head(), cirbuf\_\-del\_\-buf\_\-tail(), cirbuf\_\-del\_\-head\_\-safe(), cirbuf\_\-del\_\-tail\_\-safe(), rdline\_\-char\_\-in(), uart\_\-recv\_\-nowait(), uart\_\-send\_\-9bits\_\-nowait(), uart\_\-send\_\-next\_\-char(), and uart\_\-send\_\-nowait().\index{cirbuf.h@{cirbuf.h}!CIRBUF\_\-IS\_\-FULL@{CIRBUF\_\-IS\_\-FULL}}
\index{CIRBUF\_\-IS\_\-FULL@{CIRBUF\_\-IS\_\-FULL}!cirbuf.h@{cirbuf.h}}
\subsubsection[CIRBUF\_\-IS\_\-FULL]{\setlength{\rightskip}{0pt plus 5cm}\#define CIRBUF\_\-IS\_\-FULL({\bf cirbuf})~(({\bf cirbuf}) $\rightarrow$ maxlen == ({\bf cirbuf}) $\rightarrow$ len)}\label{cirbuf_8h_066ff91de4e6339f00e6d5bdef6770c0}


Return 1 if the circular buffer is full 

Definition at line 76 of file cirbuf.h.

Referenced by cirbuf\_\-add\_\-head\_\-safe(), cirbuf\_\-add\_\-tail\_\-safe(), and uart\_\-send\_\-nowait().\index{cirbuf.h@{cirbuf.h}!dprintf@{dprintf}}
\index{dprintf@{dprintf}!cirbuf.h@{cirbuf.h}}
\subsubsection[dprintf]{\setlength{\rightskip}{0pt plus 5cm}\#define dprintf(args...)~do \{\} while(0)}\label{cirbuf_8h_d558bdd87d02ff3556aeb75f70515d95}




Definition at line 63 of file cirbuf.h.

Referenced by cirbuf\_\-add\_\-buf\_\-head(), cirbuf\_\-add\_\-buf\_\-tail(), cirbuf\_\-get\_\-buf\_\-head(), and cirbuf\_\-get\_\-buf\_\-tail().

\subsection{Typedef Documentation}
\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-int@{cirbuf\_\-int}}
\index{cirbuf\_\-int@{cirbuf\_\-int}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-int]{\setlength{\rightskip}{0pt plus 5cm}typedef signed char {\bf cirbuf\_\-int}}\label{cirbuf_8h_9ed0d28ddcd64d27cf37c71a90881e11}


Circular buffer implementation. You should not use a circular buffer size $>$ 127.

Funcs are not atomic, so if $\ast$ necessary, each call should be protected by IRQ\_\-LOCKs. 

Definition at line 43 of file cirbuf.h.\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-uint@{cirbuf\_\-uint}}
\index{cirbuf\_\-uint@{cirbuf\_\-uint}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-uint]{\setlength{\rightskip}{0pt plus 5cm}typedef unsigned char {\bf cirbuf\_\-uint}}\label{cirbuf_8h_b2800915201a3192dbef9705dd0549f2}




Definition at line 44 of file cirbuf.h.

\subsection{Function Documentation}
\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-add\_\-buf\_\-head@{cirbuf\_\-add\_\-buf\_\-head}}
\index{cirbuf\_\-add\_\-buf\_\-head@{cirbuf\_\-add\_\-buf\_\-head}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-add\_\-buf\_\-head]{\setlength{\rightskip}{0pt plus 5cm}{\bf cirbuf\_\-int} cirbuf\_\-add\_\-buf\_\-head (struct {\bf cirbuf} $\ast$ {\em cbuf}, \/  const char $\ast$ {\em c}, \/  {\bf cirbuf\_\-uint} {\em n})}\label{cirbuf_8h_0b28e66b3e6b0c14e60176b35c990ec0}


Add a buffer at head of the circular buffer. 'c' is a pointer to a buffer, and n is the number of char to add. Return the number of copied bytes on success, or a negative value on \doxyref{error}{p.}{structerror}. 

Definition at line 31 of file cirbuf\_\-add\_\-buf\_\-head.c.

References cirbuf::buf, CIRBUF\_\-GET\_\-FREELEN, CIRBUF\_\-IS\_\-EMPTY, dprintf, EINVAL, cirbuf::len, cirbuf::maxlen, and cirbuf::start.

Referenced by uart\_\-send\_\-9bits(), and uart\_\-send\_\-9bits\_\-nowait().\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-add\_\-buf\_\-tail@{cirbuf\_\-add\_\-buf\_\-tail}}
\index{cirbuf\_\-add\_\-buf\_\-tail@{cirbuf\_\-add\_\-buf\_\-tail}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-add\_\-buf\_\-tail]{\setlength{\rightskip}{0pt plus 5cm}{\bf cirbuf\_\-int} cirbuf\_\-add\_\-buf\_\-tail (struct {\bf cirbuf} $\ast$ {\em cbuf}, \/  const char $\ast$ {\em c}, \/  {\bf cirbuf\_\-uint} {\em n})}\label{cirbuf_8h_cd0c8dc1a4b13df161c5adcd9351720d}


Add a buffer at tail of the circular buffer. 'c' is a pointer to a buffer, and n is the number of char to add. Return the number of copied bytes on success, or a negative value on \doxyref{error}{p.}{structerror}. 

Definition at line 31 of file cirbuf\_\-add\_\-buf\_\-tail.c.

References cirbuf::buf, CIRBUF\_\-GET\_\-FREELEN, CIRBUF\_\-IS\_\-EMPTY, dprintf, EINVAL, cirbuf::end, cirbuf::len, and cirbuf::maxlen.

Referenced by rdline\_\-char\_\-in().\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-add\_\-head@{cirbuf\_\-add\_\-head}}
\index{cirbuf\_\-add\_\-head@{cirbuf\_\-add\_\-head}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-add\_\-head]{\setlength{\rightskip}{0pt plus 5cm}void cirbuf\_\-add\_\-head (struct {\bf cirbuf} $\ast$ {\em cbuf}, \/  char {\em c})}\label{cirbuf_8h_eaa133e35546ce46723a7956830e5e86}


Add a character at head of the circular buffer. You \_\-must\_\- check that you have enough free space in the buffer before calling this func. 

Definition at line 52 of file cirbuf\_\-add\_\-head.c.

Referenced by rdline\_\-char\_\-in(), uart\_\-send(), and uart\_\-send\_\-nowait().\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-add\_\-head\_\-safe@{cirbuf\_\-add\_\-head\_\-safe}}
\index{cirbuf\_\-add\_\-head\_\-safe@{cirbuf\_\-add\_\-head\_\-safe}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-add\_\-head\_\-safe]{\setlength{\rightskip}{0pt plus 5cm}{\bf cirbuf\_\-int} cirbuf\_\-add\_\-head\_\-safe (struct {\bf cirbuf} $\ast$ {\em cbuf}, \/  char {\em c})}\label{cirbuf_8h_4fd357026153cc8f1f7c0a240a0c8e45}


Add a character at head of the circular buffer. Return 0 on success, or a negative value on \doxyref{error}{p.}{structerror}. 

Definition at line 42 of file cirbuf\_\-add\_\-head.c.

References CIRBUF\_\-IS\_\-FULL, and EINVAL.\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-add\_\-tail@{cirbuf\_\-add\_\-tail}}
\index{cirbuf\_\-add\_\-tail@{cirbuf\_\-add\_\-tail}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-add\_\-tail]{\setlength{\rightskip}{0pt plus 5cm}void cirbuf\_\-add\_\-tail (struct {\bf cirbuf} $\ast$ {\em cbuf}, \/  char {\em c})}\label{cirbuf_8h_bc3dc3350c5de3ba6457e37a0a849cd5}


Add a character at tail of the circular buffer. You \_\-must\_\- check that you have enough free space in the buffer before calling this func. 

Definition at line 53 of file cirbuf\_\-add\_\-tail.c.

Referenced by rdline\_\-char\_\-in().\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-add\_\-tail\_\-safe@{cirbuf\_\-add\_\-tail\_\-safe}}
\index{cirbuf\_\-add\_\-tail\_\-safe@{cirbuf\_\-add\_\-tail\_\-safe}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-add\_\-tail\_\-safe]{\setlength{\rightskip}{0pt plus 5cm}{\bf cirbuf\_\-int} cirbuf\_\-add\_\-tail\_\-safe (struct {\bf cirbuf} $\ast$ {\em cbuf}, \/  char {\em c})}\label{cirbuf_8h_01b0ed6692f88f487b324b97e6d231c1}


Add a character at tail of the circular buffer. Return 0 on success, or a negative value on \doxyref{error}{p.}{structerror}. 

Definition at line 43 of file cirbuf\_\-add\_\-tail.c.

References CIRBUF\_\-IS\_\-FULL, and EINVAL.

Referenced by rdline\_\-char\_\-in().\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-align\_\-left@{cirbuf\_\-align\_\-left}}
\index{cirbuf\_\-align\_\-left@{cirbuf\_\-align\_\-left}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-align\_\-left]{\setlength{\rightskip}{0pt plus 5cm}void cirbuf\_\-align\_\-left (struct {\bf cirbuf} $\ast$ {\em cbuf})}\label{cirbuf_8h_e5a8e0d6e292a8d1c5dafbb1ddbc35c0}


Set the start of the data to the index 0 of the internal buffer. 

Definition at line 62 of file cirbuf\_\-align.c.

References cirbuf::maxlen, and cirbuf::start.

Referenced by rdline\_\-char\_\-in(), and rdline\_\-get\_\-buffer().\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-align\_\-right@{cirbuf\_\-align\_\-right}}
\index{cirbuf\_\-align\_\-right@{cirbuf\_\-align\_\-right}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-align\_\-right]{\setlength{\rightskip}{0pt plus 5cm}void cirbuf\_\-align\_\-right (struct {\bf cirbuf} $\ast$ {\em cbuf})}\label{cirbuf_8h_7d305c625511b76d4766fa4dedb16468}


Set the end of the data to the last index of the internal buffer. 

Definition at line 77 of file cirbuf\_\-align.c.

References cirbuf::end, cirbuf::maxlen, and cirbuf::start.\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-del\_\-buf\_\-head@{cirbuf\_\-del\_\-buf\_\-head}}
\index{cirbuf\_\-del\_\-buf\_\-head@{cirbuf\_\-del\_\-buf\_\-head}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-del\_\-buf\_\-head]{\setlength{\rightskip}{0pt plus 5cm}{\bf cirbuf\_\-int} cirbuf\_\-del\_\-buf\_\-head (struct {\bf cirbuf} $\ast$ {\em cbuf}, \/  {\bf cirbuf\_\-uint} {\em size})}\label{cirbuf_8h_115d24603e140274d48ec302dcdb4b31}


Remove chars at the head of the circular buffer. Return 0 on success, or a negative value on \doxyref{error}{p.}{structerror}. 

Definition at line 30 of file cirbuf\_\-del\_\-buf\_\-head.c.

References CIRBUF\_\-GET\_\-LEN, CIRBUF\_\-IS\_\-EMPTY, EINVAL, cirbuf::len, cirbuf::maxlen, and cirbuf::start.

Referenced by rdline\_\-char\_\-in().\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-del\_\-buf\_\-tail@{cirbuf\_\-del\_\-buf\_\-tail}}
\index{cirbuf\_\-del\_\-buf\_\-tail@{cirbuf\_\-del\_\-buf\_\-tail}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-del\_\-buf\_\-tail]{\setlength{\rightskip}{0pt plus 5cm}{\bf cirbuf\_\-int} cirbuf\_\-del\_\-buf\_\-tail (struct {\bf cirbuf} $\ast$ {\em cbuf}, \/  {\bf cirbuf\_\-uint} {\em size})}\label{cirbuf_8h_9b4abdfc398f7adbaf5f08bc40e7abca}


Remove chars at the tail of the circular buffer. Return 0 on success, or a negative value on \doxyref{error}{p.}{structerror}. 

Definition at line 30 of file cirbuf\_\-del\_\-buf\_\-tail.c.

References CIRBUF\_\-GET\_\-LEN, CIRBUF\_\-IS\_\-EMPTY, EINVAL, cirbuf::end, cirbuf::len, and cirbuf::maxlen.

Referenced by uart\_\-9bits\_\-recv\_\-nowait(), and uart\_\-send\_\-next\_\-char().\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-del\_\-head@{cirbuf\_\-del\_\-head}}
\index{cirbuf\_\-del\_\-head@{cirbuf\_\-del\_\-head}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-del\_\-head]{\setlength{\rightskip}{0pt plus 5cm}void cirbuf\_\-del\_\-head (struct {\bf cirbuf} $\ast$ {\em cbuf})}\label{cirbuf_8h_bf12989a841ca0510d41fd50caf612da}


Remove a char at the head of the circular buffer. You \_\-must\_\- check that buffer is not empty before calling the function. 

Definition at line 50 of file cirbuf\_\-del\_\-head.c.

Referenced by rdline\_\-char\_\-in().\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-del\_\-head\_\-safe@{cirbuf\_\-del\_\-head\_\-safe}}
\index{cirbuf\_\-del\_\-head\_\-safe@{cirbuf\_\-del\_\-head\_\-safe}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-del\_\-head\_\-safe]{\setlength{\rightskip}{0pt plus 5cm}{\bf cirbuf\_\-int} cirbuf\_\-del\_\-head\_\-safe (struct {\bf cirbuf} $\ast$ {\em cbuf})}\label{cirbuf_8h_217f725ee86b3cb61b2ddf352e8f5661}


Remove a char at the head of the circular buffer. Return 0 on success, or a negative value on \doxyref{error}{p.}{structerror}. 

Definition at line 40 of file cirbuf\_\-del\_\-head.c.

References CIRBUF\_\-IS\_\-EMPTY, and EINVAL.

Referenced by rdline\_\-char\_\-in().\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-del\_\-tail@{cirbuf\_\-del\_\-tail}}
\index{cirbuf\_\-del\_\-tail@{cirbuf\_\-del\_\-tail}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-del\_\-tail]{\setlength{\rightskip}{0pt plus 5cm}void cirbuf\_\-del\_\-tail (struct {\bf cirbuf} $\ast$ {\em cbuf})}\label{cirbuf_8h_c66f5650bd69df5c7333121166f81a96}


Remove a char at the tail of the circular buffer. You \_\-must\_\- check that buffer is not empty before calling the function. 

Definition at line 51 of file cirbuf\_\-del\_\-tail.c.

Referenced by rdline\_\-char\_\-in(), uart\_\-recv\_\-nowait(), and uart\_\-send\_\-next\_\-char().\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-del\_\-tail\_\-safe@{cirbuf\_\-del\_\-tail\_\-safe}}
\index{cirbuf\_\-del\_\-tail\_\-safe@{cirbuf\_\-del\_\-tail\_\-safe}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-del\_\-tail\_\-safe]{\setlength{\rightskip}{0pt plus 5cm}{\bf cirbuf\_\-int} cirbuf\_\-del\_\-tail\_\-safe (struct {\bf cirbuf} $\ast$ {\em cbuf})}\label{cirbuf_8h_ef1ad576965cfe8c8e9af2545154ede9}


Remove a char at the tail of the circular buffer. Return 0 on success, or a negative value on \doxyref{error}{p.}{structerror}. 

Definition at line 41 of file cirbuf\_\-del\_\-tail.c.

References CIRBUF\_\-IS\_\-EMPTY, and EINVAL.

Referenced by rdline\_\-char\_\-in().\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-get\_\-buf\_\-head@{cirbuf\_\-get\_\-buf\_\-head}}
\index{cirbuf\_\-get\_\-buf\_\-head@{cirbuf\_\-get\_\-buf\_\-head}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-get\_\-buf\_\-head]{\setlength{\rightskip}{0pt plus 5cm}{\bf cirbuf\_\-int} cirbuf\_\-get\_\-buf\_\-head (struct {\bf cirbuf} $\ast$ {\em cbuf}, \/  char $\ast$ {\em c}, \/  {\bf cirbuf\_\-uint} {\em size})}\label{cirbuf_8h_bcc63846f8b2a035e578de5df8502ae3}


Copy a maximum of 'size' characters from the head of the circular buffer to a flat one pointed by 'c'. Return the number of copied chars. 

Definition at line 30 of file cirbuf\_\-get\_\-buf\_\-head.c.

References cirbuf::buf, CIRBUF\_\-GET\_\-LEN, dprintf, cirbuf::end, cirbuf::maxlen, and cirbuf::start.

Referenced by rdline\_\-char\_\-in().\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-get\_\-buf\_\-tail@{cirbuf\_\-get\_\-buf\_\-tail}}
\index{cirbuf\_\-get\_\-buf\_\-tail@{cirbuf\_\-get\_\-buf\_\-tail}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-get\_\-buf\_\-tail]{\setlength{\rightskip}{0pt plus 5cm}{\bf cirbuf\_\-int} cirbuf\_\-get\_\-buf\_\-tail (struct {\bf cirbuf} $\ast$ {\em cbuf}, \/  char $\ast$ {\em c}, \/  {\bf cirbuf\_\-uint} {\em size})}\label{cirbuf_8h_2f74056c63744396eea367f9655b3bc4}


Copy a maximum of 'size' characters from the tail of the circular buffer to a flat one pointed by 'c'. Return the number of copied chars. 

Definition at line 31 of file cirbuf\_\-get\_\-buf\_\-tail.c.

References cirbuf::buf, CIRBUF\_\-GET\_\-LEN, dprintf, cirbuf::end, cirbuf::maxlen, and cirbuf::start.

Referenced by uart\_\-9bits\_\-recv\_\-nowait(), and uart\_\-send\_\-next\_\-char().\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-get\_\-head@{cirbuf\_\-get\_\-head}}
\index{cirbuf\_\-get\_\-head@{cirbuf\_\-get\_\-head}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-get\_\-head]{\setlength{\rightskip}{0pt plus 5cm}char cirbuf\_\-get\_\-head (struct {\bf cirbuf} $\ast$ {\em cbuf})}\label{cirbuf_8h_c90f782baf16b4928657a370df1b758b}


Return the head of the circular buffer. You \_\-must\_\- check that buffer is not empty before calling the function. 

Definition at line 30 of file cirbuf\_\-get\_\-head.c.

References cirbuf::buf, and cirbuf::start.

Referenced by rdline\_\-char\_\-in().\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-get\_\-tail@{cirbuf\_\-get\_\-tail}}
\index{cirbuf\_\-get\_\-tail@{cirbuf\_\-get\_\-tail}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-get\_\-tail]{\setlength{\rightskip}{0pt plus 5cm}char cirbuf\_\-get\_\-tail (struct {\bf cirbuf} $\ast$ {\em cbuf})}\label{cirbuf_8h_8d09eab758c29aed6f4727a698906889}


Return the tail of the circular buffer. You \_\-must\_\- check that buffer is not empty before calling the function. 

Definition at line 30 of file cirbuf\_\-get\_\-tail.c.

References cirbuf::buf, and cirbuf::end.

Referenced by rdline\_\-char\_\-in(), uart\_\-recv\_\-nowait(), and uart\_\-send\_\-next\_\-char().\index{cirbuf.h@{cirbuf.h}!cirbuf\_\-init@{cirbuf\_\-init}}
\index{cirbuf\_\-init@{cirbuf\_\-init}!cirbuf.h@{cirbuf.h}}
\subsubsection[cirbuf\_\-init]{\setlength{\rightskip}{0pt plus 5cm}void cirbuf\_\-init (struct {\bf cirbuf} $\ast$ {\em cbuf}, \/  char $\ast$ {\em buf}, \/  {\bf cirbuf\_\-uint} {\em start}, \/  {\bf cirbuf\_\-uint} {\em maxlen})}\label{cirbuf_8h_41768b866c9d086baa9c06d52110eea8}


Init the circular buffer 

Definition at line 29 of file cirbuf.c.

References cirbuf::buf, cirbuf::end, cirbuf::len, cirbuf::maxlen, and cirbuf::start.

Referenced by rdline\_\-char\_\-in(), rdline\_\-init(), rdline\_\-newline(), and uart\_\-setconf().