diff --git a/scripts/examples/50-Arduino-Boards/Nicla-Vision/50-Board-Control/i2c_control.py b/scripts/examples/50-Arduino-Boards/Nicla-Vision/50-Board-Control/i2c_control.py index 77f0ac63d..c4642d532 100644 --- a/scripts/examples/50-Arduino-Boards/Nicla-Vision/50-Board-Control/i2c_control.py +++ b/scripts/examples/50-Arduino-Boards/Nicla-Vision/50-Board-Control/i2c_control.py @@ -2,23 +2,15 @@ # Copyright (c) 2013-2023 OpenMV LLC. All rights reserved. # https://github.com/openmv/openmv/blob/master/LICENSE # -# I2C Control -# -# This example shows how to use the i2c bus on your OpenMV Cam by dumping the -# contents on a standard EEPROM. To run this example either connect the -# Thermopile Shield to your OpenMV Cam or an I2C EEPROM to your OpenMV Cam. - +# I2C Example. from pyb import I2C -i2c = I2C(1, I2C.MASTER) -mem = i2c.mem_read(256, 0x50, 0) # The eeprom slave address is 0x50. -print("\n[") -for i in range(16): - print("\t[", end="") - for j in range(16): - print("%03d" % mem[(i * 16) + j], end="") - if j != 15: - print(", ", end="") - print("]," if i != 15 else "]") -print("]") +i2c = I2C(2, I2C.MASTER) +if 0x29 not in i2c.scan(): + raise RuntimeError("Failed to detect ToF") + +# Read ToF Model ID. +mid = i2c.mem_read(1, 0x29, 0x010f, addr_size=16) +# Should print 0xEA +print(f"ToF Model ID: 0x{mid[0]:02X}") diff --git a/scripts/examples/50-Arduino-Boards/Nicla-Vision/50-Board-Control/spi_control.py b/scripts/examples/50-Arduino-Boards/Nicla-Vision/50-Board-Control/spi_control.py index 34e12616e..a99c74e60 100644 --- a/scripts/examples/50-Arduino-Boards/Nicla-Vision/50-Board-Control/spi_control.py +++ b/scripts/examples/50-Arduino-Boards/Nicla-Vision/50-Board-Control/spi_control.py @@ -11,9 +11,9 @@ import sensor import time from pyb import Pin, SPI -cs = Pin("GPIO1", Pin.OUT_OD) -rst = Pin("GPIO2", Pin.OUT_PP) -rs = Pin("GPIO3", Pin.OUT_PP) +cs = Pin("CS", Pin.OUT_OD) +rst = Pin("D0", Pin.OUT_PP) +rs = Pin("D1", Pin.OUT_PP) # NOTE: The SPI clock frequency will not always be the requested frequency. The hardware only supports # frequencies that are the bus frequency divided by a prescaler (which can be 2, 4, 8, 16, 32, 64, 128 or 256).