@@ -249,16 +249,15 @@ ESP32 specific ADC class method reference:
249249Software SPI bus
250250----------------
251251
252- There are two SPI drivers. One is implemented in software (bit-banging)
253- and works on all pins, and is accessed via the :ref: `machine.SPI <machine.SPI >`
254- class::
252+ Software SPI (using bit-banging) works on all pins, and is accessed via the
253+ :ref: `machine.SoftSPI <machine.SoftSPI >` class::
255254
256- from machine import Pin, SPI
255+ from machine import Pin, SoftSPI
257256
258- # construct an SPI bus on the given pins
257+ # construct a SoftSPI bus on the given pins
259258 # polarity is the idle state of SCK
260259 # phase=0 means sample on the first edge of SCK, phase=1 means the second
261- spi = SPI (baudrate=100000, polarity=1, phase=0, sck=Pin(0), mosi=Pin(2), miso=Pin(4))
260+ spi = SoftSPI (baudrate=100000, polarity=1, phase=0, sck=Pin(0), mosi=Pin(2), miso=Pin(4))
262261
263262 spi.init(baudrate=200000) # set the baudrate
264263
@@ -298,39 +297,54 @@ mosi 13 23
298297miso 12 19
299298===== =========== ============
300299
301- Hardware SPI has the same methods as Software SPI above::
300+ Hardware SPI is accessed via the :ref: `machine.SPI <machine.SPI >` class and
301+ has the same methods as software SPI above::
302302
303303 from machine import Pin, SPI
304304
305305 hspi = SPI(1, 10000000, sck=Pin(14), mosi=Pin(13), miso=Pin(12))
306306 vspi = SPI(2, baudrate=80000000, polarity=0, phase=0, bits=8, firstbit=0, sck=Pin(18), mosi=Pin(23), miso=Pin(19))
307307
308+ Software I2C bus
309+ ----------------
308310
309- I2C bus
310- -------
311-
312- The I2C driver has both software and hardware implementations, and the two
313- hardware peripherals have identifiers 0 and 1. Any available output-capable
314- pins can be used for SCL and SDA. The driver is accessed via the
315- :ref: `machine.I2C <machine.I2C >` class::
316-
317- from machine import Pin, I2C
311+ Software I2C (using bit-banging) works on all output-capable pins, and is
312+ accessed via the :ref: `machine.SoftI2C <machine.SoftI2C >` class::
318313
319- # construct a software I2C bus
320- i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)
314+ from machine import Pin, SoftI2C
321315
322- # construct a hardware I2C bus
323- i2c = I2C(0)
324- i2c = I2C(1, scl=Pin(5), sda=Pin(4), freq=400000)
316+ i2c = SoftI2C(scl=Pin(5), sda=Pin(4), freq=100000)
325317
326- i2c.scan() # scan for slave devices
318+ i2c.scan() # scan for devices
327319
328- i2c.readfrom(0x3a, 4) # read 4 bytes from slave device with address 0x3a
329- i2c.writeto(0x3a, '12') # write '12' to slave device with address 0x3a
320+ i2c.readfrom(0x3a, 4) # read 4 bytes from device with address 0x3a
321+ i2c.writeto(0x3a, '12') # write '12' to device with address 0x3a
330322
331323 buf = bytearray(10) # create a buffer with 10 bytes
332324 i2c.writeto(0x3a, buf) # write the given buffer to the slave
333325
326+ Hardware I2C bus
327+ ----------------
328+
329+ There are two hardware I2C peripherals with identifiers 0 and 1. Any available
330+ output-capable pins can be used for SCL and SDA but the defaults are given
331+ below.
332+
333+ ===== =========== ============
334+ \ I2C(0) I2C(1)
335+ ===== =========== ============
336+ scl 18 25
337+ sda 19 26
338+ ===== =========== ============
339+
340+ The driver is accessed via the :ref: `machine.I2C <machine.I2C >` class and
341+ has the same methods as software I2C above::
342+
343+ from machine import Pin, I2C
344+
345+ i2c = I2C(0)
346+ i2c = I2C(1, scl=Pin(5), sda=Pin(4), freq=400000)
347+
334348Real time clock (RTC)
335349---------------------
336350
0 commit comments