1
0

i2c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. .TH I2C 3
  2. .SH NAME
  3. i2c \- basic I2C interface
  4. .SH SYNOPSIS
  5. .B bind -a
  6. .BI #J n
  7. .B /dev
  8. .PP
  9. .BI /dev/i2c. n .ctl
  10. . br
  11. .BI /dev/i2c. n .data
  12. .fi
  13. .SH DESCRIPTION
  14. .I I2c
  15. serves a one-level directory with two files
  16. that give access to the target device with address
  17. .I n
  18. (given in hexadecimal)
  19. on the system's I2C bus.
  20. .I N
  21. is usually determined by the I2C device manufacturer.
  22. I2C gives address 0 special meaning as the `general call' address.
  23. See an I2C specification for details.
  24. .PP
  25. The control file
  26. .BI i2c. n .ctl
  27. accepts commands to set the valid address range and
  28. subaddressing mode for the corresponding data file.
  29. The following control messages can be written to it:
  30. .TP
  31. .B a10
  32. Force 10-bit addressing instead of 7-bit addressing.
  33. Otherwise 10-bit addressing is used only if the device address
  34. .I n
  35. is bigger than 255.
  36. .TP
  37. .BI size " nbytes"
  38. .br
  39. Set the logical size of the target device to
  40. .IR nbytes .
  41. (By default when opened, it is 256 bytes, enough for most small I2C devices.)
  42. IO requests will be kept within this limit.
  43. This value is also returned by
  44. .B Sys->stat
  45. as the length of the data file.
  46. .TP
  47. .BI subaddress " \fR[\fP n \fR]\fP"
  48. .br
  49. Cause subsequent reads and writes
  50. on the data file to use I2C subaddressing
  51. with
  52. .I n
  53. byte subaddresses (default: 1 byte).
  54. .I N
  55. must be no larger than 4.
  56. The target device must support subaddressing.
  57. By default, the device is not subaddressed.
  58. Setting
  59. .I n
  60. to zero switches off subaddressing.
  61. .PP
  62. When read,
  63. the control file displays the current settings.
  64. .PP
  65. The data file
  66. .BI i2c. n .data
  67. can be read or written to
  68. exchange data with the slave device with address
  69. .I n
  70. (where
  71. .I n
  72. is given in hexadecimal).
  73. Each write request transmits the given data
  74. to the device.
  75. Each read request sends a receive
  76. request to the device and returns the resulting data.
  77. If the I2C target is subaddressed, the current file offset
  78. is used as the subaddress;
  79. otherwise the file offset is ignored, and the device typically starts at 0 for each transfer request.
  80. Read and write requests are trimmed to the declared
  81. size of the device.
  82. .SH SOURCE
  83. .B /sys/src/9/bcm/devi2c.c
  84. .br
  85. .B /sys/src/9/bcm/i2c.c