boards/NICLA: Update examples.

This commit is contained in:
iabdalkader 2024-09-30 14:54:02 +02:00
parent 93ed9a7de3
commit f5afacf410
2 changed files with 12 additions and 20 deletions

View File

@ -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}")

View File

@ -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).