您的位置:首页 > 其它

os_int.c

2016-02-21 19:19 211 查看
uC在处理从中断中post事件有两个模式:Direct、Deferred Post 。配置OS_CFG_ISR_POST_DEFERRED_EN选择两种模式。
个人比较倾向于Direct。
此文件中的函数与Deferred有关。





typedef  struct  os_int_q            OS_INT_Q;

struct  os_int_q {
    OS_OBJ_TYPE          Type;                              /* Type of object placed in the circular list             */
    OS_INT_Q            *NextPtr;                           /* Pointer to next OS_INT_Q in  circular list             */
    void                *ObjPtr;                            /* Pointer to object placed in the queue                  */
    void                *MsgPtr;                            /* Pointer to message if posting to a message queue       */
    OS_MSG_SIZE          MsgSize;                           /* Message Size       if posting to a message queue       */
    OS_FLAGS             Flags;                             /* Value of flags if posting to an event flag group       */
    OS_OPT               Opt;                               /* Post Options                                           */
    CPU_TS               TS;                                /* Timestamp                                              */
};

OS_INT_Q                 *OSIntQInPtr;
OS_INT_Q                 *OSIntQOutPtr;
OS_OBJ_QTY                OSIntQNbrEntries;
OS_OBJ_QTY                OSIntQNbrEntriesMax;
OS_OBJ_QTY                OSIntQOvfCtr;
OS_TCB                    OSIntQTaskTCB;
CPU_TS                    OSIntQTaskTimeMax;

OS_INT_Q       OSCfg_IntQ          [OS_CFG_INT_Q_SIZE];

void  OS_IntQPost (OS_OBJ_TYPE   type,
                   void         *p_obj,
                   void         *p_void,
                   OS_MSG_SIZE   msg_size,
                   OS_FLAGS      flags,
                   OS_OPT        opt,
                   CPU_TS        ts,
                   OS_ERR       *p_err):

    此函数在OS***Post()、OSTimeTick()中调用,将参数封装到OSIntQ中添加到Interrupt Queue(OS_IntQTaskInit()中初始化)中,Ready OSIntQTask。

void  OS_IntQTaskInit (OS_ERR  *p_err):

    OS内部函数,OSInit()调用。
    根据OSCfg_IntQBasePtr、OSCfg_IntQSize初始化Interrupt Queue(一个循环链表如下图,通过OSIntQNbrEntries、OSIntQInPtr、OSIntQOutPtr操作循环链表),创建OS_IntQTask任务。
    


void  OS_IntQTask (void  *p_arg):

    将Interrupt Queue中的内容,使用OS_IntQRePost()重新Post到具体的任务中

void  OS_IntQRePost (void):

    根据OSIntQOutPtr->Type,将对象重新Post到任务。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: