![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
funtions sorted
main.cpp
- Committer:
- viswachaitanya
- Date:
- 2014-12-08
- Revision:
- 0:21ffb42911bd
File content as of revision 0:21ffb42911bd:
#include "mbed.h" char* read_from_master(); //function to write data to master int write_to_master(char*,int); I2CSlave slave(D14,D15); //configuring pins p27, p28 as I2Cslave Serial pc (USBTX,USBRX); bool read_loop = true; bool write_loop = true; char *data_rec = new char; char *data_send = new char; char *rec_data = new char; int slave_status = 1; int k; int main(){ slave.address(0x20); while(1){ slave.stop(); printf("11 press any character for slave to start \n\r"); *data_send = pc.getc(); printf("1 in main\n\r"); k = write_to_master(data_send,1); printf("4 done transfer with return %d\n\r",k); } } char* read_from_master(){ while(slave_status) slave_status=slave.read(data_rec,1); return(data_rec); //read_loop = true; //slave.stop(); } int write_to_master(char* send, int length){ slave_status=1; while(slave_status){ printf("2 wait for status\n\r"); //if(slave.receive()==1) { slave_status=slave.write(send,length); } } printf("3 wrote %c to master\n\r",*data_send); //slave.stop(); return(1); }