ジャパンオープン用のメインプログラム

Dependencies:   mbed AQM1602 HMC6352 PID

Revision:
0:ea35c18c85fc
Child:
1:3e013ae7900d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main_processing/strategy_parts/input.cpp	Sat Feb 27 09:14:37 2016 +0000
@@ -0,0 +1,92 @@
+#include "mbed.h"
+#include "extern.h"
+
+//line
+void ReadLine(void){
+    static uint8_t line_buf[3]={0,0,0};
+    wait_us(100);
+    if(Line[0].read()==1) line_buf[0] = 100;
+    if(line_buf[0]==0)  line_set.lnFlag[0]=0;
+    else                line_set.lnFlag[0]=1;
+    if(line_buf[0]>0) line_buf[0]--;
+    
+    if(Line[1].read()==1) line_buf[1] = 100;
+    if(line_buf[1]==0)  line_set.lnFlag[1]=0;
+    else                line_set.lnFlag[1]=1;
+    if(line_buf[1]>0) line_buf[1]--;
+    
+    if(Line[2].read()==1) line_buf[2] = 100;
+    if(line_buf[2]==0)  line_set.lnFlag[2]=0;
+    else                line_set.lnFlag[2]=1;
+    if(line_buf[2]>0) line_buf[2]--;
+}
+//ball
+uint8_t ReadBall(void){//1or0
+    data_set.ball = !BallChecker;
+    return (data_set.ball>0); 
+}
+void ReadGyro(void){
+    //Data can be got by interrupt.
+}
+void ReadCmps(void){
+    cmps_set.cmps = hmc.sample()/10.0;
+}
+void ReadPing(void){
+    uint16_t spi_data;
+    //Ultra Sonic Wave
+    spi_ss[1]=0;
+    wait_us(200);
+    
+    spi_data = spi.write(0xABCD);
+    
+    wait_us(200);
+    spi_ss[1]=1;
+    
+    data_set.ping[0] = (spi_data&0x00FF)>>0;
+    data_set.ping[1] = (spi_data&0xFF00)>>8;
+}
+void ReadPing_2(void){
+    uint16_t spi_data;
+    //Ultra Sonic Wave
+    spi_ss[0]=0;
+    wait_us(200);
+    
+    spi_data = spi.write(0xABCD);
+    
+    wait_us(200);
+    spi_ss[0]=1;
+    
+    data_set.ping[2] = (spi_data&0x00FF)>>0;
+    data_set.ping[3] = (spi_data&0xFF00)>>8;
+}
+void ValidIr(void){
+    if(sys.IrFlag==0){
+        sys.IrFlag=1;
+    }
+}
+void ReadIr(void){
+    uint16_t spi_data;
+    
+    //Ir
+    spi_ss[3]=0;
+    wait_us(200);
+    
+    spi_data = spi.write(0xABCD);
+    
+    wait_us(200);
+    spi_ss[3]=1;
+    //key/notice/long/short
+    data_set.irKey = (spi_data&0xF000)>>12;
+    data_set.irNotice = (spi_data&0x0F00)>>8;
+    data_set.irSpot[IR_LONG] = (spi_data&0x00F0)>>4;
+    data_set.irSpot[IR_SHORT] = (spi_data&0x000F)>>0;
+    
+    if(data_set.irKey!=0x2) data_set.irNotice=IR_NONE;
+    if(data_set.irNotice == IR_NONE) data_set.irPosition=11;
+    if(data_set.irNotice == IR_FAR) data_set.irPosition=data_set.irSpot[IR_LONG]-1;
+    if(data_set.irNotice == IR_CLOSE) data_set.irPosition=data_set.irSpot[IR_SHORT]+7;
+    if(data_set.irNotice == IR_CLOSER) data_set.irPosition=data_set.irSpot[IR_SHORT]+7;
+}
+void ReadInfo(void){
+    
+}
\ No newline at end of file