diff options
Diffstat (limited to 'docs/zephyr/quickref.rst')
| -rw-r--r-- | docs/zephyr/quickref.rst | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/docs/zephyr/quickref.rst b/docs/zephyr/quickref.rst index 31a4ac46c..63d4bced0 100644 --- a/docs/zephyr/quickref.rst +++ b/docs/zephyr/quickref.rst @@ -36,10 +36,7 @@ Use the :ref:`machine.Pin <machine.Pin>` class:: from machine import Pin - gpio1 = "gpio@400ff040" # GPIO1 device name - gpio2 = "gpio@400ff080" # GPIO2 device name - - pin = Pin((gpio1, 21), Pin.IN) # create input pin on GPIO1 + pin = Pin(("gpiob", 21), Pin.IN) # create input pin on GPIO port B print(pin) # print pin port and number pin.init(Pin.OUT, Pin.PULL_UP, value=1) # reinitialize pin @@ -50,14 +47,14 @@ Use the :ref:`machine.Pin <machine.Pin>` class:: pin.on() # set pin to high pin.off() # set pin to low - pin = Pin((gpio1, 21), Pin.IN) # create input pin on GPIO1 + pin = Pin(("gpiob", 21), Pin.IN) # create input pin on GPIO port B - pin = Pin((gpio1, 21), Pin.OUT, value=1) # set pin high on creation + pin = Pin(("gpiob", 21), Pin.OUT, value=1) # set pin high on creation - pin = Pin((gpio1, 21), Pin.IN, Pin.PULL_UP) # enable internal pull-up resistor + pin = Pin(("gpiob", 21), Pin.IN, Pin.PULL_UP) # enable internal pull-up resistor - switch = Pin((gpio2, 6), Pin.IN) # create input pin for a switch - switch.irq(lambda t: print("SW2 changed")) # enable an interrupt when switch state is changed + switch = Pin(("gpioc", 6), Pin.IN) # create input pin for a switch + switch.irq(lambda t: print("SW2 changed")) # enable an interrupt when switch state is changed Hardware I2C bus ---------------- @@ -66,7 +63,7 @@ Hardware I2C is accessed via the :ref:`machine.I2C <machine.I2C>` class:: from machine import I2C - i2c = I2C("i2c@40066000") # construct an i2c bus + i2c = I2C("i2c0") # construct an i2c bus print(i2c) # print device name i2c.scan() # scan the device for available I2C slaves @@ -87,11 +84,11 @@ Hardware SPI is accessed via the :ref:`machine.SPI <machine.SPI>` class:: from machine import SPI - spi = SPI("spi@4002c000") # construct a spi bus with default configuration + spi = SPI("spi0") # construct a spi bus with default configuration spi.init(baudrate=100000, polarity=0, phase=0, bits=8, firstbit=SPI.MSB) # set configuration # equivalently, construct spi bus and set configuration at the same time - spi = SPI("spi@4002c000", baudrate=100000, polarity=0, phase=0, bits=8, firstbit=SPI.MSB) + spi = SPI("spi0", baudrate=100000, polarity=0, phase=0, bits=8, firstbit=SPI.MSB) print(spi) # print device name and bus configuration spi.read(4) # read 4 bytes on MISO @@ -149,7 +146,7 @@ Use the :ref:`zsensor.Sensor <zsensor.Sensor>` class to access sensor data:: import zsensor from zsensor import Sensor - accel = Sensor("fxos8700@1d") # create sensor object for the accelerometer + accel = Sensor("fxos8700") # create sensor object for the accelerometer accel.measure() # obtain a measurement reading from the accelerometer |
