📄 os_cpu_c.c
字号:
/*******************************************************************************
* 礐OS-II Blackfin port test example
* Blackfin Applications Team, Analog Devices Inc.,
* Norwood, MA, US
*
* File: os_cpu_c.c
* Author: Deep Bodapati
* Last Modified: 10-10-2006
* Project: 礐OS-II Blackfin port
* Platform: Any (EZKit, custom boards etc.)
* Tools: VisualDSP++ 4.5 (Updated September 2006)
* 礐OS-II Version: v2.83
*
* This file is part of the 礐OS-II port to the Blackfin processor.
******************************************************************************/
/*
Copyright...
This code is placed in the public domain, and can be distributed freely with no restrictions provided that the heading
of each source module file is not modified to remove the credit to the original author.
Disclaimer...
This program code is provided "as is". There is no warranty, either expressed or implied as to its fitness for use in
any application. It is provided only as an example of porting the MicroC/OS operating system to the Blackfin processor.
Its use is strictly at the risk of the user. The author will not be liable for any damages direct or consequential related
to the use of this software including, but not limited to loss of profit.
*/
#include <cdefBF53x.h>
#include <sys/exception.h>
#include <ucos_ii.h>
#include <app.h> /* This file included only for the app_Init prototype */
/*
*****************************************************************************
*
* Global Variables
*
*****************************************************************************
*/
/*
*****************************************************************************
*
* Function Protoypes
*
*****************************************************************************
*/
EX_INTERRUPT_HANDLER(OSTickISR);
/*
*********************************************************************************************************
* TASK EXIT HOOK
*
* Description: This function is called when a task exits
*
* Arguments : none
*
*********************************************************************************************************
*/
void OSTaskExitHook(void)
{
}
/*
*********************************************************************************************************
* 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)
{
}
/*
*********************************************************************************************************
* 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.
*********************************************************************************************************
*/
void OSTaskDelHook(OS_TCB *ptcb)
{
#if OS_TASK_CREATE_EXT_EN == 1
free((void *)ptcb->OSTCBStkBottom); // Free stack memory used by the task that was just deleted
#endif
}
#if OS_TASK_SW_HOOK_EN
/*
*********************************************************************************************************
* 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)
{
}
#endif
/*
*********************************************************************************************************
* TCB Init HOOK
*
* Description:
*
* Arguments : pointer to TCB
*********************************************************************************************************
*/
void OSTCBInitHook(OS_TCB *ptcb)
{
}
/*
*********************************************************************************************************
* Init HOOK begin & end
*
* Description:
*
* Arguments : pointer to TCB
*********************************************************************************************************
*/
void OSInitHookBegin(void)
{
}
void OSInitHookEnd(void)
{
app_init();
// Register the context switch handler for IVG14 and enable Interrupt 14 in IMASK
register_handler_ex (ik_ivg14, (ex_handler_fn)OSCtxSw, EX_INT_ENABLE);
}
/*
*********************************************************************************************************
* 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)
{
}
#if OS_TIME_TICK_HOOK_EN
/*
*********************************************************************************************************
* TICK HOOK
*
* Description: This function is called every tick.
*
* Arguments : none
*
* Note(s) : 1) Interrupts may or may not be ENABLED during this call.
*********************************************************************************************************
*/
void OSTimeTickHook(void)
{
}
#endif
/*
*********************************************************************************************************
* IDLE HOOK
*
* Description: This function is called by uC/OS-ii IDLE Task.
*
* Arguments : none
*
* Note(s) : 1) This hook function is called when the IDLE task executes - place code here that
* needs to be done when the processor is 'idle' i.e. no tasks are being executed.
* 2) This function doesn't have to return to the call i.e. while(1) is ok.
* 3) Interrupts may or may not be ENABLED during this call.
*********************************************************************************************************
*/
void OSTaskIdleHook(void)
{
}
/*
*********************************************************************************************************
* INITIALIZE A TASK'S STACK
*
* Description: This function is called by either OSTaskCreate() or OSTaskCreateExt() to initialize the
* stack frame of the task being created. This function is highly processor specific.
*
* Arguments : task is a pointer to the task code
*
* pdata is a pointer to a user supplied data area that will be passed to the task
* when the task first executes.
*
* ptos is a pointer to the top of stack. It is assumed that 'ptos' points to
* a 'free' entry on the task stack. If OS_STK_GROWTH is set to 1 then
* 'ptos' will contain the HIGHEST valid address of the stack. Similarly, if
* OS_STK_GROWTH is set to 0, the 'ptos' will contains the LOWEST valid address
* of the stack.
*
* opt specifies options that can be used to alter the behavior of OSTaskStkInit().
* (see uCOS_II.H for OS_TASK_OPT_???).
*
* Returns : Always returns the location of the new top-of-stack' once the processor registers have
* been placed on the stack in the proper order.
*
* Note(s) : This function does the following (refer to Porting chapter (Chapter 13 of uCOS-II book)
* (1) Simulate a function call to the task with an argument
* (2) Simulate an interrupt vector
* (3) Setup stack frame to contain desired initial values of all registers
* (4) Return top of stack pointer to the caller
*
* Refer to VisualDSP++ C/C++ Compiler and Library Manual for Blackfin Processors
* and ADSP-BF53x/BF56x Blackfin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -