\doxysection{soft\+\_\+uart.\+h}
\label{soft__uart_8h_source}\index{include/osmocom/core/soft\_uart.h@{include/osmocom/core/soft\_uart.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{2 }
\DoxyCodeLine{5 \textcolor{comment}{/*}}
\DoxyCodeLine{6 \textcolor{comment}{ * (C) 2022 by Harald Welte <laforge@gnumonks.org>}}
\DoxyCodeLine{7 \textcolor{comment}{ * (C) 2023 by sysmocom -\/ s.f.m.c. GmbH <info@sysmocom.de>}}
\DoxyCodeLine{8 \textcolor{comment}{ *}}
\DoxyCodeLine{9 \textcolor{comment}{ * All Rights Reserved}}
\DoxyCodeLine{10 \textcolor{comment}{ *}}
\DoxyCodeLine{11 \textcolor{comment}{ * SPDX-\/License-\/Identifier: GPL-\/2.0+}}
\DoxyCodeLine{12 \textcolor{comment}{ *}}
\DoxyCodeLine{13 \textcolor{comment}{ * This program is free software; you can redistribute it and/or modify}}
\DoxyCodeLine{14 \textcolor{comment}{ * it under the terms of the GNU General Public License as published by}}
\DoxyCodeLine{15 \textcolor{comment}{ * the Free Software Foundation; either version 2 of the License, or}}
\DoxyCodeLine{16 \textcolor{comment}{ * (at your option) any later version.}}
\DoxyCodeLine{17 \textcolor{comment}{ *}}
\DoxyCodeLine{18 \textcolor{comment}{ * This program is distributed in the hope that it will be useful,}}
\DoxyCodeLine{19 \textcolor{comment}{ * but WITHOUT ANY WARRANTY; without even the implied warranty of}}
\DoxyCodeLine{20 \textcolor{comment}{ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the}}
\DoxyCodeLine{21 \textcolor{comment}{ * GNU General Public License for more details.}}
\DoxyCodeLine{22 \textcolor{comment}{ *}}
\DoxyCodeLine{23 \textcolor{comment}{ */}}
\DoxyCodeLine{24 }
\DoxyCodeLine{25 \textcolor{preprocessor}{\#include <stdint.h>}}
\DoxyCodeLine{26 \textcolor{preprocessor}{\#include <stdbool.h>}}
\DoxyCodeLine{27 }
\DoxyCodeLine{28 \textcolor{preprocessor}{\#include <osmocom/core/bits.h>}}
\DoxyCodeLine{29 \textcolor{preprocessor}{\#include <osmocom/core/msgb.h>}}
\DoxyCodeLine{30 }
\DoxyCodeLine{33 \textcolor{keyword}{enum} osmo\_soft\_uart\_parity\_mode \{}
\DoxyCodeLine{34         OSMO\_SUART\_PARITY\_NONE,           }
\DoxyCodeLine{35         OSMO\_SUART\_PARITY\_EVEN,           }
\DoxyCodeLine{36         OSMO\_SUART\_PARITY\_ODD,             }
\DoxyCodeLine{37         OSMO\_SUART\_PARITY\_MARK,           }
\DoxyCodeLine{38         OSMO\_SUART\_PARITY\_SPACE, }
\DoxyCodeLine{39         \_OSMO\_SUART\_PARITY\_NUM}
\DoxyCodeLine{40 \};}
\DoxyCodeLine{41 }
\DoxyCodeLine{43 \textcolor{keyword}{enum} osmo\_soft\_uart\_flags \{}
\DoxyCodeLine{44         OSMO\_SUART\_F\_FRAMING\_ERROR    = (1 << 0),     }
\DoxyCodeLine{45         OSMO\_SUART\_F\_PARITY\_ERROR      = (1 << 1),     }
\DoxyCodeLine{46         OSMO\_SUART\_F\_BREAK            = (1 << 2),     }
\DoxyCodeLine{47 \};}
\DoxyCodeLine{48 }
\DoxyCodeLine{51 \textcolor{keyword}{enum} osmo\_soft\_uart\_status \{}
\DoxyCodeLine{52         OSMO\_SUART\_STATUS\_F\_DTR          = (1 << 0),     }
\DoxyCodeLine{53         OSMO\_SUART\_STATUS\_F\_DCD          = (1 << 1),     }
\DoxyCodeLine{54         OSMO\_SUART\_STATUS\_F\_DSR          = (1 << 2),     }
\DoxyCodeLine{55         OSMO\_SUART\_STATUS\_F\_RI            = (1 << 3),     }
\DoxyCodeLine{56         OSMO\_SUART\_STATUS\_F\_RTS\_RTR  = (1 << 4),     }
\DoxyCodeLine{57         OSMO\_SUART\_STATUS\_F\_CTS          = (1 << 5),     }
\DoxyCodeLine{58 \};}
\DoxyCodeLine{59 }
\DoxyCodeLine{62 \textcolor{keyword}{enum} osmo\_soft\_uart\_flow\_ctrl\_mode \{}
\DoxyCodeLine{64         OSMO\_SUART\_FLOW\_CTRL\_NONE,}
\DoxyCodeLine{66         OSMO\_SUART\_FLOW\_CTRL\_DTR\_DSR,}
\DoxyCodeLine{72         OSMO\_SUART\_FLOW\_CTRL\_RTS\_CTS,}
\DoxyCodeLine{73 \};}
\DoxyCodeLine{74 }
\DoxyCodeLine{76 \textcolor{keyword}{struct }osmo\_soft\_uart\_cfg \{}
\DoxyCodeLine{78         uint8\_t num\_data\_bits;}
\DoxyCodeLine{80         uint8\_t num\_stop\_bits;}
\DoxyCodeLine{82         \textcolor{keyword}{enum} osmo\_soft\_uart\_parity\_mode parity\_mode;}
\DoxyCodeLine{85         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} rx\_buf\_size;}
\DoxyCodeLine{88         \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} rx\_timeout\_ms;}
\DoxyCodeLine{89 }
\DoxyCodeLine{91         \textcolor{keywordtype}{void} *priv;}
\DoxyCodeLine{92 }
\DoxyCodeLine{104         void (*rx\_cb)(\textcolor{keywordtype}{void} *priv, \textcolor{keyword}{struct }msgb *rx\_data, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} flags);}
\DoxyCodeLine{105 }
\DoxyCodeLine{114         void (*tx\_cb)(\textcolor{keywordtype}{void} *priv, \textcolor{keyword}{struct }msgb *tx\_data);}
\DoxyCodeLine{115 }
\DoxyCodeLine{119         void (*status\_change\_cb)(\textcolor{keywordtype}{void} *priv, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} status);}
\DoxyCodeLine{120 }
\DoxyCodeLine{122         \textcolor{keyword}{enum} osmo\_soft\_uart\_flow\_ctrl\_mode flow\_ctrl\_mode;}
\DoxyCodeLine{123 \};}
\DoxyCodeLine{124 }
\DoxyCodeLine{125 \textcolor{keyword}{extern} \textcolor{keyword}{const} \textcolor{keyword}{struct }osmo\_soft\_uart\_cfg osmo\_soft\_uart\_default\_cfg;}
\DoxyCodeLine{126 }
\DoxyCodeLine{127 \textcolor{keyword}{struct }osmo\_soft\_uart;}
\DoxyCodeLine{128 }
\DoxyCodeLine{129 \textcolor{keyword}{struct }osmo\_soft\_uart *osmo\_soft\_uart\_alloc(\textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name,}
\DoxyCodeLine{130                                             \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_soft\_uart\_cfg *cfg);}
\DoxyCodeLine{131 \textcolor{keywordtype}{void} osmo\_soft\_uart\_free(\textcolor{keyword}{struct} osmo\_soft\_uart *suart);}
\DoxyCodeLine{132 \textcolor{keywordtype}{int} osmo\_soft\_uart\_configure(\textcolor{keyword}{struct} osmo\_soft\_uart *suart, \textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_soft\_uart\_cfg *cfg);}
\DoxyCodeLine{133 }
\DoxyCodeLine{134 \textcolor{keyword}{const} \textcolor{keywordtype}{char} *osmo\_soft\_uart\_get\_name(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_soft\_uart *suart);}
\DoxyCodeLine{135 \textcolor{keywordtype}{void} osmo\_soft\_uart\_set\_name(\textcolor{keyword}{struct} osmo\_soft\_uart *suart, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *name);}
\DoxyCodeLine{136 }
\DoxyCodeLine{137 \textcolor{keywordtype}{int} osmo\_soft\_uart\_set\_rx(\textcolor{keyword}{struct} osmo\_soft\_uart *suart, \textcolor{keywordtype}{bool} enable);}
\DoxyCodeLine{138 \textcolor{keywordtype}{int} osmo\_soft\_uart\_set\_tx(\textcolor{keyword}{struct} osmo\_soft\_uart *suart, \textcolor{keywordtype}{bool} enable);}
\DoxyCodeLine{139 }
\DoxyCodeLine{140 \textcolor{keywordtype}{int} osmo\_soft\_uart\_rx\_ubits(\textcolor{keyword}{struct} osmo\_soft\_uart *suart, \textcolor{keyword}{const} ubit\_t *ubits, \textcolor{keywordtype}{size\_t} n\_ubits);}
\DoxyCodeLine{141 \textcolor{keywordtype}{int} osmo\_soft\_uart\_tx\_ubits(\textcolor{keyword}{struct} osmo\_soft\_uart *suart, ubit\_t *ubits, \textcolor{keywordtype}{size\_t} n\_ubits);}
\DoxyCodeLine{142 }
\DoxyCodeLine{143 \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} osmo\_soft\_uart\_get\_status(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_soft\_uart *suart);}
\DoxyCodeLine{144 \textcolor{keywordtype}{int} osmo\_soft\_uart\_set\_status(\textcolor{keyword}{struct} osmo\_soft\_uart *suart, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} status);}
\DoxyCodeLine{145 \textcolor{keywordtype}{void} osmo\_soft\_uart\_set\_status\_line(\textcolor{keyword}{struct} osmo\_soft\_uart *suart,}
\DoxyCodeLine{146                                     \textcolor{keyword}{enum} osmo\_soft\_uart\_status line,}
\DoxyCodeLine{147                                     \textcolor{keywordtype}{bool} active);}
\DoxyCodeLine{148 }
\DoxyCodeLine{149 \textcolor{keywordtype}{void} osmo\_soft\_uart\_flush\_rx(\textcolor{keyword}{struct} osmo\_soft\_uart *suart);}

\end{DoxyCode}
