-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.c
148 lines (123 loc) · 5.77 KB
/
app.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
*********************************************************************************************************
* EXAMPLE CODE
*
* (c) Copyright 2003-2013; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
* Knowledge of the source code may NOT be used to develop a similar product.
* Please help us continue to provide the Embedded community with the finest
* software available. Your honesty is greatly appreciated.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* EXAMPLE CODE
*
* uC/OS-III on POSIX
*
*
* Filename : main.c
* Version : V1.00
* Programmer(s) : DC
* SB
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* INCLUDE FILES
*********************************************************************************************************
*/
#include <app_cfg.h>
#include <os.h>
#include <stdio.h>
#include <lib_mem.h>
#include <lib_math.h>
/*
*********************************************************************************************************
* LOCAL DEFINES
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* LOCAL GLOBAL VARIABLES
*********************************************************************************************************
*/
static OS_TCB App_TaskStartTCB;
static CPU_STK_SIZE App_TaskStartStk[APP_CFG_TASK_START_STK_SIZE];
/*
*********************************************************************************************************
* LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/
static void App_TaskStart (void *p_arg);
/*
*********************************************************************************************************
* main()
*
* Description : This is the standard entry point for C code. It is assumed that your code will call
* main() once you have performed all necessary initialization.
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : This the main standard entry point.
*
* Note(s) : none.
*********************************************************************************************************
*/
int main (void)
{
OS_ERR err;
OSInit(&err); /* Initialize "uC/OS-III, The Real-Time Kernel" */
OSTaskCreate((OS_TCB *)&App_TaskStartTCB, /* Create the start task */
(CPU_CHAR *)"App Task Start",
(OS_TASK_PTR ) App_TaskStart,
(void *) 0,
(OS_PRIO ) APP_CFG_TASK_START_PRIO,
(CPU_STK *)&App_TaskStartStk[0],
(CPU_STK )(APP_CFG_TASK_START_STK_SIZE / 10u),
(CPU_STK_SIZE) APP_CFG_TASK_START_STK_SIZE,
(OS_MSG_QTY ) 0,
(OS_TICK ) 0,
(void *) 0,
(OS_OPT )(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
(OS_ERR *)&err);
OSStart(&err); /* Start multitasking (i.e. give control to uC/OS-III). */
while(DEF_ON){ /* Should Never Get Here */
};
}
/*
*********************************************************************************************************
* App_TaskStart()
*
* Description : This is an example of a startup task. As mentioned in the book's text, you MUST
* initialize the ticker only once multitasking has started.
*
* Argument(s) : p_arg is the argument passed to 'App_TaskStart()' by 'OSTaskCreate()'.
*
* Return(s) : none.
*
* Caller(s) : This is a task.
*
* Notes : (1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
* used. The compiler should not generate any code for this statement.
*********************************************************************************************************
*/
static void App_TaskStart (void *p_arg)
{
OS_ERR os_err;
(void)p_arg; /* See Note #1 */
CPU_Init();
Mem_Init(); /* Initialize the Memory Management Module */
Math_Init(); /* Initialize the Mathematical Module */
OS_CPU_SysTickInit();
while (DEF_TRUE) { /* Task body, always written as an infinite loop. */
printf("uCOS-III is running.\n");
OSTimeDlyHMSM(0u, 0u, 1u, 0u,
OS_OPT_TIME_HMSM_STRICT,
&os_err);
}
}