右側のほうのセンサLPC1114FN28 fumiya版

Dependencies:   IRM2121_2 Ping mbed HMC6352 Watchdog

Fork of CatPot_SensorRight by CatPot 2015-2016

Revision:
12:4bf564955c53
Parent:
11:735a59ebc63f
Child:
13:c73f90a890b6
--- a/main.cpp	Thu Mar 05 08:26:28 2015 +0000
+++ b/main.cpp	Thu Mar 05 10:01:37 2015 +0000
@@ -7,30 +7,24 @@
  
 #include "mbed.h"
  
- 
-#define SYSAHBCLKDIV_Val      0x00000001        // Reset: 0x001
-#define CLOCK_SETUP           1                  // デフォルト=1
-#define SYSPLLCTRL_Val        0x00000023        // デフォルト=23 Reset: 0x000
-#define SYSPLLCLKSEL_Val      0x00000001        // デフォルト=0  Reset: 0x000
-#define MAINCLKSEL_Val        0x00000003        // デフォルト=3  Reset: 0x000
- 
 #include "IRM2121.h"
 #include "Ping.h"
-#include "WatchDogTimer.h"
+#include "MultiSerial.h"
  
 #define PING_COUNT 5 //5回に1回にPing処理
 #define IR_LEVEL 400 //irのしきい値
-#define I2C_ADDRESS 0xAA//
- 
+#define ADDRESS 0xAA//
+#define DATA_NUM 8
  
  
-IRM2121 Ir[6] = {dp17,dp18,dp24,dp25,dp26,dp28};
+IRM2121 Ir[6] = {p25, p26, p27, p28, p29, p30};
  
-Ping Ping1(dp2,dp1);
-Ping Ping2(dp6,dp4);
+Ping Ping1(p21, p22);
+Ping Ping2(p23, p24);
 DigitalOut Led(LED1);
  
-I2CSlave Mbed(dp5,dp27);//sda,scl
+//I2CSlave Mbed(dp5,dp27);//sda,scl
+MultiSerial Mbed(p13, p14);
 Serial pc(USBTX,USBRX);
  
 /*irm2121平均化*/
@@ -105,9 +99,9 @@
     
     /*begin SetUp*/
     //default Mbed.frequency();
-    Mbed.address(I2C_ADDRESS);
-    Watchdog g;
-    g.kick(1.0f);//1秒でWDT発生
+    //Mbed.address(I2C_ADDRESS);
+    //Watchdog g;
+    //g.kick(1.0f);//1秒でWDT発生
     /*end   Setup*/
     
     
@@ -120,18 +114,23 @@
     unsigned int IrBase[6] = {0};
     
     /*State(operate_value etc...)*/
-    int I2CState;
+    //int I2CState;
     
     /* I2Cdata*/
-    char SendData[9]={0};
-    char AddressData[1] = {0};
- 
+    //char SendData[9]={0};
+    //char AddressData[1] = {0};
+    
+    /*Serial*/
+    uint8_t tx_data[DATA_NUM]={0};
+    
+    Mbed.write_data(tx_data, ADDRESS);
+    Mbed.start_write();
  
     while(1) {
         Led = 1;//周回の初め    
  
         //通信していないとき
-        if(!AddressData[0])
+        if(1/*!AddressData[0]*/)
         {
             PingCk ++;
             
@@ -179,7 +178,14 @@
             
         
         }
-        I2CState = Mbed.receive();
+        
+        tx_data[0] = PingData[0];
+        tx_data[1] = PingData[1];
+        tx_data[2] = IrData[0];
+        tx_data[3] = IrData[1];
+        tx_data[4] = IrData[2];
+        
+        /*I2CState = Mbed.receive();
         
         switch(I2CState){    
             case I2CSlave::ReadAddressed:
@@ -221,13 +227,14 @@
                  break;
         
         }
+        */
         Led = 0;
         /*
         pc.printf("%d \t %d \t %d ",IrBase[0],IrBase[1],IrBase[2]);
         
         pc.printf("\t %d \t %d \t %d \n",IrBase[3],IrBase[4],IrBase[5]);
         */
-  
+        
         //wait(0.1);
     }
 }
\ No newline at end of file