?? driv_coretimer_asm.s
字號:
/*
*********************************************************************************************************
* uC/OS-II
* The Real-Time Kernel
*
* Driver functions for
* ADSP-BF533 Core Timer
*
* File : Driv_CoreTimer_Asm.s
* By : Ron Territo ron@territocomputerservices.com
*********************************************************************************************************
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 <cdefBF533.h>
#include "uCOS-II_V2.70\os_cfg.h";
.import "uCOS-II_V2.70\source\ucos_ii.h";
/*
*****************************************************************************
*
* Global variables
*
*****************************************************************************
*/
.extern _CpuRegisterEventHandler;
.extern _CpuEnableEvent;
.extern _CpuSaveContext;
.extern _CpuRestoreContext;
.extern struct OS_TCB _OSTCBCur;
.extern _OSIntExit;
.extern _OSIntNesting;
.extern _OSRunning;
.extern _OSPrioCur;
.extern _OSPrioHighRdy;
.extern OSTCBHighRdy;
.extern _OSTCBHighRdy;
.section data1;
.var __IRQCallback; // address of callback function from IRQ
.var __TimerSaveMask;
.section program;
/*
*********************************************************************************************************
*
* Core Timer Initialization
*
* Description: This function is called to initialize the Core Timer
*
*
* Arguments : SCALE - Value for Scale register
* TICK - Count for load- reload registers
* ISR - Address of callback function called at ISR
*
*********************************************************************************************************
*/
.global _CoreTimerInit;
_CoreTimerInit:
[ --sp ] = rets;
/* Clear TCNTL */
p1.H = ( TCNTL >>16 );
p1.L = ( TCNTL &0xFFFF );
r3 = 1; // Only power on
[ p1 ] = r3;
/* Load TSCALE */
p1.H = ( TSCALE >>16 );
p1.L = ( TSCALE &0xFFFF );
[ p1 ] = r0; // Load scale factor ( arg 1 )
/* Load TCOUNT */
p1.H = ( TCOUNT >>16 );
p1.L = ( TCOUNT &0xFFFF );
[ p1 ] = r1; // Load counter ( arg 2 )
/* Load TPERIOD */
p1.H = ( TPERIOD >>16 );
p1.L = ( TPERIOD &0xFFFF );
[ p1 ] = r1; // Load re-load count ( arg 2 )
/* Set up interrupt vectors */
p1.H = __IRQCallback;
p1.L = __IRQCallback;
[ p1 ] = r2; // save callback function address ( arg 3 )
r0 = 6; // Interrupt Event 6 = Core Timer
r1.H = _CoreTimerInt;
r1.L = _CoreTimerInt;
call _CpuRegisterEventHandler;
r0 = 0x40; // Interrupt Masj 0x40 = Core Timer
call _CpuEnableEvent;
/* Load TCNTL */
p1.H = ( TCNTL >>16 );
p1.L = ( TCNTL &0xFFFF );
r1 = 0x07; // Power On, Enabled, Auto-Reload
[ p1 ] = r1;
rets = [ sp++ ];
rts;
_CoreTimerInit.end:
/*
****************************************
*
* Core Timer Interrupt Handler
* for uC/OS-II
* Calls -C- callback function
*
****************************************
*/
_CoreTimerInt:
[ --sp ] = r0;
[ --sp ] = p1;
cli r0; // stop all ints
p1.H = __TimerSaveMask;
p1.L = __TimerSaveMask;
[ p1 ] = r0;
p1 = [ sp++ ];
r0 = [ sp++ ];
[ --sp ] = reti;
[ --sp ] = fp; // save system regs
[ --sp ] = astat;
[ --sp ] = rets;
call _CpuSaveContext; // save context
p1.H = _OSRunning; // get OS Running state
p1.L = _OSRunning;
r1 = [ p1 ];
cc = r1 == 0; // is OS Running ?
if cc jump __CoreTimerIntX; // no.. go exit
p1.H = _OSIntNesting; // get OS Int Nesting level
p1.L = _OSIntNesting;
r1 = [ p1 ];
r1 += 1; // bump level
[ p1 ] = r1;
cc = r1 == 1; // is first nested level ?
if !cc jump __CoreTimerInt1; // no.. go do Tick
p1.H = _OSTCBCur;
p1.L = _OSTCBCur;
p2 = [ p1 ];
[ p2 + OFFSETOF(OS_TCB,OSTCBStkPtr)] = sp; // save the Stack for the current task
__CoreTimerInt1:
p1.H = __IRQCallback; // call callback
p1.L = __IRQCallback;
p1 = [ p1 ];
call ( p1 );
call _OSIntExit; // exit interrupt
__CoreTimerIntX:
.if OS_TASK_SW_HOOK_EN == 1;
/* Do the task switch hook function*/
call _OSTaskSwHook;
.endif;
/* Get a new task Priority */
p1.L = _OSPrioHighRdy;
p1.H = _OSPrioHighRdy;
r1 = B [ p1 ](Z);
/* Make it the current priority */
p1.L = _OSPrioCur;
p1.H = _OSPrioCur;
B [ p1 ] = r1;
/* Get a new ready task */
p1.L = _OSTCBHighRdy;
p1.H = _OSTCBHighRdy;
p2 = [ p1 ];
/* Make it the current task */
p1.L = _OSTCBCur;
p1.H = _OSTCBCur;
[ p1 ] = p2;
/* load the stack pointer for the new task */
sp = [ p2 + OFFSETOF(OS_TCB,OSTCBStkPtr) ];
/* Restore everything for new task */
call _CpuRestoreContext; // restore register file
rets = [ sp++ ]; // restore sys regs
astat = [ sp++ ];
fp = [ sp++ ];
reti = [ sp++ ];
[ --sp ] = r0; // restore interrupt mask
[ --sp ] = p1;
p1.H = __TimerSaveMask;
p1.L = __TimerSaveMask;
r0 = [ p1 ];
sti r0;
p1 = [ sp++ ];
r0 = [ sp++ ];
rti;
_CoreTimerInt.end:
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -