mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
boards/NICLA: Update examples.
This commit is contained in:
parent
93ed9a7de3
commit
f5afacf410
@ -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}")
|
||||
|
||||
@ -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).
|
||||
|
||||
Loading…
Reference in New Issue
Block a user