i2c slave working version 1.1

Dependencies:   mbed-rtos mbed

Fork of slave_i2c3 by sakthi priya amirtharaj

main.cpp

Committer:
raizel_varun
Date:
2014-12-08
Revision:
1:4c71a7675750
Parent:
0:24e80ff2c7b1
Child:
2:458f9e603814

File content as of revision 1:4c71a7675750:

#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");
    char *data_send = new char;
            *data_send = 'k';
    while(1){
        //if(pc.getc()==8){
          //  bool loopvariable1= true;
            
            slave.address(0x20);
            int slave_status=1;
            //while(loopvariable1){
                if(slave.receive()==1){
                slave_status=slave.write(data_send,1);
                    if(!slave_status){
                        printf("1 wrote %c to master\n\r",*data_send);
              //          loopvariable1 = false;
                    }
                }
            }
            printf("2 done");
        }