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. # Copyright (c) 2013-2023 OpenMV LLC. All rights reserved.
# https://github.com/openmv/openmv/blob/master/LICENSE # https://github.com/openmv/openmv/blob/master/LICENSE
# #
# I2C Control # I2C Example.
#
# 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.
from pyb import I2C from pyb import I2C
i2c = I2C(1, I2C.MASTER)
mem = i2c.mem_read(256, 0x50, 0) # The eeprom slave address is 0x50.
print("\n[") i2c = I2C(2, I2C.MASTER)
for i in range(16): if 0x29 not in i2c.scan():
print("\t[", end="") raise RuntimeError("Failed to detect ToF")
for j in range(16):
print("%03d" % mem[(i * 16) + j], end="") # Read ToF Model ID.
if j != 15: mid = i2c.mem_read(1, 0x29, 0x010f, addr_size=16)
print(", ", end="") # Should print 0xEA
print("]," if i != 15 else "]") print(f"ToF Model ID: 0x{mid[0]:02X}")
print("]")

View File

@ -11,9 +11,9 @@ import sensor
import time import time
from pyb import Pin, SPI from pyb import Pin, SPI
cs = Pin("GPIO1", Pin.OUT_OD) cs = Pin("CS", Pin.OUT_OD)
rst = Pin("GPIO2", Pin.OUT_PP) rst = Pin("D0", Pin.OUT_PP)
rs = Pin("GPIO3", 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 # 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). # frequencies that are the bus frequency divided by a prescaler (which can be 2, 4, 8, 16, 32, 64, 128 or 256).