Hallo,
ich versuche die C-Funktion xTaskCreate() von FreeRTOS innerhalb meines
C++ Codes zu verwenden, allerdings komme ich dabei auf keinen grünen
Zweig.
1 | [...]
|
2 |
|
3 | /**
|
4 | * task. h
|
5 | *<pre>
|
6 | portBASE_TYPE xTaskCreate(
|
7 | pdTASK_CODE pvTaskCode,
|
8 | const char * const pcName,
|
9 | unsigned short usStackDepth,
|
10 | void *pvParameters,
|
11 | unsigned portBASE_TYPE uxPriority,
|
12 | xTaskHandle *pvCreatedTask
|
13 | );</pre>
|
14 | *
|
15 | * Create a new task and add it to the list of tasks that are ready to run.
|
16 | *
|
17 | **/
|
18 | #define xTaskCreate( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask ) xTaskGenericCreate( ( pvTaskCode ), ( pcName ), ( usStackDepth ), ( pvParameters ), ( uxPriority ), ( pxCreatedTask ), ( NULL ), ( NULL )
|
19 | [...]
|
CPP-Header- und CPP-Source-Datei:
1 |
|
2 | /*
|
3 | CPP Header: "prl_task.hh"
|
4 | */
|
5 |
|
6 | #ifndef PRL_TASK_HH_
|
7 | #define PRL_TASK_HH_
|
8 |
|
9 | #include <stdio.h>
|
10 | #include <stdlib.h>
|
11 |
|
12 | #include <FreeRTOS.h>
|
13 | #include <task.h>
|
14 |
|
15 | #ifdef __cplusplus
|
16 |
|
17 |
|
18 | class CTask {
|
19 |
|
20 | public:
|
21 | CTask();
|
22 | ~CTask();
|
23 | void runTask1();
|
24 | void runTask2();
|
25 | };
|
26 |
|
27 | #endif
|
28 |
|
29 | #ifdef __cplusplus
|
30 | extern "C" {
|
31 | #endif
|
32 |
|
33 | /*
|
34 | * Wrapper Funktionen
|
35 | */
|
36 |
|
37 | void tskWrpT1(void* param);
|
38 | void tskWrpT2(void* param);
|
39 |
|
40 | #ifdef __cplusplus
|
41 | }
|
42 | #endif
|
43 | #endif /* PRL_TASK_HH_ */
|
1 | /*
|
2 | * prl_task.cc
|
3 | *
|
4 | */
|
5 |
|
6 | #include <prl_task.hh>
|
7 | #include <board_func.hh>
|
8 |
|
9 | void vTask1() {
|
10 |
|
11 | DO();
|
12 | }
|
13 |
|
14 |
|
15 | CTask::CTask() {
|
16 | }
|
17 |
|
18 | CTask::~CTask() {
|
19 | }
|
20 |
|
21 | void CTask::runTask1() {
|
22 |
|
23 | xTaskCreate(vTask1,"tsk1",1000,NULL,1,NULL);
|
24 | }
|
25 |
|
26 | void CTask::runTask2() {
|
27 | }
|
28 |
|
29 |
|
30 | void tskWrpT1(void* parm) {
|
31 |
|
32 | (static_cast<CTask*>(parm))->runTask1();
|
33 | }
|
34 |
|
35 | void tskWrpT2(void* parm) {
|
36 |
|
37 | (static_cast<CTask*>(parm))->runTask2();
|
38 | }
|
Rufe ich runTask1() auf und versuche mit xTaskCreate() einen Task zu
erzeugen, erhalte ich beim Kompilieren folgende Fehlermeldung:
1 | Function 'xTaskGenericCreate' could not be resolved
|
Ich habe bereits verschiedenste (Import-)Varianten ausprobiert, z.B. die
Header-Datei task.h in einen Bindungsblock auszulagern:
1 | extern "C" {
|
2 | #include <task.h>
|
3 | }
|
Hat jmd. noch eine Idee wie man da weiter vorgehen könnte?
- Florian