Contains example code to connect the mbed LPC1768 or FRDM-K64F devices to the IBM Internet of Things Cloud service via ethernet.

Dependencies:   C12832 MQTT LM75B MMA7660

Dependents:   MFT_IoT_demo_USB400 IBM_RFID

Committer:
samdanbury
Date:
Wed Aug 20 12:45:14 2014 +0000
Revision:
6:37b6d0d56190
Code completely changed to improve the structure, flow and memory usage of the application

Who changed what in which revision?

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