IonizationChamber/Documentation/Diagrams/UARTFrameFormat.tex

46 wiersze
1.6 KiB
TeX

\documentclass[tikz, border=5mm]{standalone}
\usepackage{textcomp}
\usepackage{graphicx}
\usetikzlibrary{arrows.meta,decorations.markings,fit,calc, positioning}
\usetikzlibrary{calc,positioning,shapes,decorations.pathreplacing}
% the styles for short and long nodes
\tikzset{
short/.style={draw,rectangle,text height=6pt,text depth=13pt,text width=30pt,align=center,fill=yellow!30},
long/.style={short,text width=60pt}
}
\begin{document}
% the short nodes \shnode{<label>}{<right of>}{<text>}
\def\shnode#1#2#3{%
\node[short,right=of #1] (#2) {#3}}
% the long nodes \lnode{<label>}{<right of>}{<text>}
\def\lnode#1#2#3{%
\node[long,right=of #1] (#2) {#3}}
\noindent\begin{tikzpicture}[node distance=-\pgflinewidth]
\node (StartPoint) [text depth=13pt, text height=6pt]{};
\shnode{StartPoint}{MsgId}{msg id};
\shnode{MsgId}{MsgLen}{msg length};
\lnode{MsgLen}{Configuration}{ADC configuration};
\lnode{Configuration}{MSBADC}{MSB ADC value};
\lnode{MSBADC}{LSBADC}{LSB ADC value};
\lnode{LSBADC}{CRC}{CRC};
\draw[decorate,decoration={brace,raise=3pt}] (MsgId.north west) -- node[above=4pt] {Preamble} (MsgLen.north east);
\draw[decorate,decoration={brace,raise=3pt}] (Configuration.north west) -- node[above=4pt] {Data} (LSBADC.north east);
\draw[decorate,decoration={brace,raise=3pt}] (CRC.north west) -- node[above=4pt] {CRC} (CRC.north east);
\draw (MsgId.south west) -- +(0,-1.2cm);
\draw (MsgLen.south east) -- +(0,-1.2cm);
\draw[<->] ( $ (MsgId.south west) +(0,-0.6cm) $ ) -- node[fill=white] {1 Byte} ( $ (MsgLen.south east) +(0,-0.6cm) $ );
\end{tikzpicture}
\end{document}