-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtos_start.c
142 lines (114 loc) · 4.31 KB
/
rtos_start.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
/****************************************************************************
* Afan SAME70 uC/OS-II rtos_start.c
* Author : Afan Vibrant ([email protected])
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#include <atmel_start.h>
#include <peripheral_clk_config.h>
#include "rtos_config.h"
#include "rtos.h"
#include "rtos_start.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
static const char *led_task_name = "led task";
static OS_STK led_thread_stk[LEDRUN_THREAD_STKSZ/4];
/****************************************************************************
* Public Functions Prototypes
****************************************************************************/
/****************************************************************************
* Private Functions Prototypes
****************************************************************************/
static void led_thread_entry(void *parameter);
/****************************************************************************
* Private Functions
****************************************************************************/
static void display_task_info(void)
{
OS_TCB *ptcb;
OS_STK_DATA stk;
ptcb = &OSTCBTbl[0];
printf("==================================================\r\n");
printf(" Prio Used Free Per Taskname\r\n");
while (ptcb != NULL)
{
OSTaskStkChk(ptcb->OSTCBPrio, &stk);
printf(" %2d %5d %5d %02d%% %s\r\n",
ptcb->OSTCBPrio,
stk.OSUsed,
stk.OSFree,
(stk.OSUsed * 100) / (stk.OSUsed + stk.OSFree),
ptcb->OSTCBTaskName);
ptcb = ptcb->OSTCBPrev;
}
}
/****************************************************************************
* Name: led_thread_entry
*
* Description:
* Task for LED.
*
* Input Parameters:
* NONE.
*
* Returned Value:
* None.
*
****************************************************************************/
static void led_thread_entry(void *parameter)
{
(void)parameter;
#if (OS_TASK_STAT_EN > 0)
OSStatInit(); /* Call this function in a task */
#endif
#ifdef CPU_CFG_INT_DIS_MEAS_EN
CPU_IntDisMeasMaxCurReset();
#endif
while (1)
{
printf("led task run\r\n");
display_task_info();
rtos_task_delay_ms(500);
}
}
/*
* Example
*/
void uCos2_V293X_start(void)
{
INT8U err;
printf("uCos2 with LWIP demo run on SAME70Q21\r\n");
Mem_Init(); /* Initialize Memory Management Module */
Math_Init(); /* Initialize Mathematical Module */
OS_CPU_SysTickInitFreq(CONF_CPU_FREQUENCY); /* Initialize uC/OS-II periodic timer (SysTick).*/
OSInit(); /* Initialize uC/OS-II. */
CPU_Init(); /* Initialize CPU */
if(OS_ERR_NONE == OSTaskCreate(led_thread_entry, NULL,
&led_thread_stk[LEDRUN_THREAD_STKSZ/4 - 1],
(rtos_thread_t)LEDRUN_THREAD_PRIO)) {
OSTaskNameSet(LEDRUN_THREAD_PRIO, (INT8U *)led_task_name, &err);
}
/* Start multitasking (i.e. give control to uC/OS-II) */
OSStart();
}