Chaitanya Viswa
/
freeslave1_2
slave reading from master
Revision 0:4add0b6d656a, committed 2014-12-06
- Comitter:
- viswachaitanya
- Date:
- Sat Dec 06 06:21:10 2014 +0000
- Commit message:
- m_w_s
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 4add0b6d656a main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Dec 06 06:21:10 2014 +0000 @@ -0,0 +1,25 @@ +#include "mbed.h" + +void write_to_master(char); //function to write data to master + +I2CSlave slave(D14,D15); //configuring pins p27, p28 as I2Cslave +Serial pc (USBTX,USBRX); + +void main(){ + printf("press backspace for slave to start \n\r"); + while(1){ + if(pc.getc()==8){ + bool loopvariable1= true; + char *data_rec = new char; + slave.address(0x20); + int slave_status=1; + while(loopvariable1){ + slave_status=slave.read(data_rec,1); + if(!slave_status){ + printf("read %c from master\n\r",*data_rec); + loopvariable1 = false; + } + } + } + } +} \ No newline at end of file
diff -r 000000000000 -r 4add0b6d656a mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Dec 06 06:21:10 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file