![]() If the master sends three bytes the slave sends the amount of data the third byte tells it to do. For example the master write a command byte and an address byte to the slave, the slave answers with exactly one byte of data. The slave knows because it's following a strict protocol. I'll appreciate any answer, since this doubt has me stuck can I use the parameter's value instead of available() to determine how many bytes the slave received? I don't know what's really the deal, but I think it is redundant considering that available() does the same thing. Why onReceive does have a parameter and onRequest does not? It would be more useful if the slave acknowledges how many bytes the master requested, instead of how many the slave received. ![]() How the slave can know when to stop sending bytes? The event triggers once per request or once per byte? I make this question because I want to implement a muti-byte feature that sends the state of consecutive pins if the master requests multiple bytes on a digital/analog read. If the master, in order to request (read) data from a slave, has to specify the amount of bytes it expects to receive then how the slave knows that if the onRequest event doesn't even have any parameter that tells it? What happens if the slave doesn't transmit the exact amount of bytes the master requests? I know (more or less) how I2C works and the way the master reads and writes to a slave but I don't have clear how the Wire library handles the slave's events: In order to avoid any unnecessary detour on the topic, I'm going straight to the point: the idea is to create a program that converts any of the most popular AVR Arduinos into a simple I/O expander (and keeping fuctions like analogRead and PWM output aka analogWrite) by using I2C as the controller interface.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |