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

📄 os_cpu_c.c

📁 实现Fujitsu-FFMC-16-V120 ucos系统移植
💻 C
📖 第 1 页 / 共 2 页
字号:
                OS_EXIT_CRITICAL();
                rbank = i;
                break;
            }
            OS_EXIT_CRITICAL();
            BankMask <<= 1;
        }
    }
    else {
        OS_EXIT_CRITICAL();
    }
#endif

#if TASKS_CAN_USE_BANK0 == 0
    if (rbank == 0) {                           /* It Is Added in V1.02 by Sergey Pinigin  */
        return ((OS_STK *)(0));                 /* error create stack                      */
    }
#endif

    stk    = (INT16U *)ptos;                    /* Load stack pointer                      */

#if MEMMODEL == COMPACT || MEMMODEL == LARGE
    *stk-- = (INT16U)((INT32U)(pdata)>>16);     /* It Is Added in V1.01 */
#endif

    *stk-- = (INT16U)(pdata);                   /* Simulate call to function with argument */

#if MEMMODEL == MEDIUM || MEMMODEL == LARGE
    *stk-- = (INT16U)((INT32U)(task)>>16);      /* It Is Added in V1.01 */
#endif

    *stk-- = (INT16U)(task);                    /*                                         */
    *stk-- = (INT16U)0x9999;                    /* AH = 0x9999                             */
    *stk-- = (INT16U)0xAAAA;                    /* AL = 0xAAAA                             */
    *stk-- = Get_DPR_ADB_bank();                /* DPR | ADB                               */

#if MEMMODEL == SMALL || MEMMODEL == COMPACT
    *stk-- = Get_DTB_PCB_bank();                /* DTB | PCB                               */
#endif
#if MEMMODEL == MEDIUM || MEMMODEL == LARGE
    *stk-- = (Get_DTB_PCB_bank() & 0xff00) |
           (((INT32U)(task) >>16) & 0xff);      /* DTB | PCB                               */
#endif

    *stk-- = (INT16U)(task);                    /* PC                                      */
#if TASKS_USE_USP == 1                          /* It Is Added in V1.05 by Sergey Pinigin  */
    *stk   = (INT16U)((0xE0 | rbank)*256U+0x40);/* ILM=7, RB=rbank, Interrupts enabled,USB */
#else
    *stk   = (INT16U)((0xE0 | rbank)*256U+0x60);/* ILM=7, RB=rbank, Interrupts enabled,SSB */
#endif

#if TASKS_CAN_USE_BANK0 == 1
    if (rbank == 0) {                           /* Unless has been enough separate bank    */
        stk--;                                  /* Save registers in stack                 */
        *stk-- = (INT16U)0x7777;                /* RW7-bank(0)                             */
        *stk-- = (INT16U)0x6666;                /* RW6-bank(0)                             */
        *stk-- = (INT16U)0x5555;                /* RW5-bank(0)                             */
        *stk-- = (INT16U)0x4444;                /* RW4-bank(0)                             */
        *stk-- = (INT16U)0x3333;                /* RW3-bank(0)                             */
        *stk-- = (INT16U)0x2222;                /* RW2-bank(0)                             */
        *stk-- = (INT16U)0x1111;                /* RW1-bank(0)                             */
        *stk-- = (INT16U)0x8888;                /* RW0-bank(0)                             */
        *stk   = (INT16U)((0xE0 | 0)*256U+0x60);/* ILM=7, RB=0, Interrupts enabled         */
    }
#endif
    return ((OS_STK *)stk);
}

/*$PAGE*/
#if OS_CPU_HOOKS_EN
/*
*********************************************************************************************************
*                                       OS INITIALIZATION HOOK
*                                            (BEGINNING)
*
* Description: This function is called by OSInit() at the beginning of OSInit().
*
* Arguments  : none
*
* Note(s)    : 1) Interrupts should be disabled during this call.
*********************************************************************************************************
*/
#if OS_VERSION > 203
void OSInitHookBegin (void)
{
    OSFreeBankList = 0;
}
#endif

/*
*********************************************************************************************************
*                                       OS INITIALIZATION HOOK
*                                               (END)
*
* Description: This function is called by OSInit() at the end of OSInit().
*
* Arguments  : none
*
* Note(s)    : 1) Interrupts should be disabled during this call.
*              2) Initialization Delayed Interrupt prio. Be sure, that for your
*                 F2MC-16LX chip - ICR15 is "delayed interrupt" control register.
*
*********************************************************************************************************
*/
#if OS_VERSION > 203
void OSInitHookEnd (void)
{
    /* Set delayed interrupt priority                  */
    /* It is Important!!! Must have least priority - 6 */
    ICR15 = 6;                         /*  IRQ41 IRQ42 */
}
#endif


/*
*********************************************************************************************************
*                                          TASK CREATION HOOK
*
* Description: This function is called when a task is created.
*
* Arguments  : ptcb   is a pointer to the task control block of the task being created.
*
* Note(s)    : 1) Interrupts are disabled during this call.
*********************************************************************************************************
*/
void OSTaskCreateHook (OS_TCB *ptcb)
{
    ptcb = ptcb;                       /* Prevent compiler warning                                     */
}


/*
*********************************************************************************************************
*                                           TASK DELETION HOOK
*
* Description: This function is called when a task is deleted.
*
* Arguments  : ptcb   is a pointer to the task control block of the task being deleted.
*
* Note(s)    : 1) Interrupts are disabled during this call.
*              2) This hook frees bank of registers of deleted task
*********************************************************************************************************
*/
void OSTaskDelHook (OS_TCB *ptcb)
{
#if OS_SCAN_FREE_BANK != 0
    INT8U rbank;

    if (ptcb->OSTCBPrio == OSPrioCur) {      /* Check, deletes task itself                             */
      rbank = Get_RP();                      /* If yes, that take number of current bank of registers  */
    }
    else {                                   /* If deletes other task, that take the number of bank    */
      rbank = (*ptcb->OSTCBStkPtr>>8) & 0x1f;/* of registers on top of stack of this task.             */
    }
    OSFreeBankList &= ~(1L<<rbank);            /* Note the bank in list as unused.                       */

                                             /* (1L<<rbank) is Added in V1.02 (was (1<<rbank) )        */

#else
    ptcb = ptcb;
#endif
}

/*
*********************************************************************************************************
*                                           TASK SWITCH HOOK
*
* Description: This function is called when a task switch is performed.  This allows you to perform other
*              operations during a context switch.
*
* Arguments  : none
*
* Note(s)    : 1) Interrupts are disabled during this call.
*              2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that
*                 will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the
*                 task being switched out (i.e. the preempted task).
*********************************************************************************************************
*/
void OSTaskSwHook (void)
{
}

/*
*********************************************************************************************************
*                                           STATISTIC TASK HOOK
*
* Description: This function is called every second by uC/OS-II's statistics task.  This allows your
*              application to add functionality to the statistics task.
*
* Arguments  : none
*********************************************************************************************************
*/
void OSTaskStatHook (void)
{
}

/*
*********************************************************************************************************
*                                           OSTCBInit() HOOK
*
* Description: This function is called by OSTCBInit() after setting up most of the TCB.
*
* Arguments  : ptcb    is a pointer to the TCB of the task being created.
*
* Note(s)    : 1) Interrupts may or may not be ENABLED during this call.
*********************************************************************************************************
*/
#if OS_VERSION > 203
void OSTCBInitHook (OS_TCB *ptcb)
{
  ptcb = ptcb;
}
#endif


/*
*********************************************************************************************************
*                                               TICK HOOK
*
* Description: This function is called every tick.
*
* Arguments  : none
*
* Note(s)    : 1) Interrupts may or may not be ENABLED during this call.
*              2) Clears the interrupt request flag of timer, which is used as system tick timer
*********************************************************************************************************
*/
void OSTimeTickHook (void)
{
    CLEAR_TICK_ISR_REQUEST();
}


/*
*********************************************************************************************************
*                                             IDLE TASK HOOK
*
* Description: This function is called by the idle task.  This hook has been added to allow you to do
*              such things as STOP the CPU to conserve power.
*
* Arguments  : none
*
* Note(s)    : 1) Interrupts are enabled during this call.
*********************************************************************************************************
*/
#if OS_VERSION >= 205
void OSTaskIdleHook (void)
{
}
#endif
#endif

⌨️ 快捷键说明

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