File: i2c.rst

package info (click to toggle)
python-periphery 2.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 424 kB
  • sloc: python: 3,496; makefile: 21
file content (33 lines) | stat: -rw-r--r-- 608 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
I2C
===

Code Example
------------

.. code-block:: python

    from periphery import I2C
    
    # Open i2c-0 controller
    i2c = I2C("/dev/i2c-0")
    
    # Read byte at address 0x100 of EEPROM at 0x50
    msgs = [I2C.Message([0x01, 0x00]), I2C.Message([0x00], read=True)]
    i2c.transfer(0x50, msgs)
    print("0x100: 0x{:02x}".format(msgs[1].data[0]))
    
    i2c.close()

API
---

.. autoclass:: periphery.I2C
    :members: transfer, close, fd, devpath, Message
    :undoc-members:
    :show-inheritance:

.. autoclass:: periphery.I2CError
    :members:
    :undoc-members:
    :show-inheritance: