⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 os_mbox.s43

📁 IAR project for MSP430 and uC/OS. All configured to start filling with tasks.
💻 S43
📖 第 1 页 / 共 3 页
字号:
; 326.	    }
	RET		
?0105:
; 327.	#endif
; 328.	    OS_ENTER_CRITICAL();
	DINT		
; 329.	    if (pevent->OSEventGrp != 0x00) {                 /* See if any task pending on mailbox            */
	CMP.B	#0,1(R12)	
	JEQ	(?0107)	
; 330.	        OS_EventTaskRdy(pevent, msg, OS_STAT_MBOX);   /* Ready highest priority task waiting on event  */
	PUSH.B	#2	
	CALL	#OS_EventTaskRdy	
	ADD	#2,SP	
; 331.	        OS_EXIT_CRITICAL();
	EINT		
; 332.	        OS_Sched();                                   /* Find highest priority task ready to run       */
	CALL	#OS_Sched	
; 333.	        return (OS_NO_ERR);
	MOV.B	#0,R12	
; 334.	    }
	RET		
?0107:
; 335.	    if (pevent->OSEventPtr != (void *)0) {            /* Make sure mailbox doesn't already have a msg  */
	CMP	#0,4(R12)	
	JEQ	(?0109)	
; 336.	        OS_EXIT_CRITICAL();
	EINT		
; 337.	        return (OS_MBOX_FULL);
	MOV.B	#20,R12	
; 338.	    }
	RET		
?0109:
; 339.	    pevent->OSEventPtr = msg;                         /* Place message in mailbox                      */
	MOV	R14,4(R12)	
; 340.	    OS_EXIT_CRITICAL();
	EINT		
; 341.	    return (OS_NO_ERR);
	MOV.B	#0,R12	
; 342.	}
	RET		
OSMboxPostOpt:
; 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.
; 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)
; 376.	{
	PUSH	R10	
	PUSH	R11	
	MOV	R12,R11	
	MOV	R14,R10	
; 377.	#if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
; 378.	    OS_CPU_SR  cpu_sr;
; 379.	#endif    
; 380.	    
; 381.	    
; 382.	#if OS_ARG_CHK_EN > 0
; 383.	    if (pevent == (OS_EVENT *)0) {                    /* Validate 'pevent'                             */
	CMP	#0,R11	
	JNE	(?0112)	
; 384.	        return (OS_ERR_PEVENT_NULL);
	MOV.B	#4,R12	
; 385.	    }
	JMP	(?0127)	
?0112:
; 386.	    if (msg == (void *)0) {                           /* Make sure we are not posting a NULL pointer   */
	CMP	#0,R10	
	JNE	(?0114)	
; 387.	        return (OS_ERR_POST_NULL_PTR);
	MOV.B	#3,R12	
; 388.	    }
	JMP	(?0127)	
?0114:
; 389.	    if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {  /* Validate event block type                     */
	MOV.B	#1,R12	
	CMP.B	@R11,R12	
	JNE	(?0127)	
; 390.	        return (OS_ERR_EVENT_TYPE);
; 391.	    }
; 392.	#endif
; 393.	    OS_ENTER_CRITICAL();
	DINT		
; 394.	    if (pevent->OSEventGrp != 0x00) {                 /* See if any task pending on mailbox            */
	CMP.B	#0,1(R11)	
	JEQ	(?0118)	
; 395.	        if ((opt & OS_POST_OPT_BROADCAST) != 0x00) {  /* Do we need to post msg to ALL waiting tasks ? */
	BIT.B	#1,6(SP)	
	JEQ	(?0120)	
?0119:
; 396.	            while (pevent->OSEventGrp != 0x00) {      /* Yes, Post to ALL tasks waiting on mailbox     */           
	CMP.B	#0,1(R11)	
	JEQ	(?0124)	
; 397.	                OS_EventTaskRdy(pevent, msg, OS_STAT_MBOX);    
	PUSH.B	#2	
	MOV	R10,R14	
	MOV	R11,R12	
	CALL	#OS_EventTaskRdy	
	ADD	#2,SP	
; 398.	            }
; 399.	        } else {
	JMP	(?0119)	
?0120:
; 400.	            OS_EventTaskRdy(pevent, msg, OS_STAT_MBOX);    /* No,  Post to HPT waiting on mbox         */
	PUSH.B	#2	
	MOV	R10,R14	
	MOV	R11,R12	
	CALL	#OS_EventTaskRdy	
	ADD	#2,SP	
?0124:
; 401.	        }
; 402.	        OS_EXIT_CRITICAL();
	EINT		
; 403.	        OS_Sched();                                        /* Find highest priority task ready to run  */
	CALL	#OS_Sched	
; 404.	        return (OS_NO_ERR);
	MOV.B	#0,R12	
; 405.	    }
	JMP	(?0127)	
?0118:
; 406.	    if (pevent->OSEventPtr != (void *)0) {            /* Make sure mailbox doesn't already have a msg  */
	CMP	#0,4(R11)	
	JEQ	(?0126)	
; 407.	        OS_EXIT_CRITICAL();
	EINT		
; 408.	        return (OS_MBOX_FULL);
	MOV.B	#20,R12	
; 409.	    }
	JMP	(?0127)	
?0126:
; 410.	    pevent->OSEventPtr = msg;                         /* Place message in mailbox                      */
	MOV	R10,4(R11)	
; 411.	    OS_EXIT_CRITICAL();
	EINT		
; 412.	    return (OS_NO_ERR);
	MOV.B	#0,R12	
; 413.	}
?0127:
	POP	R11	
	POP	R10	
	RET		
OSMboxQuery:
; 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.
; 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)
; 436.	{
; 437.	#if OS_CRITICAL_METHOD == 3                      /* Allocate storage for CPU status register           */
; 438.	    OS_CPU_SR  cpu_sr;
; 439.	#endif    
; 440.	    INT8U     *psrc;
; 441.	    INT8U     *pdest;
; 442.	
; 443.	
; 444.	#if OS_ARG_CHK_EN > 0
; 445.	    if (pevent == (OS_EVENT *)0) {                         /* Validate 'pevent'                        */
	CMP	#0,R12	
	JNE	(?0129)	
; 446.	        return (OS_ERR_PEVENT_NULL);
	MOV.B	#4,R12	
; 447.	    }
	RET		
?0129:
; 448.	    if (pevent->OSEventType != OS_EVENT_TYPE_MBOX) {       /* Validate event block type                */
	MOV.B	#1,R13	
	CMP.B	@R12,R13	
	JEQ	(?0131)	
; 449.	        return (OS_ERR_EVENT_TYPE);
	MOV.B	#1,R12	
; 450.	    }
	RET		
?0131:
; 451.	#endif
; 452.	    OS_ENTER_CRITICAL();
	DINT		
; 453.	    pdata->OSEventGrp = pevent->OSEventGrp;                /* Copy message mailbox wait list           */
	MOV.B	1(R12),4(R14)	
; 454.	    psrc              = &pevent->OSEventTbl[0];
	MOV	R12,R15	
	ADD	#6,R15	
; 455.	    pdest             = &pdata->OSEventTbl[0];
	MOV	R14,R13	
	ADD	#2,R13	
; 456.	
; 457.	#if OS_EVENT_TBL_SIZE > 0
; 458.	    *pdest++          = *psrc++;
	MOV.B	@R15+,0(R13)	
	ADD	#1,R13	
; 459.	#endif
; 460.	
; 461.	#if OS_EVENT_TBL_SIZE > 1
; 462.	    *pdest++          = *psrc++;
	MOV.B	@R15+,0(R13)	
; 463.	#endif
; 464.	
; 465.	#if OS_EVENT_TBL_SIZE > 2
; 466.	    *pdest++          = *psrc++;
; 467.	#endif
; 468.	
; 469.	#if OS_EVENT_TBL_SIZE > 3
; 470.	    *pdest++          = *psrc++;
; 471.	#endif
; 472.	
; 473.	#if OS_EVENT_TBL_SIZE > 4
; 474.	    *pdest++          = *psrc++;
; 475.	#endif
; 476.	
; 477.	#if OS_EVENT_TBL_SIZE > 5
; 478.	    *pdest++          = *psrc++;
; 479.	#endif
; 480.	
; 481.	#if OS_EVENT_TBL_SIZE > 6
; 482.	    *pdest++          = *psrc++;
; 483.	#endif
; 484.	
; 485.	#if OS_EVENT_TBL_SIZE > 7
; 486.	    *pdest            = *psrc;
; 487.	#endif
; 488.	    pdata->OSMsg = pevent->OSEventPtr;                     /* Get message from mailbox                 */
	MOV	4(R12),0(R14)	
; 489.	    OS_EXIT_CRITICAL();
	EINT		
; 490.	    return (OS_NO_ERR);
	MOV.B	#0,R12	
; 491.	}
	RET		
; 492.	#endif                                                     /* OS_MBOX_QUERY_EN                         */
; 493.	#endif                                                     /* OS_MBOX_EN                               */
	END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -