📄 ddi_display_controller_lds514.c
字号:
////////////////////////////////////////////////////////////////////////////////
//! \addtogroup ddi_display
//! @{
//
// Copyright (c) 2004-2005 SigmaTel, Inc.
//
//! \file ddi_display_controller_lds514.c
//! \brief Structures and code specific to the Leadis lds514 controller
//! \version 0.1
//! \date 08/2005
//!
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Includes and external references
////////////////////////////////////////////////////////////////////////////////
#include <types.h>
#include <components\gfx.h>
#include <drivers\ddi_display.h>
#include <stdarg.h>
#include <string.h>
#include "..\ddi_display_controller.h"
#include "..\ddi_display_controller_priv.h"
////////////////////////////////////////////////////////////////////////////////
// Externs
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Definitions
////////////////////////////////////////////////////////////////////////////////
//! Command byte to set the horizontal position register
#define DDI_DISPLAY_HORZ_START_REGION_CMD 0x34
#define DDI_DISPLAY_HORZ_STOP_REGION_CMD 0x35
//! Command byte to set the vertical position register
#define DDI_DISPLAY_VERT_START_REGION_CMD 0x36
#define DDI_DISPLAY_VERT_STOP_REGION_CMD 0x37
#ifdef DDI_DISPLAY_CONTROLLER_ILI814
#define MAX_CONTRAST_REGISTER_VAL 0x7f
#else
#define MAX_CONTRAST_REGISTER_VAL 0xff
#endif
//! Minimum contrast value set in hardware
#define MIN_CONTRAST_RED 0
//! Maximum contrast value set in hardware
#define MAX_CONTRAST_RED MAX_CONTRAST_REGISTER_VAL
//! Minimum contrast value set in hardware
#define MIN_CONTRAST_GREEN 0
//! Maximum contrast value set in hardware
#define MAX_CONTRAST_GREEN MAX_CONTRAST_REGISTER_VAL
//! Minimum contrast value set in hardware
#define MIN_CONTRAST_BLUE 0
//! Maximum contrast value set in hardware
#define MAX_CONTRAST_BLUE MAX_CONTRAST_REGISTER_VAL
//! Min allowed brightness setting
#define MIN_BRIGHTNESS 0
//! Max allowed brightness setting
#define MAX_BRIGHTNESS 15
#ifdef DDI_DISPLAY_CONTROLLER_ILI814
// Max width for the controller
#define DDI_DISPLAY_CONTROLLER_MAX_WIDTH 96
// Max height for the controller
#define DDI_DISPLAY_CONTROLLER_MAX_HEIGHT 96
#else
// Max width for the controller
#define DDI_DISPLAY_CONTROLLER_MAX_WIDTH 96
// Max height for the controller
#define DDI_DISPLAY_CONTROLLER_MAX_HEIGHT 64
#endif
// This controller uses data mode for parameters
#define PARAM_MODE DATA_MODE
#ifdef DDI_LCDIF_WORDLENGTH_16BITS
#define DDI_DISPLAY_DATA_SWIZZLE NO_SWAP
#else
#define DDI_DISPLAY_DATA_SWIZZLE HWD_BYTE_SWAP
#define DDI_DISPLAY_DATA_SWIZZLE_18BIT NO_SWAP
#endif
////////////////////////////////////////////////////////////////////////////////
// Prototypes
////////////////////////////////////////////////////////////////////////////////
static RtStatus_t SendControllerResolution(uint16_t u16Width, uint16_t u16Height, ddi_display_Rotation_t eRotation);
static RtStatus_t SendControllerInitSeq(gfx_BitmapTypeEnum_t eBitmapType,
uint32_t u32Width, uint32_t u32Height);
static void SendControllerOutputEnable(bool bOn);
static void SendControllerContrast(uint32_t u32Percentage);
static void SendControllerBrightness(uint32_t u32Percentage);
static RtStatus_t SendControllerRegion(uint32_t u32XDst, uint32_t u32YDst,
uint32_t *pu32Width, uint32_t *pu32Height,
ddi_display_Rotation_t eRotation);
static RtStatus_t SendControllerBitmapType(gfx_BitmapTypeEnum_t eBitmapType);
static RtStatus_t SendControllerRotation(ddi_display_Rotation_t eRotation);
////////////////////////////////////////////////////////////////////////////////
// Variables
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Code
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//! \fn static RtStatus_t SendControllerResolution(uint16_t u16Width, uint16_t u16Height, ddi_display_Rotation_t eRotation)
//!
//! \brief Sets up the controller for the specified resolution
//!
//! \fntype Function
//!
//! \param[in] u16Width Desired width of the display
//! \param[in] u16Height Desired height of the display
//! \param[in] eRotation Desired orientation of the display
//!
//! The display driver is built with a default width and height for each
//! controller. Most controllers support displays of varying screen
//! dimensions. In order to support all possible dimensions without rebuilding
//! the display libraries, this function can set the dimensions of the display
//! to match the actual display in use. This function only needs to be called
//! once to set the dimensions for the currently set screen orientation. If the
//! display is rotated after the dimensions are set, then the dimensions will
//! be adjusted accordingly in the display driver. There is no need to reset
//! the dimensions after rotating the display.
//!
//! \retval SUCCESS No error
//!
//! \retval ERROR_DDI_DISPLAY_CONTROLLER_RESOLUTION The specified resolution is
//! not supported by the controller
//!
////////////////////////////////////////////////////////////////////////////////
static RtStatus_t SendControllerResolution(uint16_t u16Width, uint16_t u16Height, ddi_display_Rotation_t eRotation)
{
uint16_t u16MaxWidth;
uint16_t u16MaxHeight;
// max dimensions are rotation specific
switch(eRotation)
{
case DDI_DISPLAY_ROTATION_NONE:
case DDI_DISPLAY_ROTATION_180:
u16MaxWidth = DDI_DISPLAY_CONTROLLER_MAX_WIDTH;
u16MaxHeight = DDI_DISPLAY_CONTROLLER_MAX_HEIGHT;
break;
case DDI_DISPLAY_ROTATION_90:
case DDI_DISPLAY_ROTATION_270:
u16MaxWidth = DDI_DISPLAY_CONTROLLER_MAX_HEIGHT;
u16MaxHeight = DDI_DISPLAY_CONTROLLER_MAX_WIDTH;
break;
}
// Check for out of bounds
if( u16Width > u16MaxWidth || u16Height > u16MaxHeight )
return ERROR_DDI_DISPLAY_CONTROLLER_RESOLUTION;
if( DDI_DISPLAY_ROTATION_90 == eRotation ||
DDI_DISPLAY_ROTATION_270 == eRotation )
{
// Swap width and height, the controller dimensions
// are only set up in one orientation
uint16_t u16Swap = u16Width;
u16Width = u16Height;
u16Height = u16Swap;
}
// Set the dimensions in the controller
ddi_display_controller_WriteDirect(CMD_MODE, 0x30); // Display size X
ddi_display_controller_WriteDirect(PARAM_MODE, 0); // --- X start
ddi_display_controller_WriteDirect(PARAM_MODE, u16Width); // --- X stop
ddi_display_controller_WriteDirect(CMD_MODE, 0x32); // Display size Y
ddi_display_controller_WriteDirect(PARAM_MODE, 0); // --- Y Start
ddi_display_controller_WriteDirect(PARAM_MODE, u16Height); // --- Y Stop
return SUCCESS;
}
////////////////////////////////////////////////////////////////////////////////
//! \fn static RtStatus_t SendControllerInitSeq(gfx_BitmapTypeEnum_t eBitmapType, uint32_t u32Width, uint32_t u32Height)
//!
//! \brief Sends commands to initialize the controller from reset
//!
//! \fntype Function
//!
//! \param[in] eBitmapType Graphics color format specifier
//! \param[in] u32Width Desired screen width setting
//! \param[in] u32Height Desired screen height setting
//!
//! This function sends commands to initialize the controller after it has
//! been taken out of reset.
//!
//! \retval SUCCESS No error
//!
//! \retval ERROR_DDI_DISPLAY_CONTROLLER_BITMAP_TYPE_UNSUPPORTED This
//! controller does not support the given bitmap color type
//!
//! \retval ERROR_DDI_DISPLAY_CONTROLLER_RESOLUTION This
//! controller does not support the given screen dimensions
//!
////////////////////////////////////////////////////////////////////////////////
static RtStatus_t SendControllerInitSeq(gfx_BitmapTypeEnum_t eBitmapType,
uint32_t u32Width, uint32_t u32Height)
{
RtStatus_t ret = SUCCESS;
//Init command
#ifdef DDI_DISPLAY_CONTROLLER_ILI814
ddi_display_controller_WriteDirect(CMD_MODE, 0xf1); // Device ID password
ddi_display_controller_WriteDirect(PARAM_MODE, 0x0d); // ILI814
#endif
ddi_display_controller_WriteDirect(CMD_MODE, 0x14); // Dot matrix stand-by
ddi_display_controller_WriteDirect(PARAM_MODE, 0x00); // --- OSCA start
ddi_display_controller_WriteDirect(CMD_MODE, 0x02); // Dot matrix on/off
ddi_display_controller_WriteDirect(PARAM_MODE, 0x00); // --- off
ddi_display_controller_WriteDirect(CMD_MODE, 0x1a); // Dot matrix freq set
ddi_display_controller_WriteDirect(PARAM_MODE, 0x02); //
ddi_display_controller_WriteDirect(CMD_MODE, 0x1d); // Addressing mode
ddi_display_controller_WriteDirect(PARAM_MODE, 0x00);
ddi_display_controller_WriteDirect(CMD_MODE, 0x09); // Display direction control
ddi_display_controller_WriteDirect(PARAM_MODE, 0x00);
ddi_display_controller_WriteDirect(CMD_MODE, 0x40); // Red dot current set
ddi_display_controller_WriteDirect(PARAM_MODE, 0x21);
ddi_display_controller_WriteDirect(CMD_MODE, 0x41); // Green dot current set
ddi_display_controller_WriteDirect(PARAM_MODE, 0x21);
ddi_display_controller_WriteDirect(CMD_MODE, 0x42); // Blue dot current set
ddi_display_controller_WriteDirect(PARAM_MODE, 0x2a);
ddi_display_controller_WriteDirect(CMD_MODE, 0x1e); // Data reverse & color masking
ddi_display_controller_WriteDirect(PARAM_MODE, 0x07);
ddi_display_controller_WriteDirect(CMD_MODE, 0x13); // Row scan sequence set
ddi_display_controller_WriteDirect(PARAM_MODE, 0x00);
#ifndef DDI_DISPLAY_CONTROLLER_ILI814
ddi_display_controller_WriteDirect(CMD_MODE, 0x16); // Peak pulse delay set
ddi_display_controller_WriteDirect(PARAM_MODE, 0x02);
ddi_display_controller_WriteDirect(CMD_MODE, 0x3a); // Red peak pulse width set
ddi_display_controller_WriteDirect(PARAM_MODE, 0x0a);
ddi_display_controller_WriteDirect(CMD_MODE, 0x3b); // Green peak pulse width set
ddi_display_controller_WriteDirect(PARAM_MODE, 0x0c);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -