I'm using the Wire library for all my I2C slave needs, and it's doing a great work!
Now I need some functionality that I'm not sure Wire provides out-of-the box, so any tips on how I could implement it would be very welcome.
I have created an I2C slave device that talks to the Nintendo Wiimote (the I2C master). This is the project I'm talking about: https://gitorious.org/wii-retropad-adapter
The thing is, there's a part in the code where I need to completely disable interrupts because I'm executing a very time sensitive routine. It doesn't take too much time (I think around 350us), but it gets repeated several times a second (it's inside a loop). This is on file https://gitorious.org/wii-retropad-adapter/wii-retropad-adapter/blobs/master/src/wii-retropad-adapter/wra.cpp
line #301. However, this brief interrupts disabling, several times a second, is being enough to get random garbage data sent to the I2C master.
My idea around this is to put Wire into "clock stretch
" mode (as a slave, not a master) before calling GCPad_read. So my questions are:
1 - Is this a feasible thing? Any tips on modifying Wire library to allow that?
2 - Does clock strecth work with interrupts disabled?
Any help would be very welcome!