lcd_example.c

来自「Sharp LH7A400 BSP平台无关部分的代码,有很高的参考价值,尤其是系」· C语言 代码 · 共 160 行

C
160
字号
/***********************************************************************
 * $Workfile:   lcd_example.c  $
 * $Revision:   1.2  $
 * $Author:   WellsK  $
 * $Date:   Oct 28 2003 14:36:14  $
 *
 * Project: LCD driver example
 *
 * Description:
 *     A simple LCD driver example.
 *
 * Revision History:
 * $Log:   //smaicnt2/pvcs/VM/sharpmcu/archives/sharpmcu/software/csps/lh7a400/bsps/sdk7a400/examples/lcd/lcd_example.c-arc  $
 * 
 *    Rev 1.2   Oct 28 2003 14:36:14   WellsK
 * Updated with common LCD parameter format changes.
 * 
 *    Rev 1.1   Oct 01 2003 16:53:22   WellsK
 * Added file header. Added support for LQ064. Updates for
 * backlight support. Additional changes for MMU table and
 * interrupt relocation.
 * 
 *
 ***********************************************************************
 * 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 "lh7a400_clcdc_driver.h"
#include "lh7a400_gpio_driver.h"
#include "sdk7a400_cpld_driver.h"

/* Physical and logical addresses of LCD frame buffer */
#define FBPHY 0xC1C00000

/* 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 c_entry(void)
{
    INT_32 lcddev, regionsize;
    SWIM_WINDOW_T win1, win2, win3;
    COLOR_T *fblog;

    /* 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 */
    lcd_ioctl(lcddev, LCD_SET_UP_FB, FBPHY);

    /* Make sure shared JTAG signal on PA2 is not active */
    gpio_set_data_dir(GPIO_PORT_A, 0x04, GPIO_OUTPUT);
    gpio_data_write(GPIO_PORT_A, 0x04);

    /* Turn on the LCD backlight */
    cpld_enable_lcd_veeen(TRUE);

    /* 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);
    }

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

    /* Get virtual address of frame buffer */
    fblog = cp15_map_physical_to_virtual(FBPHY);

    /* Create 3 SWIM windows of equal size and different colors */
    regionsize = LCD_DISPLAY.pixels_per_line / 3;
    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, WHITE, RED, DARKGRAY);
    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, WHITE, GREEN, DARKGRAY);
    swim_window_open(&win3, LCD_DISPLAY.pixels_per_line,
        LCD_DISPLAY.lines_per_panel, fblog,
        (2 * regionsize), 0, ((3 * regionsize) - 1),
        (LCD_DISPLAY.lines_per_panel - 1), 0, WHITE, BLUE, DARKGRAY);

    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 + =
减小字号Ctrl + -
显示快捷键?