Ondřej Hruška 6 years ago
parent 04cc505be1
commit ae130bf35f
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 112
      ch.unit.1wire.tex
  2. 4
      ch.unit.adc.tex
  3. 46
      document_config.tex
  4. 204
      mytabto.sty
  5. BIN
      thesis.pdf

@ -1,6 +1,6 @@
\section{1-Wire Unit} \section{1-Wire Unit}
The 1-Wire unit implements the Dallas Semiconductor's 1-Wire protocol, most commonly used to interface smart thermometers (DS18x20). The protocol is explained in section \ref{sec:theory-1wire}. The 1-Wire unit implements the Dallas Semiconductor's 1-Wire protocol, most commonly used to interface smart thermometers (DS18x20). The protocol is explained in section \ref{sec:theory-1wire}.
This unit implements the ROM Search algorithm that is used to find the unique IDs of all 1-Wire devices connected to the bus. The algorithm can find up to 32 devices in one run; More devices can be found by issuing the SEARCH\_CONTINUE command. This unit implements the ROM Search algorithm that is used to find the unique IDs of all 1-Wire devices connected to the bus. The algorithm can find up to 32 devices in one run; More devices can be found by issuing the SEARCH\_CONTINUE command.
@ -22,73 +22,69 @@ This unit generates no events.
\subsection{1-Wire Commands} \subsection{1-Wire Commands}
\begin{tabularx}{\textwidth}{p{\fldwcode}Xp{\fldwpld}} \begin{cmdlist}
\toprule
\textbf{Code} & \textbf{Function} & \textbf{Payload} \\ 0 & \cname{CHECK\_PRESENCE}
\midrule
0 & \flname{CHECK\_PRESENCE}
Test if there are any devices attached to the bus. Test if there are any devices attached to the bus.
& \makecell[tl]{ & \begin{cmdresp}
\fldresp \cfield{u8} presence detected (0, 1)
\fld{u8} presence detected (0, 1) \end{cmdresp} \\
} \\
1 & \cname{SEARCH\_ADDR}
1 & \flname{SEARCH\_ADDR}
Start the search algorithm. Start the search algorithm.
& \makecell[tl]{ & \begin{cmdresp}
\fldresp \cfield{u8} should continue (0, 1)
\fld{u8} should continue (0, 1) \\ \cfield{u64[]} device addresses
\fld{u64[]} device addresses \end{cmdresp} \\
} \\
2 & \flname{SEARCH\_ALARM} 2 & \cname{SEARCH\_ALARM}
Start the search algorithm, finding only devices in an alarm state. Start the search algorithm, finding only devices in an alarm state.
& \makecell[tl]{ & \begin{cmdresp}
\fldresp \cfield{u8} should continue (0, 1)
\fld{u8} should continue (0, 1) \\ \cfield{u64[]} device addresses
\fld{u64[]} device addresses \end{cmdresp} \\
} \\
3 & \flname{SEARCH\_CONTINUE} 3 & \cname{SEARCH\_CONTINUE}
Continue a previously started search Continue a previously started search
& \makecell[tl]{ & \begin{cmdresp}
\fldresp \cfield{u8} should continue (0, 1)
\fld{u8} should continue (0, 1) \\ \cfield{u64[]} device addresses
\fld{u64[]} device addresses \end{cmdresp} \\
} \\
4 & \flname{READ\_ADDR} 4 & \cname{READ\_ADDR}
Read a device address (single device only) Read a device address (single device only)
& \makecell[tl]{ & \begin{cmdresp}
\fldresp \cfield{u64} device address
\fld{u64} device address \end{cmdresp} \\
} \\
10 & \cname{WRITE}
10 & \flname{WRITE}
Write bytes to a device. Write bytes to a device.
& \makecell[tl]{ & \begin{cmdreq}
\fldreq \cfield{u64} device address
\fld{u64} device address \\ \cfield{u8[]} bytes to write
\fld{u8[]} bytes to write \end{cmdreq} \\
} \\
11 & \cname{READ}
11 & \flname{READ}
Write a request and read response. Write a request and read response.
& \makecell[tl]{ &
\fldreq \begin{cmdreq}
\fld{u64} device address \\ \cfield{u64} device address
\fld{u16} read length \\ \cfield{u16} read length
\fld{u8} verify checksum (0, 1) \\ \cfield{u8} verify checksum (0, 1)
\fld{u8[]} request bytes \cfield{u8[]} request bytes
} \\ \end{cmdreq}
\cjoin
20 & \flname{POLL\_FOR\_1} \begin{cmdresp}
Wait for a READY status, used by DS18x20. \cfield{u8[]} read bytes
Not available in parasitic mode. \end{cmdresp}
\\
20 & \cname{POLL\_FOR\_1}
Wait for a READY status, used by DS18x20.
Not available in parasitic mode.
Responds with SUCCESS after all devices are ready. Responds with SUCCESS after all devices are ready.
& \\ & \\
\bottomrule
\end{tabularx} \end{cmdlist}

@ -75,7 +75,7 @@ avg_factor=500
Get the last raw sample from enabled channels. Get the last raw sample from enabled channels.
& &
\begin{cmdresp} \begin{cmdresp}
\cfield{u16[]} raw values 0-4095 \cfield{u16[]} raw values 0--4095
\end{cmdresp} \end{cmdresp}
\\ \\
@ -83,7 +83,7 @@ avg_factor=500
Get the averaged values from enabled channels. Not available for high sample rates and when disabled. Get the averaged values from enabled channels. Not available for high sample rates and when disabled.
& &
\begin{cmdresp} \begin{cmdresp}
\cfield{float32[]} smoothed values 0-4095 \cfield{float32[]} smoothed values 0--4095
\end{cmdresp} \end{cmdresp}
\\ \\

@ -41,17 +41,26 @@
\newcommand{\fldresp}{\textit{Response}\newline} \newcommand{\fldresp}{\textit{Response}\newline}
\newcommand\flname[1]{\textbf{#1}\newline} \newcommand\flname[1]{\textbf{#1}\newline}
\newcommand{\cfield}[1]{\item \texttt{#1:}} \usepackage{mytabto} % customized tabto that does not break to a new line
\newcommand{\cfield}[1]{\item \texttt{#1}\tabto{.8cm}}
\newcommand{\cname}[1]{\textbf{#1}\newline} \newcommand{\cname}[1]{\textbf{#1}\newline}
\usepackage{ragged2e}
% https://tex.stackexchange.com/questions/157389/how-to-center-column-values-in-a-table % https://tex.stackexchange.com/questions/157389/how-to-center-column-values-in-a-table
% P will be a centered column that can have width % P will be a centered column that can have width
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}} \newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
% this is put before a response that follows a request
% this is needed because the request has a negative gap after itself
\newcommand*{\cjoin}{\null\vspace*{-2pt}}
% This is a table of commands of events % This is a table of commands of events
\newenvironment{cmdlist} \newenvironment{cmdlist}
{ {
\tabulinesep=3pt % \tabulinesep=3pt
\tabulinesep=7pt
\begin{longtabu} to \textwidth {P{\fldwcode} X[3] X[3,l]} \begin{longtabu} to \textwidth {P{\fldwcode} X[3] X[3,l]}
\toprule \toprule
@ -71,43 +80,54 @@
{ {
%topsep=0pt,partopsep=0pt, %topsep=0pt,partopsep=0pt,
\begin{itemize}[ \begin{itemize}[
leftmargin=.5cm, leftmargin=.7cm,
nosep, nosep,
after = \vspace{-.7\baselineskip} % remove the weird newline after the list %after = \vspace{-\baselineskip}
] ]
} }
{ {
\end{itemize} \end{itemize}
} }
% a list of request fields, with a caption
\newenvironment{cmditemlistenv}[1]
{
\begin{minipage}[t]{\linewidth}
% \begin{flushleft} % fix weird spacing in wrapped lines
\textit{#1} \begin{cmdpldlist}
}
{
\end{cmdpldlist}
% \end{flushleft}
\end{minipage}
}
% a list of request fields, with a caption % a list of request fields, with a caption
\newenvironment{cmdreq} \newenvironment{cmdreq}
{ {
\textit{Request:} \begin{cmditemlistenv}{Request:}
\begin{cmdpldlist}
} }
{ {
\end{cmdpldlist} \end{cmditemlistenv}
} }
% a list of request fields, with a caption % a list of request fields, with a caption
\newenvironment{cmdresp} \newenvironment{cmdresp}
{ {
\textit{Response:} \begin{cmditemlistenv}{Response:}
\begin{cmdpldlist}
} }
{ {
\end{cmdpldlist} \end{cmditemlistenv}
} }
% a list of payload fields, with a caption % a list of payload fields, with a caption
\newenvironment{cmdpld} \newenvironment{cmdpld}
{ {
\textit{Payload:} \begin{cmditemlistenv}{Payload:}
\begin{cmdpldlist}
} }
{ {
\end{cmdpldlist} \end{cmditemlistenv}
} }

@ -0,0 +1,204 @@
% tabto.sty
%
% version 1.3 (Mar 2013)
%
% Tabbing to fixed positions in a paragraph.
%
% Copyright 2006,2009,2012,2013 by
% Donald Arseneau, Vancouver, Canada (asnd@triumf.ca)
% Permission to use, distribute and modify this software is granted
% under the conditions of the LaTeX Project Public License, either
% version 1.3 or (at your option) any later version. The license is
% found at http://www.latex-project.org/lppl.txt, and is part of all
% recent distributions of LaTeX.
%
% This work has the LPPL maintenance status `maintained' (by author).
%
% Two new text positioning commands are defined: \tabto and \tab.
%
% \tabto{<length>}
% Tab to a position relative to the left margin in a paragraph (any
% indentation due to a list or \leftskip is part of the `margin' in
% this context). If the text on the line already goes past the desired
% position, the tab starts a new line and moves to the requested
% horizontal position.
%
% \tabto*{<length>}
% Similar to \tabto, except it will perform backspacing, and over-
% print previous text on the line whenever that text is already
% longer than the specified length (i.e., no linebreak is produced).
% Line-breaks are suppressed immediately after \tabto or \tabto*.
%
% The length register "\CurrentLineWidth" will report the width
% of the existing text on the line, and it may be used in the
% <length> argument (using calc.sty, for example). Also, there
% is "\TabPrevPos" which gives the "\CurrentLineWidth" from the
% previous tab command, and can be used to return to that position
% if no line breaks have occurred in between.
%
% \tab
% Tab to the next tab-stop chosen from a list of tab positions, in
% the traditional style of typewriters. A \tab will always move
% to the next tab stop (or the next line), even if it is already
% exactly at a tab stop. Thus, "\tab" at the beginning of a line,
% or "\tab\tab" elsewhere skips a position. A linebreak is permitted
% immediately following a \tab, in case the ensuing text does not
% fit well in the remaining space.
%
% If you do not want to skip positions, use "\tabto{\NextTabStop}"
% instead of "\tab". This is particularly useful when you want to
% use \tab in some other command, but do not want to skip a column
% for the first item.
%
% The tab-stop positions are declared using either \TabPositions
% or \NumTabs:
%
% \TabPositions{<length>, <length>,...<length>}
% Declares the tab stops as a comma-separated list of positions
% relative to the left margin. A tab-stop at 0pt is implicit, and
% need not be listed.
%
% \NumTabs{<number>}
% Declares a list of <number> equally-spaced tabs, starting at the
% left margin and spanning \linewidth. For example \NumTabs{2}
% declares tab-stops at 0pt and 0.5\linewidth, the same as
% \TabPositions{0pt, 0.5\linewidth} or \TabPositions{0.5\linewidth}
%
% After these declarations, the list of tab positions is saved in
% \TabStopList, and the next tab position, relative to the current
% position, is given by \NextTabStop. You do not normally need
% to access them, but they are available.
%
% Problems:
%
% Tall objects after a tab stop may overlap the line above, rather
% than forcing a greater separation between lines.
\ProvidesPackage{tabto}[2013/03/25 \space v 1.3 \space
Another tabbing mechanism]\relax
\newdimen\CurrentLineWidth
\let\TabPrevPos\z@
\newcommand\tabto[1]{%
\leavevmode
\begingroup
\def\@tempa{*}\def\@tempb{#1}%
\ifx\@tempa\@tempb % \tab*
\endgroup
\TTo@overlaptrue % ... set a flag and re-issue \tabto to get argument
\expandafter\tabto
\else
\ifinner % in a \hbox, so ignore
\else % unrestricted horizontal mode
\null% \predisplaysize will tell the position of this box (must be box)
\parfillskip\fill
\everydisplay{}\everymath{}%
\predisplaypenalty\@M \postdisplaypenalty\@M
$$% math display so we can test \predisplaysize
\lineskiplimit=-999pt % so we get pure \baselineskip
\abovedisplayskip=-\baselineskip \abovedisplayshortskip=-\baselineskip
\belowdisplayskip\z@skip \belowdisplayshortskip\z@skip
\halign{##\cr\noalign{%
% get the width of the line above
\ifdim\predisplaysize=\maxdimen %\message{Mixed R and L, so say the line is full. }%
\CurrentLineWidth\linewidth
\else
\ifdim\predisplaysize=-\maxdimen
% \message{Not in a paragraph, so call the line empty. }%
\CurrentLineWidth\z@
\else
\ifnum\TTo@Direction<\z@
\CurrentLineWidth\linewidth \advance\CurrentLineWidth\predisplaysize
\else
\CurrentLineWidth\predisplaysize
\fi
% Correct the 2em offset
\advance\CurrentLineWidth -2em
\advance\CurrentLineWidth -\displayindent
\advance\CurrentLineWidth -\leftskip
\fi\fi
\ifdim\CurrentLineWidth<\z@ \CurrentLineWidth\z@\fi
% Enshrine the tab-to position; #1 might reference \CurrentLineWidth
\@tempdimb=#1\relax
%\message{*** Tab to \the\@tempdimb, previous width is \the\CurrentLineWidth. ***}%
% Save width for possible return use
\xdef\TabPrevPos{\the\CurrentLineWidth}%
% Build the action to perform
\protected@xdef\TTo@action{%
\vrule\@width\z@\@depth\the\prevdepth
\ifdim\CurrentLineWidth>\@tempdimb
\protect\hskip\the\CurrentLineWidth\hskip5pt\relax
\else
\protect\nobreak
\protect\hskip\the\@tempdimb\relax
\fi
}%
%\message{\string\TTo@action: \meaning \TTo@action. }%
% get back to the baseline, regardless of its depth.
\vskip-\prevdepth
\prevdepth-99\p@
\vskip\prevdepth
}}%
$$
% Don't count the display as lines in the paragraph
\count@\prevgraf \advance\count@-4 \prevgraf\count@
\TTo@action
%% \penalty\@m % to allow a penalized line break
\fi
\endgroup
\TTo@overlapfalse
\ignorespaces
\fi
}
% \tab -- to the next position
% \hskip so \tab\tab moves two positions
% Allow a (penalized but flexible) line-break right after the tab.
%
\newcommand\tab{\leavevmode\hskip2sp\tabto{\NextTabStop}%
\nobreak\hskip\z@\@plus 30\p@\penalty4000\hskip\z@\@plus-30\p@\relax}
% Expandable macro to select the next tab position from the list
\newcommand\NextTabStop{%
\expandafter \TTo@nexttabstop \TabStopList,\maxdimen,>%
}
\def\TTo@nexttabstop #1,{%
\ifdim#1<\CurrentLineWidth
\expandafter\TTo@nexttabstop
\else
\ifdim#1<0.9999\linewidth#1\else\z@\fi
\expandafter\strip@prefix
\fi
}
\def\TTo@foundtabstop#1>{}
\newcommand\TabPositions[1]{\def\TabStopList{\z@,#1}}
\newcommand\NumTabs[1]{%
\def\TabStopList{}%
\@tempdimb\linewidth
\divide\@tempdimb by#1\relax
\advance\@tempdimb 1sp % counteract rounding-down by \divide
\CurrentLineWidth\z@
\@whiledim\CurrentLineWidth<\linewidth\do {%
\edef\TabStopList{\TabStopList\the\CurrentLineWidth,}%
\advance\CurrentLineWidth\@tempdimb
}%
\edef\TabStopList{\TabStopList\linewidth}%
}
% default setting of tab positions:
\TabPositions{\parindent,.5\linewidth}
\newif\ifTTo@overlap \TTo@overlapfalse
\@ifundefined{predisplaydirection}{
\let\TTo@Direction\predisplaysize
\let\predisplaydirection\@undefined
}{
\let\TTo@Direction\predisplaydirection
}

Binary file not shown.
Loading…
Cancel
Save