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.
Diff: userTask.cpp
- Revision:
- 17:f9610f3cfa1b
- Parent:
- 16:05b9e44889f1
- Child:
- 18:5aa48aec9cae
diff -r 05b9e44889f1 -r f9610f3cfa1b userTask.cpp --- a/userTask.cpp Wed Nov 28 01:31:46 2018 +0000 +++ b/userTask.cpp Fri Nov 30 05:24:27 2018 +0000 @@ -2,61 +2,65 @@ #include "FreeRTOS.h" #include "task.h" #include "queue.h" -//#include "led.h" +#include "globalFlags.h" +#include "HbManager.h" #include "command.h" -#include "hbManager.h" -#include "Gyro.h" -#include "uart.h" -#include "globalFlags.h" //---------------------------------------------------------------- -//タスク処理 +//ホバーバイク制御タスク //---------------------------------------------------------------- -void task50Hz(void *pvParameters){ - - long tmp; - /* - tmp = strtol( "0x0001" , NULL , 16);//Z軸角速度 - sp.printf("%d(%X)\r\n",tmp,tmp); - - tmp = strtol( "0xFFFE" , NULL , 16);//Z軸角速度 - sp.printf("%d(%X)\r\n",tmp,tmp); -*/ - - int8_t *pcTaskName; - portTickType xLastWakeTime; - Gyro gy(p28,p27); +void taskHbControl(void *pvParameters){ + int8_t *pcTaskName; + portTickType xLastWakeTime; + HbManager hb; pcTaskName = (int8_t *) pvParameters; xLastWakeTime = xTaskGetTickCount(); while(1){ led1=!led1; - - if(!gDebugFlg){ - userTest(); - } + // + hb.controlEngine(); //次の周期まで待つ - sp.printf("%0.2f\t%d\r\n",gy.GetAngle(),gy.GetAngularRate()); - - if(gfSetYawRef){gy.SetYawRef();} - vTaskDelayUntil(&xLastWakeTime, 20 / portTICK_RATE_MS ); } } +//---------------------------------------------------------------- +//コマンド解析タスク +//---------------------------------------------------------------- +void taskCmdParser(void *pvParameters){ + int8_t *pcTaskName; + portTickType xLastWakeTime; + + pcTaskName = (int8_t *) pvParameters; + xLastWakeTime = xTaskGetTickCount(); + + while(1){ + led2=!led2; + // + commandParse(); + //次の周期まで待つ + vTaskDelayUntil(&xLastWakeTime, 100 / portTICK_RATE_MS ); + } +} + + + //------------------------------------------------------------- -//初期化 +//初期化:タスク登録 //------------------------------------------------------------- void taskInit(){ portBASE_TYPE TaskRtn; - TaskRtn= xTaskCreate(task50Hz, (signed portCHAR *)"TaskB", 192, NULL, 1, NULL); + // - if(TaskRtn==pdTRUE){ - printf("task1 OK\r\n"); - } + TaskRtn= xTaskCreate(taskHbControl, (signed portCHAR *)"Task50Hz", 192, NULL, 1, NULL); + if(TaskRtn==pdTRUE){printf("Hoverbike Control task Set\r\n");} + // + TaskRtn= xTaskCreate(taskCmdParser, (signed portCHAR *)"TaskParser", 192, NULL, 1, NULL); + if(TaskRtn==pdTRUE){printf("Command Parser task Set\r\n");} //カーネルの起動 vTaskStartScheduler();