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

📄 halasm.src

📁 Wince4.2 BSP for SH4 engineering development board
💻 SRC
字号:

;
;   Copyright (c) Renesas Technology Corp. 1999-2003
;
;   OEM Adaptation Layer
;
;	File		:	halasm.src
;	Created		:
;   Modified    :   2003.08.06
;   Author      :   Renesas Technology Corp.
;   Hardware    :   RENESAS HS7751RSTC01H (S1-E, ITS-DS5)
;   Target OS   :   Microsoft(R) Windows(R) CE .NET 4.2
;	NOTES   	:	
;	History		:
;					1999. 4.26  
;					- Modified for PFM-DS6x
;       				2001. 7. 4  
;       				- Modified for ITS-DS2A (BigSur AMANDA).
;       				2001.10.31  
;       				- Modified HalSleep independent to counter wraparound.
;       				2002. 5. 2  
;       				- Modified for HS7751RSTC01H (S1-E,ITS-DS5).
;       				2002. 9.26
;       				- Released for HS7751RSTC01H (S1-E,ITS-DS5).
;
;------------------------------------------------------------------------------
;
;  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
;  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
;  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
;  PARTICULAR PURPOSE.
;  Copyright (c) 1995-2000 Microsoft Corporation.  All rights reserved.
;  
;------------------------------------------------------------------------------


    .include "kxshx.h"
    .include "shx.inc"
    .include "s1e.inc"

;    .import _ClockToUSecLow
;    .import _ClockToUSecHigh
    .import _USecToClockLow
    .import _USecToClockHigh

    .section .text,code

;
; HalTimerInit:
;
;    Initializes an elapsed timer for use by the Hal. 
;
; Syntax:
;
;    void
;    HalTimerInit(
;        void
;        )
;
; Arguments:
;
;
; Return Value:
;

    LEAF_ENTRY _HalTimerInit

    mov.l   #TMU_REGBASE, r1
    mov.l   #~TMU_TSTR_STR1, r0
    mov.b   r0, @(TMU_TSTR_OFFSET, r1)  ; Stop Timer 1
    mov.l   #TMU_TCR_D4, r0
    mov.w   r0, @(TMU_TCR1_OFFSET, r1)  ; Use peripheral clock / 4
    mov.l   #h'ffffffff, r0
    mov.l   r0, @(TMU_TCNT1_OFFSET, r1) ; Set initial count
    mov.l   r0, @(TMU_TCOR1_OFFSET, r1) ; Set reload value
    mov.l   #TMU_TSTR_STR1, r2
    mov.b   @(TMU_TSTR_OFFSET, r1), r0
    or      r2, r0
    mov.b   r0, @(TMU_TSTR_OFFSET, r1)  ; Start Timer 1
    rts
    nop

    ENTRY_END _HalTimerInit

;
; HalSleep:
;
;    This routine waits for a desired number of microseconds, to the resolution
;    of the CPU's TMU timer and computational overhead.  This routine checks how
;    many times does the counter ticks instead of checking whether counter value
;    reach to desired value or not, so it can wait without considering wrap
;    around.
;     Note that USecToClockLow and UsecToClockHigh assumes 1/16 peripheral clock
;    to tick counter but we are using 1/4 for Timer1 so we need to shift them
;    2 bits to left.
;
; Syntax:
;
;    void
;    HalSleep(
;        DWORD nUSec
;        )
;
; Arguments:
;
;    nUSec (r4) - Provides the number of microseconds to wait.
;
; Return Value:
;
;    None.
;
;

    LEAF_ENTRY _HalSleep

    mov.l   #_USecToClockLow, r0        ; Get decimal fraction part.
    mov.l   @r0, r1                     ;   ..
    mov.l   #_USecToClockHigh, r0       ; Get integer part.
    mov.l   @r0, r2                     ;   ..
    shll    r1                          ; Shift [r2:r1] to left 2 bits.
    rotl    r2                          ;   ..
    shll    r1                          ;   ..
    rotl    r2                          ;   ..
    dmulu.l r1, r4                      ; Calculate nUSec * fraction part.
    sts     mach, r5                    ; Get upper DWORD of partial product.
    dmulu.l r2, r4                      ; Calculate nUSec * integer part.
    sts     macl, r3                    ; Get lower DWORD of partial product.
    add     r3, r5                      ; Add partial products.

    mov.l   #TMU_REGBASE, r0            ; Wait loop, it counts how many times
    mov.l   @(TMU_TCNT1_OFFSET, r0), r1 ;  does the TCNT1 ticks.
    mov     r1, r2                      ; Before entering loop, copy r1 to r2.
Loop:
    mov.l   @(TMU_TCNT1_OFFSET, r0), r2 ; Get current counter value
    cmp/eq  r1, r2                      ; Is counter ticked?
    bt      Loop                        ; When not ticked, return to Loop.
    dt      r5                          ; Is already ticked desired times?
    bf/s    Loop                        ; When not, return to Loop.
    mov     r2, r1                      ; Update value to comparate with.
    rts                                 ; Done, just return.
    nop                                 ; Delay slot, nothing to do.

    ENTRY_END _HalSleep

    .end

⌨️ 快捷键说明

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