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

📄 lh7a400_clcdc_driver.c

📁 sharp的arm920t 7A400的评估板附带光盘Sharp KEVLH7A400 v0.3b Welcome to the SHARP KEV7A400 Evaluation board
💻 C
📖 第 1 页 / 共 2 页
字号:
*   Parameters:	pal - Pointer to the color palette.
                size - number of entries in the palette as 16-bit values
* 
*   Outputs:	None
* 
*   Returns:	None
**********************************************************************/
void lcd_load_palette(void *pal, UNS_32 size)
{
    palette_entry_t pal_entry, *ptr_pal_entry;
    UNS_8 *pal_ptr;
    UNS_32 i;

    ptr_pal_entry = &pal_entry;
    pal_ptr = (UNS_8 *) pal;

    for(i = 0; i < size/2 && i < MAX_PAL_ENTRY; i++)
    {
        pal_entry.Bl = (*pal_ptr++) >> 3;  /* blue first */
        pal_entry.Gl = (*pal_ptr++) >> 3;  /* get green */
        pal_entry.Rl = (*pal_ptr++) >> 3;  /* get red */
        pal_ptr++;      /* skip over the unused byte */
        /* do the most significant halfword of the palette */
        pal_entry.Bu = (*pal_ptr++) >> 3;  /* blue first */
        pal_entry.Gu = (*pal_ptr++) >> 3;  /* get green */
        pal_entry.Ru = (*pal_ptr++) >> 3;  /* get red */
        pal_ptr++;      /* skip over the unused byte */

        CLCDC->lcdpalette[i] = *(UNS_32 *)ptr_pal_entry;
    }
}

/**********************************************************************
*   Function:	lcd_setup_lpoverflow
* 
*   Purpose:  Sets up the CLCDC overflow base register
*
*   Processing:  Sets up the overflow base register to the virtual 
*                address passed as argument
*
*   Parameters:	lpoverflowbase - virtual address of the overflow
*               location in SDRAM
*
*   Outputs:	None
*
*   Returns:    None
**********************************************************************/
void lcd_setup_lpoverflow(void *lpovflowbase)
{
   CLCDC->lcdlpoverflow = 
            LH7A400_cp15_map_virtual_to_physical(lpovflowbase);
}

/**********************************************************************
* Function:	lcd_display_width
*
* Purpose:  Returns the display width in pixels
*
* Processing:  Get the display width from the LCDTIMING0 register
*
* Parameters: None
*
* Outputs: None
*
* Returns:  The display width in pixels
*
**********************************************************************/
INT_32 lcd_display_width(void)
{
   INT_32 lcdtiming0_ppl;
   lcdtiming0_ppl = CLCDC->lcdtiming0 & 
                       _SBF(2,_BITMASK(CLCDC_LCDTIMING0_PPL_WIDTH));
   return ( (lcdtiming0_ppl >> 2) + 1) * 16;
}

/**********************************************************************
* Function:	lcd_display_height
*
* Purpose:  Returns the display height in pixels
*
* Processing:  Get the display width from the LCDTIMING1 register
*
* Parameters: None
*
* Outputs: None
*
* Returns:  The display height in pixels
*
**********************************************************************/
INT_32 lcd_display_height(void)
{
   return (CLCDC->lcdtiming1 & \
           _BITMASK(CLCDC_LCDTIMING1_LPP_WIDTH)) + 1;
}

/**********************************************************************
* Function:	lcd_display_is_tft
*
* Purpose:  Returns 1 if the display type is TFT
*
* Processing:  See code
*
* Parameters: None
*
* Outputs: None
*
* Returns:  0 if the display is not TFT, 1 if it is
*
**********************************************************************/
INT_32 lcd_display_is_tft(void)
{
   if ((CLCDC->lcdctrl & CLCDC_LCDCTRL_TFT) == 0)
      return 0;
   if ((LCDICP->setup & LCDICP_SETUP_MODE_HRTFT) == \
        LCDICP_SETUP_MODE_HRTFT)
      return 0;
   return 1;
}

/**********************************************************************
* Function:	lcd_display_is_hrtft
*
* Purpose:  Returns 1 if the display type is HRTFT
*
* Processing:  See code
*
* Parameters: None
*
* Outputs: None
*
* Returns:  0 if the display is not HRTFT, 1 if it is
*
**********************************************************************/
INT_32 lcd_display_is_hrtft(void)
{
   if ( (CLCDC->lcdctrl & CLCDC_LCDCTRL_TFT) == 0)
      return 0;
   if ( (LCDICP->setup & LCDICP_SETUP_MODE_HRTFT) == 0)
      return 0;
   return 1;
}

/**********************************************************************
* Function:	lcd_display_is_stn
*
* Purpose:  Returns 1 if the display type is STN
*
* Processing:  See code
*
* Parameters: None
*
* Outputs: None
*
* Returns:  0 if the display is not STN, 1 if it is
*
**********************************************************************/
INT_32 lcd_display_is_stn(void)
{
   if ((CLCDC->lcdctrl & CLCDC_LCDCTRL_TFT) == CLCDC_LCDCTRL_TFT)
      return 0;
   if ((LCDICP->setup & LCDICP_SETUP_MODE_HRTFT) == \
        LCDICP_SETUP_MODE_HRTFT)
      return 0;
   return 1;
}

/*********************************************************************
* Function:	lcd_display_is_mono
*
* Purpose:  Returns 1 if the display type is monochrome
*
* Processing:  See code
*
* Parameters: None
*
* Outputs: None
*
* Returns:  0 if the display is not STN, 1 if it is
*
**********************************************************************/
INT_32 lcd_display_is_mono(void)
{
   if (!lcd_display_is_stn() )
      return 0;
   if ( (CLCDC->lcdctrl & CLCDC_LCDCTRL_BW_MONO) == 0)
      return 0;
   return 1;
}

/**********************************************************************
* Function:	lcd_display_is_dual_panel
*
* Purpose:  Returns 1 if the display type is dual-panel STN
*
* Processing:  See code
*
* Parameters: None
*
* Outputs: None
*
* Returns:  0 if the display is not STN, 1 if it is
*
**********************************************************************/
INT_32 lcd_display_is_dual_panel(void)
{
   if (!lcd_display_is_stn() )
      return 0;
   if ( (CLCDC->lcdctrl & CLCDC_LCDCTRL_DUAL) == 0)
      return 0;
   return 1;
}

/**********************************************************************
* Function:	lcd_read_display_type
*
* Purpose:  Returns display type as read from DIP switches.
*
* Processing:  See code
*
* Parameters: None
*
* Outputs: None
*
* Returns:  Returns display type as read from DIP switches.or 
*           MAX_DISPLAY if the switch setting is invalid.
*
**********************************************************************/
display_type_t lcd_read_display_type(void)
{
   UNS_8 switch_setting;
   switch_setting = LH7A400_pld_get_display_brd_switch();
   if (switch_setting >= MAX_DISPLAY)
      return MAX_DISPLAY;
   return (display_type_t)switch_setting;
}

/**********************************************************************
* Function:	lcd_set_bits_per_pixel
*
* Purpose:  Set the current display bits per pixel
*
* Processing:  Write the appropriate value to the lcdctrl register
*
* Parameters:  bpp: bits per pixel. Must be one of 1, 2, 4, 8, or 16
*
* Outputs: None
*
* Returns:  The resulting bits per pixel
*
**********************************************************************/
INT_32 lcd_set_bits_per_pixel(INT_32 bpp)
{
   switch (bpp)
   {
      case 1:
         CLCDC->lcdctrl &= ~_SBF(1,_BITMASK(3) );
         CLCDC->lcdctrl |= CLCDC_LCDCTRL_BPP1;
         break;
      case 2:
         CLCDC->lcdctrl &= ~_SBF(1,_BITMASK(3) );
         CLCDC->lcdctrl |= CLCDC_LCDCTRL_BPP2;
         break;
      case 4:
         CLCDC->lcdctrl &= ~_SBF(1,_BITMASK(3) );
         CLCDC->lcdctrl |= CLCDC_LCDCTRL_BPP4;
         break;
      case 8:
         CLCDC->lcdctrl &= ~_SBF(1,_BITMASK(3) );
         CLCDC->lcdctrl |= CLCDC_LCDCTRL_BPP8;
         break;
      case 16:
         CLCDC->lcdctrl &= ~_SBF(1,_BITMASK(3) );
         CLCDC->lcdctrl |= CLCDC_LCDCTRL_BPP16;
         break;
   }
   return lcd_get_bits_per_pixel();
}

/**********************************************************************
* Function:	lcd_get_bits_per_pixel
*
* Purpose:  Return the current display bits per pixel
*
* Processing:  Return the decoded value of bits 3:1 of the lcdctrl 
*              register.
*
* Parameters: None
*
* Outputs: None
*
* Returns:  The resulting bits per pixel. If the value is illegal, 
*           return _ERROR.
*
**********************************************************************/
INT_32 lcd_get_bits_per_pixel(void)
{
   INT_32 bpp_field = (CLCDC->lcdctrl) & _SBF(1,_BITMASK(3) );
   switch (bpp_field)
   {
      case CLCDC_LCDCTRL_BPP1:
         return 1;
      case CLCDC_LCDCTRL_BPP2:
         return 2;
      case CLCDC_LCDCTRL_BPP4:
         return 4;
      case CLCDC_LCDCTRL_BPP8:
         return 8;
      case CLCDC_LCDCTRL_BPP16:
         return 16;
   }
   return _ERROR;
}

/**********************************************************************
* Function:	lcd_color_bgr
*
* Purpose:  Palette and direct color storage is:
*               blue in bits 4-0,
*               green in bits 9-5,
*               red in bits 14-10,
*               intensity in bit 15.
*
* Processing:  Set the BGR bit in the LCD control register
*
* Parameters: None
*
* Outputs: none
*
* Returns: nothing
*
**********************************************************************/
void lcd_color_bgr(void)
{
   CLCDC->lcdctrl |= CLCDC_LCDCTRL_BGR;
}

/**********************************************************************
* Function:	lcd_color_rgb
*
* Purpose:  Palette and direct color storage is: 
*               red in bits 4-0,
*               green in bits 9-5,
*               blue in bits 14-10,
*               intensity in bit 15.
*
* Processing:  Set the BGR bit in the LCD control register
*
* Parameters: None
*
* Outputs: None
*
* Returns: Nothing
*
**********************************************************************/
void lcd_color_rgb(void)
{
   CLCDC->lcdctrl &= ~CLCDC_LCDCTRL_BGR;
}

⌨️ 快捷键说明

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