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.
Fork of freemaster_write2master_working by
Diff: main.cpp
- Revision:
- 2:2dd5bd9a64fb
- Parent:
- 1:8e4b5e1f8039
- Child:
- 3:c810e140a6bf
--- a/main.cpp Mon Dec 08 03:54:47 2014 +0000 +++ b/main.cpp Wed Dec 10 16:39:17 2014 +0000 @@ -3,29 +3,46 @@ const int addr = 0x20; //slave address I2C master (D14,D15); //configure pins p27,p28 as I2C master Serial pc (USBTX,USBRX); - -void main() +DigitalOut interrupt(D9); +InterruptIn data_ready(D10); +void FUNC_I2C_MASTER() { - printf("press backspace for master to start \n\r"); - while(1){ - if(pc.getc()==8){ - bool ack0 =true; + //printf("press backspace for master to start \n\r"); + //while(1){ + // interrupt = 0; + // if(pc.getc()=='z'){ + interrupt = 1; + printf("\nEntered master function\n"); + int ack0 =true; char *data = new char; *data = 'b'; bool loopvariable0 = true; master.frequency(100000); //set clock frequency //master.start(); - while(ack0){ + while(ack0) + { //printf("2 master clk freq setup and addressing slave\n\r"); - + master.start(); //initiating the data transfer - ack0 = (bool) master.read(addr,data,1);} - if(!ack0){ - printf("3 master has read %c from slave\n\r",*data); + ack0 = master.read(addr,data,1); + } + if(!ack0) + { + printf("\n master has read %c from slave\n\r",*data); loopvariable0=false; - } } - printf("done\n\r"); - } + //master.stop(); + + //printf("done\n\r"); + delete data; + interrupt=0; +} +void main() +{ + data_ready.rise(&FUNC_I2C_MASTER); + printf("\nstarted master\n"); + while(1) + { + ; } - \ No newline at end of file +} \ No newline at end of file