summaryrefslogtreecommitdiffstatshomepage
path: root/docs/wipy/quickref.rst
diff options
context:
space:
mode:
authorDaniel Campora <daniel@wipy.io>2015-09-11 14:57:48 +0200
committerDaniel Campora <daniel@wipy.io>2015-09-16 10:10:22 +0200
commitf38d16483a41313bedef683d331c8cb26af50f14 (patch)
tree82156d53a534b1f9085aef5101c98f5b9f5f0434 /docs/wipy/quickref.rst
parente77abc261bf47343d14c4b5e26c80a0136b93e7c (diff)
downloadmicropython-f38d16483a41313bedef683d331c8cb26af50f14.tar.gz
micropython-f38d16483a41313bedef683d331c8cb26af50f14.zip
docs: Update I2C and UART docs to match the new API.
Diffstat (limited to 'docs/wipy/quickref.rst')
-rw-r--r--docs/wipy/quickref.rst22
1 files changed, 6 insertions, 16 deletions
diff --git a/docs/wipy/quickref.rst b/docs/wipy/quickref.rst
index fe6b053b73..cad6d98b07 100644
--- a/docs/wipy/quickref.rst
+++ b/docs/wipy/quickref.rst
@@ -87,12 +87,7 @@ UART (serial bus)
See :ref:`pyb.Pin <pyb.Pin>` and :ref:`pyb.UART <pyb.UART>`. ::
from pyb import Pin, UART
-
- # first assign TX and RX to the correct pins
- Pin('GP1', af=3, mode=Pin.STD_PU) # TX
- Pin('GP2', af=3, mode=Pin.STD_PU) # RX
-
- uart = UART(1, 9600)
+ uart = UART(0, 9600)
uart.write('hello')
uart.read(5) # read up to 5 bytes
@@ -121,18 +116,13 @@ I2C bus
See :ref:`pyb.Pin <pyb.Pin>` and :ref:`pyb.I2C <pyb.I2C>`. ::
from pyb import Pin, I2C
-
- # first assign SCL and SDA to the correct pins
- Pin('GP23', af=9, mode=Pin.STD_PU) # SCL
- Pin('GP24', af=9, mode=Pin.STD_PU) # SDA
-
# configure the I2C bus
- i2c = I2C(1, I2C.MASTER, baudrate=100000)
+ i2c = I2C(0, I2C.MASTER, baudrate=100000)
i2c.scan() # returns list of slave addresses
- i2c.send('hello', 0x42) # send 5 bytes to slave with address 0x42
- i2c.recv(5, 0x42) # receive 5 bytes from slave
- i2c.mem_read(2, 0x42, 0x10) # read 2 bytes from slave 0x42, slave memory 0x10
- i2c.mem_write('xy', 0x42, 0x10) # write 2 bytes to slave 0x42, slave memory 0x10
+ i2c.writeto(0x42, 'hello') # send 5 bytes to slave with address 0x42
+ i2c.readfrom(0x42, 5) # receive 5 bytes from slave
+ i2c.readfrom_mem(0x42, 0x10, 2) # read 2 bytes from slave 0x42, slave memory 0x10
+ i2c.writeto_mem(0x42, 0x10, 'xy') # write 2 bytes to slave 0x42, slave memory 0x10
Watchdog timer (WDT)
--------------------