diff options
author | Damien George <damien.p.george@gmail.com> | 2019-07-10 13:43:52 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-07-19 16:31:25 +1000 |
commit | a29334761dc7b8eaf9f78611e3cd9033928b110c (patch) | |
tree | a7aec0729ec131ff8b581ced647881d70c9ae4f6 /docs/esp32 | |
parent | 3967dd68e80b296d1beead5e630807d914d98de6 (diff) | |
download | micropython-a29334761dc7b8eaf9f78611e3cd9033928b110c.tar.gz micropython-a29334761dc7b8eaf9f78611e3cd9033928b110c.zip |
esp32: Add support for hardware I2C.
Diffstat (limited to 'docs/esp32')
-rw-r--r-- | docs/esp32/quickref.rst | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/docs/esp32/quickref.rst b/docs/esp32/quickref.rst index 76fe0d9f9e..dd85b102b2 100644 --- a/docs/esp32/quickref.rst +++ b/docs/esp32/quickref.rst @@ -303,14 +303,22 @@ Hardware SPI has the same methods as Software SPI above:: I2C bus ------- -The I2C driver is implemented in software and works on all pins, -and is accessed via the :ref:`machine.I2C <machine.I2C>` class:: +The I2C driver has both software and hardware implementations, and the two +hardware peripherals have identifiers 0 and 1. Any available output-capable +pins can be used for SCL and SDA. The driver is accessed via the +:ref:`machine.I2C <machine.I2C>` class:: from machine import Pin, I2C - # construct an I2C bus + # construct a software I2C bus i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000) + # construct a hardware I2C bus + i2c = I2C(0) + i2c = I2C(1, scl=Pin(5), sda=Pin(4), freq=400000) + + i2c.scan() # scan for slave devices + i2c.readfrom(0x3a, 4) # read 4 bytes from slave device with address 0x3a i2c.writeto(0x3a, '12') # write '12' to slave device with address 0x3a |