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

📄 hwdrv_lcd.c

📁 The combined demo is dedicated for S1C33L05, so DMT33L05 should be used to load and run the demo. F
💻 C
📖 第 1 页 / 共 2 页
字号:
        y = SCREEN_HEIGHT - y - 1;
    #else
        y = y;
    #endif

    offsetPos = SCREEN_WIDTH*y + x;
    srcbufAdr = (U32)buffer;
    desbufAdr = cur_vram_lcdc_addr + offsetPos * LCD_BPP_UNIT;

    for (i=0; i<height; i++){

    #ifdef PANEL_XMIRROR
        lcd_startDMA(srcbufAdr, desbufAdr, width, INVERSE_DMA);
    #else
        lcd_startDMA(srcbufAdr, desbufAdr, width, NORMAL_DMA);
    #endif

        srcbufAdr+=BufLen;

        #ifdef PANEL_YMIRROR
            desbufAdr-=SCREEN_WIDTH*LCD_BPP_UNIT;
        #else
            desbufAdr+=SCREEN_WIDTH*LCD_BPP_UNIT;
        #endif
 
    }

}




//---------------------------------------------------------------------------------
//      Function name       :lcd_GetImage()
//  Function description    :This function retrieves a block of screen data as an image into a buffer.
//
//      Parameters
//         Input  :x,y: specified the left-up position where the image will be placed, start from 0
//                 width: specified the image width
//                 height: specified the image height
//         Output :buffer: the buffer contains the image data
//         I/O    :None
//
//      Return value :None
//
//  Global variable  :cur_vram_lcdc_addr, SCREEN_WIDTH, LCD_BPP_UNIT
//---------------------------------------------------------------------------------
void lcd_GetImage( S16 x, S16 y, S16 width, S16 height, U16 *buffer, U32 BufLen ){

    // operating memory is cur_vram_lcdc_addr

    U32 offsetPos;
    U32 srcbufAdr, desbufAdr;
    int i;

    #ifdef PANEL_XMIRROR
        x = SCREEN_WIDTH - x - width;
    #else
        x = x;
    #endif
    #ifdef PANEL_YMIRROR
        y = SCREEN_HEIGHT - y - 1;
    #else
        y = y;
    #endif

    offsetPos = SCREEN_WIDTH*y + x;
    srcbufAdr = cur_vram_lcdc_addr + offsetPos * LCD_BPP_UNIT;

    #ifdef PANEL_XMIRROR
        desbufAdr = (U32)buffer + (width - 1) * LCD_BPP_UNIT;
    #else
        desbufAdr = (U32)buffer;
    #endif


    for (i=0; i<height; i++){

    #ifdef PANEL_XMIRROR
        lcd_startDMA(srcbufAdr, desbufAdr, width, INVERSE_DMA);
    #else
        lcd_startDMA(srcbufAdr, desbufAdr, width, NORMAL_DMA);
    #endif

        #ifdef PANEL_YMIRROR
            srcbufAdr-=SCREEN_WIDTH*LCD_BPP_UNIT;
        #else
            srcbufAdr+=SCREEN_WIDTH*LCD_BPP_UNIT;
        #endif

        desbufAdr+=BufLen;

    }

}

//---------------------------------------------------------------------------------
//      Function name       :lcd_GetImage_Dyn()
//  Function description    :This function retrieves a block of screen data as an image into a buffer.
//
//      Parameters
//         Input  :vram_staddr: the vram start address
//                 x,y: specified the left-up position where the image will be placed, start from 0
//                 width: specified the image width
//                 height: specified the image height
//         Output :buffer: the buffer contains the image data
//         I/O    :None
//
//      Return value :None
//
//  Global variable  :SCREEN_WIDTH, LCD_BPP_UNIT
//---------------------------------------------------------------------------------
void lcd_GetImage_Dyn(SCREEN_PAR* s_par, U16 * des ){

    //U32 offset;
    S16 triggerCount;
    U32 srcbufAdr, desbufAdr;
    int i;

    srcbufAdr = s_par->vram_start_addr + (s_par->virtual_width * s_par->y_pos + s_par->x_pos) * LCD_BPP_UNIT;
    triggerCount = s_par->v_size;

    #ifdef PANEL_XMIRROR
        desbufAdr = (U32)des + (SCREEN_WIDTH - 1 ) * LCD_BPP_UNIT;
    #else
        desbufAdr = (U32)des;
    #endif


    for (i=0; i<triggerCount; i++){

    #ifdef PANEL_XMIRROR
        lcd_startDMA(srcbufAdr, desbufAdr, SCREEN_WIDTH, INVERSE_DMA);
    #else
        lcd_startDMA(srcbufAdr, desbufAdr, SCREEN_WIDTH, NORMAL_DMA);
    #endif
        srcbufAdr+=s_par->virtual_width * LCD_BPP_UNIT;

        #ifdef PANEL_YMIRROR
            desbufAdr-=SCREEN_WIDTH*LCD_BPP_UNIT;
        #else
            desbufAdr+=SCREEN_WIDTH*LCD_BPP_UNIT;
        #endif

    }

}
//---------------------------------------------------------------------------------
//      Function name       :lcd_SetPixel()
//  Function description    :This function draw a pixel according to input location and display color pattern.
//
//      Parameters
//         Input  :x,y: specified the position where the pixel will be placed, start from 0
//                 ColorPattern : display color pattern
//         Output :None
//         I/O    :None
//
//      Return value :None
//
//  Global variable  :cur_vram_lcdc_addr, SCREEN_WIDTH, SCREEN_HEIGHT, LCD_BPP_UNIT
//---------------------------------------------------------------------------------
void lcd_SetPixel( S16 x, S16 y, U16 ColorPattern ){

    // operating memory is cur_vram_lcdc_addr

    U32 pos_sdramAddr;
    U32 offsetPos;
    U16* pos_ptr;

    #ifdef PANEL_XMIRROR
        x = SCREEN_WIDTH - x - 1;
    #else
        x = x;
    #endif
    #ifdef PANEL_YMIRROR
        y = SCREEN_HEIGHT - y - 1;
    #else
        y = y;
    #endif

    offsetPos = SCREEN_WIDTH*y + x;
    pos_sdramAddr = cur_vram_lcdc_addr + offsetPos * LCD_BPP_UNIT;

    //write to external SDRAM
    pos_ptr = (U16*)pos_sdramAddr;
    *pos_ptr = ColorPattern;

    return;

}

//---------------------------------------------------------------------------------
//      Function name       :lcd_GetPixel()
//  Function description    :This function retrieves the color pattern of a pixel.
//
//      Parameters
//         Input  :x,y: specified the position where the pixel will be placed, start from 0
//         Output :ColorPattern: store gotten color pattern
//         I/O    :None
//
//      Return value :None
//
//  Global variable  :cur_vram_lcdc_addr, SCREEN_WIDTH, SCREEN_HEIGHT, LCD_BPP_UNIT
//---------------------------------------------------------------------------------
void lcd_GetPixel( S16 x, S16 y, U16 *ColorPattern )
{

    //operating memory is cur_vram_lcdc_addr

    U32 pos_sdramAddr;
    U32 offsetPos;
    U16* pos_ptr;

    #ifdef PANEL_XMIRROR
        x = SCREEN_WIDTH - x - 1;
    #else
        x = x;
    #endif
    #ifdef PANEL_YMIRROR
        y = SCREEN_HEIGHT - y - 1;
    #else
        y = y;
    #endif

    offsetPos = SCREEN_WIDTH*y + x;
    pos_sdramAddr = cur_vram_lcdc_addr + offsetPos * LCD_BPP_UNIT;

    //read from external SDRAM
    pos_ptr = (U16*) pos_sdramAddr;
    *ColorPattern = *pos_ptr;

}

//---------------------------------------------------------------------------------
//      Function name       :lcd_display
//  Function description    :L05 S/W spilt window and visual display function
//
//      Parameters
//         Input  :  SCREEN_PAR*    ptrS1_par,ptrS2_par ;   paramter of screen1 and screen2
//         Output :
//         I/O    :
//
//      Return value : T_UBYTE LCD_OK          display OK
//                             LCD_NG          display NG
//                             LCD_PAR_ERROR   paramter error
//  Global variable     :   cur_vram_working_addr   ; next display buffer
//                          cur_vram_lcdc_addr      ; current display buffer
//                          SCREEN_WIDTH, SCREEN_HEIGHT, LCD_BPP_UNIT
//                          VRAM_ADDR_1, VRAM_ADDR_2
//---------------------------------------------------------------------------------
U8 lcd_display(SCREEN_PAR* ptrS1_par, SCREEN_PAR* ptrS2_par){

    U16* sec_vram_working_addr;
    U32 offset;
    U8 RetVal;
    // check parameter
/*  if (ptrS1_par->x_pos > ptrS1_par->virtual_width - SCREEN_WIDTH)
        return LCD_PAR_ERROR;
    if (ptrS1_par->y_pos > ptrS1_par->virtual_height - SCREEN_HEIGHT)
        return LCD_PAR_ERROR;

    if (ptrS2_par->x_pos > ptrS2_par->virtual_width - SCREEN_WIDTH)
        return LCD_PAR_ERROR;
    if (ptrS2_par->y_pos > ptrS2_par->virtual_height - SCREEN_HEIGHT)
        return LCD_PAR_ERROR;

    if ((ptrS2_par->v_size+ptrS1_par->v_size)!=SCREEN_HEIGHT)
        return LCD_PAR_ERROR;
*/
    // first display screen1
    if ((ptrS1_par->v_size<=SCREEN_HEIGHT) && (ptrS1_par->v_size>0)){

    #ifdef PANEL_YMIRROR
        sec_vram_working_addr = cur_vram_working_addr + (SCREEN_HEIGHT -1) * SCREEN_WIDTH * LCD_BPP_UNIT;
    #else
        sec_vram_working_addr = cur_vram_working_addr;
    #endif

        lcd_GetImage_Dyn(ptrS1_par,sec_vram_working_addr);
    }

    // then display screen2
    if ((ptrS2_par->v_size<=SCREEN_HEIGHT) && (ptrS2_par->v_size>0)){

    #ifdef PANEL_YMIRROR
        sec_vram_working_addr = cur_vram_working_addr + (ptrS2_par->v_size -1) * SCREEN_WIDTH * LCD_BPP_UNIT;
    #else
        sec_vram_working_addr =(cur_vram_working_addr + ptrS1_par->v_size * SCREEN_WIDTH * LCD_BPP_UNIT);
    #endif

        lcd_GetImage_Dyn(ptrS2_par, sec_vram_working_addr);
    }

    // swith the LCD display pointer
    if (cur_vram_working_addr==VRAM_ADDR_1){
        cur_vram_working_addr=VRAM_ADDR_2;
        cur_vram_lcdc_addr=VRAM_ADDR_1;
        // SET VRAM_ADDR_1 as current display memory
        if (cur_vram_lcdc_addr > 0x3fffff)
            *(volatile unsigned short*) 0x380210 = ((cur_vram_lcdc_addr - 0x2000000) / 32) | 0x8000;
        else
            *(volatile unsigned short*) 0x380210 = ((cur_vram_lcdc_addr - 0x3c0000) / 2) & 0x7fff;
    }
    else {
        cur_vram_working_addr=VRAM_ADDR_1;
        cur_vram_lcdc_addr=VRAM_ADDR_2;
        // SET VRAM_ADDR_2 as current display memory
        if (cur_vram_lcdc_addr > 0x3fffff)
            *(volatile unsigned short*) 0x380210 = ((cur_vram_lcdc_addr - 0x2000000) / 32) | 0x8000;
        else
            *(volatile unsigned short*) 0x380210 = ((cur_vram_lcdc_addr - 0x3c0000) / 2) & 0x7fff;

    }

    return LCD_OK;

}

//---------------------------------------------------------------------------------
//      Function name       	:seLcd_ChgCLK()
//  Function description    	:This function change LCD frequence
//
//      Parameters
//         Input  		:	unsigned char lcdclkdt
//                 		 
//         Output :None
//         I/O    :None
//
//      Return value :None
//
//  Global variable  :None
//---------------------------------------------------------------------------------

void seLcd_ChgCLK(unsigned char lcdclkdt){ 
 	int             i;
    unsigned char   dt;
    //LCDC clock divider ratio:(D3--0)=fosc3/16=pclk=3MHz
    for (i=1; i<16; i*=2)
    {
        dt = lcdclkdt & i;
        dt = (*(volatile unsigned char*) 0x300f34 ) & ~i | dt;
        *(volatile unsigned char*)  0x300f2f = 0x96; //remove write protection
        *(volatile unsigned char*)  0x300f34 = dt;
     };

     *(volatile unsigned char*)  0x300f2f = 0x96; //remove write protection
     *(volatile unsigned char*)  0x300f34 = lcdclkdt;
     
}

⌨️ 快捷键说明

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