teamALI / Mbed 2 deprecated HB2018

Dependencies:   mbed FreeRTOS

userTask.cpp

Committer:
takeru0x1103
Date:
2018-11-30
Revision:
17:f9610f3cfa1b
Parent:
16:05b9e44889f1
Child:
18:5aa48aec9cae

File content as of revision 17:f9610f3cfa1b:

//RTOS関連
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "globalFlags.h"
#include "HbManager.h"
#include "command.h"


//----------------------------------------------------------------
//ホバーバイク制御タスク
//----------------------------------------------------------------
void taskHbControl(void *pvParameters){
    int8_t          *pcTaskName;
    portTickType    xLastWakeTime;
    HbManager       hb;
    
    pcTaskName = (int8_t *) pvParameters;
    xLastWakeTime = xTaskGetTickCount();
    
    while(1){
        led1=!led1;
        //
        hb.controlEngine();
        
        //次の周期まで待つ
        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(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();
}