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

📄 lcd.c

📁 NXP ARM处理器240*320液晶驱动程序(IAR开发环境)
💻 C
字号:
/***********************************************************************
 * File:   lcd.c
 * Rev:    1.0
 * Author: Chun Sing Chu
 * Date:   March 26 2007
 *
 * Description:
 *     This example shows how to use LCD driver
 *
 * Revision History:
 * Rev 1.0 March 26 2007
 * Initial revision.
 *
 **********************************************************************/

#include <intrinsics.h>
#include "lcd_driver.h"
#include "lcd_params.h"
#include "low_level_init.h"
#include "irq.h"

#define LCD_DISPLAY dh240

void Lcd_ClearScr(INT32S x,INT32S y,INT32S c);
void Glib_Line(INT32S x1,INT32S y1,INT32S x2,INT32S y2,INT32S color);
void Glib_Rectangle(INT32S x1,INT32S y1,INT32S x2,INT32S y2,INT32S color);
void Glib_FilledRectangle(INT32S x1,INT32S y1,INT32S x2,INT32S y2,INT32S color);

static INT32S dev_lcd;
static INT32U num_frms;


/***********************************************************************
 *
 * Function: irq_handler
 *
 * Purpose: IRQ handler.
 *
 * Processing:
 *
 * Parameters: 	None
 *
 * Outputs: None
 *
 * Returns: None
 *
 **********************************************************************/
__irq __arm void irq_handler (void)
{
    void (*interrupt_function)();
    INT32S vector;

    vector = VICAddress;     // Get interrupt vector.
    interrupt_function = (void(*)())vector;
    if(interrupt_function != NULL)
    {
        interrupt_function();  // Call vectored interrupt function.
    }
    else
    {
        VICAddress = 0;      // Clear interrupt in VIC.
    }
}

/***********************************************************************
 *
 * Function: main
 *
 * Purpose: Function entry point from the startup code.
 *
 * Processing:
 *
 * Parameters: 	None
 *
 * Outputs: None
 *
 * Returns: None
 *
 **********************************************************************/
INT32S main(void)
{

    INT32U cursorimage[256];
    INT32U swap;
    
    low_level_init();

    for(INT32U i = 0; i < 256; i++)
    {
       cursorimage[i] = 0x55555555;
    }


    /* Open LCD */
    if ((dev_lcd = lcd_open(CLCDC, (INT32S)&LCD_DISPLAY)) == 0x0)
    {
        /* Error opening the device */
        return 0;
    }

    /* Set LCD display pointer */
    lcd_ioctl(dev_lcd, LCD_SET_BUFFER, (INT32S)SDRAM_BASE);

    /* Turn on LCD */
    lcd_ioctl(dev_lcd, LCD_PWR_ON, 1);
    /* Enable LCD */
    lcd_ioctl(dev_lcd, LCD_ENABLE, 1);
    
     swap = *(volatile INT32U *)(0xFFE10018);
       *(volatile INT32U *)(0xFFE10018) = swap |(1 << 8);//swap red and blue

     Lcd_ClearScr(320,240,0xffff);
      
         Glib_FilledRectangle(10, 191,310, 196, 0x07e0);    //Green,bottm
         Glib_FilledRectangle(5, 197,315, 202, 0xf800);  //red,bottm
         Glib_FilledRectangle(16, 185,305, 190, 0x001f);    //blue,bottm

	delayMs(10);
	Glib_FilledRectangle( 5, 35, 315, 40, 0xf800);	//red,top
	Glib_FilledRectangle(10, 40, 310, 45, 0x07e0);	//Green,top
	Glib_FilledRectangle(15, 45, 305, 50, 0x001f);	//blue,top

	delayMs(10);
	Glib_FilledRectangle( 5, 37, 9, 200, 0xf800);	//red,left
	Glib_FilledRectangle(10, 45, 15, 195, 0x07e0);	//Green,left
	Glib_FilledRectangle(16, 50, 20, 190, 0x001f);	//blue,left

	delayMs(10);
	Glib_FilledRectangle(311, 40, 315, 200, 0xf800);	//Red,right
	Glib_FilledRectangle(305, 45, 310, 195, 0x07e0);	//Green,right
	Glib_FilledRectangle(300, 50, 304, 190, 0x001f);	//Blue,right
    num_frms = 0;

    while(num_frms < 0x10000);

    return 1;
}


⌨️ 快捷键说明

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