📄 lcdinit.asm
字号:
;**************************************************************************
;*
;* LCDINIT.ASM
;*
;* Copyright (c) 1998-1999 National Semiconductor Corporation.
;* All Rights Reserved.
;*
;* Function:
;* LCD initialization routine.
;*
;* $Revision:: 2 $
;*
;**************************************************************************
.486P
INCLUDE MACROS.INC
INCLUDE DEF.INC
INCLUDE PORT80.INC
INCLUDE STRINGS.INC
INCLUDE OPTIONS.INC
INCLUDE MPC.INC
INCLUDE VR.INC
_TEXT SEGMENT PUBLIC use16 'CODE'
EXTERN LCD_INIT_COUNT0:near
EXTERN LCD_INIT_TABLE0:near
EXTERN LCD_INIT_COUNT1:near
EXTERN LCD_INIT_TABLE1:near
EXTERN LCD_INIT_COUNT2:near
EXTERN LCD_INIT_TABLE2:near
EXTERN LCD_INIT_COUNT3:near
EXTERN LCD_INIT_TABLE3:near
EXTERN Delay_1_mSec:NEAR
;**************************************************************************
;*
;* lcdInit
;*
;* Initialize the LCD panel
;*
;* Entry: al defines resolution
;* 0: 640x480
;* 1: 800x600
;* 2: 1024x768
;* 3: unfixed
;* Exit:
;* Destroys:
;*
;**************************************************************************
lcdInit PROC NEAR PUBLIC
push dx
push cx
push ax
push si
;
; Configure LCD
;
mov dx, 03d4h ; Point to Video Extended Registers
cmp al, 1
je TFT800
jb TFT640
cmp al, 2
je TFT1024
UNFIXED:
mov cx, LCD_INIT_COUNT3
lea si, LCD_INIT_TABLE3
jmp LCDLoop
TFT640:
mov cx, LCD_INIT_COUNT0
lea si, LCD_INIT_TABLE0
jmp LCDLoop
TFT800:
mov cx, LCD_INIT_COUNT1
lea si, LCD_INIT_TABLE1
jmp LCDLoop
TFT1024:
mov cx, LCD_INIT_COUNT2
lea si, LCD_INIT_TABLE2
; jmp LCDLoop
LCDLoop:
mov al, cs:[si] ; Get index/data
inc si ; Advance table pointer
;;;;
;;;; The SC processor needs delays when turning on or off a TFT
;;;;
IF SCx2xx_PROCESSOR
cmp al, 50h ; look for index of 50h
jne LCDLoopContinue
mov ah, cs:[si] ; Get index/data
bt ax, 8 ; see if flat panel is getting turned on
jnc LCDDelay4
call SCTFTDelay21 ; A 21ms delay while we wait for the SC power to stabilize
jmp LCDLoopContinue
LCDDelay4:
call SCTFTDelay4 ; A 4ms delay while we wait for the SC power to stabilize
LCDLoopContinue:
ENDIF
out dx, al
xor dl, 1 ; Toggle between index & data registers
loop LCDLoop
noTFTPanel:
pop si
pop ax
pop cx
pop dx
ret
lcdInit ENDP
;**************************************************************************
;*
;* SCTFTDelay4
;*
;* A 4ms delay while we wait for the SC power to stabilize
;*
;* Exit:
;* Destroys:
;*
;**************************************************************************
SCTFTDelay4 proc near
pushad
mov cx, 4
LCDPowerDelay4:
call Delay_1_mSec
loop LCDPowerDelay4
popad
ret
SCTFTDelay4 endp
;**************************************************************************
;*
;* SCTFTDelay21
;*
;* A 21ms delay while we wait for the SC power to stabilize. Ok, really a
;* 25ms delay.
;*
;* Exit:
;* Destroys:
;*
;**************************************************************************
SCTFTDelay21 proc near
pushad
mov cx, 25
LCDPowerDelay21:
call Delay_1_mSec
loop LCDPowerDelay21
popad
ret
SCTFTDelay21 endp
_TEXT ENDS
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -