GEX thesis source code, full text, references
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gex-thesis/ch.unit.1wire.tex

86 lines
2.3 KiB

\section{1-Wire Unit}
7 years ago
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 \cref{sec:theory_1wire}.
This unit implements the ROM Search algorithm that is used to find the ROM codes 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.
Devices are addressed using their ROM codes, unique 64-bit (8-byte) identifiers that work as addresses. When only one device is connected, the value 0 may be used instead and the addressing will be skipped. Its ROM code may be recovered using the READ\_ADDR command or by the search algorithm.
\subsection{1-Wire Configuration}
\begin{inicode}
[1WIRE:ow@7]
# Data pin
pin=A0
# Parasitic (bus-powered) mode
parasitic=N
\end{inicode}
\subsection{1-Wire Commands}
7 years ago
\begin{cmdlist}
0 & \cname{CHECK\_PRESENCE}
Test if there are any devices attached to the bus.
7 years ago
& \begin{cmdresp}
\cfield{bool} presence detected
7 years ago
\end{cmdresp} \\
1 & \cname{SEARCH\_ADDR}
Start the search algorithm.
7 years ago
& \begin{cmdresp}
\cfield{bool} should continue
\cfield{u64[]} ROM codes
7 years ago
\end{cmdresp} \\
7 years ago
2 & \cname{SEARCH\_ALARM}
Start the search algorithm, finding only devices in an alarm state.
7 years ago
& \begin{cmdresp}
\cfield{bool} should continue
\cfield{u64[]} ROM codes
7 years ago
\end{cmdresp} \\
7 years ago
3 & \cname{SEARCH\_CONTINUE}
Continue a previously started search
7 years ago
& \begin{cmdresp}
\cfield{bool} should continue
\cfield{u64[]} ROM codes
7 years ago
\end{cmdresp} \\
7 years ago
4 & \cname{READ\_ADDR}
Read a device address (single device only)
7 years ago
& \begin{cmdresp}
\cfield{u64} ROM code
7 years ago
\end{cmdresp} \\
10 & \cname{WRITE}
Write bytes to a device.
7 years ago
& \begin{cmdreq}
\cfield{u64} ROM code
7 years ago
\cfield{u8[]} bytes to write
\end{cmdreq} \\
11 & \cname{READ}
Write a request and read response.
&
7 years ago
\begin{cmdreq}
\cfield{u64} ROM code
7 years ago
\cfield{u16} read length
\cfield{bool} verify checksum
7 years ago
\cfield{u8[]} request bytes
\end{cmdreq}
\cjoin
\begin{cmdresp}
\cfield{u8[]} read bytes
\end{cmdresp}
7 years ago
\\
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.
7 years ago
& \\
\end{cmdlist}