1
0

spi 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. .TH SPI 3
  2. .SH NAME
  3. spi \- access to the main Raspberry Pi SPI interface
  4. .SH SYNOPSIS
  5. .B bind -a #π /dev
  6. .PP
  7. .B /dev/spictl
  8. .br
  9. .B /dev/spi0
  10. .br
  11. .B /dev/spi1
  12. .SH DESCRIPTION
  13. The Broadcom SoC on the Raspberry Pi has three SPI interfaces:
  14. the main SPI interface, designated SPI0, and two auxiliary SPI
  15. interfaces, designated SPI1 and SPI2.
  16. On the first generation Pis, only SPI0 was brought out to the
  17. header on the board.
  18. For the B+ and Pi2 models, SPI0 and SPI1 are available.
  19. The driver described in this man page only supports SPI0.
  20. .PP
  21. Reads and writes to the files
  22. .B spi0
  23. and
  24. .B spi1
  25. transfer data over the SPI bus.
  26. Accesses to
  27. .B spi0
  28. cause the transfers to take place with the CE0\_0 line asserted
  29. low.
  30. Similarly, transfers to
  31. .B spi1
  32. are carried out with CE1\_0 asserted low.
  33. .PP
  34. The
  35. .B spictl
  36. file is used to set various control parameters.
  37. It accepts the following commands:
  38. .TP
  39. .BI clock " freq"
  40. Set the frequency of the SPI clock.
  41. The clock from which the SPI clock is derived runs at 250MHz,
  42. and the divisor must be a multiple of 2.
  43. (The Broadcom documentation incorrectly says "power of 2".)
  44. The driver sets the divisor to the highest multiple of 2 that results
  45. in a clock rate that is less than or equal to the
  46. .I freq
  47. parameter in MHz.
  48. .TP
  49. .BI mode " n"
  50. Treats
  51. .I n
  52. as a two-bit number specifying the settings for the clock phase
  53. and clock polarity.
  54. The default value of 0 matches the polarity and phase requirements
  55. of most peripheral devices.
  56. .TP
  57. .B lossi
  58. Enable a bidirectional mode where the MOSI line is used for both
  59. reads and writes.
  60. .SH SOURCE
  61. .B /sys/src/9/bcm/devspi.c
  62. .br
  63. .B /sys/src/9/bcm/spi.c
  64. .SH BUGS
  65. The various SPI modes are untested and the LoSSI support is
  66. unimplemented.