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

Dependencies:   IRM2121_2 Ping mbed HMC6352 Watchdog

Fork of CatPot_SensorRight by CatPot 2015-2016

Revision:
16:83721dac1049
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/usart.cpp	Wed Mar 11 01:03:39 2015 +0000
@@ -0,0 +1,64 @@
+#include "mbed.h"
+
+#define KEYCODE 0xAA
+#define TX_CHECKCODE (tx_data[1]^tx_data[2]^tx_data[3]^tx_data[4]^tx_data[5]^tx_data[6]^tx_data[7]^tx_data[8]^tx_data[9])
+#define RX_CHECKCODE (rx_data[1]^rx_data[2]^rx_data[3]^rx_data[4]^rx_data[5]^rx_data[6]^rx_data[7]^rx_data[8]^rx_data[9])
+#define DATA_NUM 11
+#define CHECK (DATA_NUM - 1)
+
+
+extern Serial Mbed;
+extern Serial pc;
+extern uint8_t PingData[4];
+extern uint8_t IrData[3];
+extern uint8_t CompassData[2];
+/*
+void micon_rx(){
+    
+    static uint8_t rx;
+    static uint8_t rx_data[DATA_NUM];
+    
+    rx_data[rx] = sensor.getc();
+    
+    if(rx_data[0] == KEYCODE){
+        rx++;
+    }
+    
+    if(rx >= DATA_NUM){
+        if(rx_data[CHECK] == RX_CHECKCODE){
+             pc.printf("%d %d %d %d %d\n", rx_data[1], rx_data[2], rx_data[3], rx_data[4], rx_data[5]);
+        }  
+     rx = 0;   
+    }
+
+}
+*/
+void micon_tx(){
+    
+    static uint8_t tx;
+    static uint8_t tx_data[DATA_NUM];
+    
+    if(tx >= DATA_NUM){
+        
+        tx_data[0] = KEYCODE;
+        tx_data[1] = IrData[0];
+        tx_data[2] = IrData[1];
+        tx_data[3] = IrData[2];
+        tx_data[4] = PingData[0];
+        tx_data[5] = PingData[1];
+        tx_data[6] = PingData[2];
+        tx_data[7] = PingData[3];
+        tx_data[8] = CompassData[0];
+        tx_data[9] = CompassData[1];
+        tx_data[10] = TX_CHECKCODE;
+        
+        tx = 0;
+        
+    //pc.printf("%d %d %d %d\n",PingData[0],PingData[1],PingData[2],PingData[3]);
+    }
+    
+    
+    Mbed.putc(tx_data[tx]);
+    tx++;
+    //wait(0.1);
+}
\ No newline at end of file