我正在通过 SPI 连接 nRF52832(M) 和 ESP8266 12E(S) 以发送图像数据。两者都在 4M 模式下,正常
通信工作但传输 10kb 时,它没有得到正确的数据。
我正在使用 Arduino IDE 进行编程。使用 SPI.Slave 函数在 ESP 端接收数据的
问题是,当传输延迟(5000 毫秒)的数据时,数据接收正常,但使用更短的延迟,如 100 毫秒,它只接收大约 1800 字节而不是 10kb
nrf 端发送
代码:
全选uint32_t wifiSpiWrite(uint8_t *txBuf, uint32_t len)
{
uint32_t ret = SPI_SUCCESS;
ret = nrf_drv_spi_transfer(&spi_2, txBuf, len, NULL, 0);
return ret;
}
wifiSpiWrite(No
tifyData,34);
if(imageByteCount >= 10230 ) // when sent 10kb then send this
{
imageByteCount = 0;
wifiMod.firstData[0] = 0x02;
wifiMod.firstData[1] = 0x00;
for(int i =2; i<34;i++)
{
wifiMod.firstData
= 0x06; // when data is complete then send this
}
wifiSpiWrite(wifiMod.firstData, 34);
for (int i = 0; i < 34; i++)
{
wifiMod.rxBuff= 0;
}
nrf_delay_ms(100); // so that spi can write and send
}
}
ESP 端接收
SPI 的初始化
hspi_slave_begin(0, this); // 对于 4M 模式
代码:全选SPISlave.onData([](uint8_t * data, size_t len)
{
if (data[0] == 0x02 )
{
Serial.printf("- - Value of index1 %d n",index1);
memcpy(&Event_Data[index1],&data[1],31);
index1 += 31;
}
}
以上输出
代码:全选- - Value of index1 32
- - Value of index1 63
- - Value of index1 94
- - Value of index1 125
- - Value of index1 156
- - Value of index1 187
- - Value of index1 218
- - Value of index1 249
- - Value of index1 280
- - Value of index1 311
- - Value of index1 342
- - Value of index1 373
- - Value of index1 404
- - Value of index1 435
- - Value of index1 466
- - Value of index1 497
- - Value of index1 528
- - Value of index1 559
- - Value of index1 590
- - Value of index1 621
- - Value of index1 652
- - Value of index1 683
- - Value of index1 714
- - Value of index1 745
- - Value of index1 776
- - Value of index1 807
- - Value of index1 838
- - Value of index1 869
- - Value of index1 900
- - Value of index1 931
- - Value of index1 962
- - Value of index1 993
- - Value of index1 1024
- - Value of index1 1055
- - Value of index1 1086
- - Value of index1 1117
- - Value of index1 1148
- - Value of index1 1179
- - Value of index1 1210
- - Value of index1 1241
- - Value of index1 1272
- - Value of index1 1303
- - Value of index1 1334
- - Value of index1 1365
- - Value of index1 1396
- - Value of index1 1427
- - Value of index1 1458
- - Value of index1 1489
- - Value of index1 1520
- - Value of index1 1551
- - Value of index1 1582
- - Value of index1 1613
- - Value of index1 1644
- - Value of index1 1675
- - Value of index1 1706
- - Value of index1 1737
- - Value of index1 1768
- - Value of index1 1799
- - Value of index1 1830
- - Value of index1 1861
- - Value of index1 1892
0