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

📄 lines.c

📁 SHARP_ARM720T_LH79524/5软件开发包_支持TFT_LCD_NAND_FLASH_ETH_USB
💻 C
字号:
/*********************************************************************** 
 * $Workfile:   lines.c  $ 
 * $Revision:   1.0  $ 
 * $Author:   ZhangJ  $ 
 * $Date:   Oct 20 2004 09:13:24  $ 
 * 
 * Project:     LH79524 swim/lines demo
 * 
 * Description: 
 * 
 * Revision History:
 * $Log: 
 * 
 *********************************************************************** 
 * 
 *  Copyright (c) 2002 Sharp Microelectronics of the Americas 
 * 
 *  All rights reserved 
 * 
 *  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. 
 * 
 **********************************************************************/

#include "abl_api.h"
#include "abl_swim.h"
#include "abl_fonts.h"
#include "abl_swim_font.h"
#include "abl_swim_image.h"
#include "abl_irq_fiq.h"
#include "lh79524_chip.h"
#include "lh79524_clcdc_driver.h"
#include "lh79524_int_driver.h"
#include "lh79524_timer_driver.h"


/* Display type */
#define LCD_DISPLAY sharp_lq035

/* Board specific definition */
#define SDK79524_XTAL_IN    11289600 

/* Sample irq handlers that will be called via timer interrupts */
STATIC void timer0_callback (void);

/* Image related defines */
#define FRAME 0x21000000
#define DISPLAY_WIDTH  (240)
#define DISPLAY_HEIGHT (320)

/* Device handles */
STATIC INT_32 dev_timer0 = 0;
STATIC INT_32 dev_irq = 0;
STATIC INT_32 dev_lcd = 0;

/* Local variable */
STATIC volatile INT_32 write_ready = FALSE;

/* Local prototypes */
STATIC void wm_task_init (void);
STATIC void wm_task_start (void);
STATIC SWIM_WINDOW_T window[1];


/************************************************************************
*
* Function: c_entry
*
* Purpose:
*    To demostrate using chip specific, platform independent, and board
*    specific drivers.
*
* Processing:
*     
* Parameters: 
*     None
*
* Outputs: 
*     None
*
* Returns: 
*     None
*
* Notes: 
*
************************************************************************/

INT_32 c_entry (void)
{
    CLCDC_SETTINGS_T lcdcfg = {(LCD_PARAM_T*)&LCD_DISPLAY, SDK79524_XTAL_IN};
    UNS_32*     pfb  = NULL;
    void *      intr_handler;
    
    /* Open IRQ */
    if ((dev_irq = irq_open(0, 0)) == 0x0)
    {
        /* Error opening the device */
        return 1;
    }

    /* Open LCD */
    if ((dev_lcd = lcd_open(LCD_BASE, (INT_32) &lcdcfg)) == 0x0)
    {
        /* Error opening the device */
        return 0;
    }
        
    /* Set LCD display pointer */
    lcd_ioctl(dev_lcd, LCD_SET_FB, (INT_32)FRAME );
    
    /* Clear the frame buffer memory */
    pfb = (UNS_32*)FRAME;
    while ((UNS_32)pfb < (FRAME+(DISPLAY_WIDTH*DISPLAY_HEIGHT*2)))
    {
        *pfb++ = 0;
    }

    /* Turn on LCD */
    lcd_ioctl(dev_lcd, LCD_PW_ENABLE, 0);

    /* open TIMER0 device */
    if ((dev_timer0 = timer0_open(TIMER0_BASE, SDK79524_XTAL_IN)) == 0x0)
    {
        /* Error opening the device */
        return 3;
    }
    
    /* Clear the counter */
    timer0_ioctl(dev_timer0, TIMER_CLEAR_CNT, 0);
    
    /* Set up the timer clock rate */
    timer0_ioctl (dev_timer0, TIMER_SET_CLK_RATE, TIMER_HCLK_DIV_128);
    
    /* Set up the device to act like a free running counter */
    timer0_ioctl (dev_timer0, TIMER_SET_CNT_MODE, 0);
    
    /* Set up the counter interval - 1 millisecond */
    timer0_ioctl (dev_timer0, TIMER_SET_CMP1, 1000);

    /* Bind a callback to be used by the interrupt service routine */
    timer0_ioctl(dev_timer0, TIMER_SET_CALLBACK, (INT_32)timer0_callback);
    
    /* Enable IRQ source */
    irq_ioctl(dev_irq, IRQ_ENABLE_SOURCE, VIC_TIMER0);

    /* Get a binding to the interrupt service routine */
    timer0_ioctl(dev_timer0, TIMER_GET_ISR, (INT_32)&intr_handler);
    
    /* Set up interruption handler */
    irq_ioctl(dev_irq, IRQ_SET_HANDLER, (INT_32)intr_handler);
    
    /* Enable timer0 compare interrupt */
    timer0_ioctl(dev_timer0, TIMER_ENABLE_INT, TM0_INTCTRL_CMP1);
          
    /* Start the timer. It is started in other place.  */
    // timer0_ioctl(dev_timer0, TIMER_START, 0);

    /* Init the windowing manager */
    wm_task_init ();

    /* Enable global IRQ bit */
    irq_ioctl(dev_irq, IRQ_GLOBAL_ENABLE, 1);
 
    /* Jump to the windowing manager task */
    wm_task_start ();
    
    return (5);
}

/************************************************************************
*
* Function: timer0_callback
*
* Purpose:
*    To demonstrate handling a timer interrupt. 
*
* Processing:
*     
* Parameters: 
*     None
*
* Outputs: 
*     None
*
* Returns: 
*     None
*
* Notes: 
*
************************************************************************/

STATIC void timer0_callback (void)
{
    static UNS_32 time = 0;

    /* Signal line drawing task every 30 ms */
    if (++time == 5)
    {
        /* Send flag to screen update task */
        if (write_ready == FALSE)
        {
            write_ready = TRUE;
        }
        time = 0;
    }
}

/************************************************************************
*
* Function: wm_task_init
*
* Purpose:
*   To initialize the windewing manager task. 
*
* Processing:
*     
* Parameters: 
*     None
*
* Outputs: 
*     None
*
* Returns: 
*     None
*
* Notes: 
*
************************************************************************/

void wm_task_init (void)
{
    /*
     * Open the event windows  
     * win          : Preallocated windows structure to fill
     * xsize        : Physical horizontal dimension of the display
     * ysize        : Physical vertical dimension of the display
     * fbaddr       : Address of the display's frame buffer
     * xwin_min     : Physical window left coordinate
     * ywin_min     : Physical window top coordinate
     * xwin_max     : Physical window right coordinate
     * ywin_max     : Physical window bottom coordinate
     * border_width : Width of the window border in pixels
     * pcolor       : Pen color
     * bkcolor      : Background color
     * fcolor       : Fill color
     */
    /* Open window 1 */
    swim_window_open (&window[0], 
                      DISPLAY_WIDTH, 
                      DISPLAY_HEIGHT, 
                      (COLOR_T *)FRAME,
                      DISPLAY_WIDTH-(DISPLAY_WIDTH-5), 
                      DISPLAY_HEIGHT-(DISPLAY_HEIGHT-5), 
                      DISPLAY_WIDTH-5, 
                      DISPLAY_HEIGHT-5, 
                      0, 
                      BLACK, 
                      BLACK, 
                      LIGHTGRAY);
    swim_set_title (&window[0], "LINES APPLICATION- 51 lines per scan", RED);
    write_ready = FALSE;
}

/************************************************************************
*
* Function: wm_task_start
*
* Purpose:
*    To start the window manager task. 
*
* Processing:
*  win0_id - window 0 id 
*  win1_id - window 1 id
*  win2_id - windoe 3 id
*     
* Parameters: 
*     None
*
* Outputs: 
*     None
*
* Returns: 
*     None
*
* Notes: 
*
************************************************************************/

STATIC void wm_task_start (void)
{
    INT_32  x1        = 0;
    INT_32  step      = 0;
    INT_32  direction = 0;
    INT_32  xoffset   = 0;
    UNS_32  xwin      = 0;
    UNS_32  ywin      = 0;
    UNS_32  ioffset   = 4;
    UNS_32  currcolor = 0;
    COLOR_T colors [] = {WHITE, GREEN, YELLOW, RED};

    /* Get a reference to the swim window */
    SWIM_WINDOW_T* pwin = (SWIM_WINDOW_T*)&window[0];

    /* Calculate the minumum step size */
    step = pwin->xvsize/51;

    /* Save the virtual window maximum width */
    xwin = pwin->xvsize;

    /* Save the virtual window maximum width */
    ywin = pwin->yvsize;

    /* Set up the pen color */
    swim_set_pen_color (pwin, WHITE);

    /* Start the timers */
    timer0_ioctl (dev_timer0, TIMER_START, 0);

    /* Enter the line drawing loop */
    while (1)
    {
        /* Reset the offset counter */
        x1   = ioffset*step;
        xwin = x1+(51*step);

        /* Change the line color based on the direction */
        swim_set_pen_color (pwin, colors[currcolor]);

        /* Write the line from left to right */
        while (x1 <= xwin)
        {
            /* Wait for the timer to clear this flag */
            while (write_ready == FALSE);
            
            /* Update the x offset */
            if (direction == 0)
            {
                /* We are moving left to right */
                xoffset = x1;
            }
            else
            {
                /* We are moving right to left */
                xoffset = (xwin+(ioffset*step))-x1;
            }

            /* Update the display */
            swim_put_line (pwin, xoffset, 0, xoffset, ywin);

            /* Increment the step counter */
            x1 += step;

            /* Mark ready flag as off */
            write_ready = FALSE;
        }

        /* Update the direction and offset variables */
        direction = (direction == 0) ? 1 : 0;

        /* Check the boundaries on the colors array */
        if (++currcolor > NELEMENTS(colors)-1)
        {
            currcolor = 0;
        }
    }
}


#ifdef __iar

void main(void)
{
	c_entry();
	while(1);
}

#endif

/* EOF */




⌨️ 快捷键说明

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