GEX thesis source code, full text, references

ch.unit.spi.tex 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. \section{SPI Unit}
  2. The \gls{SPI} unit provides access to one of the microcontroller's \gls{SPI} peripherals. The unit can be configured to any of the hardware-supported speeds, clock polarity, and clock phase settings. Explanation of those options, including diagrams, can be found in \cref{sec:theory_spi}.
  3. The unit handles up to 16 slave select (\gls{NSS}) signals and supports message multi-cast (addressing more than one slaves at once). Protection resistors should be used if a multi-cast transaction is issued with \gls{MISO} connected to prevent a short circuit between slaves transmitting the opposite logical level.
  4. The QUERY command of this unit, illustrated by \cref{fig:spi_query}, is flexible enough to support all types of \gls{SPI} transactions: read-only, write-only, and read-write, with different request and response lengths and paddings. The slave select signal is asserted during the entire transaction.
  5. \begin{figure}[h]
  6. \centering
  7. \includegraphics[scale=1.1] {img/spi-query.pdf}
  8. \caption{\label{fig:spi_query}SPI transaction using the QUERY command}
  9. \end{figure}
  10. \subsection{SPI Configuration}
  11. \begin{inicode}
  12. [SPI:spi@5]
  13. # Peripheral number (SPIx)
  14. device=1
  15. # Pin mappings (SCK,MISO,MOSI)
  16. # SPI1: (0) A5,A6,A7 (1) B3,B4,B5
  17. # SPI2: (0) B13,B14,B15
  18. remap=0
  19. # Prescaller: 2,4,8,...,256
  20. prescaller=64
  21. # Clock polarity: 0,1 (clock idle level)
  22. cpol=0
  23. # Clock phase: 0,1 (active edge, 0-first, 1-second)
  24. cpha=0
  25. # Transmit only, disable MISO
  26. tx-only=N
  27. # Bit order (LSB or MSB first)
  28. first-bit=MSB
  29. # SS port name
  30. port=A
  31. # SS pins (comma separated, supports ranges)
  32. pins=0
  33. \end{inicode}
  34. \subsection{SPI Commands}
  35. \begin{cmdlist}
  36. 0 & \cname{QUERY}
  37. Exchange bytes with a slave device; see the diagram in \cref{fig:spi_query}
  38. & \begin{cmdreq}
  39. \cfield{u8} slave number 0--16
  40. \cfield{u16} response padding
  41. \cfield{u16} response length
  42. \cfield{u8[]} bytes to write
  43. \end{cmdreq}
  44. \cjoin
  45. \begin{cmdresp}
  46. \cfield{u8[]} received bytes
  47. \end{cmdresp} \\
  48. 1 & \cname{MULTICAST}
  49. Send a message to multiple slaves at once. The ``addressed slaves'' word uses the packed pins format (\cref{sec:packedpins}).
  50. & \begin{cmdreq}
  51. \cfield{u16} addressed slaves
  52. \cfield{u8[]} bytes to write
  53. \end{cmdreq} \\
  54. \end{cmdlist}