📄 tmt.s
字号:
;************************************************************************
;*
;* Copyright Mentor Graphics Corporation 2005
;* All Rights Reserved.
;*
;* THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION WHICH IS
;* THE PROPERTY OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS AND IS
;* SUBJECT TO LICENSE TERMS.
;*
;************************************************************************
;************************************************************************
;*
;* FILE NAME VERSION
;*
;* tmt.s Nucleus PLUS\ARM926 DM320\Code Composer 1.15.1
;*
;* COMPONENT
;*
;* TM - Timer Management
;*
;* DESCRIPTION
;*
;* This file contains the target dependent routines of the timer
;* management component.
;*
;* GLOBAL FUNCTIONS
;*
;*
;* *****************************
;* * GENERIC FUNCTIONS *
;* *****************************
;*
;* TMT_Set_Clock Set system clock
;* TMT_Retrieve_Clock Retrieve system clock
;* TMT_Read_Timer Read count-down timer
;* TMT_Enable_Timer Enable count-down timer
;* TMT_Adjust_Timer Adjust count-down timer
;* TMT_Disable_Timer Disable count-down timer
;* TMT_Retrieve_TS_Task Retrieve time-sliced task ptr
;* TMT_Timer_Interrupt Process timer interrupt
;*
;* *****************************
;* * TARGET SPECIFIC FUNCTIONS *
;* *****************************
;*
;* LOCAL FUNCTIONS
;*
;* None
;*
;************************************************************************
;**********************************
;* INCLUDE ASSEMBLY CONSTANTS *
;**********************************
.include asm_defs.inc
;**********************************
;* EXTERNAL VARIABLE DECLARATIONS *
;**********************************
;extern VOID *TCD_Current_Thread;
;extern UNSIGNED TMD_System_Clock;
;extern UNSIGNED TMD_Timer;
;extern INT TMD_Timer_State;
;extern UNSIGNED TMD_Time_Slice;
;extern TC_TCB *TMD_Time_Slice_Task;
;extern INT TMD_Time_Slice_State;
;extern TC_HCB TMD_HISR;
.ref _TCD_Current_Thread
.ref _TMD_System_Clock
.ref _TMD_Timer
.ref _TMD_Timer_State
.ref _TMD_Time_Slice
.ref _TMD_Time_Slice_Task
.ref _TMD_Time_Slice_State
.ref _TMD_HISR
;**********************************
;* EXTERNAL FUNCTION DECLARATIONS *
;**********************************
;VOID TCT_Activate_HISR(TC_HISR *hisr);
;VOID TCT_Interrupt_Context_Save(VOID);
;VOID TCT_Interrupt_Context_Restore(VOID);
.ref _TCT_Activate_HISR
.ref _TCT_Interrupt_Context_Save
.ref _TCT_Interrupt_Context_Restore
;**********************************
;* GLOBAL VARIABLE DECLARATIONS *
;**********************************
; No global variable declarations
;**********************************
;* LOCAL VARIABLES *
;**********************************
.text
.align 4
; The following are local variables. ARM Architecture uses
; PC relative addressing, so all global data accessed must
; reside within close proximity (<4Kb in ARM, <1Kb in THUMB)
; to the instructions that access them.
; These are essentially pointers to global data.
TMT_System_Clock
.word _TMD_System_Clock
TMT_Timer
.word _TMD_Timer
TMT_Timer_State
.word _TMD_Timer_State
TMT_Slice_State
.word _TMD_Time_Slice_State
TMT_Time_Slice
.word _TMD_Time_Slice
TMT_Current_Thread
.word _TCD_Current_Thread
TMT_Slice_Task
.word _TMD_Time_Slice_Task
TMT_HISR
.word _TMD_HISR
INT_BASE_ADDRESS1
.word INT_BASE_ADDRESS
;************************************************************************
;*
;* FUNCTION
;*
;* TMT_Set_Clock
;*
;* DESCRIPTION
;*
;* This function sets the system clock to the specified value.
;*
;* CALLED BY
;*
;* Application
;*
;* CALLS
;*
;* None
;*
;* INPUTS
;*
;* r0 - new clock value
;*
;* OUTPUTS
;*
;* None
;*
;* REGISTERS MODIFIED
;*
;* r1
;*
;* HISTORY
;*
;* NAME DATE REMARKS
;*
;* S. Nguyen 03/28/2005 Released version 1.15.1
;*
;************************************************************************
;VOID TMT_Set_Clock(UNSIGNED new_value)
.def _TMT_Set_Clock
_TMT_Set_Clock
; Set the system clock to the specified value.
LDR r1,TMT_System_Clock ; Build address of system clock
STR r0,[r1] ; Store new system clock value
; Return to caller
BX lr
;************************************************************************
;*
;* FUNCTION
;*
;* TMT_Retrieve_Clock
;*
;* DESCRIPTION
;*
;* This function returns the current value of the system clock.
;*
;* CALLED BY
;*
;* Application
;*
;* CALLS
;*
;* None
;*
;* INPUTS
;*
;* None
;*
;* OUTPUTS
;*
;* r0 - TMD_System_Clock
;*
;* REGISTERS MODIFIED
;*
;* None
;*
;* HISTORY
;*
;* NAME DATE REMARKS
;*
;* S. Nguyen 03/28/2005 Released version 1.15.1
;*
;************************************************************************
;UNSIGNED TMT_Retrieve_Clock(void)
.def _TMT_Retrieve_Clock
_TMT_Retrieve_Clock
; Return the current value of the system clock.
LDR r0,TMT_System_Clock ; Build address to system clock
LDR r0,[r0] ; Pickup system clock contents
; Return to caller
BX lr
;************************************************************************
;*
;* FUNCTION
;*
;* TMT_Read_Timer
;*
;* DESCRIPTION
;*
;* This function returns the current value of the count-down timer.
;*
;* CALLED BY
;*
;* TMC_Start_Timer Start timer function
;*
;* CALLS
;*
;* None
;*
;* INPUTS
;*
;* None
;*
;* OUTPUTS
;*
;* r0 - value of count-down timer
;*
;* REGISTERS MODIFIED
;*
;* r0
;*
;* HISTORY
;*
;* NAME DATE REMARKS
;*
;* S. Nguyen 03/28/2005 Released version 1.15.1
;*
;************************************************************************
;UNSIGNED TMT_Read_Timer(void)
.def _TMT_Read_Timer
_TMT_Read_Timer
; Return the current value of the count-down timer.
LDR r0,TMT_Timer ; Build address to timer
LDR r0,[r0] ; Pickup timer contents
; Return to caller
BX lr
;************************************************************************
;*
;* FUNCTION
;*
;* TMT_Enable_Timer
;*
;* DESCRIPTION
;*
;* This function enables the count-down timer with the specified
;* value.
;*
;* CALLED BY
;*
;* TMC_Start_Timer Start timer function
;* TMC_Timer_Task Timer expiration task
;*
;* CALLS
;*
;* None
;*
;* INPUTS
;*
;* r0 - New count-down time
;*
;* OUTPUTS
;*
;* None
;*
;* REGISTERS MODIFIED
;*
;* r0, r1
;*
;* HISTORY
;*
;* NAME DATE REMARKS
;*
;* S. Nguyen 03/28/2005 Released version 1.15.1
;*
;************************************************************************
;VOID TMT_Enable_Timer(UNSIGNED time)
.def _TMT_Enable_Timer
_TMT_Enable_Timer
; Place the new time value into the count-down timer.
LDR r1,TMT_Timer ; Build address of timer
STR r0,[r1] ; Store new timer value
; Indicate that the timer is active.
MOV r0,#0 ; Build TM_ACTIVE value
LDR r1,TMT_Timer_State ; Build address of timer state var
STR r0,[r1] ; Change the state to active
; Return to caller
BX lr
;************************************************************************
;*
;* FUNCTION
;*
;* TMT_Adjust_Timer
;*
;* DESCRIPTION
;*
;* This function adjusts the count-down timer with the specified
;* value - if the new value is less than the current.
;*
;* CALLED BY
;*
;* TMC_Start_Timer Start timer function
;*
;* CALLS
;*
;* None
;*
;* INPUTS
;*
;* r0 - New count-down time
;*
;* OUTPUTS
;*
;* None
;*
;* REGISTERS MODIFIED
;*
;* r1, r2, r3
;*
;* HISTORY
;*
;* NAME DATE REMARKS
;*
;* S. Nguyen 03/28/2005 Released version 1.15.1
;*
;************************************************************************
;VOID TMT_Adjust_Timer(UNSIGNED time)
.def _TMT_Adjust_Timer
_TMT_Adjust_Timer
; Lockout all interrupts
MRS r3,CPSR ; Pickup current CPSR
ORR r2,r3,#LOCKOUT ; Build lockout CPSR (r3 = orig CPSR value)
MSR CPSR,r2 ; Setup new CPSR interrupt bits
; Check for the new value is less than the current time value
LDR r1,TMT_Timer ; Build address to timer var
LDR r2,[r1] ; read value of the timer
CMP r2,r0 ; Compare timer and passed-in time
; Adjust timer with passed in value
STRHI r0,[r1]
TMT_No_Adjust
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -