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.
Dependencies: FreescaleIAP SimpleDMA eeprom mbed-rtos mbed
Fork of CDMS_QM_03MAR2017_Flash_with_obsrs by
Diff: i2c.h
- Revision:
- 52:0bd68655c651
- Child:
- 55:39e59903bc3a
- Child:
- 69:20f09a0c3fd2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/i2c.h Thu Jan 14 06:16:42 2016 +0000
@@ -0,0 +1,61 @@
+#define tm_len 134
+#define tc_len 135
+#define tc_test_len 135
+
+DigitalOut irpt_2_slv(PIN67); //I2C interrupt to CDMS
+I2C master(PIN32,PIN31);
+DigitalOut led1(PIN46);
+DigitalOut led2(PIN95);
+const int addr = 0x20; //slave address
+char telecommand[tc_len];
+char telemetry[tm_len];
+Timer test;
+Timer t_read;
+bool write_ack = true;
+bool read_ack = true;
+
+int count = 0;
+
+void FCTN_I2C_WRITE(char *data)
+{
+ irpt_2_slv = 1;
+ //t.start();
+ write_ack = master.write(addr|0x00,data,tc_len);
+ //t.stop();
+ //if(write_ack == 0)
+ //pc.printf("\n\r data not sent \n");
+
+if (write_ack == 1)
+ {
+ led2 = 1;
+ printf("\n\r data not sent \n");
+ led2 = 0;
+ }
+ irpt_2_slv = 0;
+ //pc.printf("\n\r %d \n",t.read_us());
+ //t.reset();
+}
+
+
+void FCTN_I2C_READ(char *data)
+{
+ irpt_2_slv = 1;
+ t_read.start();
+ read_ack = master.read(addr|1,data,tm_len);
+ t_read.stop();
+
+ //if(read_ack == 0)
+ // printf("\n\rData received from BAE %s \n",data);
+ if (read_ack == 1)
+ {
+ led2 = 1;
+ printf("\n \r data not received \n");
+ led2 = 0;
+ }
+//if(read_ack == 1)
+//pc.printf("\n \r data not received \n");
+
+ irpt_2_slv = 0;
+ //printf("\n\r %d \n",t.read_us());
+ //t.reset();
+}
\ No newline at end of file
