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

📄 c_entry.c

📁 sharp的arm920t 7A400的评估板附带光盘Sharp KEVLH7A400 v0.3b Welcome to the SHARP KEV7A400 Evaluation board
💻 C
📖 第 1 页 / 共 2 页
字号:
 /*****************************************************************************
 *	$Workfile:   c_entry.c  $
 *	$Revision:   1.0  $
 *	$Author:   WellsK  $
 *	$Date:   Sep 23 2002 13:54:18  $
 *
 *	Project: Simple startup demo
 *
 *	Description:
 *    This is a simple demo that performs some simple graphic operations.
 *    The demo is designed to be called from the startup-lite boot code.
 *
 *	Revision History:
 *	$Log:   //smaicnt2/pvcs/VM/CDROM/archives/KEV7A400/Software/Board applications/Simple startup demo/c_entry.c-arc  $
 * 
 *    Rev 1.0   Sep 23 2002 13:54:18   WellsK
 * Initial revision.
 * 
 * 
 *	COPYRIGHT (C) 2001 SHARP MICROELECTRONICS OF THE AMERICAS, INC.
 *		CAMAS, WA
 ****************************************************************************/

#include "SMA_colors.h"
#include "SMA_types.h"
#include "SMA_lcd_driver.h"
#include "KEV7A400_LQ039Q2DS53.h"
#include "LH7A400_cp15_driver.h"
#include "LH7A400_EVB_CPLD_driver.h"
#include "SMA_sevenseg_driver.h"
#include "LH7A400_int_driver.h"
#include "LH7A400_EVB_CPLD_driver.h"
#include "LH7A400_timer_driver.h"
#include "draw.h"
#include "rnums.h"

#include "tower1.h"
#include "bird1.h"
#include "bluest1.h"
#include "bridge1.h"
#include "buildn1.h"
#include "buildn2.h"
#include "buildn3.h"
#include "cliff1.h"
#include "frame1.h"
#include "palms1.h"
#include "park1.h"
#include "plane1.h"
#include "sisters31.h"

#define TICKS_SEC 8         // Timer interrupt rate
#define ROT_TICKS 21        // Number of timer ticks between each picture
#define NUM_WINS 4          // Number of 'windows'

// Physical and logical addresses of frame buffer
// Working and active frame buffer pointers
typedef UNS_16 * fb_ptr_t;
fb_ptr_t const fb [2] = {(fb_ptr_t) 0xC3C00000, (fb_ptr_t) 0xC3E00000};
fb_ptr_t const pfb [2] = {(fb_ptr_t) 0xDD000000, (fb_ptr_t) 0xDD200000};

// Working and active frame buffer indexes
int wfb_index;
int act_index;

// Image data pointer array
#define MAX_IMAGES 13
typedef color_type *color_type_ptr;
color_type_ptr image_list [MAX_IMAGES] = {
    (color_type_ptr) tower1,
    (color_type_ptr) bird1,
    (color_type_ptr) bluest1,
    (color_type_ptr) bridge1,
    (color_type_ptr) buildn1,
    (color_type_ptr) buildn2,
    (color_type_ptr) buildn3,
    (color_type_ptr) cliff1,
    (color_type_ptr) frame1,
    (color_type_ptr) palms1,
    (color_type_ptr) park1,
    (color_type_ptr) plane1,
    (color_type_ptr) sisters31};

// Hz counter and update counter
UNS_32 countx;
UNS_32 old_countx;

#define XMAX 320
#define YMAX 240

// Timer interrupt
void timer_isr (void)
{
    // Increment periodic counter
    countx++;

    util_set_sevenseg_hexval ((UNS_8) countx, 0);

    // The timer interrupt must be cleared, or interrupts will keep going
    timer_int_clear (TIMER1);
}

/**********************************************************************
*
* Function: lcd39_set_framebuffer
*
* Purpose:
*	Updates the frame buffer pointer for the display.
*  
* Processing:
*	
*
* Parameters:
*	vrt_addr : Virtual address of frame buffer
*
* Outputs:
*   None
*
* Returns:
*   Nothing
*
* Notes:
*   The frame buffer address referenced in the LCD controller must
*   be a physical address.
*
**********************************************************************/
 void lcd39_set_framebuffer (int phy_addr)
 {
    CLCDCREGS  *lcd_regs_ptr = (CLCDCREGS *) LCD_BASE;

    // Set high and low 16-bits of frame buffer address
    lcd_regs_ptr->lcdupbase     = phy_addr;
    lcd_regs_ptr->lcdlpoverflow = phy_addr;
 }
 
/**********************************************************************
*
* Function: dummy_wait
*
* Purpose:
*	Dummy wait function.
*  
* Processing:
*   
*
* Parameters:
*	None
*
* Outputs:
*   None
*
* Returns:
*   Nothing
*
* Notes:
*   None
*
**********************************************************************/
void dummy_wait (int x)
{
   int j;
   
   for (j = 0; j < (x * 400); j++);
}

/**********************************************************************
*
* Function: toggle_fb
*
* Purpose:
*	Switches the working and active frame buffers.
*  
* Processing:
*   Sets the address of the new frame buffer in the LCD controller.
*
* Parameters:
*	None
*
* Outputs:
*   None
*
* Returns:
*   Nothing
*
* Notes:
*   None
*
**********************************************************************/
void toggle_fb (void)
{
   // Toggle active and working frame buffer indices
   wfb_index = act_index;
   act_index = 1 - act_index;

   // Update display with new active frame buffer
   lcd39_set_framebuffer ((int) pfb [act_index]);
}

/**********************************************************************
*
* Function: get_working_fb
*
* Purpose:
*	Returns the pointer to the working frame buffer.
*  
* Processing:
*	Self explanatory
*
* Parameters:
*	None
*
* Outputs:
*   Pointer to working frame buffer
*
* Returns:
*   Nothing
*
* Notes:
*   None
*
**********************************************************************/
fb_ptr_t get_working_fb (void)
{
   return fb [wfb_index];
}

/**********************************************************************
*
* Function: move_image_to_wfb
*
* Purpose:
*	Moves an image to the working framebuffer.
*  
* Processing:
*	Copies the image pixel by pixel to the working frame buffer.
*
* Parameters:
*	image_ptr : Pointer to an image to use.
*
* Outputs:
*   None
*
* Returns:
*   Nothing
*
* Notes:
*   None
*
**********************************************************************/
void move_image_to_wfb (color_type *image_ptr)
{
   int J;
   fb_ptr_t wfb = fb [wfb_index];

   for (J = 0; J < (XMAX * YMAX); J++)
   {
      *wfb = *image_ptr;
      wfb++;
      image_ptr++;
   }
}

/**********************************************************************
*
* Function: fade_in_image
*
* Purpose:
*	Fades in an image to the display
*  
* Processing:
*	
*
* Parameters:
*	image_ptr : Pointer to an image to use
*   delay_per_frame : estimated milliSecond delay per frame
*
* Outputs:
*   None
*
* Returns:
*   Nothing
*
* Notes:
*   None
*
**********************************************************************/
void fade_in_image (color_type *image_ptr, int delay_per_frame)
{
   int J, loop;
   fb_ptr_t wfb;
   UNS_16 *o_image_ptr;

   for (loop = 0x8000; loop < 0xFFFF; loop = loop + 0x0421)
   {
      wfb = fb [wfb_index];
      o_image_ptr = image_ptr;
      for (J = 0; J < (XMAX * YMAX); J++)
      {
         *wfb = (*o_image_ptr & (UNS_16) loop);
         wfb++;
         o_image_ptr++;
      }
      
      toggle_fb ();
      dummy_wait (delay_per_frame);
   }
}

/**********************************************************************
*
* Function: fade_out_image
*
* Purpose:
*	Fades out an image from the display
*  
* Processing:
*	
*
* Parameters:
*	image_ptr : Pointer to an image to use.
*   delay_per_frame : estimated milliSecond delay per frame
*
* Outputs:
*   None
*
* Returns:
*   Nothing
*
* Notes:
*   None
*
**********************************************************************/
void fade_out_image (color_type *image_ptr, int delay_per_frame)
{
   int J, loop;
   fb_ptr_t wfb;
   UNS_16 *o_image_ptr;

   for (loop = 0xFFFF; loop > 0x8000; loop = loop - 0x0421)
   {
      wfb = fb [wfb_index];
      o_image_ptr = image_ptr;
      for (J = 0; J < (XMAX * YMAX); J++)
      {
         *wfb = (*o_image_ptr & (UNS_16) loop);
         wfb++;
         o_image_ptr++;
      }
      
      toggle_fb ();
      dummy_wait (delay_per_frame);
   }
}

/**********************************************************************
*
* Function: sweep_in_image
*
* Purpose:
*	Sweeps an image into the display
*  
* Processing:
*	
*
* Parameters:
*	image_ptr : Pointer to an image to use.
*   delay_per_frame : estimated milliSecond delay per frame
*
* Outputs:
*   None
*
* Returns:
*   Nothing
*
* Notes:
*   None
*
**********************************************************************/
void sweep_in_image (color_type *image_ptr, int delay_per_frame)
{
   int J;
   int x, y;
   fb_ptr_t wfb;
   UNS_16 *a_image_ptr;
   int vindex = (XMAX / 20);

   // 20 steps of image sweep
   for (J = vindex; J <= XMAX; J = J + vindex)
   {
      // Use working frame buffer for new image
      wfb = fb [wfb_index];

      // Get old image data from active frame buffer
      a_image_ptr = fb [1 - wfb_index];

      // Get left half of sweep image from right edge of new image
      for (x = 0; x < J; x++)
      {
         for (y = 0; y < YMAX; y++)
         {
            *(wfb + x + (XMAX * y)) =
               *(image_ptr + (XMAX - J + x) + (XMAX * y));
         }
      }

      // Get right half of sweep image from 'center' edge of
      // active image
      for (x = vindex; x < XMAX; x++)
      {
         for (y = 0; y < YMAX; y++)
         {
            *(wfb + x + (XMAX * y)) =
               *(a_image_ptr + (x - vindex) + (XMAX * y));
         }
      }

      toggle_fb ();
      dummy_wait (delay_per_frame);
   }
}

/**********************************************************************
*
* Function: check_exit_button

⌨️ 快捷键说明

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