No tags
|
3 replies
Version 24 of the library has gone live. Highlights are:
#include
I2CSlave slave(p9, p10);
int main() {
char buf[10];
char msg[] = "Slave!";
slave.address(0x30);
while (1) {
int i = slave.receive();
switch (i) {
case I2CSlave::ReadAddressed: // Master has performed a read on the slave
slave.write(msg, strlen(msg) + 1); // Includes null char
break;
case I2CSlave::WriteGeneral: // Master has performed a general call write
slave.read(buf, 10);
printf("Read G: %s\n", buf);
break;
case I2CSlave::WriteAddressed: // Master has performed an addressed write
slave.read(buf, 10);
printf("Read A: %s\n", buf);
break;
}
for(int i = 0; i < 10; i++) buf[i] = 0; // Clear buffer
}
} Updating to the new Library
As usual, to get these updates for existing programs, simply click on the mbed library in your compiler project and choose "Update to latest revision!". New programs will automatically pull it in.
Any problems, suggestions or thumbs ups, please tell us in the Bugs/Suggestions forum!
Please log in to post a comment.
These changes look great Jon.
However, as with your previous SPISlave class, the documentation for the new I2CSlave didn't make it into the "Handbook", although I can see it in the compiler when I expand the mbed library. I think there are a couple of others that aren't shown in the Handbook also.
Any chance of an update to the Handbook also, so you don't have to launch the compiler just to see the details of these new classes?