AMB82 MINI SPI Read Not Working

Hi,
I’m using Arduino 4.0.4 SDK, and I’m trying to migrate RTL8722DN(with Standard SDK) project to AMB82-MINI.
Here are my questions:

  1. I’m wand to use SPI read, but in SPI.h, only “transfer” API can use.
    I directly use “spi_master_write” to receive data, but there is nothing happened. (In RTL8722DN, the spi_master_write API works).

(Due to this project may become a product, I only can show part of the code)
#include <SPI.h>
extern spi_t spi_obj0;
static uint8_t MasterRxBuf[SPI_BUF_SIZE + 32] attribute((aligned(32)));
const uint8_t dummy = 0;
static bool Flag = false; //Flag triggered by GPIO interrupt

void Setup() {
SPI.begin();
}

void Loop() {
if(Flag){
for(uint16_t i=0; i<SPI_BUF_SIZE ; i++){
MasterRxBuf[i] = spi_master_write(&spi_obj0, dummy);
}
Flag = false;
}
}

  1. I want to set SPI speed as 25MHz, except edit “SPI_DEFAULT_FREQ” in SPI.h, should I edit “SPISettings” line( SPISettings(4000000, MSBFIRST, SPI_MODE0); ) ?

Hi @Po_Quan_Hsieh,

  1. If you have set your board as Master, to send data to Slave, you can use the "transfer“ API. You may refer to SPI.cpp. This API is executing “spi_master_write”.

The code you have provided is unable to compile in the Arduino IDE; therefore, I have provided basic SPI Master and Slave test examples in the zip file for your reference.

SPI.zip (708 Bytes)

As we have updated our SPI API, you can find it in our dev branch. (https://github.com/ambiot/ambpro2_arduino/tree/dev/Arduino_package/hardware/libraries/SPI/src). Please download and replace the updated SPI.h and SPI.cpp in your Arduino15 before running the example in the zip file.

  1. To modify your SPI Speed, you can call "setDefaultFrequency” API in Arduino IDE. You may refer to SPI.cpp.

image

Thank you.

Hi @pammyleong,
Thanks for your reply, instead of the slaveRead(), dose current SDK support master read?
If not, will the future SDK support it?

Thanks.

Hi @Po_Quan_Hsieh,

Currently, the SDK does not support master read.

If you are looking at the open-source standard SDK (https://github.com/ambiot/ambpro2_sdk/blob/5fb0674ab6267285920808556ae1d84790638a0c/component/mbed/targets/hal/rtl8735b/spi_api.c#L254) , there are APIs for SPI data Communication via DMA such as spi_master_read_stream and spi_master_write_stream. However, SPI data Communication via DMA is still not supported in the Arduino SDK.

If you require this API in Arduino SDK, you may request it under feature request (🌟Feature Request - Realtek Ameba IOT Developers Forum (AMB82, RTL8722, RTL8195, RTL8710, RTL8720, BW16 Development board) - IOT / MCU Solutions 瑞昱開發者論壇 開發板 开發者论坛 开發板) and we’ll look into whether we can incorporate it into the Arduino SDK.