Integrating the ublox LISA C200 modem

Fork of SprintUSBModemHTTPClientTest by Donatien Garnier

Committer:
sam_grove
Date:
Thu Sep 26 00:44:20 2013 -0500
Revision:
5:3f93dd1d4cb3
Exported program and replaced contents of the repo with the source
to build and debug using keil mdk. Libs NOT upto date are lwip, lwip-sys
and socket. these have newer versions under mbed_official but were starting
from a know working point

Who changed what in which revision?

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