Renesas GR-PEACH OpenCV Development / gr-peach-opencv-project-sd-card_update

Fork of gr-peach-opencv-project-sd-card by the do

Committer:
thedo
Date:
Fri Jul 21 01:26:54 2017 +0000
Revision:
167:2ee3e82cb6f5
Parent:
166:240bc5a0f42a
gr-peach-opencv-project-sd-card

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thedo 166:240bc5a0f42a 1 /*----------------------------------------------------------------------------
thedo 166:240bc5a0f42a 2 * RL-ARM - RTX
thedo 166:240bc5a0f42a 3 *----------------------------------------------------------------------------
thedo 166:240bc5a0f42a 4 * Name: RT_TASK.C
thedo 166:240bc5a0f42a 5 * Purpose: Task functions and system start up.
thedo 166:240bc5a0f42a 6 * Rev.: V4.60
thedo 166:240bc5a0f42a 7 *----------------------------------------------------------------------------
thedo 166:240bc5a0f42a 8 *
thedo 166:240bc5a0f42a 9 * Copyright (c) 1999-2009 KEIL, 2009-2015 ARM Germany GmbH
thedo 166:240bc5a0f42a 10 * All rights reserved.
thedo 166:240bc5a0f42a 11 * Redistribution and use in source and binary forms, with or without
thedo 166:240bc5a0f42a 12 * modification, are permitted provided that the following conditions are met:
thedo 166:240bc5a0f42a 13 * - Redistributions of source code must retain the above copyright
thedo 166:240bc5a0f42a 14 * notice, this list of conditions and the following disclaimer.
thedo 166:240bc5a0f42a 15 * - Redistributions in binary form must reproduce the above copyright
thedo 166:240bc5a0f42a 16 * notice, this list of conditions and the following disclaimer in the
thedo 166:240bc5a0f42a 17 * documentation and/or other materials provided with the distribution.
thedo 166:240bc5a0f42a 18 * - Neither the name of ARM nor the names of its contributors may be used
thedo 166:240bc5a0f42a 19 * to endorse or promote products derived from this software without
thedo 166:240bc5a0f42a 20 * specific prior written permission.
thedo 166:240bc5a0f42a 21 *
thedo 166:240bc5a0f42a 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
thedo 166:240bc5a0f42a 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
thedo 166:240bc5a0f42a 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
thedo 166:240bc5a0f42a 25 * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
thedo 166:240bc5a0f42a 26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
thedo 166:240bc5a0f42a 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
thedo 166:240bc5a0f42a 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
thedo 166:240bc5a0f42a 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
thedo 166:240bc5a0f42a 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
thedo 166:240bc5a0f42a 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
thedo 166:240bc5a0f42a 32 * POSSIBILITY OF SUCH DAMAGE.
thedo 166:240bc5a0f42a 33 *---------------------------------------------------------------------------*/
thedo 166:240bc5a0f42a 34
thedo 166:240bc5a0f42a 35 #include "rt_TypeDef.h"
thedo 166:240bc5a0f42a 36 #include "RTX_Conf.h"
thedo 166:240bc5a0f42a 37 #include "rt_System.h"
thedo 166:240bc5a0f42a 38 #include "rt_Task.h"
thedo 166:240bc5a0f42a 39 #include "rt_List.h"
thedo 166:240bc5a0f42a 40 #include "rt_MemBox.h"
thedo 166:240bc5a0f42a 41 #include "rt_Robin.h"
thedo 166:240bc5a0f42a 42 #include "rt_HAL_CM.h"
thedo 166:240bc5a0f42a 43
thedo 166:240bc5a0f42a 44 /*----------------------------------------------------------------------------
thedo 166:240bc5a0f42a 45 * Global Variables
thedo 166:240bc5a0f42a 46 *---------------------------------------------------------------------------*/
thedo 166:240bc5a0f42a 47
thedo 166:240bc5a0f42a 48 /* Running and next task info. */
thedo 166:240bc5a0f42a 49 struct OS_TSK os_tsk;
thedo 166:240bc5a0f42a 50
thedo 166:240bc5a0f42a 51 /* Task Control Blocks of idle demon */
thedo 166:240bc5a0f42a 52 struct OS_TCB os_idle_TCB;
thedo 166:240bc5a0f42a 53
thedo 166:240bc5a0f42a 54
thedo 166:240bc5a0f42a 55 /*----------------------------------------------------------------------------
thedo 166:240bc5a0f42a 56 * Local Functions
thedo 166:240bc5a0f42a 57 *---------------------------------------------------------------------------*/
thedo 166:240bc5a0f42a 58
thedo 166:240bc5a0f42a 59 OS_TID rt_get_TID (void) {
thedo 166:240bc5a0f42a 60 U32 tid;
thedo 166:240bc5a0f42a 61
thedo 166:240bc5a0f42a 62 for (tid = 1; tid <= os_maxtaskrun; tid++) {
thedo 166:240bc5a0f42a 63 if (os_active_TCB[tid-1] == NULL) {
thedo 166:240bc5a0f42a 64 return ((OS_TID)tid);
thedo 166:240bc5a0f42a 65 }
thedo 166:240bc5a0f42a 66 }
thedo 166:240bc5a0f42a 67 return (0);
thedo 166:240bc5a0f42a 68 }
thedo 166:240bc5a0f42a 69
thedo 166:240bc5a0f42a 70 #if defined (__CC_ARM) && !defined (__MICROLIB)
thedo 166:240bc5a0f42a 71 /*--------------------------- __user_perthread_libspace ---------------------*/
thedo 166:240bc5a0f42a 72 extern void *__libspace_start;
thedo 166:240bc5a0f42a 73
thedo 166:240bc5a0f42a 74 void *__user_perthread_libspace (void) {
thedo 166:240bc5a0f42a 75 /* Provide a separate libspace for each task. */
thedo 166:240bc5a0f42a 76 if (os_tsk.run == NULL) {
thedo 166:240bc5a0f42a 77 /* RTX not running yet. */
thedo 166:240bc5a0f42a 78 return (&__libspace_start);
thedo 166:240bc5a0f42a 79 }
thedo 166:240bc5a0f42a 80 return (void *)(os_tsk.run->std_libspace);
thedo 166:240bc5a0f42a 81 }
thedo 166:240bc5a0f42a 82 #endif
thedo 166:240bc5a0f42a 83
thedo 166:240bc5a0f42a 84 /*--------------------------- rt_init_context -------------------------------*/
thedo 166:240bc5a0f42a 85
thedo 166:240bc5a0f42a 86 void rt_init_context (P_TCB p_TCB, U8 priority, FUNCP task_body) {
thedo 166:240bc5a0f42a 87 /* Initialize general part of the Task Control Block. */
thedo 166:240bc5a0f42a 88 p_TCB->cb_type = TCB;
thedo 166:240bc5a0f42a 89 p_TCB->state = READY;
thedo 166:240bc5a0f42a 90 p_TCB->prio = priority;
thedo 166:240bc5a0f42a 91 p_TCB->p_lnk = NULL;
thedo 166:240bc5a0f42a 92 p_TCB->p_rlnk = NULL;
thedo 166:240bc5a0f42a 93 p_TCB->p_dlnk = NULL;
thedo 166:240bc5a0f42a 94 p_TCB->p_blnk = NULL;
thedo 166:240bc5a0f42a 95 p_TCB->delta_time = 0;
thedo 166:240bc5a0f42a 96 p_TCB->interval_time = 0;
thedo 166:240bc5a0f42a 97 p_TCB->events = 0;
thedo 166:240bc5a0f42a 98 p_TCB->waits = 0;
thedo 166:240bc5a0f42a 99 p_TCB->stack_frame = 0;
thedo 166:240bc5a0f42a 100
thedo 166:240bc5a0f42a 101 rt_init_stack (p_TCB, task_body);
thedo 166:240bc5a0f42a 102 }
thedo 166:240bc5a0f42a 103
thedo 166:240bc5a0f42a 104
thedo 166:240bc5a0f42a 105 /*--------------------------- rt_switch_req ---------------------------------*/
thedo 166:240bc5a0f42a 106
thedo 166:240bc5a0f42a 107 void rt_switch_req (P_TCB p_new) {
thedo 166:240bc5a0f42a 108 /* Switch to next task (identified by "p_new"). */
thedo 166:240bc5a0f42a 109 os_tsk.new_tsk = p_new;
thedo 166:240bc5a0f42a 110 p_new->state = RUNNING;
thedo 166:240bc5a0f42a 111 DBG_TASK_SWITCH(p_new->task_id);
thedo 166:240bc5a0f42a 112 }
thedo 166:240bc5a0f42a 113
thedo 166:240bc5a0f42a 114
thedo 166:240bc5a0f42a 115 /*--------------------------- rt_dispatch -----------------------------------*/
thedo 166:240bc5a0f42a 116
thedo 166:240bc5a0f42a 117 void rt_dispatch (P_TCB next_TCB) {
thedo 166:240bc5a0f42a 118 /* Dispatch next task if any identified or dispatch highest ready task */
thedo 166:240bc5a0f42a 119 /* "next_TCB" identifies a task to run or has value NULL (=no next task) */
thedo 166:240bc5a0f42a 120 if (next_TCB == NULL) {
thedo 166:240bc5a0f42a 121 /* Running task was blocked: continue with highest ready task */
thedo 166:240bc5a0f42a 122 next_TCB = rt_get_first (&os_rdy);
thedo 166:240bc5a0f42a 123 rt_switch_req (next_TCB);
thedo 166:240bc5a0f42a 124 }
thedo 166:240bc5a0f42a 125 else {
thedo 166:240bc5a0f42a 126 /* Check which task continues */
thedo 166:240bc5a0f42a 127 if (next_TCB->prio > os_tsk.run->prio) {
thedo 166:240bc5a0f42a 128 /* preempt running task */
thedo 166:240bc5a0f42a 129 rt_put_rdy_first (os_tsk.run);
thedo 166:240bc5a0f42a 130 os_tsk.run->state = READY;
thedo 166:240bc5a0f42a 131 rt_switch_req (next_TCB);
thedo 166:240bc5a0f42a 132 }
thedo 166:240bc5a0f42a 133 else {
thedo 166:240bc5a0f42a 134 /* put next task into ready list, no task switch takes place */
thedo 166:240bc5a0f42a 135 next_TCB->state = READY;
thedo 166:240bc5a0f42a 136 rt_put_prio (&os_rdy, next_TCB);
thedo 166:240bc5a0f42a 137 }
thedo 166:240bc5a0f42a 138 }
thedo 166:240bc5a0f42a 139 }
thedo 166:240bc5a0f42a 140
thedo 166:240bc5a0f42a 141
thedo 166:240bc5a0f42a 142 /*--------------------------- rt_block --------------------------------------*/
thedo 166:240bc5a0f42a 143
thedo 166:240bc5a0f42a 144 void rt_block (U16 timeout, U8 block_state) {
thedo 166:240bc5a0f42a 145 /* Block running task and choose next ready task. */
thedo 166:240bc5a0f42a 146 /* "timeout" sets a time-out value or is 0xffff (=no time-out). */
thedo 166:240bc5a0f42a 147 /* "block_state" defines the appropriate task state */
thedo 166:240bc5a0f42a 148 P_TCB next_TCB;
thedo 166:240bc5a0f42a 149
thedo 166:240bc5a0f42a 150 if (timeout) {
thedo 166:240bc5a0f42a 151 if (timeout < 0xffff) {
thedo 166:240bc5a0f42a 152 rt_put_dly (os_tsk.run, timeout);
thedo 166:240bc5a0f42a 153 }
thedo 166:240bc5a0f42a 154 os_tsk.run->state = block_state;
thedo 166:240bc5a0f42a 155 next_TCB = rt_get_first (&os_rdy);
thedo 166:240bc5a0f42a 156 rt_switch_req (next_TCB);
thedo 166:240bc5a0f42a 157 }
thedo 166:240bc5a0f42a 158 }
thedo 166:240bc5a0f42a 159
thedo 166:240bc5a0f42a 160
thedo 166:240bc5a0f42a 161 /*--------------------------- rt_tsk_pass -----------------------------------*/
thedo 166:240bc5a0f42a 162
thedo 166:240bc5a0f42a 163 void rt_tsk_pass (void) {
thedo 166:240bc5a0f42a 164 /* Allow tasks of same priority level to run cooperatively.*/
thedo 166:240bc5a0f42a 165 P_TCB p_new;
thedo 166:240bc5a0f42a 166
thedo 166:240bc5a0f42a 167 p_new = rt_get_same_rdy_prio();
thedo 166:240bc5a0f42a 168 if (p_new != NULL) {
thedo 166:240bc5a0f42a 169 rt_put_prio ((P_XCB)&os_rdy, os_tsk.run);
thedo 166:240bc5a0f42a 170 os_tsk.run->state = READY;
thedo 166:240bc5a0f42a 171 rt_switch_req (p_new);
thedo 166:240bc5a0f42a 172 }
thedo 166:240bc5a0f42a 173 }
thedo 166:240bc5a0f42a 174
thedo 166:240bc5a0f42a 175
thedo 166:240bc5a0f42a 176 /*--------------------------- rt_tsk_self -----------------------------------*/
thedo 166:240bc5a0f42a 177
thedo 166:240bc5a0f42a 178 OS_TID rt_tsk_self (void) {
thedo 166:240bc5a0f42a 179 /* Return own task identifier value. */
thedo 166:240bc5a0f42a 180 if (os_tsk.run == NULL) {
thedo 166:240bc5a0f42a 181 return (0);
thedo 166:240bc5a0f42a 182 }
thedo 166:240bc5a0f42a 183 return (os_tsk.run->task_id);
thedo 166:240bc5a0f42a 184 }
thedo 166:240bc5a0f42a 185
thedo 166:240bc5a0f42a 186
thedo 166:240bc5a0f42a 187 /*--------------------------- rt_tsk_prio -----------------------------------*/
thedo 166:240bc5a0f42a 188
thedo 166:240bc5a0f42a 189 OS_RESULT rt_tsk_prio (OS_TID task_id, U8 new_prio) {
thedo 166:240bc5a0f42a 190 /* Change execution priority of a task to "new_prio". */
thedo 166:240bc5a0f42a 191 P_TCB p_task;
thedo 166:240bc5a0f42a 192
thedo 166:240bc5a0f42a 193 if (task_id == 0) {
thedo 166:240bc5a0f42a 194 /* Change execution priority of calling task. */
thedo 166:240bc5a0f42a 195 os_tsk.run->prio = new_prio;
thedo 166:240bc5a0f42a 196 run:if (rt_rdy_prio() > new_prio) {
thedo 166:240bc5a0f42a 197 rt_put_prio (&os_rdy, os_tsk.run);
thedo 166:240bc5a0f42a 198 os_tsk.run->state = READY;
thedo 166:240bc5a0f42a 199 rt_dispatch (NULL);
thedo 166:240bc5a0f42a 200 }
thedo 166:240bc5a0f42a 201 return (OS_R_OK);
thedo 166:240bc5a0f42a 202 }
thedo 166:240bc5a0f42a 203
thedo 166:240bc5a0f42a 204 /* Find the task in the "os_active_TCB" array. */
thedo 166:240bc5a0f42a 205 if (task_id > os_maxtaskrun || os_active_TCB[task_id-1] == NULL) {
thedo 166:240bc5a0f42a 206 /* Task with "task_id" not found or not started. */
thedo 166:240bc5a0f42a 207 return (OS_R_NOK);
thedo 166:240bc5a0f42a 208 }
thedo 166:240bc5a0f42a 209 p_task = os_active_TCB[task_id-1];
thedo 166:240bc5a0f42a 210 p_task->prio = new_prio;
thedo 166:240bc5a0f42a 211 if (p_task == os_tsk.run) {
thedo 166:240bc5a0f42a 212 goto run;
thedo 166:240bc5a0f42a 213 }
thedo 166:240bc5a0f42a 214 rt_resort_prio (p_task);
thedo 166:240bc5a0f42a 215 if (p_task->state == READY) {
thedo 166:240bc5a0f42a 216 /* Task enqueued in a ready list. */
thedo 166:240bc5a0f42a 217 p_task = rt_get_first (&os_rdy);
thedo 166:240bc5a0f42a 218 rt_dispatch (p_task);
thedo 166:240bc5a0f42a 219 }
thedo 166:240bc5a0f42a 220 return (OS_R_OK);
thedo 166:240bc5a0f42a 221 }
thedo 166:240bc5a0f42a 222
thedo 166:240bc5a0f42a 223 /*--------------------------- rt_tsk_delete ---------------------------------*/
thedo 166:240bc5a0f42a 224
thedo 166:240bc5a0f42a 225 OS_RESULT rt_tsk_delete (OS_TID task_id) {
thedo 166:240bc5a0f42a 226 /* Terminate the task identified with "task_id". */
thedo 166:240bc5a0f42a 227 P_TCB task_context;
thedo 166:240bc5a0f42a 228
thedo 166:240bc5a0f42a 229 if (task_id == 0 || task_id == os_tsk.run->task_id) {
thedo 166:240bc5a0f42a 230 /* Terminate itself. */
thedo 166:240bc5a0f42a 231 os_tsk.run->state = INACTIVE;
thedo 166:240bc5a0f42a 232 os_tsk.run->tsk_stack = 0;
thedo 166:240bc5a0f42a 233 rt_stk_check ();
thedo 166:240bc5a0f42a 234 os_active_TCB[os_tsk.run->task_id-1] = NULL;
thedo 166:240bc5a0f42a 235
thedo 166:240bc5a0f42a 236 os_tsk.run->stack = NULL;
thedo 166:240bc5a0f42a 237 DBG_TASK_NOTIFY(os_tsk.run, __FALSE);
thedo 166:240bc5a0f42a 238 os_tsk.run = NULL;
thedo 166:240bc5a0f42a 239 rt_dispatch (NULL);
thedo 166:240bc5a0f42a 240 /* The program should never come to this point. */
thedo 166:240bc5a0f42a 241 }
thedo 166:240bc5a0f42a 242 else {
thedo 166:240bc5a0f42a 243 /* Find the task in the "os_active_TCB" array. */
thedo 166:240bc5a0f42a 244 if (task_id > os_maxtaskrun || os_active_TCB[task_id-1] == NULL) {
thedo 166:240bc5a0f42a 245 /* Task with "task_id" not found or not started. */
thedo 166:240bc5a0f42a 246 return (OS_R_NOK);
thedo 166:240bc5a0f42a 247 }
thedo 166:240bc5a0f42a 248 task_context = os_active_TCB[task_id-1];
thedo 166:240bc5a0f42a 249 rt_rmv_list (task_context);
thedo 166:240bc5a0f42a 250 rt_rmv_dly (task_context);
thedo 166:240bc5a0f42a 251 os_active_TCB[task_id-1] = NULL;
thedo 166:240bc5a0f42a 252
thedo 166:240bc5a0f42a 253 task_context->stack = NULL;
thedo 166:240bc5a0f42a 254 DBG_TASK_NOTIFY(task_context, __FALSE);
thedo 166:240bc5a0f42a 255 }
thedo 166:240bc5a0f42a 256 return (OS_R_OK);
thedo 166:240bc5a0f42a 257 }
thedo 166:240bc5a0f42a 258
thedo 166:240bc5a0f42a 259
thedo 166:240bc5a0f42a 260 /*--------------------------- rt_sys_init -----------------------------------*/
thedo 166:240bc5a0f42a 261
thedo 166:240bc5a0f42a 262 #ifdef __CMSIS_RTOS
thedo 166:240bc5a0f42a 263 void rt_sys_init (void) {
thedo 166:240bc5a0f42a 264 #else
thedo 166:240bc5a0f42a 265 void rt_sys_init (FUNCP first_task, U32 prio_stksz, void *stk) {
thedo 166:240bc5a0f42a 266 #endif
thedo 166:240bc5a0f42a 267 /* Initialize system and start up task declared with "first_task". */
thedo 166:240bc5a0f42a 268 U32 i;
thedo 166:240bc5a0f42a 269
thedo 166:240bc5a0f42a 270 DBG_INIT();
thedo 166:240bc5a0f42a 271
thedo 166:240bc5a0f42a 272 /* Initialize dynamic memory and task TCB pointers to NULL. */
thedo 166:240bc5a0f42a 273 for (i = 0; i < os_maxtaskrun; i++) {
thedo 166:240bc5a0f42a 274 os_active_TCB[i] = NULL;
thedo 166:240bc5a0f42a 275 }
thedo 166:240bc5a0f42a 276
thedo 166:240bc5a0f42a 277 /* Set up TCB of idle demon */
thedo 166:240bc5a0f42a 278 os_idle_TCB.task_id = 255;
thedo 166:240bc5a0f42a 279 os_idle_TCB.priv_stack = idle_task_stack_size;
thedo 166:240bc5a0f42a 280 os_idle_TCB.stack = idle_task_stack;
thedo 166:240bc5a0f42a 281 rt_init_context (&os_idle_TCB, 0, os_idle_demon);
thedo 166:240bc5a0f42a 282
thedo 166:240bc5a0f42a 283 /* Set up ready list: initially empty */
thedo 166:240bc5a0f42a 284 os_rdy.cb_type = HCB;
thedo 166:240bc5a0f42a 285 os_rdy.p_lnk = NULL;
thedo 166:240bc5a0f42a 286 /* Set up delay list: initially empty */
thedo 166:240bc5a0f42a 287 os_dly.cb_type = HCB;
thedo 166:240bc5a0f42a 288 os_dly.p_dlnk = NULL;
thedo 166:240bc5a0f42a 289 os_dly.p_blnk = NULL;
thedo 166:240bc5a0f42a 290 os_dly.delta_time = 0;
thedo 166:240bc5a0f42a 291
thedo 166:240bc5a0f42a 292 /* Fix SP and systemvariables to assume idle task is running */
thedo 166:240bc5a0f42a 293 /* Transform main program into idle task by assuming idle TCB */
thedo 166:240bc5a0f42a 294 #ifndef __CMSIS_RTOS
thedo 166:240bc5a0f42a 295 rt_set_PSP (os_idle_TCB.tsk_stack);
thedo 166:240bc5a0f42a 296 #endif
thedo 166:240bc5a0f42a 297 os_tsk.run = &os_idle_TCB;
thedo 166:240bc5a0f42a 298 os_tsk.run->state = RUNNING;
thedo 166:240bc5a0f42a 299
thedo 166:240bc5a0f42a 300 /* Initialize ps queue */
thedo 166:240bc5a0f42a 301 os_psq->first = 0;
thedo 166:240bc5a0f42a 302 os_psq->last = 0;
thedo 166:240bc5a0f42a 303 os_psq->size = os_fifo_size;
thedo 166:240bc5a0f42a 304
thedo 166:240bc5a0f42a 305 rt_init_robin ();
thedo 166:240bc5a0f42a 306
thedo 166:240bc5a0f42a 307 /* Intitialize SVC and PendSV */
thedo 166:240bc5a0f42a 308 rt_svc_init ();
thedo 166:240bc5a0f42a 309
thedo 166:240bc5a0f42a 310 #ifndef __CMSIS_RTOS
thedo 166:240bc5a0f42a 311 /* Intitialize and start system clock timer */
thedo 166:240bc5a0f42a 312 os_tick_irqn = os_tick_init ();
thedo 166:240bc5a0f42a 313 if (os_tick_irqn >= 0) {
thedo 166:240bc5a0f42a 314 OS_X_INIT(os_tick_irqn);
thedo 166:240bc5a0f42a 315 }
thedo 166:240bc5a0f42a 316
thedo 166:240bc5a0f42a 317 /* Start up first user task before entering the endless loop */
thedo 166:240bc5a0f42a 318 rt_tsk_create (first_task, prio_stksz, stk, NULL);
thedo 166:240bc5a0f42a 319 #endif
thedo 166:240bc5a0f42a 320 }
thedo 166:240bc5a0f42a 321
thedo 166:240bc5a0f42a 322
thedo 166:240bc5a0f42a 323 /*--------------------------- rt_sys_start ----------------------------------*/
thedo 166:240bc5a0f42a 324
thedo 166:240bc5a0f42a 325 #ifdef __CMSIS_RTOS
thedo 166:240bc5a0f42a 326 void rt_sys_start (void) {
thedo 166:240bc5a0f42a 327 /* Start system */
thedo 166:240bc5a0f42a 328
thedo 166:240bc5a0f42a 329 /* Intitialize and start system clock timer */
thedo 166:240bc5a0f42a 330 os_tick_irqn = os_tick_init ();
thedo 166:240bc5a0f42a 331 if (os_tick_irqn >= 0) {
thedo 166:240bc5a0f42a 332 OS_X_INIT(os_tick_irqn);
thedo 166:240bc5a0f42a 333 }
thedo 166:240bc5a0f42a 334 extern void RestoreContext();
thedo 166:240bc5a0f42a 335 RestoreContext(); // Start the first task
thedo 166:240bc5a0f42a 336 }
thedo 166:240bc5a0f42a 337 #endif
thedo 166:240bc5a0f42a 338
thedo 166:240bc5a0f42a 339 /*----------------------------------------------------------------------------
thedo 166:240bc5a0f42a 340 * end of file
thedo 166:240bc5a0f42a 341 *---------------------------------------------------------------------------*/