((* extends "messages_table.tex" *))

((* block message_desc scoped *))

\newpage
\subsection{(((m.name|escape_tex))) ((( '(0x%04X)'|format(m.id) )))}
\label{sec:(((m.name)))}

(((m.desc)))

\vspace{3em}
\begin{table}[h]
  \centering
  \begin{tabular}{llllll}
    \toprule
    Offset & Size & Format & Units & Name & Description \\
    \midrule
    ((* for f in m.fields *))
    (((f.offset))) & (((f.size))) & \texttt{(((f.type)))} & (((f.units))) & \texttt{(((f.name|escape_tex)))} & (((f.desc)))
    ((*- if 'fields' in f *)), \em{See Field \ref{fld:(((m.name)))_(((f.name)))}} ((* endif -*)) \\
    ((* endfor *))
    \midrule
    & (((m.size))) \\
    \bottomrule
  \end{tabular}
  \caption{(((m.name|escape_tex))) (((( '0x%04X'|format(m.id) )))) message structure}
  \label{tab:(((m.name)))}
\end{table}

((*- for f in m.fields *))
((*- if 'fields' in f *))
\begin{table}[h]
  \centering
  ((*- if f.n_with_values == 1 *))
  \begin{minipage}[b][][b]{.48\textwidth}
  ((*- else *))
  \begin{minipage}[c][][c]{.48\textwidth}
  ((*- endif *))

    \centering
    ((*- for bf in f.fields *))
    \regfieldb{(((bf.desc)))((* if 'vals' in bf *)) (\autoref{tab:(((m.name)))_(((f.name)))(((bf.range)))})((* endif *))}{(((bf.len)))}{(((bf.lsb)))}
    ((*- endfor *))
    \captionof{field}{(((f.desc))) (\texttt{(((f.name|escape_tex)))})}
    \label{fld:(((m.name)))_(((f.name)))}

  \end{minipage}
  \hfill
  ((*- if f.n_with_values == 1 *))
  \begin{minipage}[b][][b]{.48\textwidth}
  ((*- else *))
  \begin{minipage}[c][][c]{.48\textwidth}
  ((*- endif *))

    \centering

    ((*- for bf in f.fields|reverse if 'vals' in bf *))
    \begin{tabular}{ll}
      \toprule
      Value & Description \\
      \midrule
      ((*- for v in bf.vals *))
      (((v.value))) & (((v.desc))) \\
      ((*- endfor *))
      \bottomrule
    \end{tabular}
    \caption{(((bf.desc))) values (\texttt{(((f.name|escape_tex)))[(((bf.range)))]})}
    \label{tab:(((m.name)))_(((f.name)))(((bf.range)))}

    ((*- if not loop.last *))
    \vspace{2em}
    ((*- endif *))
    ((*- endfor *))

  \end{minipage}
\end{table}
((*- endif *))
((*- endfor *))

((*- endblock *))

