Beispiel #1
0
void  OSTimeTick (void)
{
#if ((OS_CFG_TASK_TICK_EN == DEF_ENABLED) || (OS_CFG_TMR_EN == DEF_ENABLED))
    OS_ERR  err;
#endif


    if (OSRunning != OS_STATE_OS_RUNNING) {
        return;
    }

    OSTimeTickHook();                                           /* Call user definable hook                             */

#if (OS_CFG_TASK_TICK_EN == DEF_ENABLED)

   (void)OSTaskSemPost(&OSTickTaskTCB,                          /* Signal tick task                                     */
                        OS_OPT_POST_NONE,
                       &err);


#if (OS_CFG_SCHED_ROUND_ROBIN_EN == DEF_ENABLED)
    OS_SchedRoundRobin(&OSRdyList[OSPrioCur]);
#endif

#if (OS_CFG_TMR_EN == DEF_ENABLED)
    OSTmrUpdateCtr--;
    if (OSTmrUpdateCtr == 0u) {
        OSTmrUpdateCtr = OSTmrUpdateCnt;
        (void)OSTaskSemPost(&OSTmrTaskTCB,                      /* Signal timer task                                    */
                             OS_OPT_POST_NONE,
                            &err);
    }
#endif
#endif
}
void  OSTimeTick (void)
{
    OS_ERR  err;
#if OS_CFG_ISR_POST_DEFERRED_EN > 0u
    CPU_TS  ts;
#endif


    OSTimeTickHook();                                       /* Call user definable hook                               */

#if OS_CFG_ISR_POST_DEFERRED_EN > 0u

    ts = OS_TS_GET();                                       /* Get timestamp                                          */
    OS_IntQPost((OS_OBJ_TYPE) OS_OBJ_TYPE_TICK,             /* Post to ISR queue                                      */
                (void      *)&OSRdyList[OSPrioCur],
                (void      *) 0,
                (OS_MSG_SIZE) 0u,
                (OS_FLAGS   ) 0u,
                (OS_OPT     ) 0u,
                (CPU_TS     ) ts,
                (OS_ERR    *)&err);

#else

   (void)OSTaskSemPost((OS_TCB *)&OSTickTaskTCB,            /* Signal tick task                                       */
                       (OS_OPT  ) OS_OPT_POST_NONE,
                       (OS_ERR *)&err);


#if OS_CFG_SCHED_ROUND_ROBIN_EN > 0u
    OS_SchedRoundRobin(&OSRdyList[OSPrioCur]);
#endif

#if OS_CFG_TMR_EN > 0u
    OSTmrUpdateCtr--;
    if (OSTmrUpdateCtr == (OS_CTR)0u) {
        OSTmrUpdateCtr = OSTmrUpdateCnt;
        OSTaskSemPost((OS_TCB *)&OSTmrTaskTCB,              /* Signal timer task                                      */
                      (OS_OPT  ) OS_OPT_POST_NONE,
                      (OS_ERR *)&err);
    }
#endif

#endif
}
void  OS_IntQRePost (void)
{
#if (OS_CFG_TMR_EN == DEF_ENABLED)
    CPU_TS  ts;
#endif
    OS_ERR  err;


    switch (OSIntQOutPtr->Type) {                               /* Re-post to task                                      */
        case OS_OBJ_TYPE_FLAG:
#if (OS_CFG_FLAG_EN == DEF_ENABLED)
             (void)OS_FlagPost((OS_FLAG_GRP *) OSIntQOutPtr->ObjPtr,
                                OSIntQOutPtr->Flags,
                                OSIntQOutPtr->Opt,
#if (OS_CFG_TS_EN == DEF_ENABLED)
                                OSIntQOutPtr->TS,
#else
                                0u,
#endif
                               &err);
#endif
             break;

        case OS_OBJ_TYPE_Q:
#if (OS_CFG_Q_EN == DEF_ENABLED)
             OS_QPost((OS_Q *) OSIntQOutPtr->ObjPtr,
                       OSIntQOutPtr->MsgPtr,
                       OSIntQOutPtr->MsgSize,
                       OSIntQOutPtr->Opt,
#if (OS_CFG_TS_EN == DEF_ENABLED)
                        OSIntQOutPtr->TS,
#else
                        0u,
#endif
                      &err);
#endif
             break;

        case OS_OBJ_TYPE_SEM:
#if (OS_CFG_SEM_EN == DEF_ENABLED)
             (void)OS_SemPost((OS_SEM *) OSIntQOutPtr->ObjPtr,
                               OSIntQOutPtr->Opt,
#if (OS_CFG_TS_EN == DEF_ENABLED)
                               OSIntQOutPtr->TS,
#else
                               0u,
#endif
                              &err);
#endif
             break;

        case OS_OBJ_TYPE_TASK_MSG:
#if (OS_CFG_TASK_Q_EN == DEF_ENABLED)
             OS_TaskQPost((OS_TCB    *) OSIntQOutPtr->ObjPtr,
                          (void      *) OSIntQOutPtr->MsgPtr,
                           OSIntQOutPtr->MsgSize,
                           OSIntQOutPtr->Opt,
#if (OS_CFG_TS_EN == DEF_ENABLED)
                           OSIntQOutPtr->TS,
#else
                           0u,
#endif
                          &err);
#endif
             break;

        case OS_OBJ_TYPE_TASK_RESUME:
#if (OS_CFG_TASK_SUSPEND_EN == DEF_ENABLED)
             (void)OS_TaskResume((OS_TCB *) OSIntQOutPtr->ObjPtr,
                                 &err);
#endif
             break;

        case OS_OBJ_TYPE_TASK_SIGNAL:
             (void)OS_TaskSemPost((OS_TCB *) OSIntQOutPtr->ObjPtr,
                                   OSIntQOutPtr->Opt,
#if (OS_CFG_TS_EN == DEF_ENABLED)
                                   OSIntQOutPtr->TS,
#else
                                   0u,
#endif
                                  &err);
             break;

        case OS_OBJ_TYPE_TASK_SUSPEND:
#if (OS_CFG_TASK_SUSPEND_EN == DEF_ENABLED)
             (void)OS_TaskSuspend((OS_TCB *) OSIntQOutPtr->ObjPtr,
                                  &err);
#endif
             break;

        case OS_OBJ_TYPE_TICK:
#if (OS_CFG_TASK_TICK_EN == DEF_ENABLED)
#if (OS_CFG_SCHED_ROUND_ROBIN_EN == DEF_ENABLED)
             OS_SchedRoundRobin(&OSRdyList[OSPrioSaved]);
#endif

             (void)OS_TaskSemPost((OS_TCB *)&OSTickTaskTCB,     /* Signal tick task                                     */
                                   OS_OPT_POST_NONE,
#if (OS_CFG_TS_EN == DEF_ENABLED)
                                   OSIntQOutPtr->TS,
#else
                                   0u,
#endif
                                  &err);
#endif

#if (OS_CFG_TMR_EN == DEF_ENABLED)
             OSTmrUpdateCtr--;
             if (OSTmrUpdateCtr == 0u) {
                 OSTmrUpdateCtr = OSTmrUpdateCnt;
#if (OS_CFG_TS_EN == DEF_ENABLED)
                 ts             = OS_TS_GET();                  /* Get timestamp                                        */
#else
                 ts             = 0u;
#endif
                 (void)OS_TaskSemPost(&OSTmrTaskTCB,            /* Signal timer task                                    */
                                       OS_OPT_POST_NONE,
                                       ts,
                                      &err);
             }
#endif
             break;

        default:
             break;
    }
}
void  OS_IntQRePost (void)
{
    CPU_TS  ts;
    OS_ERR  err;


    switch (OSIntQOutPtr->Type) {                           /* Re-post to task                                        */
        case OS_OBJ_TYPE_FLAG:
#if OS_CFG_FLAG_EN > 0u
             (void)OS_FlagPost((OS_FLAG_GRP *) OSIntQOutPtr->ObjPtr,
                               (OS_FLAGS     ) OSIntQOutPtr->Flags,
                               (OS_OPT       ) OSIntQOutPtr->Opt,
                               (CPU_TS       ) OSIntQOutPtr->TS,
                               (OS_ERR      *)&err);
#endif
             break;

        case OS_OBJ_TYPE_Q:
#if OS_CFG_Q_EN > 0u
             OS_QPost((OS_Q      *) OSIntQOutPtr->ObjPtr,
                      (void      *) OSIntQOutPtr->MsgPtr,
                      (OS_MSG_SIZE) OSIntQOutPtr->MsgSize,
                      (OS_OPT     ) OSIntQOutPtr->Opt,
                      (CPU_TS     ) OSIntQOutPtr->TS,
                      (OS_ERR    *)&err);
#endif
             break;

        case OS_OBJ_TYPE_SEM:
#if OS_CFG_SEM_EN > 0u
             (void)OS_SemPost((OS_SEM *) OSIntQOutPtr->ObjPtr,
                              (OS_OPT  ) OSIntQOutPtr->Opt,
                              (CPU_TS  ) OSIntQOutPtr->TS,
                              (OS_ERR *)&err);
#endif
             break;

        case OS_OBJ_TYPE_TASK_MSG:
#if OS_CFG_TASK_Q_EN > 0u
             OS_TaskQPost((OS_TCB    *) OSIntQOutPtr->ObjPtr,
                          (void      *) OSIntQOutPtr->MsgPtr,
                          (OS_MSG_SIZE) OSIntQOutPtr->MsgSize,
                          (OS_OPT     ) OSIntQOutPtr->Opt,
                          (CPU_TS     ) OSIntQOutPtr->TS,
                          (OS_ERR    *)&err);
#endif
             break;

        case OS_OBJ_TYPE_TASK_RESUME:
#if OS_CFG_TASK_SUSPEND_EN > 0u
             (void)OS_TaskResume((OS_TCB *) OSIntQOutPtr->ObjPtr,
                                 (OS_ERR *)&err);
#endif
             break;

        case OS_OBJ_TYPE_TASK_SIGNAL:
             (void)OS_TaskSemPost((OS_TCB *) OSIntQOutPtr->ObjPtr,
                                  (OS_OPT  ) OSIntQOutPtr->Opt,
                                  (CPU_TS  ) OSIntQOutPtr->TS,
                                  (OS_ERR *)&err);
             break;

        case OS_OBJ_TYPE_TASK_SUSPEND:
#if OS_CFG_TASK_SUSPEND_EN > 0u
             (void)OS_TaskSuspend((OS_TCB *) OSIntQOutPtr->ObjPtr,
                                  (OS_ERR *)&err);
#endif
             break;

        case OS_OBJ_TYPE_TICK:
#if OS_CFG_SCHED_ROUND_ROBIN_EN > 0u
             OS_SchedRoundRobin(&OSRdyList[OSPrioSaved]);
#endif

             (void)OS_TaskSemPost((OS_TCB *)&OSTickTaskTCB,                /* Signal tick task                        */
                                  (OS_OPT  ) OS_OPT_POST_NONE,
                                  (CPU_TS  ) OSIntQOutPtr->TS,
                                  (OS_ERR *)&err);
#if OS_CFG_TMR_EN > 0u
             OSTmrUpdateCtr--;
             if (OSTmrUpdateCtr == (OS_CTR)0u) {
                 OSTmrUpdateCtr = OSTmrUpdateCnt;
                 ts             = OS_TS_GET();                             /* Get timestamp                           */
                 (void)OS_TaskSemPost((OS_TCB *)&OSTmrTaskTCB,             /* Signal timer task                       */
                                      (OS_OPT  ) OS_OPT_POST_NONE,
                                      (CPU_TS  ) ts,
                                      (OS_ERR *)&err);
             }
#endif
             break;

        default:
             break;
    }
}