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

📄 lcd_example.c

📁 sharp触摸屏测试代码
💻 C
字号:
/***********************************************************************
 * $Workfile:   lcd_example.c  $
 * $Revision:   1.5  $
 * $Author:   WellsK  $
 * $Date:   Dec 08 2003 14:31:26  $
 *
 * Project: LCD driver example
 *
 * Description:
 *     A simple LCD driver example.
 *
 * Revision History:
 * $Log:   //smaicnt2/pvcs/VM/sharpmcu/archives/sharpmcu/software/csps/lh7a404/bsps/sdk7a404/examples/lcd/lcd_example.c-arc  $
 * 
 *    Rev 1.5   Dec 08 2003 14:31:26   WellsK
 * Updated frame buffer logic to use logical address instead of
 * physical address for fame buffer.
 * 
 *    Rev 1.4   Oct 28 2003 10:51:54   WellsK
 * Updated to use common LCD parameters file.
 * 
 *    Rev 1.3   Oct 01 2003 12:03:58   WellsK
 * Added logic to get TTB address from register CP15 TTB.
 * 
 *    Rev 1.2   Sep 18 2003 09:33:26   WellsK
 * Corrected frame buffer address for LOLO.
 * 
 *    Rev 1.1   Sep 03 2003 15:19:18   WellsK
 * Added support for LQ064 display. Added support for display
 * specific power and backlight control.
 * 
 *    Rev 1.0   Jul 01 2003 09:23:10   WellsK
 * Initial revision.
 * 
 *
 ***********************************************************************
 * SHARP MICROELECTRONICS OF THE AMERICAS MAKES NO REPRESENTATION
 * OR WARRANTIES WITH RESPECT TO THE PERFORMANCE OF THIS SOFTWARE,
 * AND SPECIFICALLY DISCLAIMS ANY RESPONSIBILITY FOR ANY DAMAGES, 
 * SPECIAL OR CONSEQUENTIAL, CONNECTED WITH THE USE OF THIS SOFTWARE.
 *
 * SHARP MICROELECTRONICS OF THE AMERICAS PROVIDES THIS SOFTWARE SOLELY 
 * FOR THE PURPOSE OF SOFTWARE DEVELOPMENT INCORPORATING THE USE OF A 
 * SHARP MICROCONTROLLER OR SYSTEM-ON-CHIP PRODUCT. USE OF THIS SOURCE
 * FILE IMPLIES ACCEPTANCE OF THESE CONDITIONS.
 *
 * COPYRIGHT (C) 2001 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
 *     CAMAS, WA
 **********************************************************************/

#include "abl_types.h"
#include "abl_swim.h"
#include "abl_arm922t_cp15_driver.h"
#include "lh7a404_clcdc_driver.h"
#include "lh7a404_gpio_driver.h"
#include "sdk7a404_cpld_driver.h"

/* Logical address of LCD frame buffer */
#define FBLOG 0xC0000000

/* Pick only one display! */
#define LCD_DISPLAY sharp_lq035
//#define LCD_DISPLAY sharp_lq039
//#define LCD_DISPLAY sharp_lq057
//#define LCD_DISPLAY sharp_lq064
//#define LCD_DISPLAY sharp_lq104
//#define LCD_DISPLAY sharp_lq121

/***********************************************************************
 *
 * Function: c_entry
 *
 * Purpose: LCD driver example
 *
 * Processing:
 *     See function. This example sets up the LCD and draws 3 colored
 *     stripes on the display using SWIM.
 *
 * Parameters: None
 *
 * Outputs: None
 *
 * Returns: Always returns 1
 *
 * Notes:
 *     This example works fine for 555 (RGB) color displays. The colors
 *     will be different for 8-bit displays. If you have the LCD
 *     configured for 8-bit color, be sure to also change the COLOR_T
 *     define in the abl_colors package to match the LCD color depth.
 *
 **********************************************************************/
int v_start(void)
{
    INT_32 lcddev, regionsize;
    SWIM_WINDOW_T win1, win2, win3;
    COLOR_T *fblog;
    int i;

    /* Initialize CPLD */
    cpld_init();

    /* Set virtual address of MMU table (needed for VIC driver
       functions) */
   // cp15_set_vmmu_addr((UNS_32 *) cp15_get_ttb());

    /* Setup LCD muxing for all 16 data bits */
    gpio_lcd_signal_select(GPIO_LCDV_0_15);

    /* Setup LCD paramaters in the LCD controller */
    lcddev = lcd_open(CLCDC, (INT_32) &LCD_DISPLAY);

    /* Set frame buffer address */
    fblog = (COLOR_T *) FBLOG;
    lcd_ioctl(lcddev, LCD_SET_UP_FB,
            FBLOG);
 
    /* Also make sure that the CPLD_JTAG_OE signal is in the
       correct state */
	gpio_set_data_dir(GPIO_PORT_H, 0xff, GPIO_OUTPUT);
	gpio_data_write(GPIO_PORT_H, 0x0);

    gpio_set_data_dir(GPIO_PORT_A, 0x04, GPIO_OUTPUT);
    gpio_data_write(GPIO_PORT_A, 0x04);
	
    /* Set color depth to 16 bits per pixel */
    lcd_ioctl(lcddev, LCD_SET_BPP, 16);
 
    /* For displays that require more bandwidth, set DMA to request
       a transfer on 4 words empty instead of the default 8. This may
       help prevent 'display tearing' due to a starved LCD controller */
    regionsize = lcd_ioctl(lcddev, LCD_GET_STATUS, LCD_XSIZE) *
        lcd_ioctl(lcddev, LCD_GET_STATUS, LCD_YSIZE) *
        sizeof (COLOR_T);
    if (regionsize >= (800 * 600 * 2))
    {
        /* Displays of 800x600 pixels and 16-bits of color (or larger)
           will use faster DMA requests */
        lcd_ioctl(lcddev, LCD_DMA_ON_4MT, 1);
   }

    /* HRTFT/TFT panel board initialization only */
    if ((lcd_ioctl(lcddev, LCD_GET_STATUS, LCD_PANEL_TYPE) == HRTFT) ||
       (lcd_ioctl(lcddev, LCD_GET_STATUS, LCD_PANEL_TYPE) == ADTFT) ||
        (lcd_ioctl(lcddev, LCD_GET_STATUS, LCD_PANEL_TYPE) == TFT))
    {
        /* Enable power to the LCD panel (sets VDDEN on PC3) */
        gpio_set_data_dir(GPIO_PORT_C, 0x08, GPIO_OUTPUT);
        gpio_data_write(GPIO_PORT_C, 0x08);
    }
    else
    {
        /* Other displays - do nothing (yet) */
        ;
    }

	gpio_data_write(GPIO_PORT_H, 0xff);
    /* Enable LCD controller and power signals */
    lcd_ioctl(lcddev, LCD_PWENABLE, 1);

    /* Create 3 SWIM windows of equal size and different colors */
    regionsize = LCD_DISPLAY.pixels_per_line/3 ;


/*while(1)
{
	unsigned char * tmp =0x80000e0c;
	int i;
	for (i=0;i<800*600;i++)
	{
		*tmp++=0xff;
	}
}
*/
#define def_color RED
while(1)
{
    swim_window_open(&win1, LCD_DISPLAY.pixels_per_line,
        LCD_DISPLAY.lines_per_panel, fblog, 
	0,0,(regionsize-1), (LCD_DISPLAY.lines_per_panel-1),
        0,RED ,RED, RED);
    swim_window_open(&win2, LCD_DISPLAY.pixels_per_line,
        LCD_DISPLAY.lines_per_panel, fblog, 
	regionsize,0, ((2 * regionsize) - 1), (LCD_DISPLAY.lines_per_panel - 1),
        0, RED,RED, RED);
    swim_window_open(&win3, 
	LCD_DISPLAY.pixels_per_line,LCD_DISPLAY.lines_per_panel, 
	fblog,
        ((2 * regionsize)-1),0,((3 * regionsize)-1),(LCD_DISPLAY.lines_per_panel - 1), 
	0,
	 RED,RED, RED);


/*for(i=0;i<100;i++);
   swim_window_close(&win2);
swim_window_close(&win1);
swim_window_close(&win3);
*/
}
    return 1;
}

#ifndef __GNUC__
/* With ARM and GHS toolsets, the entry point is main() - this will
   allow the linker to generate wrapper code to setup stacks, allocate
   heap area, and initialize and copy code and data segments. For GNU
   toolsets, the entry point is through __start() in the crt0_gnu.asm
   file, and that startup code will setup stacks and data */
int main(void)
{
    return c_entry();
}
#endif

⌨️ 快捷键说明

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