FEZ Hydra as I2C Slave devive

Hi.
I’m trying to implement an I2C slave on FEZ Hydra. Sorry if the question sounds stupid, but how do I create I2C slave device?
As I understand, I2CDevice acts as a master, so it’s not an option.
You may send me to “Search”, but I’m searching for a few days now, and the only thing I see is communicating with other slaves, as I2CDevice master.

Thanks!

Welcome to the forum. Unfortunately there is no built-in implementation of the slave. You will need to do it yourself.

Heh… as I thought.
So just to make it clear, I would need to build all the I2C slave stack, right? There’s nothing I can reuse/modifiy from other classes?

I do not think there is any implementation you can base off as most use master not slave.

Can you tell us what are you trying to connect?

Welcome to the community.

Long story short - I need to emulate a sensor without actual sensor. The idea is to connect Hydra on I2C bus as a slave and act as a sensor, sending predefined data.

P.S. Thanks for the warm welcoming :slight_smile:

A device emulator, interesting use. I would look into using “Register” class as a base to writing the driver. This way you do not have to rebuild the firmware… RLP is a good option as well. This is an example on how CAN drivers were implemented in C# using register class http://www.tinyclr.com/codeshare/entry/552

You will not be able to use interrupts but I2C has clock stretching so you will be able to handle the I2C traffic.

If you happen to implement slave, please share the code is possible.

Yes, I thought working with RLP as performance is very critical in our project. I’m hoping to emulate up to 6 sensors, each ready with data at up to 400Hz and hope to support up to 1.7MHz I2C bus speed, though bus speed is not so critical - can work with 400KHz as well.

Hi,
I just read your post. Perhaps the principle of http://www.tinyclr.com/codeshare/entry/568 can help you. It makes the I2C master of a spider mainboard to a I2C slave on a second I2C-Bus. I dont know whether it is fast enough.

Well, unfortunately there’s no way for us to have C# solution - managed code is too slow for us, even on 200MHz Hydra.
Anyways, thanks for the reference! I will definitely take a closer look at it, as we have other gadgeteer based projects going on here.