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.
userTask.cpp@46:5074781a28dd, 2019-02-19 (annotated)
- Committer:
- MasashiNomura
- Date:
- Tue Feb 19 11:52:49 2019 +0000
- Revision:
- 46:5074781a28dd
- Parent:
- 41:45c982b1c5b6
- Child:
- 47:d3fa874f336e
2019/02/19 change Engine Throttle UP/DOWN Btn Quantity and modify comment
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| MasashiNomura | 46:5074781a28dd | 1 | ///////////////////////////////////// |
| MasashiNomura | 46:5074781a28dd | 2 | /// RTOS関連------------------ |
| takeru0x1103 | 1:15ab74f0d0f1 | 3 | #include "FreeRTOS.h" |
| takeru0x1103 | 1:15ab74f0d0f1 | 4 | #include "task.h" |
| MasashiNomura | 46:5074781a28dd | 5 | /// ------------------RTOS関連 |
| MasashiNomura | 46:5074781a28dd | 6 | ///////////////////////////////////// |
| takeru0x1103 | 21:78302ecdb661 | 7 | |
| takeru0x1103 | 17:f9610f3cfa1b | 8 | #include "globalFlags.h" |
| takeru0x1103 | 17:f9610f3cfa1b | 9 | #include "HbManager.h" |
| takeru0x1103 | 18:5aa48aec9cae | 10 | #include "hbCommand.h" |
| takeru0x1103 | 18:5aa48aec9cae | 11 | #include "uart.h" |
| MasashiNomura | 24:c5945aaae777 | 12 | #include "fpga.h" |
| takeru0x1103 | 1:15ab74f0d0f1 | 13 | |
| takeru0x1103 | 18:5aa48aec9cae | 14 | //タスクハンドル(停止とか再開に必要) |
| takeru0x1103 | 18:5aa48aec9cae | 15 | static xTaskHandle tskHandle[3]={NULL,}; |
| takeru0x1103 | 1:15ab74f0d0f1 | 16 | |
| takeru0x1103 | 21:78302ecdb661 | 17 | //------------------ |
| takeru0x1103 | 18:5aa48aec9cae | 18 | //タスク停止 |
| takeru0x1103 | 18:5aa48aec9cae | 19 | //------------------ |
| takeru0x1103 | 18:5aa48aec9cae | 20 | static void taskStop(int iId){ |
| takeru0x1103 | 18:5aa48aec9cae | 21 | sp.printf("Task[%d] Stop\r\n" , iId); |
| takeru0x1103 | 18:5aa48aec9cae | 22 | vTaskSuspend(tskHandle[iId]);//タスクを止める |
| takeru0x1103 | 18:5aa48aec9cae | 23 | } |
| takeru0x1103 | 18:5aa48aec9cae | 24 | |
| takeru0x1103 | 21:78302ecdb661 | 25 | //------------------ |
| takeru0x1103 | 18:5aa48aec9cae | 26 | //タスク再開 |
| takeru0x1103 | 18:5aa48aec9cae | 27 | //------------------ |
| takeru0x1103 | 18:5aa48aec9cae | 28 | static void taskStart(int iId){ |
| takeru0x1103 | 18:5aa48aec9cae | 29 | sp.printf("Task[%d] Start!!\r\n" , iId); |
| takeru0x1103 | 18:5aa48aec9cae | 30 | vTaskResume(tskHandle[iId]);//タスク再開 |
| takeru0x1103 | 18:5aa48aec9cae | 31 | } |
| takeru0x1103 | 18:5aa48aec9cae | 32 | |
| takeru0x1103 | 18:5aa48aec9cae | 33 | //======================================================== |
| takeru0x1103 | 21:78302ecdb661 | 34 | //コマンド解析タスク |
| takeru0x1103 | 21:78302ecdb661 | 35 | //======================================================== |
| takeru0x1103 | 21:78302ecdb661 | 36 | void taskCmdParser(void *pvParameters){ |
| takeru0x1103 | 21:78302ecdb661 | 37 | // int8_t *pcTaskName = (int8_t *) pvParameters;; |
| takeru0x1103 | 21:78302ecdb661 | 38 | portTickType xLastWakeTime = xTaskGetTickCount(); |
| takeru0x1103 | 21:78302ecdb661 | 39 | |
| takeru0x1103 | 21:78302ecdb661 | 40 | // vTaskDelay(300);//制御タスクを先に走らせたいので待たす |
| takeru0x1103 | 21:78302ecdb661 | 41 | |
| takeru0x1103 | 21:78302ecdb661 | 42 | while(1){ |
| takeru0x1103 | 21:78302ecdb661 | 43 | led2=!led2; |
| takeru0x1103 | 21:78302ecdb661 | 44 | //コマンド解釈 |
| takeru0x1103 | 21:78302ecdb661 | 45 | commandParse(); |
| takeru0x1103 | 21:78302ecdb661 | 46 | |
| takeru0x1103 | 21:78302ecdb661 | 47 | // |
| MasashiNomura | 24:c5945aaae777 | 48 | // if(gf_Armed){ |
| MasashiNomura | 24:c5945aaae777 | 49 | // setState(WAKEUP); |
| MasashiNomura | 24:c5945aaae777 | 50 | // gf_Armed = false; |
| MasashiNomura | 24:c5945aaae777 | 51 | // // taskStop(0);//制御タスクを止める |
| MasashiNomura | 24:c5945aaae777 | 52 | // // taskStart(2);//デバッグタスク再開 |
| MasashiNomura | 24:c5945aaae777 | 53 | // } |
| MasashiNomura | 22:24c9c2dedca9 | 54 | // else{ |
| MasashiNomura | 22:24c9c2dedca9 | 55 | // taskStop(2);//デバッグタスクを止める |
| MasashiNomura | 22:24c9c2dedca9 | 56 | // taskStart(0);//制御タスク再開 |
| MasashiNomura | 22:24c9c2dedca9 | 57 | // }//switch |
| takeru0x1103 | 21:78302ecdb661 | 58 | |
| takeru0x1103 | 21:78302ecdb661 | 59 | //次の周期まで待つ |
| takeru0x1103 | 21:78302ecdb661 | 60 | vTaskDelayUntil(&xLastWakeTime, 50 / portTICK_RATE_MS ); |
| takeru0x1103 | 21:78302ecdb661 | 61 | } |
| takeru0x1103 | 21:78302ecdb661 | 62 | } |
| takeru0x1103 | 21:78302ecdb661 | 63 | //======================================================== |
| takeru0x1103 | 17:f9610f3cfa1b | 64 | //ホバーバイク制御タスク |
| takeru0x1103 | 18:5aa48aec9cae | 65 | //======================================================== |
| takeru0x1103 | 17:f9610f3cfa1b | 66 | void taskHbControl(void *pvParameters){ |
| takeru0x1103 | 21:78302ecdb661 | 67 | // int8_t *pcTaskName = (int8_t *) pvParameters;; |
| takeru0x1103 | 21:78302ecdb661 | 68 | portTickType xLastWakeTime = xTaskGetTickCount(); |
| takeru0x1103 | 21:78302ecdb661 | 69 | |
| takeru0x1103 | 17:f9610f3cfa1b | 70 | HbManager hb; |
| takeru0x1103 | 8:1ca49cb18290 | 71 | |
| MasashiNomura | 23:79e20be4bc5b | 72 | bool bDoCtrlAtt; |
| MasashiNomura | 23:79e20be4bc5b | 73 | bool bDoCtrlMot; |
| MasashiNomura | 31:56c554c560c1 | 74 | bool bDoCtrlEng; |
| MasashiNomura | 37:d51dacb4c30f | 75 | bool bTmp; |
| MasashiNomura | 31:56c554c560c1 | 76 | //INT16 tmpRpm, difRpm; |
| MasashiNomura | 36:2cc739c7e4cb | 77 | INT16 cntSW1 = 0; |
| MasashiNomura | 36:2cc739c7e4cb | 78 | INT16 cntSW2 = 0; |
| MasashiNomura | 33:eb260dbfc22a | 79 | INT16 AxlRpm; |
| MasashiNomura | 36:2cc739c7e4cb | 80 | INT16 TrtlVal; |
| MasashiNomura | 38:24ee50452755 | 81 | float AxlRow; |
| MasashiNomura | 46:5074781a28dd | 82 | //float TrtlRow; |
| takeru0x1103 | 1:15ab74f0d0f1 | 83 | while(1){ |
| MasashiNomura | 41:45c982b1c5b6 | 84 | // DISPLAY LED |
| takeru0x1103 | 16:05b9e44889f1 | 85 | led1=!led1; |
| MasashiNomura | 41:45c982b1c5b6 | 86 | setDO4LED(gf_State); |
| MasashiNomura | 41:45c982b1c5b6 | 87 | |
| MasashiNomura | 39:1b76f7df8804 | 88 | hb.proofOfSurvival(); |
| MasashiNomura | 23:79e20be4bc5b | 89 | bDoCtrlAtt = false; |
| MasashiNomura | 23:79e20be4bc5b | 90 | bDoCtrlMot = false; |
| MasashiNomura | 31:56c554c560c1 | 91 | bDoCtrlEng = false; |
| MasashiNomura | 24:c5945aaae777 | 92 | // PID係数アップデートチェック |
| MasashiNomura | 24:c5945aaae777 | 93 | if(gf_PidParaUpdate){ |
| MasashiNomura | 24:c5945aaae777 | 94 | hb.setAttPara(g_PidPara); |
| MasashiNomura | 24:c5945aaae777 | 95 | sp.printf("Pp : [%f]\r\n",g_PidPara.PP); |
| MasashiNomura | 24:c5945aaae777 | 96 | sp.printf("P : [%f]\r\n",g_PidPara.P); |
| MasashiNomura | 24:c5945aaae777 | 97 | sp.printf("I : [%f]\r\n",g_PidPara.I); |
| MasashiNomura | 24:c5945aaae777 | 98 | sp.printf("D : [%f]\r\n",g_PidPara.D); |
| MasashiNomura | 24:c5945aaae777 | 99 | sp.printf("IMAX: [%f]\r\n",g_PidPara.IMax); |
| MasashiNomura | 24:c5945aaae777 | 100 | sp.printf("IMIN: [%f]\r\n",g_PidPara.IMin); |
| MasashiNomura | 31:56c554c560c1 | 101 | sp.printf("V : [%f]\r\n",g_PidPara.V); |
| MasashiNomura | 24:c5945aaae777 | 102 | gf_PidParaUpdate = false; |
| MasashiNomura | 24:c5945aaae777 | 103 | } |
| MasashiNomura | 37:d51dacb4c30f | 104 | // 確実にモーター等を止めるため |
| MasashiNomura | 25:f3a6e7eec9c3 | 105 | if(gf_StopMot){ |
| MasashiNomura | 29:eb3d72dd94aa | 106 | for(int i = 0; i < 4; ++i){ |
| MasashiNomura | 32:7f4145cc3551 | 107 | gf_MtReq[i].req = true; |
| MasashiNomura | 32:7f4145cc3551 | 108 | gf_MtReq[i].val = 0; |
| MasashiNomura | 32:7f4145cc3551 | 109 | gf_MtReqOfs[i].req = true; |
| MasashiNomura | 32:7f4145cc3551 | 110 | gf_MtReqOfs[i].val = 0; |
| MasashiNomura | 29:eb3d72dd94aa | 111 | } |
| MasashiNomura | 37:d51dacb4c30f | 112 | for(int i = 0; i < 2; ++i){ |
| MasashiNomura | 37:d51dacb4c30f | 113 | gf_AxReq[i].bf.req = true; |
| MasashiNomura | 37:d51dacb4c30f | 114 | gf_AxReq[i].bf.val = 0; |
| MasashiNomura | 37:d51dacb4c30f | 115 | } |
| MasashiNomura | 37:d51dacb4c30f | 116 | gf_FromActiveStat = isActiveState(); |
| MasashiNomura | 37:d51dacb4c30f | 117 | setStateF(MOT_STOP); |
| MasashiNomura | 25:f3a6e7eec9c3 | 118 | gf_StopMot = false; |
| MasashiNomura | 25:f3a6e7eec9c3 | 119 | } |
| MasashiNomura | 23:79e20be4bc5b | 120 | |
| MasashiNomura | 29:eb3d72dd94aa | 121 | |
| takeru0x1103 | 21:78302ecdb661 | 122 | //▼①状態読み出し系 |
| MasashiNomura | 22:24c9c2dedca9 | 123 | hb.getAttitude(); //現在角度読み出し |
| MasashiNomura | 39:1b76f7df8804 | 124 | hb.getEngine(); //エンジン回転数読み出し |
| MasashiNomura | 22:24c9c2dedca9 | 125 | hb.getUserCommand(); //操作ボタン状態読み出し |
| MasashiNomura | 29:eb3d72dd94aa | 126 | |
| takeru0x1103 | 21:78302ecdb661 | 127 | //▼②ステート遷移 |
| MasashiNomura | 22:24c9c2dedca9 | 128 | switch(gf_State){ |
| MasashiNomura | 22:24c9c2dedca9 | 129 | case SLEEP: |
| MasashiNomura | 36:2cc739c7e4cb | 130 | if(gf_StateEnt){ |
| MasashiNomura | 36:2cc739c7e4cb | 131 | sp.printf("SLEEP state\r\n"); |
| MasashiNomura | 36:2cc739c7e4cb | 132 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 133 | } |
| MasashiNomura | 36:2cc739c7e4cb | 134 | // DEBUGタスクスタートフラグの監視 |
| MasashiNomura | 22:24c9c2dedca9 | 135 | if(gf_Dbg){ |
| MasashiNomura | 24:c5945aaae777 | 136 | gf_Dbg = false; |
| MasashiNomura | 22:24c9c2dedca9 | 137 | taskStart(2); |
| MasashiNomura | 22:24c9c2dedca9 | 138 | } |
| MasashiNomura | 37:d51dacb4c30f | 139 | if(hb.chkSWUserOpeAny()){ |
| MasashiNomura | 37:d51dacb4c30f | 140 | typUserSw sw = hb.getUserSw(); |
| MasashiNomura | 41:45c982b1c5b6 | 141 | //sp.printf("%d%d%d%d%d%d%d%d%d%d\r\n",sw.bf.brk_l,sw.bf.flt_off,sw.bf.r_eng_down,sw.bf.r_eng_up,sw.bf.rsv_1 |
| MasashiNomura | 41:45c982b1c5b6 | 142 | // ,sw.bf.brk_r,sw.bf.flt_on,sw.bf.f_eng_down,sw.bf.f_eng_up, sw.bf.all_stop); |
| MasashiNomura | 38:24ee50452755 | 143 | } else { |
| MasashiNomura | 38:24ee50452755 | 144 | //TrtlRow = hb.getUserEngTrottleRaw(); |
| MasashiNomura | 41:45c982b1c5b6 | 145 | if(gf_Print.d2.bf.ain){ |
| MasashiNomura | 40:debe99e228d3 | 146 | AxlRow = hb.getUserMotAxlRaw(); |
| MasashiNomura | 41:45c982b1c5b6 | 147 | sp.printf("MotAxl:%f ",AxlRow); |
| MasashiNomura | 38:24ee50452755 | 148 | } |
| MasashiNomura | 37:d51dacb4c30f | 149 | } |
| MasashiNomura | 36:2cc739c7e4cb | 150 | // 浮上(離陸)ボタン、着陸ボタンの同時長押し監視 |
| MasashiNomura | 36:2cc739c7e4cb | 151 | if(hb.chkSWUserOpeBoth(HbUserOpe::FLT_ON,HbUserOpe::FLT_OFF)){ |
| MasashiNomura | 36:2cc739c7e4cb | 152 | ++cntSW1; |
| MasashiNomura | 36:2cc739c7e4cb | 153 | if(cntSW1 > 30){ |
| MasashiNomura | 36:2cc739c7e4cb | 154 | cntSW1 = 0; |
| MasashiNomura | 36:2cc739c7e4cb | 155 | setStateF(CHK_EG_ENT); |
| MasashiNomura | 36:2cc739c7e4cb | 156 | } |
| MasashiNomura | 36:2cc739c7e4cb | 157 | } |
| MasashiNomura | 36:2cc739c7e4cb | 158 | else { |
| MasashiNomura | 36:2cc739c7e4cb | 159 | cntSW1 = 0; |
| MasashiNomura | 36:2cc739c7e4cb | 160 | } |
| MasashiNomura | 36:2cc739c7e4cb | 161 | if(hb.chkSWUserOpeBoth(HbUserOpe::BRK_L, HbUserOpe::BRK_R)){ |
| MasashiNomura | 36:2cc739c7e4cb | 162 | ++cntSW2; |
| MasashiNomura | 36:2cc739c7e4cb | 163 | if(cntSW2 > 30){ |
| MasashiNomura | 36:2cc739c7e4cb | 164 | cntSW2 = 0; |
| MasashiNomura | 36:2cc739c7e4cb | 165 | setStateF(WAKEUP); |
| MasashiNomura | 36:2cc739c7e4cb | 166 | } |
| MasashiNomura | 36:2cc739c7e4cb | 167 | } |
| MasashiNomura | 36:2cc739c7e4cb | 168 | else { |
| MasashiNomura | 36:2cc739c7e4cb | 169 | cntSW2 = 0; |
| MasashiNomura | 36:2cc739c7e4cb | 170 | } |
| MasashiNomura | 40:debe99e228d3 | 171 | // Debug用 |
| MasashiNomura | 40:debe99e228d3 | 172 | bDoCtrlMot = true; |
| MasashiNomura | 22:24c9c2dedca9 | 173 | break; |
| MasashiNomura | 22:24c9c2dedca9 | 174 | case WAKEUP: |
| MasashiNomura | 36:2cc739c7e4cb | 175 | if(gf_StateEnt){ |
| MasashiNomura | 36:2cc739c7e4cb | 176 | //スイッチが何も押されていないことの確認 |
| MasashiNomura | 36:2cc739c7e4cb | 177 | if(!hb.chkSWUserOpeAny()){ |
| MasashiNomura | 36:2cc739c7e4cb | 178 | sp.printf("WAKEUP state\r\n"); |
| MasashiNomura | 36:2cc739c7e4cb | 179 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 180 | } |
| MasashiNomura | 36:2cc739c7e4cb | 181 | } |
| MasashiNomura | 36:2cc739c7e4cb | 182 | else |
| MasashiNomura | 36:2cc739c7e4cb | 183 | { |
| MasashiNomura | 36:2cc739c7e4cb | 184 | //各種モーター |
| MasashiNomura | 36:2cc739c7e4cb | 185 | //機材のチェック |
| MasashiNomura | 36:2cc739c7e4cb | 186 | hb.calAtt();//現在値でヨー角校正 |
| MasashiNomura | 36:2cc739c7e4cb | 187 | //モーター用のアナログ入力が下げられているかの確認 |
| MasashiNomura | 36:2cc739c7e4cb | 188 | AxlRpm = hb.getUserMotAxl(); |
| MasashiNomura | 36:2cc739c7e4cb | 189 | if(AxlRpm > 0){ |
| MasashiNomura | 36:2cc739c7e4cb | 190 | // 将来的に警告音等 |
| MasashiNomura | 38:24ee50452755 | 191 | sp.printf("Warning!! Motor Accel Opened!![%d]\r\n",AxlRpm); |
| MasashiNomura | 36:2cc739c7e4cb | 192 | setStateF(SLEEP); |
| MasashiNomura | 36:2cc739c7e4cb | 193 | } else { |
| MasashiNomura | 36:2cc739c7e4cb | 194 | setState(STANDBY); |
| MasashiNomura | 36:2cc739c7e4cb | 195 | } |
| MasashiNomura | 35:3779201b4c73 | 196 | } |
| MasashiNomura | 22:24c9c2dedca9 | 197 | break; |
| MasashiNomura | 22:24c9c2dedca9 | 198 | case STANDBY: |
| MasashiNomura | 36:2cc739c7e4cb | 199 | bDoCtrlMot = true; |
| MasashiNomura | 36:2cc739c7e4cb | 200 | if(gf_StateEnt){ |
| MasashiNomura | 36:2cc739c7e4cb | 201 | // モーター回転数のチェック→モーターの回転数をオフセット値まで上げる |
| MasashiNomura | 36:2cc739c7e4cb | 202 | // TODO |
| MasashiNomura | 36:2cc739c7e4cb | 203 | sp.printf("STANDBY state\r\n"); |
| MasashiNomura | 36:2cc739c7e4cb | 204 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 205 | } |
| MasashiNomura | 36:2cc739c7e4cb | 206 | else { |
| MasashiNomura | 40:debe99e228d3 | 207 | |
| MasashiNomura | 25:f3a6e7eec9c3 | 208 | if(hb.chkInRangeIDLE()){ |
| MasashiNomura | 36:2cc739c7e4cb | 209 | hb.calAtt();//現在値でヨー角校正 |
| MasashiNomura | 25:f3a6e7eec9c3 | 210 | setState(IDLE); |
| MasashiNomura | 25:f3a6e7eec9c3 | 211 | } |
| MasashiNomura | 25:f3a6e7eec9c3 | 212 | else{ |
| MasashiNomura | 25:f3a6e7eec9c3 | 213 | // デバッグのためここもスルー |
| MasashiNomura | 36:2cc739c7e4cb | 214 | hb.calAtt();//現在値でヨー角校正 |
| MasashiNomura | 25:f3a6e7eec9c3 | 215 | setState(IDLE); |
| MasashiNomura | 25:f3a6e7eec9c3 | 216 | } |
| MasashiNomura | 23:79e20be4bc5b | 217 | } |
| MasashiNomura | 22:24c9c2dedca9 | 218 | break; |
| MasashiNomura | 22:24c9c2dedca9 | 219 | case IDLE: |
| MasashiNomura | 36:2cc739c7e4cb | 220 | if(gf_StateEnt){ |
| MasashiNomura | 36:2cc739c7e4cb | 221 | sp.printf("IDLE state\r\n"); |
| MasashiNomura | 36:2cc739c7e4cb | 222 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 223 | } |
| MasashiNomura | 23:79e20be4bc5b | 224 | //SWのチェック |
| MasashiNomura | 31:56c554c560c1 | 225 | hb.chkSW(IDLE); |
| MasashiNomura | 33:eb260dbfc22a | 226 | AxlRpm = hb.getUserMotAxl(); |
| MasashiNomura | 33:eb260dbfc22a | 227 | hb.setMotVal(R_L,AxlRpm); |
| MasashiNomura | 33:eb260dbfc22a | 228 | hb.setMotVal(R_R,AxlRpm); |
| MasashiNomura | 46:5074781a28dd | 229 | // hb.setMotValOfs(R_L,AxlRpm); |
| MasashiNomura | 46:5074781a28dd | 230 | // hb.setMotValOfs(R_R,AxlRpm); |
| MasashiNomura | 31:56c554c560c1 | 231 | bDoCtrlEng = true; |
| MasashiNomura | 25:f3a6e7eec9c3 | 232 | bDoCtrlMot = true; |
| MasashiNomura | 40:debe99e228d3 | 233 | //bDoCtrlAtt = true; |
| MasashiNomura | 22:24c9c2dedca9 | 234 | break; |
| MasashiNomura | 22:24c9c2dedca9 | 235 | case TAKE_OFF: |
| MasashiNomura | 36:2cc739c7e4cb | 236 | if(gf_StateEnt){ |
| MasashiNomura | 36:2cc739c7e4cb | 237 | sp.printf("TAKE_OFF state\r\n"); |
| MasashiNomura | 36:2cc739c7e4cb | 238 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 239 | } |
| MasashiNomura | 23:79e20be4bc5b | 240 | // エンジン回転数のチェック |
| MasashiNomura | 23:79e20be4bc5b | 241 | // 着陸ボタンが優先度が高いので先に判定、たが、まだ作ってないのでコメントアウト |
| MasashiNomura | 40:debe99e228d3 | 242 | // if(hb.chkSWUserOpe(HbUserOpe::STOP)){ |
| MasashiNomura | 23:79e20be4bc5b | 243 | // setState(GROUND); |
| MasashiNomura | 23:79e20be4bc5b | 244 | // } |
| MasashiNomura | 23:79e20be4bc5b | 245 | //else |
| MasashiNomura | 34:234b87f3e6ce | 246 | hb.chkSW(TAKE_OFF); |
| MasashiNomura | 34:234b87f3e6ce | 247 | AxlRpm = hb.getUserMotAxl(); |
| MasashiNomura | 34:234b87f3e6ce | 248 | hb.setMotVal(R_L,AxlRpm); |
| MasashiNomura | 34:234b87f3e6ce | 249 | hb.setMotVal(R_R,AxlRpm); |
| MasashiNomura | 46:5074781a28dd | 250 | // hb.setMotValOfs(R_L,AxlRpm); |
| MasashiNomura | 46:5074781a28dd | 251 | // hb.setMotValOfs(R_R,AxlRpm); |
| MasashiNomura | 31:56c554c560c1 | 252 | bDoCtrlEng = true; |
| MasashiNomura | 23:79e20be4bc5b | 253 | bDoCtrlMot = true; |
| MasashiNomura | 23:79e20be4bc5b | 254 | bDoCtrlAtt = true; |
| MasashiNomura | 22:24c9c2dedca9 | 255 | break; |
| MasashiNomura | 22:24c9c2dedca9 | 256 | case GROUND: |
| MasashiNomura | 36:2cc739c7e4cb | 257 | if(gf_StateEnt){ |
| MasashiNomura | 36:2cc739c7e4cb | 258 | sp.printf("GROUND state\r\n"); |
| MasashiNomura | 36:2cc739c7e4cb | 259 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 260 | } |
| MasashiNomura | 23:79e20be4bc5b | 261 | // そのままスルー |
| MasashiNomura | 36:2cc739c7e4cb | 262 | // TODO エンジン回転数が一定以下になることを確認する |
| MasashiNomura | 23:79e20be4bc5b | 263 | setState(IDLE); |
| MasashiNomura | 22:24c9c2dedca9 | 264 | break; |
| MasashiNomura | 22:24c9c2dedca9 | 265 | case HOVER: |
| MasashiNomura | 36:2cc739c7e4cb | 266 | gf_StateEnt = false; |
| MasashiNomura | 23:79e20be4bc5b | 267 | // |
| MasashiNomura | 22:24c9c2dedca9 | 268 | break; |
| MasashiNomura | 22:24c9c2dedca9 | 269 | case DRIVE: |
| MasashiNomura | 36:2cc739c7e4cb | 270 | gf_StateEnt = false; |
| MasashiNomura | 22:24c9c2dedca9 | 271 | break; |
| MasashiNomura | 22:24c9c2dedca9 | 272 | case EMGGND: |
| MasashiNomura | 36:2cc739c7e4cb | 273 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 274 | break; |
| MasashiNomura | 36:2cc739c7e4cb | 275 | case CHK_EG_ENT: |
| MasashiNomura | 36:2cc739c7e4cb | 276 | if(gf_StateEnt){ |
| MasashiNomura | 36:2cc739c7e4cb | 277 | sp.printf("Check Engine enter\r\n"); |
| MasashiNomura | 36:2cc739c7e4cb | 278 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 279 | } |
| MasashiNomura | 36:2cc739c7e4cb | 280 | if(!hb.chkSWUserOpeAny()){ |
| MasashiNomura | 39:1b76f7df8804 | 281 | //AxlRpm = hb.getUserMotAxl(); |
| MasashiNomura | 36:2cc739c7e4cb | 282 | TrtlVal = hb.getUserEngTrottle(); |
| MasashiNomura | 38:24ee50452755 | 283 | //if(AxlRpm > 0 || TrtlVal > 40){ |
| MasashiNomura | 39:1b76f7df8804 | 284 | if(TrtlVal > 10){ |
| MasashiNomura | 38:24ee50452755 | 285 | sp.printf("Throttle Val:%d\r\n",TrtlVal); |
| MasashiNomura | 36:2cc739c7e4cb | 286 | break; |
| MasashiNomura | 36:2cc739c7e4cb | 287 | } else { |
| MasashiNomura | 38:24ee50452755 | 288 | hb.clearHvAxl(); |
| MasashiNomura | 36:2cc739c7e4cb | 289 | setState(CHK_EG_F); |
| MasashiNomura | 36:2cc739c7e4cb | 290 | } |
| MasashiNomura | 36:2cc739c7e4cb | 291 | } |
| MasashiNomura | 36:2cc739c7e4cb | 292 | break; |
| MasashiNomura | 36:2cc739c7e4cb | 293 | case CHK_EG_F: |
| MasashiNomura | 36:2cc739c7e4cb | 294 | if(gf_StateEnt){ |
| MasashiNomura | 36:2cc739c7e4cb | 295 | sp.printf("Check Engine Front\r\n"); |
| MasashiNomura | 36:2cc739c7e4cb | 296 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 297 | } |
| MasashiNomura | 36:2cc739c7e4cb | 298 | TrtlVal = hb.getUserEngTrottle(); |
| MasashiNomura | 36:2cc739c7e4cb | 299 | hb.setAccelVal(FRONT, TrtlVal); |
| MasashiNomura | 36:2cc739c7e4cb | 300 | if(hb.chkSWUserOpe(HbUserOpe::F_ENG_UP)){ |
| MasashiNomura | 38:24ee50452755 | 301 | sp.printf("FRONT Throttle Val:%d\r\n",TrtlVal); |
| MasashiNomura | 36:2cc739c7e4cb | 302 | hb.setHvAxl(FRONT, TrtlVal); |
| MasashiNomura | 36:2cc739c7e4cb | 303 | } |
| MasashiNomura | 36:2cc739c7e4cb | 304 | if(hb.chkSWUserOpe(HbUserOpe::R_ENG_UP)){ |
| MasashiNomura | 36:2cc739c7e4cb | 305 | if(hb.chkSetHvAxl(FRONT)){ |
| MasashiNomura | 41:45c982b1c5b6 | 306 | gf_AxReq[0].bf.req = true; |
| MasashiNomura | 41:45c982b1c5b6 | 307 | //gf_AxReq[1].bf.req = true; |
| MasashiNomura | 41:45c982b1c5b6 | 308 | gf_AxReq[0].bf.val = 0; |
| MasashiNomura | 41:45c982b1c5b6 | 309 | //gf_AxReq[1].bf.val = 0; |
| MasashiNomura | 36:2cc739c7e4cb | 310 | setState(CHK_EG_MID); |
| MasashiNomura | 36:2cc739c7e4cb | 311 | } |
| MasashiNomura | 36:2cc739c7e4cb | 312 | } |
| MasashiNomura | 39:1b76f7df8804 | 313 | bDoCtrlEng = true; |
| MasashiNomura | 36:2cc739c7e4cb | 314 | break; |
| MasashiNomura | 36:2cc739c7e4cb | 315 | case CHK_EG_MID: |
| MasashiNomura | 36:2cc739c7e4cb | 316 | if(gf_StateEnt){ |
| MasashiNomura | 36:2cc739c7e4cb | 317 | sp.printf("Check Engine MIDDLE\r\n"); |
| MasashiNomura | 36:2cc739c7e4cb | 318 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 319 | } |
| MasashiNomura | 36:2cc739c7e4cb | 320 | if(!hb.chkSWUserOpeAny()){ |
| MasashiNomura | 39:1b76f7df8804 | 321 | //AxlRpm = hb.getUserMotAxl(); |
| MasashiNomura | 36:2cc739c7e4cb | 322 | TrtlVal = hb.getUserEngTrottle(); |
| MasashiNomura | 39:1b76f7df8804 | 323 | //if(AxlRpm > 0 || TrtlVal > 40){ |
| MasashiNomura | 39:1b76f7df8804 | 324 | if(TrtlVal > 10){ |
| MasashiNomura | 36:2cc739c7e4cb | 325 | break; |
| MasashiNomura | 36:2cc739c7e4cb | 326 | } else { |
| MasashiNomura | 36:2cc739c7e4cb | 327 | setState(CHK_EG_R); |
| MasashiNomura | 36:2cc739c7e4cb | 328 | } |
| MasashiNomura | 36:2cc739c7e4cb | 329 | } |
| MasashiNomura | 41:45c982b1c5b6 | 330 | bDoCtrlEng = true; |
| MasashiNomura | 36:2cc739c7e4cb | 331 | break; |
| MasashiNomura | 36:2cc739c7e4cb | 332 | case CHK_EG_R: |
| MasashiNomura | 36:2cc739c7e4cb | 333 | if(gf_StateEnt){ |
| MasashiNomura | 36:2cc739c7e4cb | 334 | sp.printf("Check Engine Rear\r\n"); |
| MasashiNomura | 36:2cc739c7e4cb | 335 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 336 | } |
| MasashiNomura | 36:2cc739c7e4cb | 337 | TrtlVal = hb.getUserEngTrottle(); |
| MasashiNomura | 36:2cc739c7e4cb | 338 | hb.setAccelVal(REAR, TrtlVal); |
| MasashiNomura | 36:2cc739c7e4cb | 339 | if(hb.chkSWUserOpe(HbUserOpe::F_ENG_UP)){ |
| MasashiNomura | 38:24ee50452755 | 340 | sp.printf("REAR Throttle Val:%d\r\n",TrtlVal); |
| MasashiNomura | 36:2cc739c7e4cb | 341 | hb.setHvAxl(REAR, TrtlVal); |
| MasashiNomura | 36:2cc739c7e4cb | 342 | } |
| MasashiNomura | 36:2cc739c7e4cb | 343 | if(hb.chkSWUserOpe(HbUserOpe::R_ENG_UP)){ |
| MasashiNomura | 36:2cc739c7e4cb | 344 | if(hb.chkSetHvAxl(REAR)){ |
| MasashiNomura | 41:45c982b1c5b6 | 345 | //gf_AxReq[0].bf.req = true; |
| MasashiNomura | 41:45c982b1c5b6 | 346 | gf_AxReq[1].bf.req = true; |
| MasashiNomura | 41:45c982b1c5b6 | 347 | //gf_AxReq[0].bf.val = 0; |
| MasashiNomura | 41:45c982b1c5b6 | 348 | gf_AxReq[1].bf.val = 0; |
| MasashiNomura | 36:2cc739c7e4cb | 349 | setState(CHK_EG_EXIT); |
| MasashiNomura | 36:2cc739c7e4cb | 350 | } |
| MasashiNomura | 36:2cc739c7e4cb | 351 | } |
| MasashiNomura | 39:1b76f7df8804 | 352 | bDoCtrlEng = true; |
| MasashiNomura | 36:2cc739c7e4cb | 353 | break; |
| MasashiNomura | 36:2cc739c7e4cb | 354 | case CHK_EG_EXIT: |
| MasashiNomura | 36:2cc739c7e4cb | 355 | if(gf_StateEnt){ |
| MasashiNomura | 36:2cc739c7e4cb | 356 | sp.printf("Check Engine Exit\r\n"); |
| MasashiNomura | 36:2cc739c7e4cb | 357 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 358 | } |
| MasashiNomura | 36:2cc739c7e4cb | 359 | if(!hb.chkSWUserOpeAny()){ |
| MasashiNomura | 36:2cc739c7e4cb | 360 | TrtlVal = hb.getUserEngTrottle(); |
| MasashiNomura | 39:1b76f7df8804 | 361 | if(TrtlVal > 10){ |
| MasashiNomura | 36:2cc739c7e4cb | 362 | break; |
| MasashiNomura | 36:2cc739c7e4cb | 363 | } else { |
| MasashiNomura | 36:2cc739c7e4cb | 364 | setState(SLEEP); |
| MasashiNomura | 36:2cc739c7e4cb | 365 | } |
| MasashiNomura | 36:2cc739c7e4cb | 366 | } |
| MasashiNomura | 41:45c982b1c5b6 | 367 | bDoCtrlEng = true; |
| MasashiNomura | 22:24c9c2dedca9 | 368 | break; |
| MasashiNomura | 23:79e20be4bc5b | 369 | case CHK_ENT: //チェックエンター |
| MasashiNomura | 36:2cc739c7e4cb | 370 | if(gf_StateEnt){ |
| MasashiNomura | 36:2cc739c7e4cb | 371 | sp.printf("Check enter\r\n"); |
| MasashiNomura | 36:2cc739c7e4cb | 372 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 373 | } |
| MasashiNomura | 38:24ee50452755 | 374 | //setStateF(CHK_MOT); |
| MasashiNomura | 23:79e20be4bc5b | 375 | break; |
| MasashiNomura | 23:79e20be4bc5b | 376 | case CHK_MOT: //モーターチェック |
| MasashiNomura | 36:2cc739c7e4cb | 377 | if(gf_StateEnt){ |
| MasashiNomura | 36:2cc739c7e4cb | 378 | sp.printf("Check Motor\r\n"); |
| MasashiNomura | 36:2cc739c7e4cb | 379 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 380 | } |
| MasashiNomura | 38:24ee50452755 | 381 | //AxlRpm = hb.getUserMotAxl(); |
| MasashiNomura | 23:79e20be4bc5b | 382 | bDoCtrlMot = true; |
| MasashiNomura | 23:79e20be4bc5b | 383 | break; |
| MasashiNomura | 23:79e20be4bc5b | 384 | case CHK_AXL: //アクセルサーボチェック |
| MasashiNomura | 36:2cc739c7e4cb | 385 | if(gf_StateEnt){ |
| MasashiNomura | 36:2cc739c7e4cb | 386 | sp.printf("Check Accel Servo\r\n"); |
| MasashiNomura | 36:2cc739c7e4cb | 387 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 388 | } |
| MasashiNomura | 38:24ee50452755 | 389 | //TrtlVal = hb.getUserEngTrottle(); |
| MasashiNomura | 23:79e20be4bc5b | 390 | break; |
| MasashiNomura | 23:79e20be4bc5b | 391 | case CHK_ATT: //姿勢制御チェック |
| MasashiNomura | 36:2cc739c7e4cb | 392 | if(gf_StateEnt){ |
| MasashiNomura | 36:2cc739c7e4cb | 393 | sp.printf("Check Attitude\r\n"); |
| MasashiNomura | 36:2cc739c7e4cb | 394 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 395 | } |
| MasashiNomura | 23:79e20be4bc5b | 396 | bDoCtrlAtt = true; |
| MasashiNomura | 23:79e20be4bc5b | 397 | break; |
| MasashiNomura | 23:79e20be4bc5b | 398 | case CHK_EXIT: //チェックステート脱出 |
| MasashiNomura | 36:2cc739c7e4cb | 399 | if(gf_StateEnt){ |
| MasashiNomura | 36:2cc739c7e4cb | 400 | sp.printf("Check Exit\r\n"); |
| MasashiNomura | 36:2cc739c7e4cb | 401 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 402 | } |
| MasashiNomura | 23:79e20be4bc5b | 403 | break; |
| MasashiNomura | 25:f3a6e7eec9c3 | 404 | case MOT_STOP: |
| MasashiNomura | 36:2cc739c7e4cb | 405 | if(gf_StateEnt){ |
| MasashiNomura | 36:2cc739c7e4cb | 406 | sp.printf("Motor Stop\r\n"); |
| MasashiNomura | 36:2cc739c7e4cb | 407 | gf_StateEnt = false; |
| MasashiNomura | 36:2cc739c7e4cb | 408 | } |
| MasashiNomura | 37:d51dacb4c30f | 409 | bDoCtrlAtt = false; |
| MasashiNomura | 37:d51dacb4c30f | 410 | bDoCtrlMot = true; |
| MasashiNomura | 37:d51dacb4c30f | 411 | bTmp = true; |
| MasashiNomura | 37:d51dacb4c30f | 412 | for(int i = 0; i < 4; ++i){ |
| MasashiNomura | 37:d51dacb4c30f | 413 | if(gf_MtReq[i].req){ |
| MasashiNomura | 37:d51dacb4c30f | 414 | bTmp = false; |
| MasashiNomura | 37:d51dacb4c30f | 415 | break; |
| MasashiNomura | 37:d51dacb4c30f | 416 | } |
| MasashiNomura | 37:d51dacb4c30f | 417 | if(gf_MtReqOfs[i].req){ |
| MasashiNomura | 37:d51dacb4c30f | 418 | bTmp = false; |
| MasashiNomura | 37:d51dacb4c30f | 419 | break; |
| MasashiNomura | 37:d51dacb4c30f | 420 | } |
| MasashiNomura | 37:d51dacb4c30f | 421 | } |
| MasashiNomura | 37:d51dacb4c30f | 422 | if(!bTmp)break; |
| MasashiNomura | 37:d51dacb4c30f | 423 | for(int i = 0; i < 2; ++i){ |
| MasashiNomura | 37:d51dacb4c30f | 424 | if(gf_AxReq[i].bf.req){ |
| MasashiNomura | 37:d51dacb4c30f | 425 | bTmp = false; |
| MasashiNomura | 37:d51dacb4c30f | 426 | break; |
| MasashiNomura | 37:d51dacb4c30f | 427 | } |
| MasashiNomura | 37:d51dacb4c30f | 428 | } |
| MasashiNomura | 37:d51dacb4c30f | 429 | if(bTmp){ |
| MasashiNomura | 37:d51dacb4c30f | 430 | if(gf_FromActiveStat){ |
| MasashiNomura | 40:debe99e228d3 | 431 | setStateF(IDLE); |
| MasashiNomura | 37:d51dacb4c30f | 432 | } |
| MasashiNomura | 37:d51dacb4c30f | 433 | else{ |
| MasashiNomura | 37:d51dacb4c30f | 434 | setStateF(SLEEP); |
| MasashiNomura | 37:d51dacb4c30f | 435 | } |
| MasashiNomura | 37:d51dacb4c30f | 436 | } |
| MasashiNomura | 37:d51dacb4c30f | 437 | |
| MasashiNomura | 32:7f4145cc3551 | 438 | // if(hb.stopMotor() == true){ |
| MasashiNomura | 32:7f4145cc3551 | 439 | // hb.initMotVal(); |
| MasashiNomura | 32:7f4145cc3551 | 440 | // setState(SLEEP); |
| MasashiNomura | 32:7f4145cc3551 | 441 | // sp.printf("MOTOR STOPPED!\r\n"); |
| MasashiNomura | 32:7f4145cc3551 | 442 | // } |
| MasashiNomura | 32:7f4145cc3551 | 443 | // else{ |
| MasashiNomura | 32:7f4145cc3551 | 444 | // //bDoCtrlMot = true; |
| MasashiNomura | 32:7f4145cc3551 | 445 | // sp.printf("."); |
| MasashiNomura | 32:7f4145cc3551 | 446 | // } |
| MasashiNomura | 25:f3a6e7eec9c3 | 447 | break; |
| MasashiNomura | 22:24c9c2dedca9 | 448 | } |
| takeru0x1103 | 21:78302ecdb661 | 449 | |
| takeru0x1103 | 21:78302ecdb661 | 450 | //▼③各種設定 |
| takeru0x1103 | 21:78302ecdb661 | 451 | //hb.controlAttitude(); //姿勢制御 |
| takeru0x1103 | 21:78302ecdb661 | 452 | //hb.controlMotor();//モーター指令出し |
| MasashiNomura | 23:79e20be4bc5b | 453 | if(bDoCtrlAtt)hb.controlAttitude(); //姿勢制御 |
| MasashiNomura | 23:79e20be4bc5b | 454 | if(bDoCtrlMot)hb.controlMotor();//モーター指令出し |
| MasashiNomura | 46:5074781a28dd | 455 | //if(bDoCtrlEng)hb.controlEngine();//エンジン指令出し |
| MasashiNomura | 46:5074781a28dd | 456 | if(bDoCtrlEng)hb.controlEngine(gf_State);//エンジン指令出し |
| MasashiNomura | 31:56c554c560c1 | 457 | |
| MasashiNomura | 41:45c982b1c5b6 | 458 | if(gf_Print.d1.bf.stat){ |
| MasashiNomura | 41:45c982b1c5b6 | 459 | sp.printf("stat : [%X] ",gf_State); |
| MasashiNomura | 23:79e20be4bc5b | 460 | } |
| takeru0x1103 | 18:5aa48aec9cae | 461 | //表示フラグを落とす(けどモニタフラグが立ってる箇所は残る) |
| MasashiNomura | 41:45c982b1c5b6 | 462 | if(gf_Print.d1.flg!=0 || gf_Print.d2.flg!=0){ |
| MasashiNomura | 41:45c982b1c5b6 | 463 | gf_Print.d1.flg=gf_Mon.d1.flg; |
| MasashiNomura | 41:45c982b1c5b6 | 464 | gf_Print.d2.flg=gf_Mon.d2.flg; |
| MasashiNomura | 26:732bc37fbefd | 465 | sp.printf("\r\n"); |
| MasashiNomura | 26:732bc37fbefd | 466 | } |
| takeru0x1103 | 1:15ab74f0d0f1 | 467 | |
| takeru0x1103 | 1:15ab74f0d0f1 | 468 | //次の周期まで待つ |
| takeru0x1103 | 1:15ab74f0d0f1 | 469 | vTaskDelayUntil(&xLastWakeTime, 20 / portTICK_RATE_MS ); |
| takeru0x1103 | 1:15ab74f0d0f1 | 470 | } |
| takeru0x1103 | 1:15ab74f0d0f1 | 471 | } |
| takeru0x1103 | 18:5aa48aec9cae | 472 | //======================================================== |
| takeru0x1103 | 21:78302ecdb661 | 473 | //タスク2:デバッグ用タスク |
| takeru0x1103 | 18:5aa48aec9cae | 474 | //======================================================== |
| takeru0x1103 | 18:5aa48aec9cae | 475 | void taskDebug(void *pvParameters){ |
| takeru0x1103 | 21:78302ecdb661 | 476 | |
| takeru0x1103 | 21:78302ecdb661 | 477 | taskStop(2);//自ら止めてレジュームされるまで待つ |
| MasashiNomura | 24:c5945aaae777 | 478 | UCHAR Num; |
| MasashiNomura | 24:c5945aaae777 | 479 | INT16 iVal; |
| MasashiNomura | 25:f3a6e7eec9c3 | 480 | //bool rvFlg; |
| MasashiNomura | 24:c5945aaae777 | 481 | |
| takeru0x1103 | 21:78302ecdb661 | 482 | //この関数をリターンしてしまうと他のタスクも止まるのでwhileで回すこと! |
| takeru0x1103 | 18:5aa48aec9cae | 483 | while(1){ |
| MasashiNomura | 24:c5945aaae777 | 484 | for(Num = 0; Num < 8; ++Num){ |
| MasashiNomura | 24:c5945aaae777 | 485 | for(iVal = 50; iVal < 300; ++iVal){ |
| MasashiNomura | 24:c5945aaae777 | 486 | fpgaMotor(Num, iVal); |
| MasashiNomura | 25:f3a6e7eec9c3 | 487 | wait(0.002); |
| MasashiNomura | 24:c5945aaae777 | 488 | } |
| MasashiNomura | 24:c5945aaae777 | 489 | for(iVal = 300; iVal >= 50; --iVal){ |
| MasashiNomura | 24:c5945aaae777 | 490 | fpgaMotor(Num, iVal); |
| MasashiNomura | 25:f3a6e7eec9c3 | 491 | wait(0.002); |
| MasashiNomura | 24:c5945aaae777 | 492 | } |
| MasashiNomura | 24:c5945aaae777 | 493 | } |
| MasashiNomura | 23:79e20be4bc5b | 494 | //自タスク停止させて次の周期まで待つ |
| MasashiNomura | 22:24c9c2dedca9 | 495 | gf_Dbg = false; |
| MasashiNomura | 23:79e20be4bc5b | 496 | sp.printf("Do DebugTask!"); |
| takeru0x1103 | 18:5aa48aec9cae | 497 | taskStop(2); |
| takeru0x1103 | 18:5aa48aec9cae | 498 | } |
| takeru0x1103 | 18:5aa48aec9cae | 499 | } |
| takeru0x1103 | 17:f9610f3cfa1b | 500 | |
| takeru0x1103 | 1:15ab74f0d0f1 | 501 | //------------------------------------------------------------- |
| takeru0x1103 | 17:f9610f3cfa1b | 502 | //初期化:タスク登録 |
| takeru0x1103 | 1:15ab74f0d0f1 | 503 | //------------------------------------------------------------- |
| takeru0x1103 | 1:15ab74f0d0f1 | 504 | void taskInit(){ |
| takeru0x1103 | 21:78302ecdb661 | 505 | portBASE_TYPE TaskRtn;//タスククリエイトの結果を受け取る型 |
| takeru0x1103 | 18:5aa48aec9cae | 506 | |
| takeru0x1103 | 21:78302ecdb661 | 507 | //タスク0:コマンド解析タスク |
| MasashiNomura | 26:732bc37fbefd | 508 | TaskRtn= xTaskCreate(taskCmdParser, (signed portCHAR *)"TaskCmd", 512, NULL, 1, &tskHandle[0]); |
| takeru0x1103 | 21:78302ecdb661 | 509 | if(TaskRtn==pdTRUE){sp.printf("Task0 Set : Command parser\r\n");} |
| takeru0x1103 | 21:78302ecdb661 | 510 | |
| takeru0x1103 | 21:78302ecdb661 | 511 | //タスク1:制御タスク |
| MasashiNomura | 28:fdb3b144e342 | 512 | TaskRtn= xTaskCreate(taskHbControl, (signed portCHAR *)"TaskHbCont", 1024, NULL, 2, &tskHandle[1]); |
| takeru0x1103 | 21:78302ecdb661 | 513 | if(TaskRtn==pdTRUE){sp.printf("Task1 Set : Hoverbike Control\r\n");} |
| takeru0x1103 | 21:78302ecdb661 | 514 | |
| takeru0x1103 | 21:78302ecdb661 | 515 | //タスク2:デバッグタスク |
| MasashiNomura | 23:79e20be4bc5b | 516 | TaskRtn= xTaskCreate(taskDebug, (signed portCHAR *)"TaskDebug", 192, NULL, 0, &tskHandle[2]); |
| takeru0x1103 | 21:78302ecdb661 | 517 | if(TaskRtn==pdTRUE){sp.printf("Task2 Set : Debug\r\n");} |
| takeru0x1103 | 8:1ca49cb18290 | 518 | |
| takeru0x1103 | 21:78302ecdb661 | 519 | //RTOSカーネル起動(タスクが走り出す) |
| takeru0x1103 | 1:15ab74f0d0f1 | 520 | vTaskStartScheduler(); |
| takeru0x1103 | 1:15ab74f0d0f1 | 521 | } |
| takeru0x1103 | 1:15ab74f0d0f1 | 522 | |
| takeru0x1103 | 1:15ab74f0d0f1 | 523 |