rrr

Dependencies:   mbed

Revision:
0:0b1cea62a239
diff -r 000000000000 -r 0b1cea62a239 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jun 25 05:37:31 2018 +0000
@@ -0,0 +1,54 @@
+#include "mbed.h"
+I2C i2c(D14, D15); 
+Serial pic(D8, D2);
+DigitalOut PWL1(D9);
+DigitalOut PWL2(D7);
+DigitalOut PWL3(D6);
+int ADRR = 0x0a;
+int data,rcv_data;
+/*
+void i2c_send()     //MDへのデータ送信
+{
+    i2c.start();
+    i2c.write(ADRR);
+    i2c.write(data);
+    i2c.stop();
+}
+*/
+void judge()
+{
+    if(rcv_data == 0x01){
+        PWL2 = 1;
+        PWL3 = 0;
+        data = 0x01;
+        //i2c_send();
+    }else if(rcv_data == 0x02){
+        PWL2 = 0;
+        PWL3 = 1;
+        data = 0x60;
+        //i2c_send();
+    }else{
+        PWL2 = 0;
+        PWL3 = 0;
+        data = 0xff;
+    }
+}
+int main()
+{
+    PWL1 = 1;
+    i2c.frequency(400000);
+    //NVIC_SetPriority(USART2_IRQn,2);
+    NVIC_SetPriority(I2C1_EV_IRQn,1);
+    wait(5);
+    
+    while(1){
+        rcv_data = pic.getc();
+        judge();
+        
+        i2c.start();
+        i2c.write(0x0a);
+        i2c.write(data);
+        i2c.stop();
+        
+    }
+}
\ No newline at end of file