/**
 *******************************************************************************
 * @brief      Respond the request in the service request queue.	 
 * @param[in]  None
 * @param[out] None 
 * @retval     None  
 *
 * @par Description		 
 * @details    This function be called to respond the request in the service  
 *             request queue.
 * @note 
 *******************************************************************************
 */
void RespondSRQ(void)
{
#if CFG_MAX_SERVICE_REQUEST > 0
    U16 i;
    P_SQC pcell;
#endif
 
#if (CFG_TASK_WAITTING_EN > 0)
    if(TimeReq == TRUE)                 /* Time delay request?                */
    {
        TimeDispose();                  /* Yes,call handler                   */
        TimeReq = FALSE;                /* Reset time delay request false     */
    }
#endif
#if CFG_TMR_EN  > 0
    if(TimerReq == TRUE)                /* Timer request?                     */
    {
        TmrDispose();                   /* Yes,call handler                   */
        TimerReq = FALSE;               /* Reset timer request false          */
    }
#endif

#if CFG_MAX_SERVICE_REQUEST > 0
    pcell = &ServiceReq.cell[0];  /* Get the head item of service request list*/
    for(i=0;i<ServiceReq.cnt;i++,pcell++) 
    {
        switch(pcell->type)             /* Judge service request type         */
        {
#if CFG_SEM_EN > 0
            case SEM_REQ:               /* Semaphore post request,call handler*/
                  CoPostSem(pcell->id);
                  break;
#endif
#if CFG_MAILBOX_EN > 0
            case MBOX_REQ:              /* Mailbox post request,call handler  */
                  CoPostMail(pcell->id,pcell->arg);
                  break;
#endif
#if CFG_FLAG_EN > 0
            case FLAG_REQ:              /* Flag set request,call handler      */
                  CoSetFlag(pcell->id);
                  break;
#endif	 
#if CFG_QUEUE_EN > 0
            case QUEUE_REQ:             /* Queue post request,call handler    */
				  CoPostQueueMail(pcell->id,pcell->arg);
                  break;
#endif
            default:                    /* Others,break                       */
                  break;
		}
    pcell->type = 0;                    /* Initialize the service request cell*/
    pcell->id   = 0;
    pcell->arg  = 0;	
	}
    ServiceReq.cnt = 0;               /* Initialize the service request queue */
#endif
    IsrReq = FALSE;
}
Exemple #2
0
StatusType isr_PostMail(OS_EventID id,void* pmail)
{
    if(OSSchedLock > 0)         /* If scheduler is locked,(the caller is ISR) */
    {
        /* Insert the request into service request queue                      */
        if(InsertInSRQ(MBOX_REQ,id,pmail) == FALSE)  
        {
            return E_SEV_REQ_FULL;        /* If service request queue is full */
        }			
        else                              /* Operate successfully             */
        {
            return E_OK;
        }
    }
    else
    {
        return(CoPostMail(id,pmail));     /* Sends the message to the mailbox */ 
    }
}
Exemple #3
0
/**
 *******************************************************************************
 * @brief      Respond the request in the service request queue.
 * @param[in]  None
 * @param[out] None
 * @retval     None
 *
 * @par Description
 * @details    This function be called to respond the request in the service
 *             request queue.
 * @note
 *******************************************************************************
 */
void RespondSRQ(void) {

#if CFG_MAX_SERVICE_REQUEST > 0
	SQC cell;

#endif

#if (CFG_TASK_WAITTING_EN > 0)
	if(TimeReq == Co_TRUE) {               /* Time delay request?                */
		TimeDispose();                  /* Yes,call handler                   */
		TimeReq = Co_FALSE;                /* Reset time delay request Co_FALSE     */
	}
#endif
#if CFG_TMR_EN  > 0
	if(TimerReq == Co_TRUE) {              /* Timer request?                     */
		TmrDispose();                   /* Yes,call handler                   */
		TimerReq = Co_FALSE;               /* Reset timer request Co_FALSE          */
	}
#endif

#if CFG_MAX_SERVICE_REQUEST > 0

	while (ServiceReq.cnt != 0) {
		IRQ_DISABLE_SAVE ();            /* need to protect the following      */
		cell = ServiceReq.cell[ServiceReq.head];  /* extract one cell         */
		ServiceReq.head = (ServiceReq.head + 1) % /* move head (pop)          */
						  CFG_MAX_SERVICE_REQUEST;
		ServiceReq.cnt--;
		IRQ_ENABLE_RESTORE ();          /* now use the cell copy              */

		switch(cell.type) {             /* Judge service request type         */
#if CFG_SEM_EN > 0
			case SEM_REQ:                   /* Semaphore post request,call handler*/
				CoPostSem(cell.id);
				break;
#endif
#if CFG_MAILBOX_EN > 0
			case MBOX_REQ:                  /* Mailbox post request,call handler  */
				CoPostMail(cell.id, cell.arg);
				break;
#endif
#if CFG_FLAG_EN > 0
			case FLAG_REQ:                  /* Flag set request,call handler      */
				CoSetFlag(cell.id);
				break;
#endif
#if CFG_QUEUE_EN > 0
			case QUEUE_REQ:                 /* Queue post request,call handler    */
				CoPostQueueMail(cell.id, cell.arg);
				break;
#endif
			default:                        /* Others,break                       */
				break;
		}
	}
#endif
	IRQ_DISABLE_SAVE ();                /* need to protect the following      */

	if (ServiceReq.cnt == 0) {          /* another item in the queue already? */
		IsrReq = Co_FALSE;                 /* queue still empty here             */
	}
	IRQ_ENABLE_RESTORE ();              /* now it is done and return          */
}