FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/nucleus/tmse.c @ 143:afceeeb2cba1
Our nuc-fw is destined to become gsm-fw, so I went ahead and did the big hg mv
| author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
|---|---|
| date | Tue, 12 Nov 2013 05:35:48 +0000 |
| parents | nuc-fw/nucleus/tmse.c@947b1f473960 |
| children |
comparison
equal
deleted
inserted
replaced
| 142:15d5977390c2 | 143:afceeeb2cba1 |
|---|---|
| 1 /*************************************************************************/ | |
| 2 /* */ | |
| 3 /* Copyright Mentor Graphics Corporation 2002 */ | |
| 4 /* All Rights Reserved. */ | |
| 5 /* */ | |
| 6 /* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS */ | |
| 7 /* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS */ | |
| 8 /* SUBJECT TO LICENSE TERMS. */ | |
| 9 /* */ | |
| 10 /*************************************************************************/ | |
| 11 | |
| 12 /*************************************************************************/ | |
| 13 /* */ | |
| 14 /* FILE NAME VERSION */ | |
| 15 /* */ | |
| 16 /* tmse.c Nucleus PLUS 1.14 */ | |
| 17 /* */ | |
| 18 /* COMPONENT */ | |
| 19 /* */ | |
| 20 /* TM - Timer Management */ | |
| 21 /* */ | |
| 22 /* DESCRIPTION */ | |
| 23 /* */ | |
| 24 /* This file contains the error checking routines for the functions */ | |
| 25 /* in the Timer component. This permits easy removal of error */ | |
| 26 /* checking logic when it is not needed. */ | |
| 27 /* */ | |
| 28 /* DATA STRUCTURES */ | |
| 29 /* */ | |
| 30 /* None */ | |
| 31 /* */ | |
| 32 /* FUNCTIONS */ | |
| 33 /* */ | |
| 34 /* TMSE_Create_Timer Create an application timer */ | |
| 35 /* TMSE_Delete_Timer Delete an application timer */ | |
| 36 /* TMSE_Reset_Timer Reset application timer */ | |
| 37 /* TMSE_Control_Timer Enable/Disable application */ | |
| 38 /* timer */ | |
| 39 /* */ | |
| 40 /* DEPENDENCIES */ | |
| 41 /* */ | |
| 42 /* cs_extr.h Common Service functions */ | |
| 43 /* tm_extr.h Timer functions */ | |
| 44 /* */ | |
| 45 /* HISTORY */ | |
| 46 /* */ | |
| 47 /* DATE REMARKS */ | |
| 48 /* */ | |
| 49 /* 03-01-1993 Created initial version 1.0 */ | |
| 50 /* 04-19-1993 Verified version 1.0 */ | |
| 51 /* 03-01-1994 Changed names of error checking */ | |
| 52 /* shell to match new conventions, */ | |
| 53 /* resulting in version 1.1 */ | |
| 54 /* */ | |
| 55 /* 03-18-1994 Verified version 1.1 */ | |
| 56 /* 04-17-1996 updated to version 1.2 */ | |
| 57 /* 03-24-1998 Released version 1.3 */ | |
| 58 /* 04-17-2002 Released version 1.13m */ | |
| 59 /* 11-07-2002 Released version 1.14 */ | |
| 60 /*************************************************************************/ | |
| 61 #define NU_SOURCE_FILE | |
| 62 | |
| 63 | |
| 64 #include "cs_extr.h" /* Common service functions */ | |
| 65 #include "tm_extr.h" /* Timer functions */ | |
| 66 | |
| 67 | |
| 68 | |
| 69 /*************************************************************************/ | |
| 70 /* */ | |
| 71 /* FUNCTION */ | |
| 72 /* */ | |
| 73 /* TMSE_Create_Timer */ | |
| 74 /* */ | |
| 75 /* DESCRIPTION */ | |
| 76 /* */ | |
| 77 /* This function performs error checking on the parameters supplied */ | |
| 78 /* to the create timer function. */ | |
| 79 /* */ | |
| 80 /* CALLED BY */ | |
| 81 /* */ | |
| 82 /* Application */ | |
| 83 /* */ | |
| 84 /* CALLS */ | |
| 85 /* */ | |
| 86 /* TMS_Create_Timer Actual create timer function */ | |
| 87 /* */ | |
| 88 /* INPUTS */ | |
| 89 /* */ | |
| 90 /* timer_ptr Timer control block pointer */ | |
| 91 /* name Timer name */ | |
| 92 /* expiration_routine Timer expiration routine */ | |
| 93 /* id Timer expiration ID */ | |
| 94 /* initial_time Initial expiration time */ | |
| 95 /* reschedule_time Reschedule expiration time */ | |
| 96 /* enable Automatic enable option */ | |
| 97 /* */ | |
| 98 /* OUTPUTS */ | |
| 99 /* */ | |
| 100 /* NU_INVALID_TIMER Indicates timer pointer is */ | |
| 101 /* NULL */ | |
| 102 /* NU_INVALID_FUNCTION Indicates timer expiration */ | |
| 103 /* function pointer is NULL */ | |
| 104 /* NU_INVALID_ENABLE Indicates enable parameter */ | |
| 105 /* is invalid */ | |
| 106 /* */ | |
| 107 /* HISTORY */ | |
| 108 /* */ | |
| 109 /* DATE REMARKS */ | |
| 110 /* */ | |
| 111 /* 03-01-1993 Created initial version 1.0 */ | |
| 112 /* 04-19-1993 Verified version 1.0 */ | |
| 113 /* 03-01-1994 Changed function interface, */ | |
| 114 /* resulting in version 1.1 */ | |
| 115 /* */ | |
| 116 /* 03-18-1994 Verified version 1.1 */ | |
| 117 /* */ | |
| 118 /*************************************************************************/ | |
| 119 STATUS TMSE_Create_Timer(NU_TIMER *timer_ptr, CHAR *name, | |
| 120 VOID (*expiration_routine)(UNSIGNED), UNSIGNED id, | |
| 121 UNSIGNED initial_time, UNSIGNED reschedule_time, OPTION enable) | |
| 122 { | |
| 123 | |
| 124 TM_APP_TCB *timer; /* Timer control block ptr */ | |
| 125 STATUS status; /* Completion status */ | |
| 126 | |
| 127 | |
| 128 /* Move input timer pointer into internal pointer. */ | |
| 129 timer = (TM_APP_TCB *) timer_ptr; | |
| 130 | |
| 131 /* Check the parameters to the create timer function. */ | |
| 132 if ((timer == NU_NULL) || (timer -> tm_id == TM_TIMER_ID)) | |
| 133 | |
| 134 /* Invalid timer pointer. */ | |
| 135 status = NU_INVALID_TIMER; | |
| 136 | |
| 137 else if (expiration_routine == NU_NULL) | |
| 138 | |
| 139 /* Invalid expiration function pointer. */ | |
| 140 status = NU_INVALID_FUNCTION; | |
| 141 | |
| 142 else if (initial_time == 0) | |
| 143 | |
| 144 /* Invalid time value. */ | |
| 145 status = NU_INVALID_OPERATION; | |
| 146 | |
| 147 | |
| 148 else if ((enable != NU_ENABLE_TIMER) && (enable != NU_DISABLE_TIMER)) | |
| 149 | |
| 150 /* Invalid enable parameter. */ | |
| 151 status = NU_INVALID_ENABLE; | |
| 152 | |
| 153 else | |
| 154 | |
| 155 /* Call the actual create timer function. */ | |
| 156 status = TMS_Create_Timer(timer_ptr, name, expiration_routine, id, | |
| 157 initial_time, reschedule_time, enable); | |
| 158 | |
| 159 /* Return the completion status. */ | |
| 160 return(status); | |
| 161 } | |
| 162 | |
| 163 | |
| 164 /*************************************************************************/ | |
| 165 /* */ | |
| 166 /* FUNCTION */ | |
| 167 /* */ | |
| 168 /* TMSE_Delete_Timer */ | |
| 169 /* */ | |
| 170 /* DESCRIPTION */ | |
| 171 /* */ | |
| 172 /* This function performs error checking on the parameters supplied */ | |
| 173 /* to the delete timer function. */ | |
| 174 /* */ | |
| 175 /* CALLED BY */ | |
| 176 /* */ | |
| 177 /* Application */ | |
| 178 /* */ | |
| 179 /* CALLS */ | |
| 180 /* */ | |
| 181 /* TMS_Delete_Timer Actual delete timer function */ | |
| 182 /* */ | |
| 183 /* INPUTS */ | |
| 184 /* */ | |
| 185 /* timer_ptr Timer control block pointer */ | |
| 186 /* */ | |
| 187 /* OUTPUTS */ | |
| 188 /* */ | |
| 189 /* NU_INVALID_TIMER Indicates the timer pointer */ | |
| 190 /* is NULL or not a timer */ | |
| 191 /* */ | |
| 192 /* HISTORY */ | |
| 193 /* */ | |
| 194 /* DATE REMARKS */ | |
| 195 /* */ | |
| 196 /* 03-01-1993 Created initial version 1.0 */ | |
| 197 /* 04-19-1993 Verified version 1.0 */ | |
| 198 /* 03-01-1994 Changed function interface, */ | |
| 199 /* resulting in version 1.1 */ | |
| 200 /* */ | |
| 201 /* 03-18-1994 Verified version 1.1 */ | |
| 202 /* */ | |
| 203 /*************************************************************************/ | |
| 204 STATUS TMSE_Delete_Timer(NU_TIMER *timer_ptr) | |
| 205 { | |
| 206 | |
| 207 TM_APP_TCB *timer; /* Timer control block ptr */ | |
| 208 STATUS status; /* Completion status */ | |
| 209 | |
| 210 | |
| 211 /* Move input timer pointer into internal pointer. */ | |
| 212 timer = (TM_APP_TCB *) timer_ptr; | |
| 213 | |
| 214 /* Check the parameters to the delete timer function. */ | |
| 215 if (timer == NU_NULL) | |
| 216 | |
| 217 /* Invalid timer pointer. */ | |
| 218 status = NU_INVALID_TIMER; | |
| 219 | |
| 220 else if (timer -> tm_id != TM_TIMER_ID) | |
| 221 | |
| 222 /* Invalid timer pointer. */ | |
| 223 status = NU_INVALID_TIMER; | |
| 224 | |
| 225 else | |
| 226 | |
| 227 /* Call the actual delete timer function. */ | |
| 228 status = TMS_Delete_Timer(timer_ptr); | |
| 229 | |
| 230 /* Return completion status. */ | |
| 231 return(status); | |
| 232 } | |
| 233 | |
| 234 | |
| 235 /*************************************************************************/ | |
| 236 /* */ | |
| 237 /* FUNCTION */ | |
| 238 /* */ | |
| 239 /* TMSE_Reset_Timer */ | |
| 240 /* */ | |
| 241 /* DESCRIPTION */ | |
| 242 /* */ | |
| 243 /* This function performs error checking on the parameters supplied */ | |
| 244 /* to the reset timer function. */ | |
| 245 /* */ | |
| 246 /* CALLED BY */ | |
| 247 /* */ | |
| 248 /* Application */ | |
| 249 /* */ | |
| 250 /* CALLS */ | |
| 251 /* */ | |
| 252 /* TMS_Reset_Timer Actual reset timer function */ | |
| 253 /* */ | |
| 254 /* INPUTS */ | |
| 255 /* */ | |
| 256 /* timer_ptr Timer control block pointer */ | |
| 257 /* expiration_routine Timer expiration routine */ | |
| 258 /* initial_time Initial expiration time */ | |
| 259 /* reschedule_time Reschedule expiration time */ | |
| 260 /* enable Automatic enable option */ | |
| 261 /* */ | |
| 262 /* OUTPUTS */ | |
| 263 /* */ | |
| 264 /* NU_INVALID_TIMER Indicates timer pointer is */ | |
| 265 /* invalid */ | |
| 266 /* NU_INVALID_FUNCTION Indicates that expiration */ | |
| 267 /* function pointer is NULL */ | |
| 268 /* NU_INVALID_ENABLE Indicates enable parameter */ | |
| 269 /* is invalid */ | |
| 270 /* */ | |
| 271 /* HISTORY */ | |
| 272 /* */ | |
| 273 /* DATE REMARKS */ | |
| 274 /* */ | |
| 275 /* 03-01-1993 Created initial version 1.0 */ | |
| 276 /* 04-19-1993 Verified version 1.0 */ | |
| 277 /* 03-01-1994 Changed function interface, */ | |
| 278 /* resulting in version 1.1 */ | |
| 279 /* */ | |
| 280 /* 03-18-1994 Verified version 1.1 */ | |
| 281 /* */ | |
| 282 /*************************************************************************/ | |
| 283 STATUS TMSE_Reset_Timer(NU_TIMER *timer_ptr, | |
| 284 VOID (*expiration_routine)(UNSIGNED), | |
| 285 UNSIGNED initial_time, UNSIGNED reschedule_time, OPTION enable) | |
| 286 { | |
| 287 | |
| 288 TM_APP_TCB *timer; /* Timer contorl block ptr */ | |
| 289 STATUS status; /* Completion status */ | |
| 290 | |
| 291 | |
| 292 /* Move input timer pointer into internal pointer. */ | |
| 293 timer = (TM_APP_TCB *) timer_ptr; | |
| 294 | |
| 295 /* Check the parameters to the reset timer function. */ | |
| 296 if (timer == NU_NULL) | |
| 297 | |
| 298 /* Invalid timer pointer. */ | |
| 299 status = NU_INVALID_TIMER; | |
| 300 | |
| 301 else if (timer -> tm_id != TM_TIMER_ID) | |
| 302 | |
| 303 /* Invalid timer pointer. */ | |
| 304 status = NU_INVALID_TIMER; | |
| 305 | |
| 306 else if (initial_time == 0) | |
| 307 | |
| 308 /* Invalid time value. */ | |
| 309 status = NU_INVALID_OPERATION; | |
| 310 | |
| 311 | |
| 312 else if (expiration_routine == NU_NULL) | |
| 313 | |
| 314 /* Invalid expiration function pointer. */ | |
| 315 status = NU_INVALID_FUNCTION; | |
| 316 | |
| 317 else if ((enable != NU_ENABLE_TIMER) && (enable != NU_DISABLE_TIMER)) | |
| 318 | |
| 319 /* Invalid enable parameter. */ | |
| 320 status = NU_INVALID_ENABLE; | |
| 321 | |
| 322 else | |
| 323 | |
| 324 /* Call the actual reset timer function. */ | |
| 325 status = TMS_Reset_Timer(timer_ptr, expiration_routine, initial_time, | |
| 326 reschedule_time, enable); | |
| 327 | |
| 328 /* Return completion status. */ | |
| 329 return(status); | |
| 330 } | |
| 331 | |
| 332 | |
| 333 /*************************************************************************/ | |
| 334 /* */ | |
| 335 /* FUNCTION */ | |
| 336 /* */ | |
| 337 /* TMSE_Control_Timer */ | |
| 338 /* */ | |
| 339 /* DESCRIPTION */ | |
| 340 /* */ | |
| 341 /* This function performs error checking on the parameters supplied */ | |
| 342 /* to the control timer function. */ | |
| 343 /* */ | |
| 344 /* CALLED BY */ | |
| 345 /* */ | |
| 346 /* Application */ | |
| 347 /* */ | |
| 348 /* CALLS */ | |
| 349 /* */ | |
| 350 /* TMS_Control_Timer Actual control timer function*/ | |
| 351 /* */ | |
| 352 /* INPUTS */ | |
| 353 /* */ | |
| 354 /* timer_ptr Timer control block pointer */ | |
| 355 /* enable Disable/enable timer option */ | |
| 356 /* */ | |
| 357 /* OUTPUTS */ | |
| 358 /* */ | |
| 359 /* NU_INVALID_TIMER Indicates the timer pointer */ | |
| 360 /* is invalid */ | |
| 361 /* NU_INVALID_ENABLE Indicates enable parameter */ | |
| 362 /* is invalid */ | |
| 363 /* */ | |
| 364 /* HISTORY */ | |
| 365 /* */ | |
| 366 /* DATE REMARKS */ | |
| 367 /* */ | |
| 368 /* 03-01-1993 Created initial version 1.0 */ | |
| 369 /* 04-19-1993 Verified version 1.0 */ | |
| 370 /* 03-01-1994 Changed function interface, */ | |
| 371 /* resulting in version 1.1 */ | |
| 372 /* */ | |
| 373 /* 03-18-1994 Verified version 1.1 */ | |
| 374 /* */ | |
| 375 /*************************************************************************/ | |
| 376 STATUS TMSE_Control_Timer(NU_TIMER *timer_ptr, OPTION enable) | |
| 377 { | |
| 378 | |
| 379 TM_APP_TCB *timer; /* Timer control block ptr */ | |
| 380 STATUS status; /* Completion status */ | |
| 381 | |
| 382 | |
| 383 /* Move input timer pointer to internal pointer. */ | |
| 384 timer = (TM_APP_TCB *) timer_ptr; | |
| 385 | |
| 386 /* Check the parameters to the reset timer function. */ | |
| 387 if (timer == NU_NULL) | |
| 388 | |
| 389 /* Invalid timer pointer. */ | |
| 390 status = NU_INVALID_TIMER; | |
| 391 | |
| 392 else if (timer -> tm_id != TM_TIMER_ID) | |
| 393 | |
| 394 /* Invalid timer pointer. */ | |
| 395 status = NU_INVALID_TIMER; | |
| 396 | |
| 397 else if ((enable != NU_ENABLE_TIMER) && (enable != NU_DISABLE_TIMER)) | |
| 398 | |
| 399 /* Invalid enable parameter. */ | |
| 400 status = NU_INVALID_ENABLE; | |
| 401 | |
| 402 else | |
| 403 | |
| 404 /* Call actual control timer function. */ | |
| 405 status = TMS_Control_Timer(timer_ptr, enable); | |
| 406 | |
| 407 /* Return completion status. */ | |
| 408 return(status); | |
| 409 } | |
| 410 | |
| 411 | |
| 412 | |
| 413 | |
| 414 |
