os_mbox.lst
来自「一个关于UCOS的KEIL工程」· LST 代码 · 共 534 行 · 第 1/3 页
LST
534 行
338 2 }
339 1 pevent->OSEventPtr = msg; /* Place message in mailbox */
340 1 OS_EXIT_CRITICAL();
341 1 return (OS_NO_ERR);
342 1 }
343 #endif
344
345 /*$PAGE*/
346 /*
347 *********************************************************************************************************
348 * POST MESSAGE TO A MAILBOX
349 *
350 * Description: This function sends a message to a mailbox
351 *
352 * Arguments : pevent is a pointer to the event control block associated with the desired mailbox
353 *
354 * msg is a pointer to the message to send. You MUST NOT send a NULL pointer.
355 *
356 * opt determines the type of POST performed:
357 * OS_POST_OPT_NONE POST to a single waiting task
358 * (Identical to OSMboxPost())
359 * OS_POST_OPT_BROADCAST POST to ALL tasks that are waiting on the mailbox
360 *
361 * Returns : OS_NO_ERR The call was successful and the message was sent
362 * OS_MBOX_FULL If the mailbox already contains a message. You can can only send one
363 * message at a time and thus, the message MUST be consumed before you
364 * are allowed to send another one.
365 * OS_ERR_EVENT_TYPE If you are attempting to post to a non mailbox.
C51 COMPILER V6.23a OS_MBOX 12/09/2004 16:50:25 PAGE 7
366 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
367 * OS_ERR_POST_NULL_PTR If you are attempting to post a NULL pointer
368 *
369 * Warning : Interrupts can be disabled for a long time if you do a 'broadcast'. In fact, the
370 * interrupt disable time is proportional to the number of tasks waiting on the mailbox.
371 *********************************************************************************************************
372 */
373
374 #if OS_MBOX_POST_OPT_EN > 0
375 INT8U OSMboxPostOpt (OS_EVENT *pevent, void *msg, INT8U opt) KCREENTRANT
376 {
377 1 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
380 1
381 1
382 1 #if OS_ARG_CHK_EN > 0
383 1 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
384 2 return (OS_ERR_PEVENT_NULL);
385 2 }
386 1 if (msg == (void *)0) { /* Make sure we are not posting a NULL pointer */
387 2 return (OS_ERR_POST_NULL_PTR);
388 2 }
389 1 if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) { /* Validate event block type */
390 2 return (OS_ERR_EVENT_TYPE);
391 2 }
392 1 #endif
393 1 OS_ENTER_CRITICAL();
394 1 if (pevent->OSEventGrp != 0x00) { /* See if any task pending on mailbox */
395 2 if ((opt & OS_POST_OPT_BROADCAST) != 0x00) { /* Do we need to post msg to ALL waiting tasks ? */
396 3 while (pevent->OSEventGrp != 0x00) { /* Yes, Post to ALL tasks waiting on mailbox */
-
397 4 OS_EventTaskRdy(pevent, msg, OS_STAT_MBOX);
398 4 }
399 3 } else {
400 3 OS_EventTaskRdy(pevent, msg, OS_STAT_MBOX); /* No, Post to HPT waiting on mbox */
401 3 }
402 2 OS_EXIT_CRITICAL();
403 2 OS_Sched(); /* Find highest priority task ready to run */
404 2 return (OS_NO_ERR);
405 2 }
406 1 if (pevent->OSEventPtr != (void *)0) { /* Make sure mailbox doesn't already have a msg */
407 2 OS_EXIT_CRITICAL();
408 2 return (OS_MBOX_FULL);
409 2 }
410 1 pevent->OSEventPtr = msg; /* Place message in mailbox */
411 1 OS_EXIT_CRITICAL();
412 1 return (OS_NO_ERR);
413 1 }
414 #endif
415
416 /*$PAGE*/
417 /*
418 *********************************************************************************************************
419 * QUERY A MESSAGE MAILBOX
420 *
421 * Description: This function obtains information about a message mailbox.
422 *
423 * Arguments : pevent is a pointer to the event control block associated with the desired mailbox
424 *
425 * pdata is a pointer to a structure that will contain information about the message
426 * mailbox.
C51 COMPILER V6.23a OS_MBOX 12/09/2004 16:50:25 PAGE 8
427 *
428 * Returns : OS_NO_ERR The call was successful and the message was sent
429 * OS_ERR_EVENT_TYPE If you are attempting to obtain data from a non mailbox.
430 * OS_ERR_PEVENT_NULL If 'pevent' is a NULL pointer
431 *********************************************************************************************************
432 */
433
434 #if OS_MBOX_QUERY_EN > 0
435 INT8U OSMboxQuery (OS_EVENT *pevent, OS_MBOX_DATA *pdata) KCREENTRANT
436 {
437 1 #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr;
#endif
440 1 INT8U *psrc;
441 1 INT8U *pdest;
442 1
443 1
444 1 #if OS_ARG_CHK_EN > 0
445 1 if (pevent == (OS_EVENT *)0) { /* Validate 'pevent' */
446 2 return (OS_ERR_PEVENT_NULL);
447 2 }
448 1 if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) { /* Validate event block type */
449 2 return (OS_ERR_EVENT_TYPE);
450 2 }
451 1 #endif
452 1 OS_ENTER_CRITICAL();
453 1 pdata->OSEventGrp = pevent->OSEventGrp; /* Copy message mailbox wait list */
454 1 psrc = &pevent->OSEventTbl[0];
455 1 pdest = &pdata->OSEventTbl[0];
456 1
457 1 #if OS_EVENT_TBL_SIZE > 0
458 1 *pdest++ = *psrc++;
459 1 #endif
460 1
461 1 #if OS_EVENT_TBL_SIZE > 1
462 1 *pdest++ = *psrc++;
463 1 #endif
464 1
465 1 #if OS_EVENT_TBL_SIZE > 2
*pdest++ = *psrc++;
#endif
468 1
469 1 #if OS_EVENT_TBL_SIZE > 3
*pdest++ = *psrc++;
#endif
472 1
473 1 #if OS_EVENT_TBL_SIZE > 4
*pdest++ = *psrc++;
#endif
476 1
477 1 #if OS_EVENT_TBL_SIZE > 5
*pdest++ = *psrc++;
#endif
480 1
481 1 #if OS_EVENT_TBL_SIZE > 6
*pdest++ = *psrc++;
#endif
484 1
485 1 #if OS_EVENT_TBL_SIZE > 7
*pdest = *psrc;
#endif
488 1 pdata->OSMsg = pevent->OSEventPtr; /* Get message from mailbox */
C51 COMPILER V6.23a OS_MBOX 12/09/2004 16:50:25 PAGE 9
489 1 OS_EXIT_CRITICAL();
490 1 return (OS_NO_ERR);
491 1 }
492 #endif /* OS_MBOX_QUERY_EN */
493 #endif /* OS_MBOX_EN */
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 2314 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?