I have a Pi B+ on which I'm trying to bit-bash an I2C Slave in C / C++ (code's pretty much C despite the fact I'm using
.cpp files), utilizing GPIO 18 as my Clock and GPIO 17 as my Data. I'm utilizing the BCM2835 C library from Mike M. My code is a little less featured that a true Slave, if only because I don't expect to be sending information back to the Master.
To test my code, I've used the Pi's built-in I2C Master bus, as well as a RasPi 2's Master Bus. Both utilized the BCM2835 library's native functions to communicate with the PI B+ Slave code. And from both I find that the Pi recognizes that the Master on the bus is trying to communicate with Slave
I've checked the clock and data lines with an oscilloscope, and I see for certain that it's sending
11001100 - address
0x66, write. I've coded the Slave to respond to
0x66, but it doesn't seem to see the data at all.
I know for certain that the Pi is seeing the clock - debugging output displays that a message was sent to
0x00 after 8 bits on the clock - but for some reason it doesn't see the data. A separate pin test I've run, wiring the 3v3 pin direct to my Data pin, indicates it's reading as intended.
My question for you all is this: what would I need to do to get my code to recognize information flowing in through my data pin? Here's my code, if that's something you'd like to look over. This isn't the full code - I start a thread in
main to initialize this function, and then I listen for a keypress on
q to turn
alive to false.
Because I've got a B+, I'm currently investigating using the BSC module the BCM2835 has in it. Supposedly it can be used as an I2C Slave. While it's not implemented for access in Mike M's code, I can still use his code to get at the base registers.