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_LIST.C
sam_grove 5:3f93dd1d4cb3 5 * Purpose: Functions for the management of different lists
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_List.h"
sam_grove 5:3f93dd1d4cb3 39 #include "rt_Task.h"
sam_grove 5:3f93dd1d4cb3 40 #include "rt_Time.h"
sam_grove 5:3f93dd1d4cb3 41 #include "rt_HAL_CM.h"
sam_grove 5:3f93dd1d4cb3 42
sam_grove 5:3f93dd1d4cb3 43 /*----------------------------------------------------------------------------
sam_grove 5:3f93dd1d4cb3 44 * Global Variables
sam_grove 5:3f93dd1d4cb3 45 *---------------------------------------------------------------------------*/
sam_grove 5:3f93dd1d4cb3 46
sam_grove 5:3f93dd1d4cb3 47 /* List head of chained ready tasks */
sam_grove 5:3f93dd1d4cb3 48 struct OS_XCB os_rdy;
sam_grove 5:3f93dd1d4cb3 49 /* List head of chained delay tasks */
sam_grove 5:3f93dd1d4cb3 50 struct OS_XCB os_dly;
sam_grove 5:3f93dd1d4cb3 51
sam_grove 5:3f93dd1d4cb3 52
sam_grove 5:3f93dd1d4cb3 53 /*----------------------------------------------------------------------------
sam_grove 5:3f93dd1d4cb3 54 * Functions
sam_grove 5:3f93dd1d4cb3 55 *---------------------------------------------------------------------------*/
sam_grove 5:3f93dd1d4cb3 56
sam_grove 5:3f93dd1d4cb3 57
sam_grove 5:3f93dd1d4cb3 58 /*--------------------------- rt_put_prio -----------------------------------*/
sam_grove 5:3f93dd1d4cb3 59
sam_grove 5:3f93dd1d4cb3 60 void rt_put_prio (P_XCB p_CB, P_TCB p_task) {
sam_grove 5:3f93dd1d4cb3 61 /* Put task identified with "p_task" into list ordered by priority. */
sam_grove 5:3f93dd1d4cb3 62 /* "p_CB" points to head of list; list has always an element at end with */
sam_grove 5:3f93dd1d4cb3 63 /* a priority less than "p_task->prio". */
sam_grove 5:3f93dd1d4cb3 64 P_TCB p_CB2;
sam_grove 5:3f93dd1d4cb3 65 U32 prio;
sam_grove 5:3f93dd1d4cb3 66 BOOL sem_mbx = __FALSE;
sam_grove 5:3f93dd1d4cb3 67
sam_grove 5:3f93dd1d4cb3 68 if (p_CB->cb_type == SCB || p_CB->cb_type == MCB || p_CB->cb_type == MUCB) {
sam_grove 5:3f93dd1d4cb3 69 sem_mbx = __TRUE;
sam_grove 5:3f93dd1d4cb3 70 }
sam_grove 5:3f93dd1d4cb3 71 prio = p_task->prio;
sam_grove 5:3f93dd1d4cb3 72 p_CB2 = p_CB->p_lnk;
sam_grove 5:3f93dd1d4cb3 73 /* Search for an entry in the list */
sam_grove 5:3f93dd1d4cb3 74 while (p_CB2 != NULL && prio <= p_CB2->prio) {
sam_grove 5:3f93dd1d4cb3 75 p_CB = (P_XCB)p_CB2;
sam_grove 5:3f93dd1d4cb3 76 p_CB2 = p_CB2->p_lnk;
sam_grove 5:3f93dd1d4cb3 77 }
sam_grove 5:3f93dd1d4cb3 78 /* Entry found, insert the task into the list */
sam_grove 5:3f93dd1d4cb3 79 p_task->p_lnk = p_CB2;
sam_grove 5:3f93dd1d4cb3 80 p_CB->p_lnk = p_task;
sam_grove 5:3f93dd1d4cb3 81 if (sem_mbx) {
sam_grove 5:3f93dd1d4cb3 82 if (p_CB2 != NULL) {
sam_grove 5:3f93dd1d4cb3 83 p_CB2->p_rlnk = p_task;
sam_grove 5:3f93dd1d4cb3 84 }
sam_grove 5:3f93dd1d4cb3 85 p_task->p_rlnk = (P_TCB)p_CB;
sam_grove 5:3f93dd1d4cb3 86 }
sam_grove 5:3f93dd1d4cb3 87 else {
sam_grove 5:3f93dd1d4cb3 88 p_task->p_rlnk = NULL;
sam_grove 5:3f93dd1d4cb3 89 }
sam_grove 5:3f93dd1d4cb3 90 }
sam_grove 5:3f93dd1d4cb3 91
sam_grove 5:3f93dd1d4cb3 92
sam_grove 5:3f93dd1d4cb3 93 /*--------------------------- rt_get_first ----------------------------------*/
sam_grove 5:3f93dd1d4cb3 94
sam_grove 5:3f93dd1d4cb3 95 P_TCB rt_get_first (P_XCB p_CB) {
sam_grove 5:3f93dd1d4cb3 96 /* Get task at head of list: it is the task with highest priority. */
sam_grove 5:3f93dd1d4cb3 97 /* "p_CB" points to head of list. */
sam_grove 5:3f93dd1d4cb3 98 P_TCB p_first;
sam_grove 5:3f93dd1d4cb3 99
sam_grove 5:3f93dd1d4cb3 100 p_first = p_CB->p_lnk;
sam_grove 5:3f93dd1d4cb3 101 p_CB->p_lnk = p_first->p_lnk;
sam_grove 5:3f93dd1d4cb3 102 if (p_CB->cb_type == SCB || p_CB->cb_type == MCB || p_CB->cb_type == MUCB) {
sam_grove 5:3f93dd1d4cb3 103 if (p_first->p_lnk != NULL) {
sam_grove 5:3f93dd1d4cb3 104 p_first->p_lnk->p_rlnk = (P_TCB)p_CB;
sam_grove 5:3f93dd1d4cb3 105 p_first->p_lnk = NULL;
sam_grove 5:3f93dd1d4cb3 106 }
sam_grove 5:3f93dd1d4cb3 107 p_first->p_rlnk = NULL;
sam_grove 5:3f93dd1d4cb3 108 }
sam_grove 5:3f93dd1d4cb3 109 else {
sam_grove 5:3f93dd1d4cb3 110 p_first->p_lnk = NULL;
sam_grove 5:3f93dd1d4cb3 111 }
sam_grove 5:3f93dd1d4cb3 112 return (p_first);
sam_grove 5:3f93dd1d4cb3 113 }
sam_grove 5:3f93dd1d4cb3 114
sam_grove 5:3f93dd1d4cb3 115
sam_grove 5:3f93dd1d4cb3 116 /*--------------------------- rt_put_rdy_first ------------------------------*/
sam_grove 5:3f93dd1d4cb3 117
sam_grove 5:3f93dd1d4cb3 118 void rt_put_rdy_first (P_TCB p_task) {
sam_grove 5:3f93dd1d4cb3 119 /* Put task identified with "p_task" at the head of the ready list. The */
sam_grove 5:3f93dd1d4cb3 120 /* task must have at least a priority equal to highest priority in list. */
sam_grove 5:3f93dd1d4cb3 121 p_task->p_lnk = os_rdy.p_lnk;
sam_grove 5:3f93dd1d4cb3 122 p_task->p_rlnk = NULL;
sam_grove 5:3f93dd1d4cb3 123 os_rdy.p_lnk = p_task;
sam_grove 5:3f93dd1d4cb3 124 }
sam_grove 5:3f93dd1d4cb3 125
sam_grove 5:3f93dd1d4cb3 126
sam_grove 5:3f93dd1d4cb3 127 /*--------------------------- rt_get_same_rdy_prio --------------------------*/
sam_grove 5:3f93dd1d4cb3 128
sam_grove 5:3f93dd1d4cb3 129 P_TCB rt_get_same_rdy_prio (void) {
sam_grove 5:3f93dd1d4cb3 130 /* Remove a task of same priority from ready list if any exists. Other- */
sam_grove 5:3f93dd1d4cb3 131 /* wise return NULL. */
sam_grove 5:3f93dd1d4cb3 132 P_TCB p_first;
sam_grove 5:3f93dd1d4cb3 133
sam_grove 5:3f93dd1d4cb3 134 p_first = os_rdy.p_lnk;
sam_grove 5:3f93dd1d4cb3 135 if (p_first->prio == os_tsk.run->prio) {
sam_grove 5:3f93dd1d4cb3 136 os_rdy.p_lnk = os_rdy.p_lnk->p_lnk;
sam_grove 5:3f93dd1d4cb3 137 return (p_first);
sam_grove 5:3f93dd1d4cb3 138 }
sam_grove 5:3f93dd1d4cb3 139 return (NULL);
sam_grove 5:3f93dd1d4cb3 140 }
sam_grove 5:3f93dd1d4cb3 141
sam_grove 5:3f93dd1d4cb3 142
sam_grove 5:3f93dd1d4cb3 143 /*--------------------------- rt_resort_prio --------------------------------*/
sam_grove 5:3f93dd1d4cb3 144
sam_grove 5:3f93dd1d4cb3 145 void rt_resort_prio (P_TCB p_task) {
sam_grove 5:3f93dd1d4cb3 146 /* Re-sort ordered lists after the priority of 'p_task' has changed. */
sam_grove 5:3f93dd1d4cb3 147 P_TCB p_CB;
sam_grove 5:3f93dd1d4cb3 148
sam_grove 5:3f93dd1d4cb3 149 if (p_task->p_rlnk == NULL) {
sam_grove 5:3f93dd1d4cb3 150 if (p_task->state == READY) {
sam_grove 5:3f93dd1d4cb3 151 /* Task is chained into READY list. */
sam_grove 5:3f93dd1d4cb3 152 p_CB = (P_TCB)&os_rdy;
sam_grove 5:3f93dd1d4cb3 153 goto res;
sam_grove 5:3f93dd1d4cb3 154 }
sam_grove 5:3f93dd1d4cb3 155 }
sam_grove 5:3f93dd1d4cb3 156 else {
sam_grove 5:3f93dd1d4cb3 157 p_CB = p_task->p_rlnk;
sam_grove 5:3f93dd1d4cb3 158 while (p_CB->cb_type == TCB) {
sam_grove 5:3f93dd1d4cb3 159 /* Find a header of this task chain list. */
sam_grove 5:3f93dd1d4cb3 160 p_CB = p_CB->p_rlnk;
sam_grove 5:3f93dd1d4cb3 161 }
sam_grove 5:3f93dd1d4cb3 162 res:rt_rmv_list (p_task);
sam_grove 5:3f93dd1d4cb3 163 rt_put_prio ((P_XCB)p_CB, p_task);
sam_grove 5:3f93dd1d4cb3 164 }
sam_grove 5:3f93dd1d4cb3 165 }
sam_grove 5:3f93dd1d4cb3 166
sam_grove 5:3f93dd1d4cb3 167
sam_grove 5:3f93dd1d4cb3 168 /*--------------------------- rt_put_dly ------------------------------------*/
sam_grove 5:3f93dd1d4cb3 169
sam_grove 5:3f93dd1d4cb3 170 void rt_put_dly (P_TCB p_task, U16 delay) {
sam_grove 5:3f93dd1d4cb3 171 /* Put a task identified with "p_task" into chained delay wait list using */
sam_grove 5:3f93dd1d4cb3 172 /* a delay value of "delay". */
sam_grove 5:3f93dd1d4cb3 173 P_TCB p;
sam_grove 5:3f93dd1d4cb3 174 U32 delta,idelay = delay;
sam_grove 5:3f93dd1d4cb3 175
sam_grove 5:3f93dd1d4cb3 176 p = (P_TCB)&os_dly;
sam_grove 5:3f93dd1d4cb3 177 if (p->p_dlnk == NULL) {
sam_grove 5:3f93dd1d4cb3 178 /* Delay list empty */
sam_grove 5:3f93dd1d4cb3 179 delta = 0;
sam_grove 5:3f93dd1d4cb3 180 goto last;
sam_grove 5:3f93dd1d4cb3 181 }
sam_grove 5:3f93dd1d4cb3 182 delta = os_dly.delta_time;
sam_grove 5:3f93dd1d4cb3 183 while (delta < idelay) {
sam_grove 5:3f93dd1d4cb3 184 if (p->p_dlnk == NULL) {
sam_grove 5:3f93dd1d4cb3 185 /* End of list found */
sam_grove 5:3f93dd1d4cb3 186 last: p_task->p_dlnk = NULL;
sam_grove 5:3f93dd1d4cb3 187 p->p_dlnk = p_task;
sam_grove 5:3f93dd1d4cb3 188 p_task->p_blnk = p;
sam_grove 5:3f93dd1d4cb3 189 p->delta_time = (U16)(idelay - delta);
sam_grove 5:3f93dd1d4cb3 190 p_task->delta_time = 0;
sam_grove 5:3f93dd1d4cb3 191 return;
sam_grove 5:3f93dd1d4cb3 192 }
sam_grove 5:3f93dd1d4cb3 193 p = p->p_dlnk;
sam_grove 5:3f93dd1d4cb3 194 delta += p->delta_time;
sam_grove 5:3f93dd1d4cb3 195 }
sam_grove 5:3f93dd1d4cb3 196 /* Right place found */
sam_grove 5:3f93dd1d4cb3 197 p_task->p_dlnk = p->p_dlnk;
sam_grove 5:3f93dd1d4cb3 198 p->p_dlnk = p_task;
sam_grove 5:3f93dd1d4cb3 199 p_task->p_blnk = p;
sam_grove 5:3f93dd1d4cb3 200 if (p_task->p_dlnk != NULL) {
sam_grove 5:3f93dd1d4cb3 201 p_task->p_dlnk->p_blnk = p_task;
sam_grove 5:3f93dd1d4cb3 202 }
sam_grove 5:3f93dd1d4cb3 203 p_task->delta_time = (U16)(delta - idelay);
sam_grove 5:3f93dd1d4cb3 204 p->delta_time -= p_task->delta_time;
sam_grove 5:3f93dd1d4cb3 205 }
sam_grove 5:3f93dd1d4cb3 206
sam_grove 5:3f93dd1d4cb3 207
sam_grove 5:3f93dd1d4cb3 208 /*--------------------------- rt_dec_dly ------------------------------------*/
sam_grove 5:3f93dd1d4cb3 209
sam_grove 5:3f93dd1d4cb3 210 void rt_dec_dly (void) {
sam_grove 5:3f93dd1d4cb3 211 /* Decrement delta time of list head: remove tasks having a value of zero.*/
sam_grove 5:3f93dd1d4cb3 212 P_TCB p_rdy;
sam_grove 5:3f93dd1d4cb3 213
sam_grove 5:3f93dd1d4cb3 214 if (os_dly.p_dlnk == NULL) {
sam_grove 5:3f93dd1d4cb3 215 return;
sam_grove 5:3f93dd1d4cb3 216 }
sam_grove 5:3f93dd1d4cb3 217 os_dly.delta_time--;
sam_grove 5:3f93dd1d4cb3 218 while ((os_dly.delta_time == 0) && (os_dly.p_dlnk != NULL)) {
sam_grove 5:3f93dd1d4cb3 219 p_rdy = os_dly.p_dlnk;
sam_grove 5:3f93dd1d4cb3 220 if (p_rdy->p_rlnk != NULL) {
sam_grove 5:3f93dd1d4cb3 221 /* Task is really enqueued, remove task from semaphore/mailbox */
sam_grove 5:3f93dd1d4cb3 222 /* timeout waiting list. */
sam_grove 5:3f93dd1d4cb3 223 p_rdy->p_rlnk->p_lnk = p_rdy->p_lnk;
sam_grove 5:3f93dd1d4cb3 224 if (p_rdy->p_lnk != NULL) {
sam_grove 5:3f93dd1d4cb3 225 p_rdy->p_lnk->p_rlnk = p_rdy->p_rlnk;
sam_grove 5:3f93dd1d4cb3 226 p_rdy->p_lnk = NULL;
sam_grove 5:3f93dd1d4cb3 227 }
sam_grove 5:3f93dd1d4cb3 228 p_rdy->p_rlnk = NULL;
sam_grove 5:3f93dd1d4cb3 229 }
sam_grove 5:3f93dd1d4cb3 230 rt_put_prio (&os_rdy, p_rdy);
sam_grove 5:3f93dd1d4cb3 231 os_dly.delta_time = p_rdy->delta_time;
sam_grove 5:3f93dd1d4cb3 232 if (p_rdy->state == WAIT_ITV) {
sam_grove 5:3f93dd1d4cb3 233 /* Calculate the next time for interval wait. */
sam_grove 5:3f93dd1d4cb3 234 p_rdy->delta_time = p_rdy->interval_time + (U16)os_time;
sam_grove 5:3f93dd1d4cb3 235 }
sam_grove 5:3f93dd1d4cb3 236 p_rdy->state = READY;
sam_grove 5:3f93dd1d4cb3 237 os_dly.p_dlnk = p_rdy->p_dlnk;
sam_grove 5:3f93dd1d4cb3 238 if (p_rdy->p_dlnk != NULL) {
sam_grove 5:3f93dd1d4cb3 239 p_rdy->p_dlnk->p_blnk = (P_TCB)&os_dly;
sam_grove 5:3f93dd1d4cb3 240 p_rdy->p_dlnk = NULL;
sam_grove 5:3f93dd1d4cb3 241 }
sam_grove 5:3f93dd1d4cb3 242 p_rdy->p_blnk = NULL;
sam_grove 5:3f93dd1d4cb3 243 }
sam_grove 5:3f93dd1d4cb3 244 }
sam_grove 5:3f93dd1d4cb3 245
sam_grove 5:3f93dd1d4cb3 246
sam_grove 5:3f93dd1d4cb3 247 /*--------------------------- rt_rmv_list -----------------------------------*/
sam_grove 5:3f93dd1d4cb3 248
sam_grove 5:3f93dd1d4cb3 249 void rt_rmv_list (P_TCB p_task) {
sam_grove 5:3f93dd1d4cb3 250 /* Remove task identified with "p_task" from ready, semaphore or mailbox */
sam_grove 5:3f93dd1d4cb3 251 /* waiting list if enqueued. */
sam_grove 5:3f93dd1d4cb3 252 P_TCB p_b;
sam_grove 5:3f93dd1d4cb3 253
sam_grove 5:3f93dd1d4cb3 254 if (p_task->p_rlnk != NULL) {
sam_grove 5:3f93dd1d4cb3 255 /* A task is enqueued in semaphore / mailbox waiting list. */
sam_grove 5:3f93dd1d4cb3 256 p_task->p_rlnk->p_lnk = p_task->p_lnk;
sam_grove 5:3f93dd1d4cb3 257 if (p_task->p_lnk != NULL) {
sam_grove 5:3f93dd1d4cb3 258 p_task->p_lnk->p_rlnk = p_task->p_rlnk;
sam_grove 5:3f93dd1d4cb3 259 }
sam_grove 5:3f93dd1d4cb3 260 return;
sam_grove 5:3f93dd1d4cb3 261 }
sam_grove 5:3f93dd1d4cb3 262
sam_grove 5:3f93dd1d4cb3 263 p_b = (P_TCB)&os_rdy;
sam_grove 5:3f93dd1d4cb3 264 while (p_b != NULL) {
sam_grove 5:3f93dd1d4cb3 265 /* Search the ready list for task "p_task" */
sam_grove 5:3f93dd1d4cb3 266 if (p_b->p_lnk == p_task) {
sam_grove 5:3f93dd1d4cb3 267 p_b->p_lnk = p_task->p_lnk;
sam_grove 5:3f93dd1d4cb3 268 return;
sam_grove 5:3f93dd1d4cb3 269 }
sam_grove 5:3f93dd1d4cb3 270 p_b = p_b->p_lnk;
sam_grove 5:3f93dd1d4cb3 271 }
sam_grove 5:3f93dd1d4cb3 272 }
sam_grove 5:3f93dd1d4cb3 273
sam_grove 5:3f93dd1d4cb3 274
sam_grove 5:3f93dd1d4cb3 275 /*--------------------------- rt_rmv_dly ------------------------------------*/
sam_grove 5:3f93dd1d4cb3 276
sam_grove 5:3f93dd1d4cb3 277 void rt_rmv_dly (P_TCB p_task) {
sam_grove 5:3f93dd1d4cb3 278 /* Remove task identified with "p_task" from delay list if enqueued. */
sam_grove 5:3f93dd1d4cb3 279 P_TCB p_b;
sam_grove 5:3f93dd1d4cb3 280
sam_grove 5:3f93dd1d4cb3 281 p_b = p_task->p_blnk;
sam_grove 5:3f93dd1d4cb3 282 if (p_b != NULL) {
sam_grove 5:3f93dd1d4cb3 283 /* Task is really enqueued */
sam_grove 5:3f93dd1d4cb3 284 p_b->p_dlnk = p_task->p_dlnk;
sam_grove 5:3f93dd1d4cb3 285 if (p_task->p_dlnk != NULL) {
sam_grove 5:3f93dd1d4cb3 286 /* 'p_task' is in the middle of list */
sam_grove 5:3f93dd1d4cb3 287 p_b->delta_time += p_task->delta_time;
sam_grove 5:3f93dd1d4cb3 288 p_task->p_dlnk->p_blnk = p_b;
sam_grove 5:3f93dd1d4cb3 289 p_task->p_dlnk = NULL;
sam_grove 5:3f93dd1d4cb3 290 }
sam_grove 5:3f93dd1d4cb3 291 else {
sam_grove 5:3f93dd1d4cb3 292 /* 'p_task' is at the end of list */
sam_grove 5:3f93dd1d4cb3 293 p_b->delta_time = 0;
sam_grove 5:3f93dd1d4cb3 294 }
sam_grove 5:3f93dd1d4cb3 295 p_task->p_blnk = NULL;
sam_grove 5:3f93dd1d4cb3 296 }
sam_grove 5:3f93dd1d4cb3 297 }
sam_grove 5:3f93dd1d4cb3 298
sam_grove 5:3f93dd1d4cb3 299
sam_grove 5:3f93dd1d4cb3 300 /*--------------------------- rt_psq_enq ------------------------------------*/
sam_grove 5:3f93dd1d4cb3 301
sam_grove 5:3f93dd1d4cb3 302 void rt_psq_enq (OS_ID entry, U32 arg) {
sam_grove 5:3f93dd1d4cb3 303 /* Insert post service request "entry" into ps-queue. */
sam_grove 5:3f93dd1d4cb3 304 U32 idx;
sam_grove 5:3f93dd1d4cb3 305
sam_grove 5:3f93dd1d4cb3 306 idx = rt_inc_qi (os_psq->size, &os_psq->count, &os_psq->first);
sam_grove 5:3f93dd1d4cb3 307 if (idx < os_psq->size) {
sam_grove 5:3f93dd1d4cb3 308 os_psq->q[idx].id = entry;
sam_grove 5:3f93dd1d4cb3 309 os_psq->q[idx].arg = arg;
sam_grove 5:3f93dd1d4cb3 310 }
sam_grove 5:3f93dd1d4cb3 311 else {
sam_grove 5:3f93dd1d4cb3 312 os_error (OS_ERR_FIFO_OVF);
sam_grove 5:3f93dd1d4cb3 313 }
sam_grove 5:3f93dd1d4cb3 314 }
sam_grove 5:3f93dd1d4cb3 315
sam_grove 5:3f93dd1d4cb3 316
sam_grove 5:3f93dd1d4cb3 317 /*----------------------------------------------------------------------------
sam_grove 5:3f93dd1d4cb3 318 * end of file
sam_grove 5:3f93dd1d4cb3 319 *---------------------------------------------------------------------------*/
sam_grove 5:3f93dd1d4cb3 320