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

📄 halasm.s

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 S
字号:
; Module Name:  
;   halasm.s
; 
; Abstract:     
;    This module implements Hal timer and Sleep routines.
;
; Functions:  	HalSleepTimerInit
; 		HalSleep
; 
; Notes: 
;
;--
	
	INCLUDE kxarm.h
	INCLUDE SA11x0bd.inc
	INCLUDE SA11x0.inc

SYSREG_B		EQU	0xAD400000  ; virtual address
	
    TEXTAREA
;
; HalSleepTimerInit:
;
;    Initializes an elapsed timer for use by the Hal. 
;
; Syntax:
;
;    void
;    HalTimerInit(
;        void
;        )
;
; Arguments:
;
;
; Return Value:
;

	LEAF_ENTRY HalSleepTimerInit

; program the trim register of the RTC to get a 1Hz clock

	stmfd	sp!, {r0-r2} 
	mov r1,#0x10000			; Real Time clock counter register RCNR
	add r1, r1, #0xA9000000
	add r1, r1, #0x8
	mov r2, #0x8C00
	add r2, r2, #0xCC
	str r2, [r1]
	ldmfd   sp!, {r0-r2}
	mov	pc, lr 


	LEAF_ENTRY PHalSleepTimerInit

; program the trim register of the RTC to get a 1Hz clock ***USE physical address

	stmfd	sp!, {r0-r2} 
	mov r1,#0x10000			; Real Time clock counter register RCNR
	add r1, r1, #0x90000000
	add r1, r1, #0x8
	mov r2, #0x8C00
	add r2, r2, #0xCC
	str r2, [r1]
	ldmfd   sp!, {r0-r2}
	mov	pc, lr 

;
; HalSleepP:
;
;    This routine waits for a desired number of microseconds, to the resolution
;    of the CPU's TMU timer and computational overhead.  Wrap-around is not
;    handled.
;
;		USES PHYSICAL ADDRESS
; Syntax:
;
;    void
;    HalSleep(
;        DWORD nUSec
;        )
;
; Arguments:
;
;    nUSec (r0) - Provides the number of microseconds to wait.
;
; Return Value:
;
;    None.
;
;

	LEAF_ENTRY PHalSleep

	stmfd	sp!, {r1-r3} 
 	mov     r1,#0x10000			; Real Time clock counter register RCNR
	add 	r1, r1, #0x90000000
	add	r1, r1, #0x4
 	ldr 	r1,=0x90010004
	ldr	r2,[r1]
	add 	r2,r2,r0
10	ldr 	r3,[r1]
	subs 	r3,r3,r2
	bne 	%B10		
	ldmfd   sp!, {r1-r3}
	mov	pc, lr 
;
; HalSleep:
;
;    This routine waits for a desired number of microseconds, to the resolution
;    of the CPU's TMU timer and computational overhead.  Wrap-around is not
;    handled.
;
; Syntax:
;
;    void
;    HalSleep(
;        DWORD nUSec
;        )
;
; Arguments:
;
;    nUSec (r0) - Provides the number of microseconds to wait.
;
; Return Value:
;
;    None.
;
;

	LEAF_ENTRY 1hzHalSleep

	stmfd	sp!, {r1-r3} 
 	mov     r1,#0x10000			; Real Time clock counter register RCNR
	add 	r1, r1, #0xA9000000
	add	r1, r1, #0x4
 	ldr 	r1,=0xA9010004
	ldr	r2,[r1]
	add 	r2,r2,r0
10	ldr 	r3,[r1]
	subs 	r3,r3,r2
	bne 	%B10		
	ldmfd   sp!, {r1-r3}
	mov	pc, lr 

;
; WriteHexLEDS:
;
;    Writes two nibbles of char out to LEDS
;    
;    
;
; Syntax:
;
;    void
;    WriteHexLEDS(
;        UCHAR val
;        )
;
; Arguments:
;
;    val (r0) - Provides the number of microseconds to wait.
;
; Return Value:
;
;    None.
;
;
	LEAF_ENTRY WriteHexLEDS

	stmfd	sp!, {r1, r2} 
        LDR     r1, =LEDBANK_VIRTUAL
        str     r0, [r1]
	ldmfd   sp!, {r1, R2}
	mov	pc, lr


	LEAF_ENTRY NepWriteHexLEDS

	mov	pc, lr  ;gds to get build to work
	stmfd	sp!, {r1, r2} 

        ; Write to SA1111DB 32 bit LED display
;        LDR     r2,  =SA1111DB_REG_BASE_VIRTUAL + LED_OFFSET        ; get SA1111DB Base reg addr
;	STR     r0,  [r2]            ; display 1st byte
;        MOV	r1, r0, LSR #8
;	STR     r1,  [r2, #+4]       ; display 2nd byte
;        MOV	r1, r0, LSR #16
;	STR     r1,  [r2, #+8]       ; display 3rd byte        
;	MOV	r1, r0, LSR #24
;	STR     r1,  [r2, #+12]       ; display 4th byte
	ldmfd   sp!, {r1, R2}
	mov	pc, lr


	LEAF_ENTRY SAWriteHexLEDS
	stmfd	sp!, {r1, r2}                                  
	; Write to numeric display
	LDR	R2, =SYSREG_B
	MOV	R1, r0, ROR #4
	AND	R1,R1,#0xF	;
	; Display First 4 bits on the Left Leds
	ORR	R1, R1, #0x30
	STRH	R1, [R2]
	AND	R1, R1, #0xEF
	STRH	R1, [R2]
	ORR	R1, R1, #0x30
	STRH	R1, [R2]
	; Display Second 4 bits on the right Leds
	MOV	R1, r0
	AND	R1, R1, #0xF	;
	ORR	R1, R1, #0x30
	STRH	R1, [R2]
	AND	R1, R1, #0xDF
	STRH	R1, [R2]
	ORR	R1, R1, #0x30
	STRH	R1, [R2]
	ldmfd   sp!, {r1, R2}
	mov	pc, lr 


	LEAF_ENTRY HalSleep

 	mov     r1, #0x10000			; Real Time clock counter register RCNR
	ldr 	r1, =RCNR_VIRTUAL
	ldr		r2, [r1]
	add 	r2, r2, r0
10	ldr 	r3, [r1]
	subs 	r3, r3, r2
	bne 	%B10		
	mov		pc, lr 


	; R0 has ~ # of Milliseconds sleep duration

	LEAF_ENTRY SWHalSleep
	stmfd	sp!, {r1, r2}
10	mov r1,#1000
20	mov r2,#100		; ~ one uSecond 
30	subs  r2,r2,#1		; ~ 10 nanoseconds @ 200 MHz
	bne %b30
	subs  r1,r1,#1
	bne %b20
	subs  r0,r0,#1
	bne %b10
	ldmfd   sp!, {r1, r2}
	mov	pc, lr 



	END

⌨️ 快捷键说明

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