GEX thesis source code, full text, references

ch.unit.1wire.tex 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. \section{1-Wire Unit}
  2. 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}.
  3. 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.
  4. 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.
  5. \subsection{1-Wire Configuration}
  6. \begin{inicode}
  7. [1WIRE:ow@7]
  8. # Data pin
  9. pin=A0
  10. # Parasitic (bus-powered) mode
  11. parasitic=N
  12. \end{inicode}
  13. \subsection{1-Wire Commands}
  14. \begin{cmdlist}
  15. 0 & \cname{CHECK\_PRESENCE}
  16. Test if there are any devices attached to the bus.
  17. & \begin{cmdresp}
  18. \cfield{bool} presence detected
  19. \end{cmdresp} \\
  20. 1 & \cname{SEARCH\_ADDR}
  21. Start the search algorithm.
  22. & \begin{cmdresp}
  23. \cfield{bool} should continue
  24. \cfield{u64[]} ROM codes
  25. \end{cmdresp} \\
  26. 2 & \cname{SEARCH\_ALARM}
  27. Start the search algorithm, finding only devices in an alarm state.
  28. & \begin{cmdresp}
  29. \cfield{bool} should continue
  30. \cfield{u64[]} ROM codes
  31. \end{cmdresp} \\
  32. 3 & \cname{SEARCH\_CONTINUE}
  33. Continue a previously started search
  34. & \begin{cmdresp}
  35. \cfield{bool} should continue
  36. \cfield{u64[]} ROM codes
  37. \end{cmdresp} \\
  38. 4 & \cname{READ\_ADDR}
  39. Read a device address (single device only)
  40. & \begin{cmdresp}
  41. \cfield{u64} ROM code
  42. \end{cmdresp} \\
  43. 10 & \cname{WRITE}
  44. Write bytes to a device.
  45. & \begin{cmdreq}
  46. \cfield{u64} ROM code
  47. \cfield{u8[]} bytes to write
  48. \end{cmdreq} \\
  49. 11 & \cname{READ}
  50. Write a request and read response.
  51. &
  52. \begin{cmdreq}
  53. \cfield{u64} ROM code
  54. \cfield{u16} read length
  55. \cfield{bool} verify checksum
  56. \cfield{u8[]} request bytes
  57. \end{cmdreq}
  58. \cjoin
  59. \begin{cmdresp}
  60. \cfield{u8[]} read bytes
  61. \end{cmdresp}
  62. \\
  63. 20 & \cname{POLL\_FOR\_1}
  64. Wait for a READY status, used by DS18x20.
  65. Not available in parasitic mode.
  66. Responds with SUCCESS after all devices are ready.
  67. & \\
  68. \end{cmdlist}