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@14:76a56d517103, 2018-11-27 (annotated)
- Committer:
- MasashiNomura
- Date:
- Tue Nov 27 05:23:44 2018 +0000
- Revision:
- 14:76a56d517103
- Parent:
- 8:1ca49cb18290
- Child:
- 16:05b9e44889f1
Gyro???????????????
Who changed what in which revision?
User | Revision | Line number | New 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 | 1:15ab74f0d0f1 | 5 | #include "led.h" |
takeru0x1103 | 1:15ab74f0d0f1 | 6 | #include "command.h" |
takeru0x1103 | 1:15ab74f0d0f1 | 7 | #include "userOperate.h" |
takeru0x1103 | 8:1ca49cb18290 | 8 | #include "Gyro.h" |
takeru0x1103 | 8:1ca49cb18290 | 9 | #include "uart.h" |
takeru0x1103 | 8:1ca49cb18290 | 10 | #include "globalFlags.h" |
takeru0x1103 | 1:15ab74f0d0f1 | 11 | |
takeru0x1103 | 1:15ab74f0d0f1 | 12 | |
takeru0x1103 | 1:15ab74f0d0f1 | 13 | //---------------------------------------------------------------- |
takeru0x1103 | 1:15ab74f0d0f1 | 14 | //タスク処理 |
takeru0x1103 | 1:15ab74f0d0f1 | 15 | //---------------------------------------------------------------- |
takeru0x1103 | 1:15ab74f0d0f1 | 16 | void task50Hz(void *pvParameters){ |
takeru0x1103 | 1:15ab74f0d0f1 | 17 | |
takeru0x1103 | 1:15ab74f0d0f1 | 18 | int8_t *pcTaskName; |
takeru0x1103 | 8:1ca49cb18290 | 19 | portTickType xLastWakeTime; |
MasashiNomura | 14:76a56d517103 | 20 | Gyro gy(p28,p27); |
takeru0x1103 | 8:1ca49cb18290 | 21 | |
takeru0x1103 | 1:15ab74f0d0f1 | 22 | pcTaskName = (int8_t *) pvParameters; |
takeru0x1103 | 1:15ab74f0d0f1 | 23 | xLastWakeTime = xTaskGetTickCount(); |
takeru0x1103 | 8:1ca49cb18290 | 24 | |
takeru0x1103 | 1:15ab74f0d0f1 | 25 | while(1){ |
takeru0x1103 | 1:15ab74f0d0f1 | 26 | ledTggle(); |
takeru0x1103 | 1:15ab74f0d0f1 | 27 | |
takeru0x1103 | 8:1ca49cb18290 | 28 | if(!gDebugFlg){ |
takeru0x1103 | 1:15ab74f0d0f1 | 29 | userTest(); |
takeru0x1103 | 1:15ab74f0d0f1 | 30 | } |
takeru0x1103 | 1:15ab74f0d0f1 | 31 | |
takeru0x1103 | 1:15ab74f0d0f1 | 32 | //次の周期まで待つ |
takeru0x1103 | 8:1ca49cb18290 | 33 | sp.printf("%0.2f,%0.2f\r\n",gy.GetAngle(),gy.GetAngularRate()); |
takeru0x1103 | 8:1ca49cb18290 | 34 | |
takeru0x1103 | 8:1ca49cb18290 | 35 | if(gfSetYawRef){gy.SetYawRef();} |
takeru0x1103 | 8:1ca49cb18290 | 36 | |
takeru0x1103 | 1:15ab74f0d0f1 | 37 | vTaskDelayUntil(&xLastWakeTime, 20 / portTICK_RATE_MS ); |
takeru0x1103 | 1:15ab74f0d0f1 | 38 | } |
takeru0x1103 | 1:15ab74f0d0f1 | 39 | } |
takeru0x1103 | 1:15ab74f0d0f1 | 40 | |
takeru0x1103 | 1:15ab74f0d0f1 | 41 | //------------------------------------------------------------- |
takeru0x1103 | 1:15ab74f0d0f1 | 42 | //初期化 |
takeru0x1103 | 1:15ab74f0d0f1 | 43 | //------------------------------------------------------------- |
takeru0x1103 | 1:15ab74f0d0f1 | 44 | void taskInit(){ |
takeru0x1103 | 1:15ab74f0d0f1 | 45 | portBASE_TYPE TaskRtn; |
takeru0x1103 | 1:15ab74f0d0f1 | 46 | TaskRtn= xTaskCreate(task50Hz, (signed portCHAR *)"TaskB", 192, NULL, 1, NULL); |
takeru0x1103 | 1:15ab74f0d0f1 | 47 | // |
takeru0x1103 | 8:1ca49cb18290 | 48 | if(TaskRtn==pdTRUE){ |
takeru0x1103 | 8:1ca49cb18290 | 49 | printf("task1 OK\r\n"); |
takeru0x1103 | 8:1ca49cb18290 | 50 | } |
takeru0x1103 | 8:1ca49cb18290 | 51 | |
takeru0x1103 | 1:15ab74f0d0f1 | 52 | //カーネルの起動 |
takeru0x1103 | 1:15ab74f0d0f1 | 53 | vTaskStartScheduler(); |
takeru0x1103 | 1:15ab74f0d0f1 | 54 | } |
takeru0x1103 | 1:15ab74f0d0f1 | 55 | |
takeru0x1103 | 1:15ab74f0d0f1 | 56 |