📄 os_q.src
字号:
; .\OS_Q.SRC generated from: OS_Q.C
; COMPILER INVOKED BY:
; D:\Keil\C51\BIN\C51.EXE OS_Q.C LARGE BROWSE DEBUG OBJECTEXTEND SRC(.\OS_Q.SRC)
$NOMOD51
NAME OS_Q
P0 DATA 080H
P1 DATA 090H
P2 DATA 0A0H
P3 DATA 0B0H
T0 BIT 0B0H.4
AC BIT 0D0H.6
T1 BIT 0B0H.5
EA BIT 0A8H.7
IE DATA 0A8H
RD BIT 0B0H.7
ES BIT 0A8H.4
IP DATA 0B8H
RI BIT 098H.0
INT0 BIT 0B0H.2
CY BIT 0D0H.7
TI BIT 098H.1
INT1 BIT 0B0H.3
PS BIT 0B8H.4
SP DATA 081H
OV BIT 0D0H.2
WR BIT 0B0H.6
SBUF DATA 099H
PCON DATA 087H
SCON DATA 098H
TMOD DATA 089H
TCON DATA 088H
IE0 BIT 088H.1
IE1 BIT 088H.3
B DATA 0F0H
ACC DATA 0E0H
ET0 BIT 0A8H.1
ET1 BIT 0A8H.3
TF0 BIT 088H.5
TF1 BIT 088H.7
RB8 BIT 098H.2
TH0 DATA 08CH
EX0 BIT 0A8H.0
IT0 BIT 088H.0
TH1 DATA 08DH
TB8 BIT 098H.3
EX1 BIT 0A8H.2
IT1 BIT 088H.2
P BIT 0D0H.0
SM0 BIT 098H.7
TL0 DATA 08AH
SM1 BIT 098H.6
TL1 DATA 08BH
SM2 BIT 098H.5
PT0 BIT 0B8H.1
PT1 BIT 0B8H.3
RS0 BIT 0D0H.3
TR0 BIT 088H.4
RS1 BIT 0D0H.4
TR1 BIT 088H.6
PX0 BIT 0B8H.0
PX1 BIT 0B8H.2
DPH DATA 083H
DPL DATA 082H
REN BIT 098H.4
RXD BIT 0B0H.0
TXD BIT 0B0H.1
F0 BIT 0D0H.5
PSW DATA 0D0H
; /*
; *********************************************************************************************************
; * uC/OS-II
; * The Real-Time Kernel
; * MESSAGE QUEUE MANAGEMENT
; *
; * (c) Copyright 1992-1998, Jean J. Labrosse, Plantation, FL
; * All Rights Reserved
; *
; * V2.00
; *
; * File : OS_Q.C
; * By : Jean J. Labrosse
; *********************************************************************************************************
; */
;
; #ifndef OS_MASTER_FILE
; #include "includes.h"
; #endif
;
; #if OS_Q_EN && (OS_MAX_QS >= 2)
; /*
; *********************************************************************************************************
; * LOCAL DATA TYPES
; *********************************************************************************************************
; */
;
; typedef struct os_q { /* QUEUE CONTROL BLOCK */
; struct os_q *OSQPtr; /* Link to next queue control block in list of free blocks */
; void **OSQStart; /* Pointer to start of queue data */
; void **OSQEnd; /* Pointer to end of queue data */
; void **OSQIn; /* Pointer to where next message will be inserted in the Q */
; void **OSQOut; /* Pointer to where next message will be extracted from the Q */
; INT16U OSQSize; /* Size of queue (maximum number of entries) */
; INT16U OSQEntries; /* Current number of entries in the queue */
; } OS_Q;
;
; /*
; *********************************************************************************************************
; * LOCAL GLOBAL VARIABLES
; *********************************************************************************************************
; */
;
; static OS_Q *OSQFreeList; /* Pointer to list of free QUEUE control blocks */
; static OS_Q OSQTbl[OS_MAX_QS]; /* Table of QUEUE control blocks */
;
; /*$PAGE*/
; /*
; *********************************************************************************************************
; * ACCEPT MESSAGE FROM QUEUE
; *
; * Description: This function checks the queue to see if a message is available. Unlike OSQPend(),
; * OSQAccept() does not suspend the calling task if a message is not available.
; *
; * Arguments : pevent is a pointer to the event control block
; *
; * Returns : != (void *)0 is the message in the queue if one is available. The message is removed
; * from the so the next time OSQAccept() is called, the queue will contain
; * one less entry.
; * == (void *)0 if the queue is empty
; * if you passed an invalid event type
; *********************************************************************************************************
; */
;
; void *OSQAccept (OS_EVENT *pevent) reentrant
; {
; void *msg;
; OS_Q *pq;
;
;
; OS_ENTER_CRITICAL();
; if (pevent->OSEventType != OS_EVENT_TYPE_Q) { /* Validate event block type */
; OS_EXIT_CRITICAL();
; return ((void *)0);
; }
; pq = pevent->OSEventPtr; /* Point at queue control block */
; if (pq->OSQEntries != 0) { /* See if any messages in the queue */
; msg = *pq->OSQOut++; /* Yes, extract oldest message from the queue */
; pq->OSQEntries--; /* Update the number of entries in the queue */
; if (pq->OSQOut == pq->OSQEnd) { /* Wrap OUT pointer if we are at the end of the queue */
; pq->OSQOut = pq->OSQStart;
; }
; } else {
; msg = (void *)0; /* Queue is empty */
; }
; OS_EXIT_CRITICAL();
; return (msg); /* Return message received (or NULL) */
; }
; /*$PAGE*/
; /*
; *********************************************************************************************************
; * CREATE A MESSAGE QUEUE
; *
; * Description: This function creates a message queue if free event control blocks are available.
; *
; * Arguments : start is a pointer to the base address of the message queue storage area. The
; * storage area MUST be declared as an array of pointers to 'void' as follows
; *
; * void *MessageStorage[size]
; *
; * size is the number of elements in the storage area
; *
; * Returns : != (void *)0 is a pointer to the event control clock (OS_EVENT) associated with the
; * created queue
; * == (void *)0 if no event control blocks were available
; *********************************************************************************************************
; */
;
; OS_EVENT *OSQCreate (void **start, INT16U size) reentrant
; {
; OS_EVENT *pevent;
; OS_Q *pq;
;
;
; OS_ENTER_CRITICAL();
; pevent = OSEventFreeList; /* Get next free event control block */
; if (OSEventFreeList != (OS_EVENT *)0) { /* See if pool of free ECB pool was empty */
; OSEventFreeList = (OS_EVENT *)OSEventFreeList->OSEventPtr;
; }
; OS_EXIT_CRITICAL();
; if (pevent != (OS_EVENT *)0) { /* See if we have an event control block */
; OS_ENTER_CRITICAL(); /* Get a free queue control block */
; pq = OSQFreeList;
; if (OSQFreeList != (OS_Q *)0) {
; OSQFreeList = OSQFreeList->OSQPtr;
; }
; OS_EXIT_CRITICAL();
; if (pq != (OS_Q *)0) { /* See if we were able to get a queue control block */
; pq->OSQStart = start; /* Yes, initialize the queue */
; pq->OSQEnd = &start[size];
; pq->OSQIn = start;
; pq->OSQOut = start;
; pq->OSQSize = size;
; pq->OSQEntries = 0;
; pevent->OSEventType = OS_EVENT_TYPE_Q;
; pevent->OSEventPtr = pq;
; OSEventWaitListInit(pevent);
; } else { /* No, since we couldn't get a queue control block */
; OS_ENTER_CRITICAL(); /* Return event control block on error */
; pevent->OSEventPtr = (void *)OSEventFreeList;
; OSEventFreeList = pevent;
; OS_EXIT_CRITICAL();
; pevent = (OS_EVENT *)0;
; }
; }
; return (pevent);
; }
; /*$PAGE*/
; /*
; *********************************************************************************************************
; * FLUSH QUEUE
; *
; * Description : This function is used to flush the contents of the message queue.
; *
; * Arguments : none
; *
; * Returns : OS_NO_ERR upon success
; * OS_ERR_EVENT_TYPE If you didn't pass a pointer to a queue
; *********************************************************************************************************
; */
;
; INT8U OSQFlush (OS_EVENT *pevent) reentrant
; {
; OS_Q *pq;
;
;
; OS_ENTER_CRITICAL();
; if (pevent->OSEventType != OS_EVENT_TYPE_Q) { /* Validate event block type */
; OS_EXIT_CRITICAL();
; return (OS_ERR_EVENT_TYPE);
; }
; pq = pevent->OSEventPtr; /* Point to queue storage structure */
; pq->OSQIn = pq->OSQStart;
; pq->OSQOut = pq->OSQStart;
; pq->OSQEntries = 0;
; OS_EXIT_CRITICAL();
; return (OS_NO_ERR);
; }
;
; /*$PAGE*/
; /*
; *********************************************************************************************************
; * QUEUE MODULE INITIALIZATION
; *
; * Description : This function is called by uC/OS-II to initialize the message queue module. Your
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -