-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtos_start.c
166 lines (138 loc) · 5.33 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/****************************************************************************
* Afan SAME70 FreeRTOS rtos_start.c
* Author : Afan Vibrant (AfanVibrant@outlook.com)
*
* 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.h"
#include "rtos_start.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
static const char *led_task_name = "led task";
static xTaskHandle led_thread_id;
/****************************************************************************
* Private Functions Prototypes
****************************************************************************/
/****************************************************************************
* Public Functions Prototypes
****************************************************************************/
#if configGENERATE_RUN_TIME_STATS
volatile uint32_t ulHighFrequencyTimerTicks;
#endif
/* Prototypes for the standard FreeRTOS callback/hook functions implemented
within this file. */
void vApplicationMallocFailedHook( void );
void vApplicationIdleHook( void );
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
void vApplicationTickHook( void );
void vApplicationMallocFailedHook( void )
{
/* Called if a call to pvPortMalloc() fails because there is insufficient
free memory available in the FreeRTOS heap. pvPortMalloc() is called
internally by FreeRTOS API functions that create tasks, queues, software
timers, and semaphores. The size of the FreeRTOS heap is set by the
configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
/* Force an assert. */
configASSERT( ( volatile void * ) NULL );
}
/*-----------------------------------------------------------*/
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
{
( void ) pcTaskName;
( void ) pxTask;
/* Run time stack overflow checking is performed if
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
function is called if a stack overflow is detected. */
/* Force an assert. */
configASSERT( ( volatile void * ) NULL );
}
/*-----------------------------------------------------------*/
void vApplicationIdleHook( void )
{
volatile size_t xFreeHeapSpace;
/* This is just a trivial example of an idle hook. It is called on each
cycle of the idle task. It must *NOT* attempt to block. In this case the
idle task just queries the amount of FreeRTOS heap that remains. See the
memory management section on the http://www.FreeRTOS.org web site for memory
management options. If there is a lot of heap memory free then the
configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up
RAM. */
xFreeHeapSpace = xPortGetFreeHeapSize();
/* Remove compiler warning about xFreeHeapSpace being set but never used. */
( void ) xFreeHeapSpace;
}
/*-----------------------------------------------------------*/
void vApplicationTickHook( void )
{
}
/*-----------------------------------------------------------*/
#if configGENERATE_RUN_TIME_STATS
void vConfigureTimerForRunTimeStats(void)
{
ulHighFrequencyTimerTicks = 0UL;
}
/*-----------------------------------------------------------*/
uint32_t vGetRunTimeCounterValue(void)
{
return ulHighFrequencyTimerTicks;
}
#endif
/****************************************************************************
* Name: led_thread_entry
*
* Description:
* Task for LED.
*
* Input Parameters:
* NONE.
*
* Returned Value:
* None.
*
****************************************************************************/
static void led_thread_entry(void *parameter)
{
(void)parameter;
while (1)
{
printf("led task run\r\n");
rtos_task_delay_ms(500);
}
}
/*
* Example
*/
void FREERTOS_V1000_start(void)
{
BaseType_t ret;
ret = xTaskCreate(led_thread_entry, led_task_name,
LEDRUN_THREAD_STKSZ, NULL,
LEDRUN_THREAD_PRIO, &led_thread_id);
if (ret != pdPASS) {
printf("%s task with priority-%d create fail\r\n", led_task_name, LEDRUN_THREAD_PRIO);
}
vTaskStartScheduler();
}