albatross
/
ControlMain2017
2017年度の製作を開始します
Fork of Control_Main_Full_20160608 by
Diff: main.cpp
- Branch:
- test
- Revision:
- 9:c32999b4d2f9
- Parent:
- 8:dbc8c87dac78
- Child:
- 10:b7159feb11fd
diff -r dbc8c87dac78 -r c32999b4d2f9 main.cpp --- a/main.cpp Sat Nov 26 01:17:08 2016 +0000 +++ b/main.cpp Sat Jan 21 11:46:19 2017 +0000 @@ -1,19 +1,32 @@ //中央can program #include "mbed.h" -#include "BufferedSoftSerial.h" +//#include "BufferedSoftSerial.h" #define WAIT_LOOP_TIME 0.1 -#define YOKUTAN_DATAS_NUM 4 +#define YOKUTAN_DATAS_NUM 7 #define IMPUT_DATAS_NUM 2 #define SEND_DATAS_CAN_ID 100 #define SEND_DATAS_TIME 0.5 #define THRESHOLD_OH_VALUE 0.14 #define CALC_CADENCE_TIME 0.05 +//-----------------------------------(resetInterrupt def) +extern "C" void mbed_reset(); +InterruptIn resetPin(p26); +Timer resetTimeCount; +void resetInterrupt(){ + while(resetPin){ + resetTimeCount.start(); + if(resetTimeCount.read()>3) mbed_reset(); + } + resetTimeCount.reset(); +} +//------------------------------------------------------- + CAN can_R(p30,p29); CAN can_L(p9,p10); -//Serial toKeikiSerial(p13,p14); -BufferedSoftSerial toKeikiSerial(p17,p18); +Serial toKeikiSerial(p13,p14); +//BufferedSoftSerial toKeikiSerial(p17,p18); Serial pc(USBTX,USBRX); DigitalIn eruron_R(p22); DigitalIn eruron_L(p20); @@ -21,7 +34,7 @@ DigitalIn drug_L(p19); DigitalOut myled1(LED1); DigitalOut myled2(LED2); -Ticker sendDatasTicker; +//Ticker sendDatasTicker; Ticker cadenceTicker; Timer cadenceTimer; AnalogIn p(p15); @@ -111,9 +124,13 @@ } void init(){ +//--------------------------------------(resetInterrupt init) + resetPin.rise(resetInterrupt); + resetPin.mode(PullDown); +//----------------------------------------------------------- cadenceTimer.start(); cadenceTicker.attach(calcCadence, CALC_CADENCE_TIME); - sendDatasTicker.attach(SendDatas,SEND_DATAS_TIME); +// sendDatasTicker.attach(SendDatas,SEND_DATAS_TIME); for(int i = 0; i < IMPUT_DATAS_NUM; i++){ inputDatas_R[i] = 0; inputDatas_L[i] = 0; @@ -142,6 +159,7 @@ InputControlValues(); wait_us(10); receiveDatas(); + SendDatas(); //toString_R(); // toString_L(); wait(WAIT_LOOP_TIME);