LPC824専用プログラム

Dependencies:   Ping SDFileSystem mbed-src

Revision:
6:79dc74e4926a
Parent:
5:afba6bf6c408
Child:
7:9b1ac6fbf32c
--- a/format.cpp	Tue Jan 12 14:15:17 2016 +0000
+++ b/format.cpp	Tue Jan 12 14:59:09 2016 +0000
@@ -137,6 +137,56 @@
 #endif /*COLOR_SENSOR*/
 
 #ifdef IR_SENSOR
+void Ir_System2(void){
+    
+    static uint8_t const START_BIT      = 0x04;
+    static uint8_t const MODE_SINGLE    = 0x02;    // Single-ended mode
+    //static uint8_t const MODE_DIFF      = 0x00;    // Differential mode
+    
+    int i;//ic
+    int j;//ch
+    uint8_t ch_num[3]={8, 8, 4};
+    int command_high;
+    int command_low;
+    int high_byte;
+    int low_byte;
+    
+    uint16_t ir_data[3][8]={0};
+    //clock_t stime,etime;
+    
+    supply = 1;
+    ir.frequency(1000000);
+    
+    for(i=0; i<IC_NUM; i++) cs[i]=1;
+    while(1) {
+        //stime = clock();
+        for(i=0; i<IC_NUM; i++){//IC
+            for(j=0; j<ch_num[i]; j++){//Ch
+                command_high = START_BIT | MODE_SINGLE | ((j & 0x04) >> 2);
+                command_low = (j & 0x03) << 6;
+                
+                cs[i] = 0;
+                
+                ir.write(command_high);
+                high_byte = ir.write(command_low) & 0x0F;
+                low_byte = ir.write(0);
+                
+                cs[i] = 1;
+                wait_us(1);
+                
+                ir_data[i][j] = (high_byte << 8) | low_byte;
+            }
+        }
+        //etime = clock();
+        //pc.printf("%.4f\n", (float)(etime-stime)/CLOCKS_PER_SEC);
+        pc.printf("%Value is ");
+        pc.printf("%d\t", ir_data[1][2]);
+        pc.printf("%d\t", ir_data[1][4]);
+        pc.printf("%d\t", ir_data[0][0]);
+        pc.printf("%d\t", ir_data[0][4]);
+        pc.printf("\r\n");
+    }
+}
 void Ir_System(void){
     
     static uint8_t const START_BIT      = 0x04;
@@ -154,7 +204,7 @@
     
     uint16_t ir_data[IC_NUM][CH_NUM];
     
-    supply = 0;
+    supply = 1;
     ir.frequency(1000000);
     
     for(ic=0; ic<IC_NUM; ic++) cs[ic]=1;
@@ -176,9 +226,7 @@
 
             }
         }
-        //for(i=0; i<8; i++){
-            pc.printf("%d\t%d\t%d\t%d\t\r\n", ir_data[1][0], ir_data[1][1], ir_data[1][2], ir_data[1][3]);
-        //}
+        pc.printf("%d\t%d\t%d\t%d\t\r\n", ir_data[1][0], ir_data[1][1], ir_data[1][2], ir_data[1][3]);
         /*while(1){
             val = nucleo.receive();
             if(val){