-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.c
73 lines (62 loc) · 2.13 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <stdio.h>
#include <FreeRTOS.h>
#include <task.h>
/* Priorities at which the tasks are created. */
#define TASK_MY_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define TASK_MY_SECOND_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
/* Task stack sizes*/
#define TASK_MY_TASK_STACK ( configMINIMAL_STACK_SIZE )
#define TASK_MY_SECOND_TASK_STACK ( configMINIMAL_STACK_SIZE )
/* Task Handles */
TaskHandle_t _taskSecondHandle = NULL;
// --------------------------------------------------------------------------------------
void taskMyTask(void* pvParameters)
{
// Remove compiler warnings.
(void)pvParameters;
for (;;)
{
vTaskDelay(pdMS_TO_TICKS(200));
puts("Hi from My Task");
}
}
// --------------------------------------------------------------------------------------
void taskMySeccondTask(void* pvParameters)
{
// Remove compiler warnings.
(void)pvParameters;
for (;;)
{
vTaskDelay(pdMS_TO_TICKS(100));
puts("Hi from My Second Task");
}
}
// --------------------------------------------------------------------------------------
void main(void)
{
BaseType_t status;
/* Create the task, not storing the handle. */
status = xTaskCreate(
taskMyTask, /* Function that implements the task. */
"MyTask", /* Text name for the task. */
TASK_MY_TASK_STACK, /* Stack size in words, not bytes. */
(void*)1, /* Parameter passed into the task. */
TASK_MY_TASK_PRIORITY,/* Priority at which the task is created. */
NULL); /* Used to pass out the created task's handle. */
if (pdPASS != status) {
// Task is not created!!!!
}
/* Create the task, storing the handle. */
status = xTaskCreate(
taskMySeccondTask, /* Function that implements the task. */
"MySecondTask", /* Text name for the task. */
TASK_MY_SECOND_TASK_STACK, /* Stack size in words, not bytes. */
(void*)2, /* Parameter passed into the task. */
TASK_MY_SECOND_TASK_PRIORITY,/* Priority at which the task is created. */
&_taskSecondHandle); /* Used to pass out the created task's handle. */
if (pdPASS != status) {
// Task is not created!!!!
}
// Let the operating system take over :)
vTaskStartScheduler();
}