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 master_working_obama by
Revision 1:e5c939440756, committed 2014-12-13
- Comitter:
- sakthipriya
- Date:
- Sat Dec 13 12:04:13 2014 +0000
- Parent:
- 0:58b0c597a58c
- Child:
- 2:e80af3c366aa
- Commit message:
- master working 2
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Dec 13 11:24:36 2014 +0000
+++ b/main.cpp Sat Dec 13 12:04:13 2014 +0000
@@ -85,7 +85,7 @@
i2c_data_r->data = data_receive;
i2c_data_r->length = 1;
i2c_data_receive.put(i2c_data_r);
- printf("\n Data received from CDMS is %c\n\r",data_receive);
+ printf("\n Data received from slave is %c\n\r",data_receive);
i2c_data_receive.free(i2c_data_r);
}
}
@@ -97,30 +97,28 @@
}
-
-
-
-int main()
-{
- ptr_t_i2c = new Thread(T_I2C_MASTER_FSLAVE);
-
- data_ready.rise(&FUNC_INT);
- printf("\nstarted master\n");
- bool write2slave;
- char *writedata = new char;
-
+char *writedata = new char;
+void FUNC_MASTER_WRITE()
+{
+ bool write2slave=true;
- bool master_status_write = true;
- while(1)
- { write2slave=true;
interrupt = 0;
-
- *writedata = pc.getc();
-
+
+ char 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);
+ bool master_status_write = true;
interrupt = 1;
+ osEvent evt = i2c_data_send.get();
+ if (evt.status == osEventMail)
+ {
+ i2c_data *i2c_data_s = (i2c_data*)evt.value.p;
+ *writedata = i2c_data_s -> data;
master.frequency(100000); //set clock frequency
while(write2slave)
- {
+ {
printf("master clk freq setup and addressing slave\n\r");
master.start(); //initiating the data transfer
master_status_write = (bool) master.write(addr|0x00,writedata,1);
@@ -129,7 +127,19 @@
printf("master has written %c to slave\n\r",*writedata);
write2slave=false;
}
+ }
}
-
+}
+
+
+
+int main()
+{
+ ptr_t_i2c = new Thread(T_I2C_MASTER_FSLAVE);
+ data_ready.rise(&FUNC_INT);
+ printf("\nstarted master\n");
+ while(1)
+ {
+ FUNC_MASTER_WRITE();
}
}
\ No newline at end of file
