Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed AQM1602 HMC6352 PID
active.cpp
00001 #include "mbed.h" 00002 #include "extern.h" 00003 00004 void ActiveLoop(void){ 00005 uint8_t i; 00006 void (*DutyFunction[DUTY_NUM])(void) = { 00007 Active2Command 00008 }; 00009 void (*StrategyFunction[STRATEGY_NUM])(void) = { 00010 modeAttack2, 00011 //modeAttack3, 00012 //modeAttack4, 00013 modeAttack1, 00014 modeAttack2, 00015 modeAttack3, 00016 modeAttack4, 00017 modeAttack5, 00018 00019 modeDebug0, 00020 modeDebug1, 00021 modeDebug2, 00022 modeDebug3, 00023 modeDebug4, 00024 modeDebug5, 00025 }; 00026 for(i=0; i<DUTY_NUM; i++){ 00027 Duty[i].attach(DutyFunction[i], dutycycle[i]); 00028 } 00029 data.stopflag=0; 00030 //スタート直前の処理 00031 SetUp2(); 00032 while(1){ 00033 //pc.printf("data.stopflag=%d\r\n", data.stopflag); 00034 if(data.stopflag==1){ 00035 //システム上の停止処理 00036 button.detach(); 00037 last_statesum = statesum = 0; 00038 state[0] = state[1] = state[2] = state[3] = 0; 00039 00040 for(i=0; i<DUTY_NUM; i++){ 00041 Duty[DUTY_SW].detach(); 00042 } 00043 data.stopflag=0; 00044 //その他停止処理 00045 StopProcess(); 00046 break; 00047 } 00048 StrategyFunction[data.strategy](); 00049 } 00050 return; 00051 } 00052 //for transition 00053 void ResetState(void){ 00054 last_statesum = statesum = 0; 00055 state[0] = state[1] = state[2] = state[3] = 0; 00056 } 00057 void Active2Command(void){ 00058 uint8_t i; 00059 for(i=0; i<4; i++){ 00060 if(CountSw(i)==1) state[i]=1; 00061 } 00062 last_statesum = statesum; 00063 statesum = state[0]+state[1]+state[2]+state[3]; 00064 if((statesum>=1)&&(!(statesum==last_statesum))){ 00065 button.attach(&ResetState, 2.0); 00066 } 00067 if((statesum>=2)&&(1)){ 00068 data.stopflag=1; 00069 } 00070 }
Generated on Tue Jul 12 2022 23:12:38 by
1.7.2