Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 00003 I2CSlave slave(PB_9, PB_8); 00004 00005 int main() { 00006 char buf[10]; 00007 char msg[] = "Slave!"; 00008 00009 slave.address(0x0A); 00010 while (1) { 00011 int i = slave.receive(); 00012 switch (i) { 00013 case I2CSlave::ReadAddressed: 00014 slave.write(msg, strlen(msg) + 1); // Includes null char 00015 break; 00016 case I2CSlave::WriteGeneral: 00017 slave.read(buf, 10); 00018 //printf("Read G: %s\n", buf); 00019 break; 00020 case I2CSlave::WriteAddressed: 00021 slave.read(buf, 10); 00022 //printf("Read A: %s\n", buf); 00023 break; 00024 } 00025 for(int i = 0; i < 10; i++) buf[i] = 0; // Clear buffer 00026 } 00027 }
Generated on Fri Jul 22 2022 11:34:22 by
1.7.2