顾名思义,我想使用 Arduino IDE 编码连接两个 ESP8226 模块。在这种情况下,它们恰好是 Wemos 板。我的主要参考资料是 Espressif Technical Reference。
技术文档引用了我在这里找到的 spi_test.c 文件: https:
Master 端工作正常,使用逻辑分析仪我可以看到我正在成功发送...
* 2 字节命令
* 4 字节地址
* 13 字节数据.
(见附件Capture.png)
这是主端预期的输出,显示发送到从属端的寄存器值。
代码:
全选Master Send
SpiNum_HSPI(1610613056)
SPI_CMD [0x00000002]
SPI_ADDR [0xd3d4d5d6]
SPI_CTRL [0x0028a737]
SPI_CTRL2 [0x00040011]
SPI_CLOCK [0x000e74e7]
SPI_RD_STATUS [0x00000000]
SPI_WR_STATUS [0x00000000]
SPI_USER [0xc8000070]
SPI_USER1 [0x7cce0000]
SPI_USER2 [0xf0000002]
SPI_PIN [0x0000001e]
SPI_SLAVE [0x00800200]
SPI_SLAVE1 [0x02000000]
SPI_SLAVE2 [0x00000000]
ADDR[0x60000140],Value[0x03020100]
ADDR[0x60000144],Value[0x07060504]
ADDR[0x60000148],Value[0x0b0a0908]
ADDR[0x6000014c],Value[0x0f0e0d0c]
ADDR[0x60000150],Value[0x00000000]
ADDR[0x60000154],Value[0x00000000]
ADDR[0x60000158],Value[0x00000000]
ADDR[0x6000015c],Value[0x00000000]
ADDR[0x60000160],Value[0x00000000]
ADDR[0x60000164],Value[0x00000000]
ADDR[0x60000168],Value[0x00000000]
ADDR[0x6000016c],Value[0x00000000]
ADDR[0x60000170],Value[0x00000000]
ADDR[0x60000174],Value[0x00000000]
ADDR[0x60000178],Value[0x00000000]
ADDR[0x6000017c],Value[0x00000000]
虽然它接收和触发基于中断的回调很好,但部分传入字节被放错了地方。这是从设备上相同寄存器的输出。
代码:
全选Slave Receiving
SpiNum_HSPI(1610613056)
SPI_CMD [0x00000002]
SPI_ADDR [0x00000000]
SPI_CTRL [0x0028a000]
SPI_CTRL2 [0x00800011]
SPI_CLOCK [0x00000000]
SPI_RD_STATUS [0x00000000]
SPI_WR_STATUS [0x00000000]
SPI_USER [0xc9000040]
SPI_USER1 [0x1dfeff00]
SPI_USER2 [0x70000002]
SPI_PIN [0x0008001e]
SPI_SLAVE [0x405403e0]
SPI_SLAVE1 [0x3aff1c70]
SPI_SLAVE2 [0x00000000]
ADDR[0x60000140],Value[0xd6d5d4d3]
ADDR[0x60000144],Value[0x03020100]
ADDR[0x60000148],Value[0x07060504]
ADDR[0x6000014c],Value[0x0b0a0908]
ADDR[0x60000150],Value[0x0000000c]
ADDR[0x60000154],Value[0x00000000]
ADDR[0x60000158],Value[0x00000000]
ADDR[0x6000015c],Value[0x00000000]
ADDR[0x60000160],Value[0x00000000]
ADDR[0x60000164],Value[0x00000000]
ADDR[0x60000168],Value[0x00000000]
ADDR[0x6000016c],Value[0x00000000]
ADDR[0x60000170],Value[0x00000000]
ADDR[0x60000174],Value[0x00000000]
ADDR[0x60000178],Value[0x00000000]
ADDR[0x6000017c],Value[0x00000000]
Slave Received
请注意命令是正确的 (SPI_CMD) 但地址 (SPI_ADDR) = 0 并且地址值被填充到第一个数据字段中。所有数据都偏移这四个字节。查看从属端的代码 - 没有参数或寄存器#define 用于告诉较低级别的代码地址长度是多少。因此,它显然默认为零,因此假定地址是来自主机的数据的一部分并将其放入数据寄存器。
有人知道是否有某种方法可以告诉从端如何正确放置传入的主字节?