IP2730_DXSSK_YBTKN 固件 I2C 从机通讯例子

目的:

验证 IP2730_DXSSK_YBTKN 固件版本的 I2C Slave 从机访问的基本功能。

准备:

IP2730 Demo 板,烧录 IP2730_DXSSK_YBTKN 固件。

使用 逻辑分析仪 抓通讯波形。

ESP32 用于执行 Master 部分的逻辑。

过程

ESP32 部分使用的代码:

print("")
print("------------------------")
print("-        myI2cSvr      -")
print("-       rev.:0.0.1     -")
print("-       Tony ZHANG     -")
print("------------------------")
print("")

import machine, time
from machine import Pin, SoftI2C

Pin_SDA=Pin(13, Pin.OPEN_DRAIN, pull=Pin.PULL_UP)
Pin_SCL=Pin(14, Pin.OPEN_DRAIN, pull=Pin.PULL_UP)
W100 = SoftI2C(scl=Pin_SCL, sda=Pin_SDA, freq=10000)

# Pin_SDA=Pin(11, Pin.OPEN_DRAIN, pull=Pin.PULL_UP)
# Pin_SCL=Pin(12, Pin.OPEN_DRAIN, pull=Pin.PULL_UP)
# W40 = SoftI2C(scl=Pin_SCL, sda=Pin_SDA, freq=40000)

scanReplay = W100.scan()
print(scanReplay)

slaveAddress = 0x08
regMapAddressList = [0x00,0x01,0x02,0x03,0x04]

time.sleep(0.5)
print("---------------------IP2730_DXSSK_YBTKN----------------")
print("从机寄存器地址列表:{}".format(regMapAddressList))
print("------------------------从机访问例子---------------------")
for i in regMapAddressList:
    buf = W100.readfrom_mem(slaveAddress,i,1)
    print("寄存器地址:{},值为:{}".format(i,buf[0]))

上一段程序的执行输出

------------------------
-        myI2cSvr      -
-       rev.:0.0.1     -
-       Tony ZHANG     -
------------------------

[8]
---------------------IP2730_DXSSK_YBTKN----------------
从机寄存器地址列表:[0, 1, 2, 3, 4]
------------------------从机访问例子---------------------
寄存器地址:0,值为:204
寄存器地址:1,值为:128
寄存器地址:2,值为:47
寄存器地址:3,值为:3
寄存器地址:4,值为:0

相关波形

注意事项:

请注意在该版本中 IP2730 从上电到初始化完成大约需要 1S 左右,所以需要在访问前做延时。

IP2730_DXSSK_YBTKN 固件 I2C 从机通讯例子

One thought on “IP2730_DXSSK_YBTKN 固件 I2C 从机通讯例子

发表回复

Scroll to top