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

📄 lcd_phya_hx8310.msa

📁 Actions ucOS-II mp3方案源码,可以做参考
💻 MSA
字号:
/*************************************************************/
/*TFT lcd Driver Programm                            */
/* Write by yuyy      2005-10-29                             */
/* LCD: VL018A9A                            */
/* DRIVER IC:HX8310                         */
/*************************************************************/   
    
/****************LCD Instruction Parameter define**************************/
        public  LCM_BuffDataTrans
        public  LCM_FillBuffer
        public  LCM_Write_Pixel
        public  LCM_Fill_Area
        public  LCM_Read_Pixel
        public  LCM_Read_Area
        public  LCM_GPIOInit      
        public  LCM_Enable
        public  LCM_Disable  
        public  LCM_Write_Command
        public  Delay_10us
        public  Delay_1ms
        public  direction
        public  LCD_P0_BitFill 
        
#include "LCD_PHY_HX8310.H"  
      
        rseg    LCM_RCODE  
LCM_Enable:            
        push    af
        in      a,(02h)
        ld      ( lwrd  REG02HSAVED),a
        ld      a,10h
        out     (02h),a                     //enable CE2#         
        pop     af
        ret
        
LCM_Disable:            
        push    af
        ld      a,( lwrd  REG02HSAVED)
        out     (02h),a                        //disable CE2#         
        pop     af
        ret
        

/****************************LCD subfunction************************************/

/************************************************************/
/*  function:LCD_Init                                       */
/*  input                output                             */
/*  process: 1,switch LCD mode; 2,reset lcd  3,set CS       */
/************************************************************/   

        

LCM_GPIO_Enable:
        push     af
        in     a, ( GPIO_G_Out_Enable_Port)
        or        08h  
        out     (GPIO_G_Out_Enable_Port),a    // enable gpiok5,6 output    
        in     a, (GPIO_D_Out_Enable_Port)
        or     10h
        out     (GPIO_D_Out_Enable_Port), a         
        pop     af
        ret
LCM_RS_Reset:
        push       af
        in     a, (GPIO_G_Data_Port)
        and     0f7h  
        out     (GPIO_G_Data_Port),a    
        pop    af
        ret
LCM_RS_Set:
        push       af
        in     a, (GPIO_G_Data_Port)
        or    08h  
        out     (GPIO_G_Data_Port),a
        pop    af
        ret
LCM_RST_Reset:
        push    af
        in a,     (GPIO_D_Data_Port)
        and     0efh
        out     (GPIO_D_Data_Port), a 
        pop    af
        ret

LCM_RST_Set:
        push    af
        in     a, (GPIO_D_Data_Port)
        or     10h  
        out     (GPIO_D_Data_Port),a
        pop    af
        ret
LCM_GPIOInit:
        push     af
        ld      a,80h
        out     (0eeh),a
        call    lwrd LCM_GPIO_Enable
        call    lwrd LCM_RS_Reset
        call     lwrd Delay_10us
        call    lwrd LCM_RST_Reset
        call     lwrd Delay_10us
        call     lwrd Delay_10us
        call    lwrd LCM_RST_Set
        pop     af
        ret

   

LCM_Write_Command:
    push    ix
    ld      ix,00h
    add     ix,sp
    push    af
    push    hl
    call lwrd    LCM_Enable
    call lwrd    LCM_RS_Reset
    ld      a, d
    ld      (8000h),a 
    ld      a, E
    ld      (8000h),a
    call lwrd    LCM_RS_Set
    ld      a, b
    ld      (8000h),a
    ld      a, c
    ld      (8000h),a       
    call lwrd    LCM_Disable
    pop     hl
    pop     af
    pop     ix
    ret 

LCM_Write_Pixel:
        push af
        push de
        pop  bc
        ld   de,0x0022
        call lwrd LCM_Write_Command
        pop  af
        ret
        
LCM_Fill_Area:
        push af
        push hl
        call lwrd     LCM_Enable
        call lwrd    LCM_RS_Reset
        ld      a, 0x00
        ld      (8000h),a 
        ld      a, 0x22
        ld      (8000h),a
        call lwrd    LCM_RS_Set
LCM_Fill_Area_Loop:
                ld    a,c
                or    b
                jr    z,LCM_Fill_Area_exit
                dec  bc
        ld   a,d
        ld   (8000h),a
        ld   a,e
        ld   (8000h),a
        jr  LCM_Fill_Area_Loop
LCM_Fill_Area_exit:        
        //dec  bc
        //jr   nz,LCM_Fill_Area_Loop        
        //djnz LCM_Fill_Area_Loop
        call lwrd LCM_Disable
        pop  hl
        pop  af
        ret     
        
LCM_Read_Pixel:
        push af
        call lwrd     LCM_Enable
        call lwrd    LCM_RS_Reset
        ld      a, 0x00
        ld      (8000h),a 
        ld      a, 0x22
        ld      (8000h),a
        call lwrd    LCM_RS_Set
        ld   a,(8000h)
        ld   a,(8000h)
        ld   a,(8000h)
        ld   l,a
        ld   a,(8000h)
        ld   h,a
        call lwrd LCM_Disable
        pop  af
        ret
LCM_Read_Area
        push af
        push hl
        call lwrd LCM_Enable
        call lwrd LCM_RS_Set
        ld   hl,8000h
        ldir
        call lwrd LCM_Disable
        pop  hl
        pop     af
        ret  

////*******************************************************************************/
///* void LCM_BuffDataTrans ( char *buff , int datacnt);
//** FUNCTION:     Hdrv_BuffDataTrans
//** Description:  把指定 buff ,指定长度的数据送到 LCM 中
//**  input
//**     char *buff :数据 buffer 的首址 (de)
//**     int datacnt:传送数据的个数    (bc)
//**  output
//**     none
//********************************************************************************/
/*
void LCM_BuffDataTrans ( char *buff , int datacnt)
*/

LCM_BuffDataTrans:   
        push    af
        push    ix     
        //请在这填入你的代码 
        call     lwrd     LCM_Enable
        call lwrd    LCM_RS_Reset
        ld      a, 0x00
        ld      (8000h),a 
        ld      a, 0x22
        ld      (8000h),a
        call lwrd    LCM_RS_Set
                        
        //ld   a,( lwrd  TransMode)
        //or   a
        //jr   nz, DMATranMod       

        //用普通模式传送数据  
/*        
        //ld   ix,4000h
        //push de
        //pop  ix
BufferTransLoop:
        ld   a,(ix+0)
        ld   (8000h),a
        ld   a,(ix+1)
        ld   (8000h),a
        inc  ix
        inc  ix
        dec  c
        jr   nz,BufferTransLoop
        djnz BufferTransLoop                 
*/
        ex   de,hl
        ld   de,8000h    
        ldir 
        jr   LCM_BuffDataTrans_ret
DMATranMod: 
        //用DMA模式传送数据
           
LCM_BuffDataTrans_ret:        
        
        call lwrd  LCM_Disable 
        pop  ix
        pop  af                    
        ret   


/*
********************************************************************************
* Description : 把显示 buffer 指定空间的每个单元填充成指定的值
* Arguments   : 
                int *buf:         填充的 buffer的地址
*               int cnt:         填充的 byte 数
                int colorindex: 填充的值
* Returns     :
* Notes       :
********************************************************************************
*/
/*
void _FillBuffer(int *buf, int cnt, int colorindex)
*/
LCM_FillBuffer:
    push    ix
    ld      ix,00h
    add     ix,sp  
    ld      a,b
    or      c
    jr      z,_FillBuffer_ret
    dec     bc    
    push    de
    pop     hl
    ld      a,(ix+4)
    ld      (de),a
    inc     de
    ld      a,(ix+5)
    ld      (de),a
    inc     de
    ldir
_FillBuffer_ret:
    pop     ix
    ret
    
    
//*******************************************************************************************************
/*
    根据数据中 bit 的顺序填充屏幕(从高到低),是一的位用 c1输出,是0 的位用 c0输出
    void *buf : 比特流的首址
    int cnt: 要填充的象素个数
    int c0: 字颜色  ix+8
    int c1: 背景颜色 ix+10
    注: 调用这个函数前一定要先用 setwindow 函数设置好窗口
*/
//void LCD_P0_BitFill(void *buf, int cnt, int c0, int c1)    
//*******************************************************************************************************
LCD_P0_BitFill:
        push    hl
    push    ix
    ld      ix,00h
    add     ix,sp   //sp->ix
    call     lwrd     LCM_Enable
    call lwrd    LCM_RS_Reset
    ld      a, 0x00
    ld      (8000h),a 
    ld      a, 0x22
    ld      (8000h),a
    call lwrd    LCM_RS_Set
                              
    push de
    pop  hl                            
    ld        a,80h
    ld        (lwrd maskflag),a
loopfordraw:            
    ld        a,b
    or        c
    jr        z,BitFill_ret
        dec        bc    
        ld        a,(lwrd maskflag)
        and        (hl)
        jr        z,drawbg
        ld        a,(ix+6)
        ld        (8000h),a
        ld        a,(ix+7)
        ld        (8000h),a
        jr        drawpass
drawbg:        
        ld        a,(ix+8)
        ld        (8000h),a
        ld        a,(ix+9)
        ld        (8000h),a
drawpass:        
        ld        a,(lwrd maskflag)
        rra        
        ld        (lwrd maskflag),a 
        or      a 
        jr      nz,loopfordraw
        ld        a,80h
        ld        (lwrd maskflag),a
        inc        hl
        jr        loopfordraw
        
BitFill_ret:    
    call lwrd  LCM_Disable     
        pop ix
        pop hl
        ret        
/*********************************Function: Delay_1ms definition *****************************************
/*********************************Description **************************************************
//*  Function name:Delay_1ms                                        
//*  Function Description:Give 1ms delay ,note the cpu wait here                                         
//*  Parameter:
//*  Input:                                              
//*  Output: 

*********************************End of Delay_1ms Description *********************************/ 
Delay_1ms:
    push af
    push bc
    push de
    push hl
    ld   b,04h
contiune_delay213:
    push bc  
    ld   b,0ffh
contiune_delay31:
    ld   hl,4567h             
    djnz contiune_delay31   
    pop  bc
    djnz contiune_delay213  
    pop  hl
    pop  de
    pop  bc
    pop  af
    ret
    
                   
Delay_10us:                            
        push af
        push bc
        push de
        push hl
        ld  a, 255
delaycontinue:
        ld  b,255
loop1us: djnz  loop1us
        dec a
        jr nz, delaycontinue 
        pop hl
        pop de
        pop bc
        pop af      
        ret 
                
/*********************************End of Function definition **********************************/ 
//===========================================  
TransMode                defb    00h //0: 普通传送模式,DMA传送模式
REG02HSAVED              defb    00h
direction             defb    00h    //1:竖屏 0:横屏 Default:横屏
maskflag                            defb    80h   //用来作位屏蔽

#ifndef IncludeMSAFlag// 如果是用 include 方式时不用 end 为编译时不报 warning
end
#endif

⌨️ 快捷键说明

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