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

📄 ddi_display_controller_lds514.c

📁 LCD驱动源代码 应用于手机的话,需要改写,找了好久,网上下的,将就一下了,参考参考,自己动手改一下吧.有在MTK平台上改成功的,放上来给大家参考一下啊
💻 C
📖 第 1 页 / 共 3 页
字号:
{
    RtStatus_t ret = SUCCESS;
    switch( eBitmapType )
    {
        case BITMAP_TYPE_16BPP_565:
#if defined(DDI_DISPLAY_CONTROLLER_ILI814)
            ddi_display_controller_WriteDirect(CMD_MODE, 0xeb);
            // 65k color
            ddi_display_controller_WriteDirect(PARAM_MODE, 0x0);
            ddi_lcdif_SetDataSwizzle(DDI_DISPLAY_DATA_SWIZZLE);
#endif
            break;
#if defined(DDI_DISPLAY_CONTROLLER_ILI814) && !defined(DDI_LCDIF_WORDLENGTH_16BITS)
        // We only support 18-bit color in 8-bit mode since the graphics lib BITMAP_TYPE_18BPP_666
        // representation doesn't work with any other 18-bit transfer modes of the ILI814
        case BITMAP_TYPE_18BPP_666:
            ddi_display_controller_WriteDirect(CMD_MODE, 0xeb);
            // 262k color, 6-bit mode, no color swap
            ddi_display_controller_WriteDirect(PARAM_MODE, 0x12);
            ddi_lcdif_SetDataSwizzle(DDI_DISPLAY_DATA_SWIZZLE_18BIT);
            break;
#endif
        default:
            ret = ERROR_DDI_DISPLAY_CONTROLLER_BITMAP_TYPE_UNSUPPORTED;
            break;
    }

    return ret;
}


////////////////////////////////////////////////////////////////////////////////
//! \fn static RtStatus_t SendControllerRotation(ddi_display_Rotation_t eRotation)
//!
//! \brief Sets up the controller for the specified rotation
//!
//! \fntype Function
//!
//! \param[in] eRotation - Desired orientation of the display
//!
//! When the display driver is instructed to orient the screen to a new
//! rotation, this function sends a command to the controller to indicate this change.
//!
//! \retval SUCCESS No error
//!
//! \retval ERROR_DDI_DISPLAY_CONTROLLER_ROTATION - The specified rotation is
//!         not supported by the controller
//!
////////////////////////////////////////////////////////////////////////////////
static RtStatus_t SendControllerRotation(ddi_display_Rotation_t eRotation)
{
    RtStatus_t ret = SUCCESS;

    switch(eRotation)
    {
        case DDI_DISPLAY_ROTATION_NONE:
            ddi_display_controller_WriteDirect(CMD_MODE, 0x1d);
            ddi_display_controller_WriteDirect(PARAM_MODE, 0x00); // Horizontal address mode

#ifdef DDI_DISPLAY_CONTROLLER_SUPPORT_ROTATION_180_270
            ddi_display_controller_WriteDirect(CMD_MODE, 0xd8);
            ddi_display_controller_WriteDirect(PARAM_MODE, 0x00); // No horz mirror
#endif

            ddi_display_controller_WriteDirect(CMD_MODE, 0x09);
            ddi_display_controller_WriteDirect(PARAM_MODE, 0x02); // Vert mirror
            break;
        case DDI_DISPLAY_ROTATION_90:
            ddi_display_controller_WriteDirect(CMD_MODE, 0x1d);
            ddi_display_controller_WriteDirect(PARAM_MODE, 0x04); // Vertical address mode

#ifdef DDI_DISPLAY_CONTROLLER_SUPPORT_ROTATION_180_270
            ddi_display_controller_WriteDirect(CMD_MODE, 0xd8);
            ddi_display_controller_WriteDirect(PARAM_MODE, 0x00); // No horz Mirror
#endif

            ddi_display_controller_WriteDirect(CMD_MODE, 0x09);
            ddi_display_controller_WriteDirect(PARAM_MODE, 0x00); // No vert Mirror
            break;
#ifdef DDI_DISPLAY_CONTROLLER_SUPPORT_ROTATION_180_270
        case DDI_DISPLAY_ROTATION_180:
            ddi_display_controller_WriteDirect(CMD_MODE, 0x1d);
            ddi_display_controller_WriteDirect(PARAM_MODE, 0x00); // Horizontal address mode

            ddi_display_controller_WriteDirect(CMD_MODE, 0xd8);
            ddi_display_controller_WriteDirect(PARAM_MODE, 0x04); // Horz mirror

            ddi_display_controller_WriteDirect(CMD_MODE, 0x09);
            ddi_display_controller_WriteDirect(PARAM_MODE, 0x00); // No vert mirror
            break;
        case DDI_DISPLAY_ROTATION_270:
            ddi_display_controller_WriteDirect(CMD_MODE, 0x1d);
            ddi_display_controller_WriteDirect(PARAM_MODE, 0x04); // Vertical address mode

            ddi_display_controller_WriteDirect(CMD_MODE, 0xd8);
            ddi_display_controller_WriteDirect(PARAM_MODE, 0x04); // Horz Mirror

            ddi_display_controller_WriteDirect(CMD_MODE, 0x09);
            ddi_display_controller_WriteDirect(PARAM_MODE, 0x02); // Vert Mirror
            break;
#endif
        default:
            ret = ERROR_DDI_DISPLAY_CONTROLLER_ROTATION;
            break;
    }

    return ret;
}

////////////////////////////////////////////////////////////////////////////////
//! \fn RtStatus_t ddi_display_controller_SendCommand(ddi_display_controller_CommandType_t eType, ...)
//!
//! \brief Sends the specified command to the controller
//!
//! \fntype Function
//!
//! \param[in] eType - Type of command to send
//! \param[in] Variable argument list - The rest of the arguments are specific
//!            to the type of command is to be sent.  Reference \ref
//!            ddi_display_controller.h for command types and their
//!            corresponding argument lists.
//!
//! \retval SUCCESS No error
//!
//! \retval ERROR_DDI_DISPLAY_CONTROLLER_COMMAND_UNSUPPORTED - This
//!         controller does not support the given command type
//!
//! \retval ERROR_DDI_DISPLAY_CONTROLLER_BITMAP_TYPE_UNSUPPORTED - This
//!         controller does not support the given bitmap color type
//!
//! \retval ERROR_DDI_DISPLAY_CONTROLLER_ROTATION - The specified rotation is
//!         not supported by the controller
//!
//! \retval ERROR_DDI_DISPLAY_PLACEMENT - There was an error placing the given
//!         region on the display that clipping could not compensate for.
//!
////////////////////////////////////////////////////////////////////////////////
RtStatus_t ddi_display_controller_SendCommand(ddi_display_controller_CommandType_t eType, ...)
{
    RtStatus_t ret = SUCCESS;
    va_list valist;

    va_start(valist, eType);

    switch(eType)
    {
        case DDI_DISPLAY_CONTROLLER_SET_REGION:
            {
                uint32_t u32XDst = va_arg(valist, uint32_t);
                uint32_t u32YDst = va_arg(valist, uint32_t);
                uint32_t *pu32Width = va_arg(valist, uint32_t *);
                uint32_t *pu32Height = va_arg(valist, uint32_t *);
                ddi_display_Rotation_t eRotation = (ddi_display_Rotation_t)va_arg(valist, uint32_t);
                ret = SendControllerRegion(u32XDst, u32YDst, pu32Width, pu32Height, eRotation);
            }
            break;
        case DDI_DISPLAY_CONTROLLER_SET_CONTRAST:
            SendControllerContrast(va_arg(valist, uint32_t));
            break;
        case DDI_DISPLAY_CONTROLLER_SET_BRIGHTNESS:
            SendControllerBrightness(va_arg(valist, uint32_t));
            break;
        case DDI_DISPLAY_CONTROLLER_OUTPUT_ENABLE:
            SendControllerOutputEnable(va_arg(valist, bool));
            break;
        case DDI_DISPLAY_CONTROLLER_SET_ROTATION:
            ret = SendControllerRotation(va_arg(valist, ddi_display_Rotation_t));
            break;
        case DDI_DISPLAY_CONTROLLER_SET_RESOLUTION:
            {
                uint16_t u16Width = va_arg(valist, uint16_t);
                uint16_t u16Height = va_arg(valist, uint16_t);
                ddi_display_Rotation_t eRotation = va_arg(valist, ddi_display_Rotation_t);
                ret = SendControllerResolution(u16Width, u16Height, eRotation);
                break;
            }
        case DDI_DISPLAY_CONTROLLER_SET_BITMAP_TYPE:
            ret = SendControllerBitmapType(va_arg(valist, gfx_BitmapTypeEnum_t));
            break;
        case DDI_DISPLAY_CONTROLLER_INIT:
            {
                gfx_BitmapTypeEnum_t eBitmapType = va_arg(valist, gfx_BitmapTypeEnum_t);
                uint32_t u32ScreenWidth = va_arg(valist, uint32_t);
                uint32_t u32ScreenHeight = va_arg(valist, uint32_t);
                ret = SendControllerInitSeq(eBitmapType, u32ScreenWidth, u32ScreenHeight);
            }
            break;
        default:
            ret = ERROR_DDI_DISPLAY_CONTROLLER_COMMAND_UNSUPPORTED;
            break;
    }
    va_end(valist);

    return ret;
}

////////////////////////////////////////////////////////////////////////////////
//! \fn RtStatus_t ddi_display_controller_GetLcdifInitStruct(hw_lcdif_Init_t *pInit, gfx_BitmapTypeEnum_t eBitmapType)
//!
//! \brief Copies the LCDIF init struct that corresponds to the given color format
//!
//! \fntype Function
//!
//! This function is implemented per controller or display.  The appropriate
//! LCDIF init parameters are copied to the given init struct pointer according
//! to the type of color format is specified.  Not all controllers/displays are
//! capable of all color formats, so this function may return an error
//! indicating that the given color format is not supported.
//!
//! \param[in,out] pInit - Pointer to init struct to copy to  
//! \param[in] eBitmapType - Graphics color format specifier
//!
//! \retval SUCCESS No error
//!
//! \retval ERROR_DDI_DISPLAY_CONTROLLER_BITMAP_TYPE_UNSUPPORTED - This
//!         controller does not support the given bitmap color type
//!
////////////////////////////////////////////////////////////////////////////////
RtStatus_t ddi_display_controller_GetLcdifInitStruct(hw_lcdif_Init_t *pInit, gfx_BitmapTypeEnum_t eBitmapType)
{
    // Init structure for LCDIF, may be loaded from a resource
    hw_lcdif_Init_t LcdifInit =
    {
        // No busy line, no byte-swapping, bring LCD module out of reset
        false,                          // m_bBusyEnable
        DDI_DISPLAY_DATA_SWIZZLE,       // m_eDataSwizzle
        LCDRESET_HIGH,                  // m_eReset
        BUSMODE_8080,                   // m_eBusMode
        DDI_DISPLAY_WORDLENGTH,         // m_eWordLength
        // Bus timing info
        // 1XCLK ~= 168ns
        {
            DDI_DISPLAY_DATA_SETUP_XCLKS,              // m_u8DataSetup
            DDI_DISPLAY_DATA_HOLD_XCLKS,              // m_u8DataHold
            DDI_DISPLAY_CMD_SETUP_XCLKS,              // m_u8CmdSetup
            DDI_DISPLAY_CMD_HOLD_XCLKS,               // m_u8CmdHold
        }
    };

    if( BITMAP_TYPE_16BPP_565 != eBitmapType )
        return ERROR_DDI_DISPLAY_CONTROLLER_BITMAP_TYPE_UNSUPPORTED;

    memcpy(pInit, &LcdifInit, sizeof(hw_lcdif_Init_t));

    return SUCCESS;
}
///////////////////////////////////////////////////////////////////////////////
// End of file
///////////////////////////////////////////////////////////////////////////////
//! @}

⌨️ 快捷键说明

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