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