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.
Dependencies: mbed slave_sample
Fork of slave_sample by
main.cpp
- Committer:
- sakthipriya
- Date:
- 2014-12-06
- Revision:
- 0:17326cfa2586
- Child:
- 1:d5cf8c6f7ef4
File content as of revision 0:17326cfa2586:
#include "mbed.h" #define interrupt D8 void write_to_master(char); //function to write data to master DigitalOut led1(LED_RED); I2CSlave slave(D14,D15); //configuring pins p27, p28 as I2Cslave Serial pc(USBTX,USBRX); InterruptIn m2s_interrupt(interrupt); //int m2s = m2s_interrupt; bool read_loop = true; void write2slave() { printf("\nEntered slave code\n"); char *data_rec = new char; while(read_loop){ slave.address(0x20); int slave_status =1; printf("\nentered slave while loop\n"); // if(slave.receive()==3) slave_status=slave.read(data_rec,1); if(!slave_status){ printf("1 read %c from master\n\r",*data_rec); read_loop = false;} } printf("\n done \n \r"); delete data_rec; } void led() { led1=!led1; } int main(){ printf("interrupt for slave to start \n\r"); m2s_interrupt.rise(&led); //write2slave(); }