\doxysection{src/core/soft\+\_\+uart.c File Reference}
\label{soft__uart_8c}\index{src/core/soft\_uart.c@{src/core/soft\_uart.c}}


Software UART implementation.  


{\ttfamily \#include $<$stdbool.\+h$>$}\newline
{\ttfamily \#include $<$stdint.\+h$>$}\newline
{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/utils.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/timer.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/soft\+\_\+uart.\+h$>$}\newline
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ osmo\+\_\+soft\+\_\+uart}
\begin{DoxyCompactList}\small\item\em Internal state of a soft-\/\+UART. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \textbf{ suart\+\_\+flow\+\_\+state} \{ \newline
\textbf{ SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+IDLE}
, \newline
\textbf{ SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+DATA}
, \newline
\textbf{ SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+PARITY}
, \newline
\textbf{ SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+STOP}
 \}
\begin{DoxyCompactList}\small\item\em Rx/\+Tx flow state of a soft-\/\+UART. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+flush\+\_\+rx} (struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$suart)
\begin{DoxyCompactList}\small\item\em Flush the receive buffer, passing ownership of the msgb to the .rx\+\_\+cb(). \end{DoxyCompactList}\item 
static void \textbf{ suart\+\_\+rx\+\_\+ch} (struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$suart, uint8\+\_\+t ch)
\item 
static void \textbf{ suart\+\_\+rx\+\_\+bit} (struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$suart, const \textbf{ ubit\+\_\+t} bit)
\item 
static void \textbf{ suart\+\_\+rx\+\_\+timer\+\_\+cb} (void $\ast$\textbf{ data})
\item 
int \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+rx\+\_\+ubits} (struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$suart, const \textbf{ ubit\+\_\+t} $\ast$ubits, size\+\_\+t n\+\_\+ubits)
\begin{DoxyCompactList}\small\item\em Feed a number of unpacked bits into the soft-\/\+UART receiver. \end{DoxyCompactList}\item 
static \textbf{ ubit\+\_\+t} \textbf{ suart\+\_\+tx\+\_\+bit} (struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$suart, struct \textbf{ msgb} $\ast$\textbf{ msg})
\item 
static size\+\_\+t \textbf{ suart\+\_\+tx\+\_\+pending} (struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$suart, \textbf{ ubit\+\_\+t} $\ast$ubits, size\+\_\+t n\+\_\+ubits)
\item 
int \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+tx\+\_\+ubits} (struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$suart, \textbf{ ubit\+\_\+t} $\ast$ubits, size\+\_\+t n\+\_\+ubits)
\begin{DoxyCompactList}\small\item\em Pull a number of unpacked bits out of the soft-\/\+UART transmitter. \end{DoxyCompactList}\item 
unsigned int \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+get\+\_\+status} (const struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$suart)
\begin{DoxyCompactList}\small\item\em Get the modem status bitmask of the given soft-\/\+UART. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+set\+\_\+status} (struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$suart, unsigned int status)
\begin{DoxyCompactList}\small\item\em Set the modem status bitmask of the given soft-\/\+UART. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+set\+\_\+status\+\_\+line} (struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$suart, enum \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+status} line, bool active)
\begin{DoxyCompactList}\small\item\em Activate/deactivate a modem status line of the given soft-\/\+UART. \end{DoxyCompactList}\item 
struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$ \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+alloc} (void $\ast$ctx, const char $\ast$\textbf{ name}, const struct \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg} $\ast$cfg)
\begin{DoxyCompactList}\small\item\em Allocate a soft-\/\+UART instance. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+free} (struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$suart)
\begin{DoxyCompactList}\small\item\em Release memory taken by the given soft-\/\+UART. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+configure} (struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$suart, const struct \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg} $\ast$cfg)
\begin{DoxyCompactList}\small\item\em Change soft-\/\+UART configuration to the user-\/provided config. \end{DoxyCompactList}\item 
const char $\ast$ \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+get\+\_\+name} (const struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$suart)
\begin{DoxyCompactList}\small\item\em Get a name for the given soft-\/\+UART instance. \end{DoxyCompactList}\item 
void \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+set\+\_\+name} (struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$suart, const char $\ast$\textbf{ name})
\begin{DoxyCompactList}\small\item\em Set a new name for the given soft-\/\+UART instance. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+set\+\_\+rx} (struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$suart, bool enable)
\begin{DoxyCompactList}\small\item\em Enable/disable receiver of the given soft-\/\+UART. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+set\+\_\+tx} (struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$suart, bool enable)
\begin{DoxyCompactList}\small\item\em Enable/disable transmitter of the given soft-\/\+UART. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
const struct \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg} \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+default\+\_\+cfg}
\begin{DoxyCompactList}\small\item\em Default soft-\/\+UART configuration (8-\/N-\/1) \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Software UART implementation. 



\doxysubsection{Enumeration Type Documentation}
\mbox{\label{soft__uart_8c_a712b6e9716df97f8afbc824d84a3cd7a}} 
\index{soft\_uart.c@{soft\_uart.c}!suart\_flow\_state@{suart\_flow\_state}}
\index{suart\_flow\_state@{suart\_flow\_state}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{suart\_flow\_state}
{\footnotesize\ttfamily enum \textbf{ suart\+\_\+flow\+\_\+state}}



Rx/\+Tx flow state of a soft-\/\+UART. 

\begin{DoxyEnumFields}{Enumerator}
\raisebox{\heightof{T}}[0pt][0pt]{\index{SUART\_FLOW\_ST\_IDLE@{SUART\_FLOW\_ST\_IDLE}!soft\_uart.c@{soft\_uart.c}}\index{soft\_uart.c@{soft\_uart.c}!SUART\_FLOW\_ST\_IDLE@{SUART\_FLOW\_ST\_IDLE}}}\mbox{\label{soft__uart_8c_a712b6e9716df97f8afbc824d84a3cd7aacb8be86108ddd102dd8257eb03646b50}} 
SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+IDLE&waiting for a start bit or Tx data \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{SUART\_FLOW\_ST\_DATA@{SUART\_FLOW\_ST\_DATA}!soft\_uart.c@{soft\_uart.c}}\index{soft\_uart.c@{soft\_uart.c}!SUART\_FLOW\_ST\_DATA@{SUART\_FLOW\_ST\_DATA}}}\mbox{\label{soft__uart_8c_a712b6e9716df97f8afbc824d84a3cd7aa5eb5c405008623776afd99b76c725164}} 
SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+DATA&receiving/transmitting data bits \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{SUART\_FLOW\_ST\_PARITY@{SUART\_FLOW\_ST\_PARITY}!soft\_uart.c@{soft\_uart.c}}\index{soft\_uart.c@{soft\_uart.c}!SUART\_FLOW\_ST\_PARITY@{SUART\_FLOW\_ST\_PARITY}}}\mbox{\label{soft__uart_8c_a712b6e9716df97f8afbc824d84a3cd7aa02c83350b95976cc2e9277b9d69072ef}} 
SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+PARITY&receiving/transmitting parity bits \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{SUART\_FLOW\_ST\_STOP@{SUART\_FLOW\_ST\_STOP}!soft\_uart.c@{soft\_uart.c}}\index{soft\_uart.c@{soft\_uart.c}!SUART\_FLOW\_ST\_STOP@{SUART\_FLOW\_ST\_STOP}}}\mbox{\label{soft__uart_8c_a712b6e9716df97f8afbc824d84a3cd7aabdce5fdd17eebdc6b97ee8d16d514fa2}} 
SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+STOP&receiving/transmitting stop bits \\
\hline

\end{DoxyEnumFields}


\doxysubsection{Function Documentation}
\mbox{\label{soft__uart_8c_a063d09085ca7ea01ee93e08d6199c751}} 
\index{soft\_uart.c@{soft\_uart.c}!osmo\_soft\_uart\_alloc@{osmo\_soft\_uart\_alloc}}
\index{osmo\_soft\_uart\_alloc@{osmo\_soft\_uart\_alloc}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{osmo\_soft\_uart\_alloc()}
{\footnotesize\ttfamily struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$ osmo\+\_\+soft\+\_\+uart\+\_\+alloc (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{const char $\ast$}]{name,  }\item[{const struct \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg} $\ast$}]{cfg }\end{DoxyParamCaption})}



Allocate a soft-\/\+UART instance. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & parent talloc context. \\
\hline
\mbox{\texttt{ in}}  & {\em name} & name of the soft-\/\+UART instance. \\
\hline
\mbox{\texttt{ in}}  & {\em cfg} & initial configuration of the soft-\/\+UART instance. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
pointer to allocated soft-\/\+UART instance; NULL on error. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+soft\+\_\+uart\+::cfg}, \textbf{ name}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::name}, and \textbf{ OSMO\+\_\+\+ASSERT}.

\mbox{\label{soft__uart_8c_afc55d9d32b42aa1e3ad0e450d91d875a}} 
\index{soft\_uart.c@{soft\_uart.c}!osmo\_soft\_uart\_configure@{osmo\_soft\_uart\_configure}}
\index{osmo\_soft\_uart\_configure@{osmo\_soft\_uart\_configure}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{osmo\_soft\_uart\_configure()}
{\footnotesize\ttfamily int osmo\+\_\+soft\+\_\+uart\+\_\+configure (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$}]{suart,  }\item[{const struct \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg} $\ast$}]{cfg }\end{DoxyParamCaption})}



Change soft-\/\+UART configuration to the user-\/provided config. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em suart} & soft-\/\+UART instance to be re-\/configured. \\
\hline
\mbox{\texttt{ in}}  & {\em cfg} & the user-\/provided config to be applied. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative on error. 
\end{DoxyReturn}


References \textbf{ \+\_\+\+OSMO\+\_\+\+SUART\+\_\+\+PARITY\+\_\+\+NUM}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::cfg}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::num\+\_\+data\+\_\+bits}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::num\+\_\+stop\+\_\+bits}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+flush\+\_\+rx()}, \textbf{ osmo\+\_\+timer\+\_\+setup()}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::parity\+\_\+mode}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::rx}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::rx\+\_\+buf\+\_\+size}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::rx\+\_\+timeout\+\_\+ms}, \textbf{ suart\+\_\+rx\+\_\+timer\+\_\+cb()}, and \textbf{ osmo\+\_\+soft\+\_\+uart\+::timer}.

\mbox{\label{soft__uart_8c_a39fc01350377643743e89b630fa3ce1a}} 
\index{soft\_uart.c@{soft\_uart.c}!osmo\_soft\_uart\_flush\_rx@{osmo\_soft\_uart\_flush\_rx}}
\index{osmo\_soft\_uart\_flush\_rx@{osmo\_soft\_uart\_flush\_rx}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{osmo\_soft\_uart\_flush\_rx()}
{\footnotesize\ttfamily void osmo\+\_\+soft\+\_\+uart\+\_\+flush\+\_\+rx (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$}]{suart }\end{DoxyParamCaption})}



Flush the receive buffer, passing ownership of the msgb to the .rx\+\_\+cb(). 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em suart} & soft-\/\+UART instance holding the receive buffer. \\
\hline
\end{DoxyParams}


References \textbf{ osmo\+\_\+soft\+\_\+uart\+::cfg}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::flags}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::msg}, \textbf{ msgb\+\_\+alloc\+\_\+c()}, \textbf{ msgb\+\_\+length()}, \textbf{ msgb\+\_\+reset()}, \textbf{ osmo\+\_\+timer\+\_\+del()}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::priv}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::rx}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::rx\+\_\+buf\+\_\+size}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::rx\+\_\+cb}, and \textbf{ osmo\+\_\+soft\+\_\+uart\+::timer}.



Referenced by \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+configure()}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+set\+\_\+rx()}, \textbf{ suart\+\_\+rx\+\_\+ch()}, and \textbf{ suart\+\_\+rx\+\_\+timer\+\_\+cb()}.

\mbox{\label{soft__uart_8c_a43a70e38b6059372f81ab8f8f7f14e9d}} 
\index{soft\_uart.c@{soft\_uart.c}!osmo\_soft\_uart\_free@{osmo\_soft\_uart\_free}}
\index{osmo\_soft\_uart\_free@{osmo\_soft\_uart\_free}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{osmo\_soft\_uart\_free()}
{\footnotesize\ttfamily void osmo\+\_\+soft\+\_\+uart\+\_\+free (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$}]{suart }\end{DoxyParamCaption})}



Release memory taken by the given soft-\/\+UART. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em suart} & soft-\/\+UART instance to be free()d. \\
\hline
\end{DoxyParams}


References \textbf{ osmo\+\_\+soft\+\_\+uart\+::msg}, \textbf{ msgb\+\_\+free()}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::name}, \textbf{ osmo\+\_\+timer\+\_\+del()}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::rx}, and \textbf{ osmo\+\_\+soft\+\_\+uart\+::timer}.

\mbox{\label{soft__uart_8c_a35b6e0b25f80ed22fab1758536edc4cc}} 
\index{soft\_uart.c@{soft\_uart.c}!osmo\_soft\_uart\_get\_name@{osmo\_soft\_uart\_get\_name}}
\index{osmo\_soft\_uart\_get\_name@{osmo\_soft\_uart\_get\_name}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{osmo\_soft\_uart\_get\_name()}
{\footnotesize\ttfamily const char $\ast$ osmo\+\_\+soft\+\_\+uart\+\_\+get\+\_\+name (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$}]{suart }\end{DoxyParamCaption})}



Get a name for the given soft-\/\+UART instance. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em suart} & soft-\/\+UART instance to get the name from. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
name of the given soft-\/\+UART instance. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+soft\+\_\+uart\+::name}.

\mbox{\label{soft__uart_8c_a92c611f063e605c836017d77b6a64789}} 
\index{soft\_uart.c@{soft\_uart.c}!osmo\_soft\_uart\_get\_status@{osmo\_soft\_uart\_get\_status}}
\index{osmo\_soft\_uart\_get\_status@{osmo\_soft\_uart\_get\_status}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{osmo\_soft\_uart\_get\_status()}
{\footnotesize\ttfamily unsigned int osmo\+\_\+soft\+\_\+uart\+\_\+get\+\_\+status (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$}]{suart }\end{DoxyParamCaption})}



Get the modem status bitmask of the given soft-\/\+UART. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em suart} & soft-\/\+UART instance to get the modem status. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
bitmask of OSMO\+\_\+\+SUART\+\_\+\+STATUS\+\_\+\+F\+\_\+$\ast$. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+soft\+\_\+uart\+::status}.

\mbox{\label{soft__uart_8c_ad870a6210297fcf8a5a5b528d3b6269e}} 
\index{soft\_uart.c@{soft\_uart.c}!osmo\_soft\_uart\_rx\_ubits@{osmo\_soft\_uart\_rx\_ubits}}
\index{osmo\_soft\_uart\_rx\_ubits@{osmo\_soft\_uart\_rx\_ubits}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{osmo\_soft\_uart\_rx\_ubits()}
{\footnotesize\ttfamily int osmo\+\_\+soft\+\_\+uart\+\_\+rx\+\_\+ubits (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$}]{suart,  }\item[{const \textbf{ ubit\+\_\+t} $\ast$}]{ubits,  }\item[{size\+\_\+t}]{n\+\_\+ubits }\end{DoxyParamCaption})}



Feed a number of unpacked bits into the soft-\/\+UART receiver. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em suart} & soft-\/\+UART instance to feed bits into. \\
\hline
\mbox{\texttt{ in}}  & {\em ubits} & pointer to the unpacked bits. \\
\hline
\mbox{\texttt{ in}}  & {\em n\+\_\+ubits} & number of unpacked bits to be fed. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative on error. -\/EAGAIN indicates that the receiver is disabled. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+soft\+\_\+uart\+::running}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::rx}, and \textbf{ suart\+\_\+rx\+\_\+bit()}.

\mbox{\label{soft__uart_8c_a3351d78d1f56c05dd919c2c3a748130a}} 
\index{soft\_uart.c@{soft\_uart.c}!osmo\_soft\_uart\_set\_name@{osmo\_soft\_uart\_set\_name}}
\index{osmo\_soft\_uart\_set\_name@{osmo\_soft\_uart\_set\_name}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{osmo\_soft\_uart\_set\_name()}
{\footnotesize\ttfamily void osmo\+\_\+soft\+\_\+uart\+\_\+set\+\_\+name (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$}]{suart,  }\item[{const char $\ast$}]{name }\end{DoxyParamCaption})}



Set a new name for the given soft-\/\+UART instance. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em suart} & soft-\/\+UART instance to set the name for. \\
\hline
\mbox{\texttt{ in}}  & {\em name} & the new name. \\
\hline
\end{DoxyParams}


References \textbf{ name}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::name}, and \textbf{ osmo\+\_\+talloc\+\_\+replace\+\_\+string()}.

\mbox{\label{soft__uart_8c_a390451aed05c1adc0450fe091377f651}} 
\index{soft\_uart.c@{soft\_uart.c}!osmo\_soft\_uart\_set\_rx@{osmo\_soft\_uart\_set\_rx}}
\index{osmo\_soft\_uart\_set\_rx@{osmo\_soft\_uart\_set\_rx}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{osmo\_soft\_uart\_set\_rx()}
{\footnotesize\ttfamily int osmo\+\_\+soft\+\_\+uart\+\_\+set\+\_\+rx (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$}]{suart,  }\item[{bool}]{enable }\end{DoxyParamCaption})}



Enable/disable receiver of the given soft-\/\+UART. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em suart} & soft-\/\+UART instance to be re-\/configured. \\
\hline
\mbox{\texttt{ in}}  & {\em enable} & enable/disable state of the receiver. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative on error. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+soft\+\_\+uart\+::cfg}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::flow\+\_\+state}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::msg}, \textbf{ msgb\+\_\+alloc\+\_\+c()}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+flush\+\_\+rx()}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::running}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::rx}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::rx\+\_\+buf\+\_\+size}, and \textbf{ SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+IDLE}.

\mbox{\label{soft__uart_8c_ae5c16cdf602285cc395008816ecf6666}} 
\index{soft\_uart.c@{soft\_uart.c}!osmo\_soft\_uart\_set\_status@{osmo\_soft\_uart\_set\_status}}
\index{osmo\_soft\_uart\_set\_status@{osmo\_soft\_uart\_set\_status}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{osmo\_soft\_uart\_set\_status()}
{\footnotesize\ttfamily int osmo\+\_\+soft\+\_\+uart\+\_\+set\+\_\+status (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$}]{suart,  }\item[{unsigned int}]{status }\end{DoxyParamCaption})}



Set the modem status bitmask of the given soft-\/\+UART. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em suart} & soft-\/\+UART instance to set the modem status. \\
\hline
\mbox{\texttt{ in}}  & {\em status} & bitmask of OSMO\+\_\+\+SUART\+\_\+\+STATUS\+\_\+\+F\+\_\+$\ast$. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative on error. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+soft\+\_\+uart\+::cfg}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::priv}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::status}, and \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::status\+\_\+change\+\_\+cb}.



Referenced by \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+set\+\_\+status\+\_\+line()}.

\mbox{\label{soft__uart_8c_a2dbac5fede9255613820199209c7b580}} 
\index{soft\_uart.c@{soft\_uart.c}!osmo\_soft\_uart\_set\_status\_line@{osmo\_soft\_uart\_set\_status\_line}}
\index{osmo\_soft\_uart\_set\_status\_line@{osmo\_soft\_uart\_set\_status\_line}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{osmo\_soft\_uart\_set\_status\_line()}
{\footnotesize\ttfamily void osmo\+\_\+soft\+\_\+uart\+\_\+set\+\_\+status\+\_\+line (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$}]{suart,  }\item[{enum \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+status}}]{line,  }\item[{bool}]{active }\end{DoxyParamCaption})}



Activate/deactivate a modem status line of the given soft-\/\+UART. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em suart} & soft-\/\+UART instance to update the modem status. \\
\hline
\mbox{\texttt{ in}}  & {\em line} & a modem status line, one of OSMO\+\_\+\+SUART\+\_\+\+STATUS\+\_\+\+F\+\_\+$\ast$. \\
\hline
\mbox{\texttt{ in}}  & {\em active} & activate (true) or deactivate (false) the line. \\
\hline
\end{DoxyParams}


References \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+set\+\_\+status()}, and \textbf{ osmo\+\_\+soft\+\_\+uart\+::status}.

\mbox{\label{soft__uart_8c_a21fbc23b6423f407db7b710a18f08caf}} 
\index{soft\_uart.c@{soft\_uart.c}!osmo\_soft\_uart\_set\_tx@{osmo\_soft\_uart\_set\_tx}}
\index{osmo\_soft\_uart\_set\_tx@{osmo\_soft\_uart\_set\_tx}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{osmo\_soft\_uart\_set\_tx()}
{\footnotesize\ttfamily int osmo\+\_\+soft\+\_\+uart\+\_\+set\+\_\+tx (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$}]{suart,  }\item[{bool}]{enable }\end{DoxyParamCaption})}



Enable/disable transmitter of the given soft-\/\+UART. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em suart} & soft-\/\+UART instance to be re-\/configured. \\
\hline
\mbox{\texttt{ in}}  & {\em enable} & enable/disable state of the transmitter. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success; negative on error. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+soft\+\_\+uart\+::flow\+\_\+state}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::running}, \textbf{ SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+IDLE}, and \textbf{ osmo\+\_\+soft\+\_\+uart\+::tx}.

\mbox{\label{soft__uart_8c_a4c1a3c81790eec8747c4d33e091fb1b3}} 
\index{soft\_uart.c@{soft\_uart.c}!osmo\_soft\_uart\_tx\_ubits@{osmo\_soft\_uart\_tx\_ubits}}
\index{osmo\_soft\_uart\_tx\_ubits@{osmo\_soft\_uart\_tx\_ubits}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{osmo\_soft\_uart\_tx\_ubits()}
{\footnotesize\ttfamily int osmo\+\_\+soft\+\_\+uart\+\_\+tx\+\_\+ubits (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$}]{suart,  }\item[{\textbf{ ubit\+\_\+t} $\ast$}]{ubits,  }\item[{size\+\_\+t}]{n\+\_\+ubits }\end{DoxyParamCaption})}



Pull a number of unpacked bits out of the soft-\/\+UART transmitter. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em suart} & soft-\/\+UART instance to pull the bits from. \\
\hline
\mbox{\texttt{ out}}  & {\em ubits} & pointer to a buffer where to store pulled bits. \\
\hline
\mbox{\texttt{ in}}  & {\em n\+\_\+ubits} & number of unpacked bits to be pulled. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of bits pulled (may be less than n\+\_\+ubits); negative on error. -\/EAGAIN indicates that the transmitter is disabled. 
\end{DoxyReturn}


References \textbf{ osmo\+\_\+soft\+\_\+uart\+::cfg}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::flow\+\_\+ctrl\+\_\+mode}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::flow\+\_\+state}, \textbf{ msg}, \textbf{ msgb\+\_\+alloc\+\_\+c()}, \textbf{ msgb\+\_\+free()}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::num\+\_\+data\+\_\+bits}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::num\+\_\+stop\+\_\+bits}, \textbf{ OSMO\+\_\+\+ASSERT}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+FLOW\+\_\+\+CTRL\+\_\+\+DTR\+\_\+\+DSR}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+FLOW\+\_\+\+CTRL\+\_\+\+NONE}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+FLOW\+\_\+\+CTRL\+\_\+\+RTS\+\_\+\+CTS}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+PARITY\+\_\+\+NONE}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+STATUS\+\_\+\+F\+\_\+\+CTS}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+STATUS\+\_\+\+F\+\_\+\+DSR}, \textbf{ OSMO\+\_\+\+UNLIKELY}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::parity\+\_\+mode}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::priv}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::running}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::status}, \textbf{ SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+IDLE}, \textbf{ suart\+\_\+tx\+\_\+bit()}, \textbf{ suart\+\_\+tx\+\_\+pending()}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::tx}, and \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::tx\+\_\+cb}.

\mbox{\label{soft__uart_8c_ac877ded2270edfcb59c9783634c5223d}} 
\index{soft\_uart.c@{soft\_uart.c}!suart\_rx\_bit@{suart\_rx\_bit}}
\index{suart\_rx\_bit@{suart\_rx\_bit}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{suart\_rx\_bit()}
{\footnotesize\ttfamily static void suart\+\_\+rx\+\_\+bit (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$}]{suart,  }\item[{const \textbf{ ubit\+\_\+t}}]{bit }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



References \textbf{ osmo\+\_\+soft\+\_\+uart\+::bit\+\_\+count}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::cfg}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::flags}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::flow\+\_\+state}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::num\+\_\+data\+\_\+bits}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::num\+\_\+stop\+\_\+bits}, \textbf{ OSMO\+\_\+\+ASSERT}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+F\+\_\+\+FRAMING\+\_\+\+ERROR}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+F\+\_\+\+PARITY\+\_\+\+ERROR}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+PARITY\+\_\+\+EVEN}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+PARITY\+\_\+\+MARK}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+PARITY\+\_\+\+NONE}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+PARITY\+\_\+\+ODD}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+PARITY\+\_\+\+SPACE}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::parity\+\_\+bit}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::parity\+\_\+mode}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::rx}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::shift\+\_\+reg}, \textbf{ SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+DATA}, \textbf{ SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+IDLE}, \textbf{ SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+PARITY}, \textbf{ SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+STOP}, and \textbf{ suart\+\_\+rx\+\_\+ch()}.



Referenced by \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+rx\+\_\+ubits()}.

\mbox{\label{soft__uart_8c_a52eee842b0f5bb5c306aeaade50ce622}} 
\index{soft\_uart.c@{soft\_uart.c}!suart\_rx\_ch@{suart\_rx\_ch}}
\index{suart\_rx\_ch@{suart\_rx\_ch}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{suart\_rx\_ch()}
{\footnotesize\ttfamily static void suart\+\_\+rx\+\_\+ch (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$}]{suart,  }\item[{uint8\+\_\+t}]{ch }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+soft\+\_\+uart\+::cfg}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::flags}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::msg}, \textbf{ msgb\+\_\+length()}, \textbf{ msgb\+\_\+put\+\_\+u8()}, \textbf{ OSMO\+\_\+\+ASSERT}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+flush\+\_\+rx()}, \textbf{ osmo\+\_\+timer\+\_\+schedule()}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::rx}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::rx\+\_\+buf\+\_\+size}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::rx\+\_\+timeout\+\_\+ms}, and \textbf{ osmo\+\_\+soft\+\_\+uart\+::timer}.



Referenced by \textbf{ suart\+\_\+rx\+\_\+bit()}.

\mbox{\label{soft__uart_8c_af5115b80e507b064cb2e6a72c46f5fed}} 
\index{soft\_uart.c@{soft\_uart.c}!suart\_rx\_timer\_cb@{suart\_rx\_timer\_cb}}
\index{suart\_rx\_timer\_cb@{suart\_rx\_timer\_cb}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{suart\_rx\_timer\_cb()}
{\footnotesize\ttfamily static void suart\+\_\+rx\+\_\+timer\+\_\+cb (\begin{DoxyParamCaption}\item[{void $\ast$}]{data }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ data}, and \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+flush\+\_\+rx()}.



Referenced by \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+configure()}.

\mbox{\label{soft__uart_8c_a295f6ab8d2c8664a4812d191f8a4244f}} 
\index{soft\_uart.c@{soft\_uart.c}!suart\_tx\_bit@{suart\_tx\_bit}}
\index{suart\_tx\_bit@{suart\_tx\_bit}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{suart\_tx\_bit()}
{\footnotesize\ttfamily static \textbf{ ubit\+\_\+t} suart\+\_\+tx\+\_\+bit (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$}]{suart,  }\item[{struct \textbf{ msgb} $\ast$}]{msg }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



References \textbf{ osmo\+\_\+soft\+\_\+uart\+::bit\+\_\+count}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::cfg}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::flow\+\_\+state}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::msg}, \textbf{ msgb\+\_\+length()}, \textbf{ msgb\+\_\+pull\+\_\+u8()}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::num\+\_\+data\+\_\+bits}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::num\+\_\+stop\+\_\+bits}, \textbf{ OSMO\+\_\+\+ASSERT}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+PARITY\+\_\+\+EVEN}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+PARITY\+\_\+\+MARK}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+PARITY\+\_\+\+NONE}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+PARITY\+\_\+\+ODD}, \textbf{ OSMO\+\_\+\+SUART\+\_\+\+PARITY\+\_\+\+SPACE}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::parity\+\_\+bit}, \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg\+::parity\+\_\+mode}, \textbf{ osmo\+\_\+soft\+\_\+uart\+::shift\+\_\+reg}, \textbf{ SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+DATA}, \textbf{ SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+IDLE}, \textbf{ SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+PARITY}, \textbf{ SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+STOP}, and \textbf{ osmo\+\_\+soft\+\_\+uart\+::tx}.



Referenced by \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+tx\+\_\+ubits()}, and \textbf{ suart\+\_\+tx\+\_\+pending()}.

\mbox{\label{soft__uart_8c_af1365f2105506cc49959fdd160a0d4bc}} 
\index{soft\_uart.c@{soft\_uart.c}!suart\_tx\_pending@{suart\_tx\_pending}}
\index{suart\_tx\_pending@{suart\_tx\_pending}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{suart\_tx\_pending()}
{\footnotesize\ttfamily static size\+\_\+t suart\+\_\+tx\+\_\+pending (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+soft\+\_\+uart} $\ast$}]{suart,  }\item[{\textbf{ ubit\+\_\+t} $\ast$}]{ubits,  }\item[{size\+\_\+t}]{n\+\_\+ubits }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ osmo\+\_\+soft\+\_\+uart\+::flow\+\_\+state}, \textbf{ SUART\+\_\+\+FLOW\+\_\+\+ST\+\_\+\+IDLE}, \textbf{ suart\+\_\+tx\+\_\+bit()}, and \textbf{ osmo\+\_\+soft\+\_\+uart\+::tx}.



Referenced by \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+tx\+\_\+ubits()}.



\doxysubsection{Variable Documentation}
\mbox{\label{soft__uart_8c_a4f0f43abec08e6901270f24fb213c024}} 
\index{soft\_uart.c@{soft\_uart.c}!osmo\_soft\_uart\_default\_cfg@{osmo\_soft\_uart\_default\_cfg}}
\index{osmo\_soft\_uart\_default\_cfg@{osmo\_soft\_uart\_default\_cfg}!soft\_uart.c@{soft\_uart.c}}
\doxysubsubsection{osmo\_soft\_uart\_default\_cfg}
{\footnotesize\ttfamily const struct \textbf{ osmo\+\_\+soft\+\_\+uart\+\_\+cfg} osmo\+\_\+soft\+\_\+uart\+\_\+default\+\_\+cfg}

{\bfseries Initial value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{= \{}
\DoxyCodeLine{        .num\_data\_bits = 8,}
\DoxyCodeLine{        .num\_stop\_bits = 1,}
\DoxyCodeLine{        .parity\_mode = OSMO\_SUART\_PARITY\_NONE,}
\DoxyCodeLine{        .rx\_buf\_size = 1024,}
\DoxyCodeLine{        .rx\_timeout\_ms = 100,}
\DoxyCodeLine{        .flow\_ctrl\_mode = OSMO\_SUART\_FLOW\_CTRL\_NONE,}
\DoxyCodeLine{\}}

\end{DoxyCode}


Default soft-\/\+UART configuration (8-\/N-\/1) 

