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 freeslave_write2master_working by
Diff: main.cpp
- Revision:
- 6:b024f6ea3b24
- Parent:
- 5:ce0bb4174ca4
--- a/main.cpp Wed Dec 10 16:38:29 2014 +0000
+++ b/main.cpp Thu Dec 11 11:02:43 2014 +0000
@@ -7,7 +7,8 @@
Serial pc (USBTX,USBRX);
InterruptIn interrupt(D9);
DigitalOut data_ready(D10);
-int i2c_status=0; //read/write mode for i2c 0 : write2slave, 1 : write2master
+int i2c_status=0;
+ //read/write mode for i2c 0 : write2slave, 1 : write2master
typedef struct
{
@@ -49,7 +50,7 @@
}
//slave.stop();
}
- printf("2 done");
+ printf("\n 2 done\n\r");
}
@@ -60,10 +61,13 @@
while(1)
{
Thread::signal_wait(0x1);
+
+ printf("\n interrupt detected \n\r");
if(i2c_status == 0)
{
FUNC_I2C_WRITE2CDMS(&data_receive);
+ printf("\n entered i2c =0\n\r");
//printf("\n Data received from CDMS is %c\n",data_receive);
i2c_data * i2c_data_r = i2c_data_receive.alloc();
i2c_data_r->data = data_receive;
@@ -79,7 +83,7 @@
//printf("\nData read from CDMS is %c\n",i2c_data_r->data);
data_send = i2c_data_s -> data;
FUNC_I2C_WRITE2CDMS(&data_send);
- printf("\nData sent to CDMS is %c\n",data_send);
+ printf("\nData sent to CDMS is %c\n\r",data_send);
i2c_data_send.free(i2c_data_s);
i2c_status = 0;
//delete i2c_data_r;
@@ -100,7 +104,7 @@
void main()
{
- printf("\nStarted slave... waiting for master\n");
+ printf("\nStarted slave... waiting for master\n\r");
ptr_t_i2c = new Thread(T_I2C_BAE);
char data='a';
interrupt.rise(&FUNC_INT);
@@ -123,14 +127,15 @@
//delete i2c_data_r;
}*/
//put in comments for receiving data
+
data_ready=0;
data = pc.getc();
i2c_data * i2c_data_s = i2c_data_send.alloc();
i2c_data_s->data = data;
i2c_data_s->length = 1;
i2c_data_send.put(i2c_data_s);
+ i2c_status=1;
data_ready=1;
- i2c_status=1;
}
}
\ No newline at end of file
