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.
85 lines
2.3 KiB
85 lines
2.3 KiB
\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}.
|
|
|
|
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}
|
|
|
|
\begin{cmdlist}
|
|
0 & \cname{CHECK\_PRESENCE}
|
|
Test if there are any devices attached to the bus.
|
|
& \begin{cmdresp}
|
|
\cfield{u8} presence detected (0, 1)
|
|
\end{cmdresp} \\
|
|
|
|
1 & \cname{SEARCH\_ADDR}
|
|
Start the search algorithm.
|
|
& \begin{cmdresp}
|
|
\cfield{u8} should continue (0, 1)
|
|
\cfield{u64[]} ROM codes
|
|
\end{cmdresp} \\
|
|
|
|
2 & \cname{SEARCH\_ALARM}
|
|
Start the search algorithm, finding only devices in an alarm state.
|
|
& \begin{cmdresp}
|
|
\cfield{u8} should continue (0, 1)
|
|
\cfield{u64[]} ROM codes
|
|
\end{cmdresp} \\
|
|
|
|
3 & \cname{SEARCH\_CONTINUE}
|
|
Continue a previously started search
|
|
& \begin{cmdresp}
|
|
\cfield{u8} should continue (0, 1)
|
|
\cfield{u64[]} ROM codes
|
|
\end{cmdresp} \\
|
|
|
|
4 & \cname{READ\_ADDR}
|
|
Read a device address (single device only)
|
|
& \begin{cmdresp}
|
|
\cfield{u64} ROM code
|
|
\end{cmdresp} \\
|
|
|
|
10 & \cname{WRITE}
|
|
Write bytes to a device.
|
|
& \begin{cmdreq}
|
|
\cfield{u64} ROM code
|
|
\cfield{u8[]} bytes to write
|
|
\end{cmdreq} \\
|
|
|
|
11 & \cname{READ}
|
|
Write a request and read response.
|
|
&
|
|
\begin{cmdreq}
|
|
\cfield{u64} ROM code
|
|
\cfield{u16} read length
|
|
\cfield{u8} verify checksum (0, 1)
|
|
\cfield{u8[]} request bytes
|
|
\end{cmdreq}
|
|
\cjoin
|
|
\begin{cmdresp}
|
|
\cfield{u8[]} read bytes
|
|
\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.
|
|
& \\
|
|
|
|
\end{cmdlist}
|
|
|
|
|
|
|