RTL8720DN as I2C slave

Thanks for your contribution, we will review the PR and merge it once review is completed

Hi @xsutter

Can I check if you are still using the Arduino Wire lib (ameba edition) for the slave tx and rx or have switch completely to using the APIs available in i2c_api.c and rtl8721d_i2c.c ?


Hi Simon,
Nice to read you !

I do not use the Arduino Wire lib at all, since the Wire.onReceive and Wire.onRequest callbacks never get called. I do not even #include "Wire.h" . I just #include "i2c_api.h" and use the Mbed and raw APIs, to my complete satisfaction.

As you already know, the current release of the Arduino SDK still contains a buggy I2C_SlaveWrite(). I filed an issue on this. In the meantime I am using a private, corrected version of I2C_SlaveWrite() which now resides permanently in my code.


Nice to hear you back and good to know that the I2C works fine in your setting.

The reason why I asked is because we are planning to support the

in the Wire libraries since it has been requested many times and I am wondering if you would like to test it once it’s done so we can confirm that I2C slave works in the interrupt mode under user’s code?

Yes, I can adapt my application to serve as a test support, this should not take too much time. Tell me when the new Wire is ready!

However unless we observe a definite performance advantage in using the Wire library, we will likely stick with the underlying Mbed API in our final product. This is in the hope that a VSCode Ameba SDK will eventually emerge, which would allow us to unify our development environment and get rid of the uncomfortable Arduino toolset completely.

1 Like

Thanks! it shoud not take long~

So your dev env has been with VSCode? As far as I know, Ameba SDK usually stick to either GCC-Make/CMake env (which can be embedded into any IDE actually) or IAR env.

If VSCode is what you prefer, maybe a simple extension that integrate some core make command is all it takes.

Actually our project is built around 2 processors: ESP32 for the main application, plus RTL8720 BW16 as a 5GHz wifi peripheral. We use SPI + I2C to link both.

We use VSCode + PlatformIO + esp-idf for our our main development on ESP32, which is extremely comfortable. We wish we could do the same for RTL8720, but unfortunately at the time being we have no choice but use the Arduino environment, which is prehistoric in comparison. We do not have the resource to attempt porting the Ameba SDK to PlatformIO, nor to adapt PIO’s upload tool to the BW16. We just hope someone will do that some day…

1 Like

PlatformIO has been requested many times too and it has been discussed internally and externally with the PlatformIO team. However, the PlatformIO team seem reluctant to help porting the Ameba SDK to their build system so this has to be put on pending for now.

Hello, @xidameng .

I was wondering on the status of this development? I noticed the latest commit for ambd_arduino/Arduino_package/hardware/libraries/Wire/examples/SlaveWriter/SlaveWriter.ino was Jul 28 which leads me to believe this is the updated version. However, using this example has not provided the expected function when using the corresponding Master program.



Hi @luke I2C Slave has been implemented and added to Arduino SDK since last release [Release] Ameba Arduino SDK Official Release about 8 days ago.

If you run the I2C slave example provided with another I2C master, you should see I2C slave device sending/receiving data

could you elaborate on your settings?

You can refer to this example guide for detailed steps and demo

Apologies for resurrecting the thread, it was as simple as updating through Arduino’s Board Manager. I was still working under version 3.1.3 and now using 3.1.4 and it works fine.

Thank you for your timely response. I appreciate you and this communication medium setup between users and developers.

1 Like

No problem luke, happy coding~ :smile: