ProjetoBB

Dependencies:   F7_Ethernet WebSocketClient mbed mcp3008

Fork of Nucleo_F746ZG_Ethernet by Dieter Graef

Committer:
DieterGraef
Date:
Sat Jun 18 10:49:12 2016 +0000
Revision:
0:f9b6112278fe
Ethernet for the NUCLEO STM32F746 Board Testprogram uses DHCP and NTP to set the clock

Who changed what in which revision?

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