teamALI / Mbed 2 deprecated HB2018

Dependencies:   mbed FreeRTOS

Committer:
takeru0x1103
Date:
Fri Nov 30 05:24:27 2018 +0000
Revision:
17:f9610f3cfa1b
Parent:
16:05b9e44889f1
Child:
18:5aa48aec9cae
1130

Who changed what in which revision?

UserRevisionLine numberNew contents of line
takeru0x1103 1:15ab74f0d0f1 1 //RTOS関連
takeru0x1103 1:15ab74f0d0f1 2 #include "FreeRTOS.h"
takeru0x1103 1:15ab74f0d0f1 3 #include "task.h"
takeru0x1103 1:15ab74f0d0f1 4 #include "queue.h"
takeru0x1103 17:f9610f3cfa1b 5 #include "globalFlags.h"
takeru0x1103 17:f9610f3cfa1b 6 #include "HbManager.h"
takeru0x1103 1:15ab74f0d0f1 7 #include "command.h"
takeru0x1103 1:15ab74f0d0f1 8
takeru0x1103 1:15ab74f0d0f1 9
takeru0x1103 1:15ab74f0d0f1 10 //----------------------------------------------------------------
takeru0x1103 17:f9610f3cfa1b 11 //ホバーバイク制御タスク
takeru0x1103 1:15ab74f0d0f1 12 //----------------------------------------------------------------
takeru0x1103 17:f9610f3cfa1b 13 void taskHbControl(void *pvParameters){
takeru0x1103 17:f9610f3cfa1b 14 int8_t *pcTaskName;
takeru0x1103 17:f9610f3cfa1b 15 portTickType xLastWakeTime;
takeru0x1103 17:f9610f3cfa1b 16 HbManager hb;
takeru0x1103 8:1ca49cb18290 17
takeru0x1103 1:15ab74f0d0f1 18 pcTaskName = (int8_t *) pvParameters;
takeru0x1103 1:15ab74f0d0f1 19 xLastWakeTime = xTaskGetTickCount();
takeru0x1103 8:1ca49cb18290 20
takeru0x1103 1:15ab74f0d0f1 21 while(1){
takeru0x1103 16:05b9e44889f1 22 led1=!led1;
takeru0x1103 17:f9610f3cfa1b 23 //
takeru0x1103 17:f9610f3cfa1b 24 hb.controlEngine();
takeru0x1103 1:15ab74f0d0f1 25
takeru0x1103 1:15ab74f0d0f1 26 //次の周期まで待つ
takeru0x1103 1:15ab74f0d0f1 27 vTaskDelayUntil(&xLastWakeTime, 20 / portTICK_RATE_MS );
takeru0x1103 1:15ab74f0d0f1 28 }
takeru0x1103 1:15ab74f0d0f1 29 }
takeru0x1103 1:15ab74f0d0f1 30
takeru0x1103 17:f9610f3cfa1b 31 //----------------------------------------------------------------
takeru0x1103 17:f9610f3cfa1b 32 //コマンド解析タスク
takeru0x1103 17:f9610f3cfa1b 33 //----------------------------------------------------------------
takeru0x1103 17:f9610f3cfa1b 34 void taskCmdParser(void *pvParameters){
takeru0x1103 17:f9610f3cfa1b 35 int8_t *pcTaskName;
takeru0x1103 17:f9610f3cfa1b 36 portTickType xLastWakeTime;
takeru0x1103 17:f9610f3cfa1b 37
takeru0x1103 17:f9610f3cfa1b 38 pcTaskName = (int8_t *) pvParameters;
takeru0x1103 17:f9610f3cfa1b 39 xLastWakeTime = xTaskGetTickCount();
takeru0x1103 17:f9610f3cfa1b 40
takeru0x1103 17:f9610f3cfa1b 41 while(1){
takeru0x1103 17:f9610f3cfa1b 42 led2=!led2;
takeru0x1103 17:f9610f3cfa1b 43 //
takeru0x1103 17:f9610f3cfa1b 44 commandParse();
takeru0x1103 17:f9610f3cfa1b 45 //次の周期まで待つ
takeru0x1103 17:f9610f3cfa1b 46 vTaskDelayUntil(&xLastWakeTime, 100 / portTICK_RATE_MS );
takeru0x1103 17:f9610f3cfa1b 47 }
takeru0x1103 17:f9610f3cfa1b 48 }
takeru0x1103 17:f9610f3cfa1b 49
takeru0x1103 17:f9610f3cfa1b 50
takeru0x1103 17:f9610f3cfa1b 51
takeru0x1103 1:15ab74f0d0f1 52 //-------------------------------------------------------------
takeru0x1103 17:f9610f3cfa1b 53 //初期化:タスク登録
takeru0x1103 1:15ab74f0d0f1 54 //-------------------------------------------------------------
takeru0x1103 1:15ab74f0d0f1 55 void taskInit(){
takeru0x1103 1:15ab74f0d0f1 56 portBASE_TYPE TaskRtn;
takeru0x1103 17:f9610f3cfa1b 57
takeru0x1103 1:15ab74f0d0f1 58 //
takeru0x1103 17:f9610f3cfa1b 59 TaskRtn= xTaskCreate(taskHbControl, (signed portCHAR *)"Task50Hz", 192, NULL, 1, NULL);
takeru0x1103 17:f9610f3cfa1b 60 if(TaskRtn==pdTRUE){printf("Hoverbike Control task Set\r\n");}
takeru0x1103 17:f9610f3cfa1b 61 //
takeru0x1103 17:f9610f3cfa1b 62 TaskRtn= xTaskCreate(taskCmdParser, (signed portCHAR *)"TaskParser", 192, NULL, 1, NULL);
takeru0x1103 17:f9610f3cfa1b 63 if(TaskRtn==pdTRUE){printf("Command Parser task Set\r\n");}
takeru0x1103 8:1ca49cb18290 64
takeru0x1103 1:15ab74f0d0f1 65 //カーネルの起動
takeru0x1103 1:15ab74f0d0f1 66 vTaskStartScheduler();
takeru0x1103 1:15ab74f0d0f1 67 }
takeru0x1103 1:15ab74f0d0f1 68
takeru0x1103 1:15ab74f0d0f1 69