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

📄 lcd_phya_ssd1332.msa

📁 Actions ucOS-II mp3方案源码,可以做参考
💻 MSA
字号:
/*************************************************************/
/*           OLED Driver Programm For ATCUC                  */
/* Write by Lowell      2005-7-1                             */
/*说明:1.Sensor 选用OV9640 1.3mega Pixel                    */
/*      2.LCD 选用lancer NLMG-128EC1-CUW3G                   */
/*      3.Sdram 可选用Micron hynix samsung 64M 128M 256Mbit  */
/*************************************************************/      
//*--------set b9 register to adjust the sdram speed---------------*/      

        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  LCM_Para_Write_Command
        public  Delay_10us
        public  LCD_P0_BitFill 
        
#include "LCD_PHY_SSD1332.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

LCM_GPIO_Enable:
        push     af        
         
        in      a, (092h)    
        res       7,a
        out    (092h),a        //cmos sensor disabled
          
        
        in      a,(08dh)            //GPIO_K7~2    Enable GPIO    
        set       2,a
        res       1,a                                  //pclk disabled
        out    (08dh),a
        
         
        ld      a, 0FFh    
        out    (GPIO_K_Data_Port),a
                
        in a, (GPIO_K_IO_Port)
        and    83h     
        out    (GPIO_K_IO_Port),a      // enable    gpiok2,5,6 output
        
        pop     af
        ret      
         
LCM_RS_Reset:
        push       af     
        in a, (GPIO_K_Data_Port)    //GPIOK6 (RS) LOW   
        or 0fh 
        and 0BFh  
        out (GPIO_K_Data_Port),a      
        pop         af 
        ret
LCM_RS_Set:
        push       af
        in a, (GPIO_K_Data_Port)    //GPIOK6 (RS) HIGH  
        or 40h 
        out (GPIO_K_Data_Port),a
        pop    af
        ret
LCM_RST_Reset:
        push    af
        in a, (GPIO_K_Data_Port)   //GPIOK5 RST LOW
        or  0fh
        and 0DFh  
        out (GPIO_K_Data_Port),a
        pop    af
        ret

LCM_RST_Set:
        push    af
        in a, (GPIO_K_Data_Port)   //GPIOK5 RST HIGH
        or 20h  
        out (GPIO_K_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     af 
        push     bc
        push     hl    
        call     lwrd LCM_Enable     
        call    lwrd LCM_RS_Reset
        ld      a,e
        ld      (8000h),a
        call    lwrd     LCM_Disable
        pop     hl
        pop     bc
        pop     af
        ret   

LCM_Para_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,E
        ld      (8000h),a
        ld      a,c 
        ld      b,a 
LCM_Para_Write_Command_Loop:
        ld      a,(ix+4)
        ld      (8000h),a
        inc     ix
        inc     ix
        djnz     LCM_Para_Write_Command_Loop
        call     lwrd     LCM_Disable
        pop     hl
        pop     af
        pop     ix
        ret
               
/************************************************************/
/*  function:LCM_Write_GDDRAM                              */
/*  input: put display data to register d                   */
/*  process 1,select RS;     2,access to LCD memory         */
/************************************************************/    
LCM_Write_Pixel:
        push af
        call lwrd LCM_Enable
        call lwrd LCM_RS_Set
        ld   a,d
        ld   (8000h),a
        ld   a,e
        ld   (8000h),a
        call lwrd LCM_Disable
        call lwrd LCM_RS_Reset
        pop  af
        ret
        
LCM_Fill_Area:
        push af
        push hl
        call lwrd LCM_Enable
        call lwrd LCM_RS_Set
LCM_Fill_Area_Loop:
        ld   a,d
        ld   (8000h),a
        ld   a,e
        ld   (8000h),a
        dec  c
        jr   nz,LCM_Fill_Area_Loop        
        djnz LCM_Fill_Area_Loop
        call lwrd LCM_Disable        
        call lwrd LCM_RS_Reset
        pop  hl
        pop  af
        ret     
        
LCM_Read_Pixel:
        push af
        call lwrd LCM_Enable
        call lwrd LCM_RS_Set
        ld   a,(8000h)
        ld   l,a
        ld   a,(8000h)
        ld   h,a
        call lwrd LCM_Disable
        call lwrd LCM_RS_Reset
        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
        call lwrd LCM_RS_Reset
        pop  hl
        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 
        
////*******************************************************************************/
///* 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_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 
        call lwrd LCM_RS_Reset
        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+5)
    ld      (de),a
    inc     de
    ld      a,(ix+4)
    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_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  
        call lwrd LCM_RS_Reset       
        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
    
                   
/*********************************End of Function definition **********************************/ 
//===========================================  
TransMode                defb    00h //0: 普通传送模式,DMA传送模式
REG02HSAVED             defb    00h
maskflag                            defb    80h   //用来作位屏蔽
#ifndef IncludeMSAFlag// 如果是用 include 方式时不用 end 为编译时不报 warning
end    
#endif 

⌨️ 快捷键说明

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