summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMaureen Helm <maureen.helm@intel.com>2022-09-16 12:46:51 -0500
committerDamien George <damien@micropython.org>2024-10-02 07:49:30 +1000
commit2407c46dac4ce75a64bc167478fab45c79c3396b (patch)
treeba981b9f46adf50c6f61aefe851e371fb2a04d4e
parent4e59a5190296cabd1be8de158d18d22444381958 (diff)
downloadmicropython-2407c46dac4ce75a64bc167478fab45c79c3396b.tar.gz
micropython-2407c46dac4ce75a64bc167478fab45c79c3396b.zip
docs/zephyr: Update docs to reflect device name changes.
Zephyr v3.2.0 deprecated the devicetree label property as a base property, which had been used as the device name string for device_get_binding(). The device name string is now the devicetree node name appended with its unit-address. Update Zephyr port documentation to reflect this change. Signed-off-by: Maureen Helm <maureen.helm@intel.com>
-rw-r--r--docs/zephyr/quickref.rst23
-rw-r--r--ports/zephyr/README.md10
2 files changed, 18 insertions, 15 deletions
diff --git a/docs/zephyr/quickref.rst b/docs/zephyr/quickref.rst
index d8b1f8768d..31a4ac46c2 100644
--- a/docs/zephyr/quickref.rst
+++ b/docs/zephyr/quickref.rst
@@ -36,7 +36,10 @@ Use the :ref:`machine.Pin <machine.Pin>` class::
from machine import Pin
- pin = Pin(("GPIO_1", 21), Pin.IN) # create input pin on GPIO1
+ gpio1 = "gpio@400ff040" # GPIO1 device name
+ gpio2 = "gpio@400ff080" # GPIO2 device name
+
+ pin = Pin((gpio1, 21), Pin.IN) # create input pin on GPIO1
print(pin) # print pin port and number
pin.init(Pin.OUT, Pin.PULL_UP, value=1) # reinitialize pin
@@ -47,14 +50,14 @@ Use the :ref:`machine.Pin <machine.Pin>` class::
pin.on() # set pin to high
pin.off() # set pin to low
- pin = Pin(("GPIO_1", 21), Pin.IN) # create input pin on GPIO1
+ pin = Pin((gpio1, 21), Pin.IN) # create input pin on GPIO1
- pin = Pin(("GPIO_1", 21), Pin.OUT, value=1) # set pin high on creation
+ pin = Pin((gpio1, 21), Pin.OUT, value=1) # set pin high on creation
- pin = Pin(("GPIO_1", 21), Pin.IN, Pin.PULL_UP) # enable internal pull-up resistor
+ pin = Pin((gpio1, 21), Pin.IN, Pin.PULL_UP) # enable internal pull-up resistor
- switch = Pin(("GPIO_2", 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((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
Hardware I2C bus
----------------
@@ -63,7 +66,7 @@ Hardware I2C is accessed via the :ref:`machine.I2C <machine.I2C>` class::
from machine import I2C
- i2c = I2C("I2C_0") # construct an i2c bus
+ i2c = I2C("i2c@40066000") # construct an i2c bus
print(i2c) # print device name
i2c.scan() # scan the device for available I2C slaves
@@ -84,11 +87,11 @@ Hardware SPI is accessed via the :ref:`machine.SPI <machine.SPI>` class::
from machine import SPI
- spi = SPI("SPI_0") # construct a spi bus with default configuration
+ spi = SPI("spi@4002c000") # 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_0", baudrate=100000, polarity=0, phase=0, bits=8, firstbit=SPI.MSB)
+ spi = SPI("spi@4002c000", 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
@@ -146,7 +149,7 @@ Use the :ref:`zsensor.Sensor <zsensor.Sensor>` class to access sensor data::
import zsensor
from zsensor import Sensor
- accel = Sensor("FXOX8700") # create sensor object for the accelerometer
+ accel = Sensor("fxos8700@1d") # create sensor object for the accelerometer
accel.measure() # obtain a measurement reading from the accelerometer
diff --git a/ports/zephyr/README.md b/ports/zephyr/README.md
index c463b37d1f..11cd0acfa2 100644
--- a/ports/zephyr/README.md
+++ b/ports/zephyr/README.md
@@ -107,7 +107,7 @@ To blink an LED:
import time
from machine import Pin
- LED = Pin(("GPIO_1", 21), Pin.OUT)
+ LED = Pin(("gpio@400ff040", 21), Pin.OUT)
while True:
LED.value(1)
time.sleep(0.5)
@@ -125,8 +125,8 @@ To respond to Pin change IRQs, on a FRDM-K64F board run:
from machine import Pin
- SW2 = Pin(("GPIO_2", 6), Pin.IN)
- SW3 = Pin(("GPIO_0", 4), Pin.IN)
+ SW2 = Pin(("gpio@400ff080", 6), Pin.IN)
+ SW3 = Pin(("gpio@400ff000", 4), Pin.IN)
SW2.irq(lambda t: print("SW2 changed"))
SW3.irq(lambda t: print("SW3 changed"))
@@ -138,14 +138,14 @@ Example of using I2C to scan for I2C slaves:
from machine import I2C
- i2c = I2C("I2C_0")
+ i2c = I2C("i2c@40066000")
i2c.scan()
Example of using SPI to write a buffer to the MOSI pin:
from machine import SPI
- spi = SPI("SPI_0")
+ spi = SPI("spi@4002c000")
spi.init(baudrate=500000, polarity=1, phase=1, bits=8, firstbit=SPI.MSB)
spi.write(b'abcd')