2652|7

206

帖子

0

TA的资源

纯净的硅(初级)

楼主
 

【小华工规级高性能MCU-HC32F4A0开发板】03.LCD显示、电容触摸与ADC [复制链接]

 

本篇主要分享一下LCD TFT显示、GT911电容触摸与ADC采样的功能演示,我们使用的是4.3英寸的TFT LCD液晶显示屏,它是一个并口屏,内置驱动为NT35510;通过HC32F4A0的EXMC外部存储器控制器接口完成对LCD屏的读写操作,通过硬件I2C接口完成对电容触摸芯片GT911的状态和触摸坐标位置的读取,通过ADC外设完成对板载可调节变阻器的ADC值采集和对应电压的换算,并ADC采样结果显示在LCD液晶屏幕上,并实时动态显示ADC曲线图……

 

对于在LCD上显示字符的解决方案,我们选择直接将GBK_FONT字库存储在HC32F4A0芯片内部的FLASH当中,HC32F4A0的512KB的SRAM空间和2MB的FLASH程序存储空间,而一个完整的GBK_FONT只占用大概700多KB,完全满足要求,就是在后期通过板载DAP工具烧录程序到MCU时,占用的时间太长了;调试和生产都不适宜,所以后期还是建议使用QSPI FLASH或者TF CARD等其它方式吧……

 

而我手上只有一个GBK_FONT.BIN文件,如何将这个BIN文件通过添加到当前的KEIL工程,烧录到MCU FLASH空间,然后在程序中还需要调用GBK_FONT的数据呢?在文末有不一样的解决方案哦^^

 

一、原理图

1.1.LCD & TOUCH

 

1.2.端口扩展

 

1.3.ADC

 

二、驱动设计

2.1.NT35510驱动程序设计

/***********************************************************************************************************************
   [url=home.php?mod=space&uid=1307177]@File[/url] NT35510.c
   [url=home.php?mod=space&uid=1315547]@author[/url] king
   [url=home.php?mod=space&uid=311857]@date[/url] 06-Mar-2023
   [url=home.php?mod=space&uid=159083]@brief[/url] THIS FILE PROVIDES ALL THE SYSTEM FUNCTIONS.
  *********************************************************************************************************************/

/* Define to prevent recursive inclusion */
#define __NT35510_C__

/* Files include */
#include "NT35510.h"

/**
  * @addtogroup HC32F4A0_DDL_Examples
  * @{
  */

/**
  * @addtogroup Project_Templates
  * @{
  */

/* Private typedef ****************************************************************************************************/
typedef struct
{
    uint16_t Directoin;                /*!< Direction: 0, Vertical; 1, Horizontal */
    uint16_t WhoAmI;                   /*!< LCD ID */
    uint16_t Width;                    /*!< LCD Width */
    uint16_t Height;                   /*!< LCD Heigth */
    uint16_t WRamCmd;                  /*!< Start to write GRAM */
    uint16_t SetXCmd;                  /*!< Set X axis */
    uint16_t SetYCmd;                  /*!< Set Y axis */
} stc_lcd_device_t;

/* Private define *****************************************************************************************************/

/* Private macro ******************************************************************************************************/
#define SMC_MAX_TIMEOUT                 (0x100000UL)

/* Private variables **************************************************************************************************/
static stc_lcd_device_t stcLcdDevice;

/* Private functions **************************************************************************************************/

/***********************************************************************************************************************
  * @brief  Write data on LCD data register
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void NT35510_WriteData(stc_lcd_controller_t *pstcLcdController, uint16_t Data)
{
    pstcLcdController->RAM = Data;
}

/***********************************************************************************************************************
  * @brief  Write register on LCD register
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void NT35510_WriteReg(stc_lcd_controller_t *pstcLcdController, uint16_t Index)
{
    pstcLcdController->REG = Index;
}

/***********************************************************************************************************************
  * @brief  Read data from LCD data register
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
uint16_t NT35510_ReadData(stc_lcd_controller_t *pstcLcdController)
{
    return (pstcLcdController->RAM);
}

/***********************************************************************************************************************
  * @brief  Write to the selected LCD register
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void NT35510_WriteRegData(stc_lcd_controller_t *pstcLcdController, uint16_t Index, uint16_t Data)
{
    pstcLcdController->REG = Index;
    pstcLcdController->RAM = Data;
}

/***********************************************************************************************************************
  * @brief  Read the selected LCD register
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
uint16_t NT35510_ReadRegData(stc_lcd_controller_t *pstcLcdController, uint16_t Index)
{
    pstcLcdController->REG = Index;

    return (pstcLcdController->RAM);
}

/***********************************************************************************************************************
  * @brief  Prepare to write LCD RAM
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void NT35510_PrepareWriteRAM(stc_lcd_controller_t *pstcLcdController)
{
    NT35510_WriteReg(pstcLcdController, stcLcdDevice.WRamCmd);
}

/***********************************************************************************************************************
  * @brief  Set Cursor position
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void NT35510_SetCursor(stc_lcd_controller_t *pstcLcdController, uint16_t X, uint16_t Y)
{
    NT35510_WriteRegData(pstcLcdController, (stcLcdDevice.SetXCmd + 0U), (X >> 8U) & 0xFFU);
    NT35510_WriteRegData(pstcLcdController, (stcLcdDevice.SetXCmd + 1U), (X >> 0U) & 0xFFU);
    NT35510_WriteRegData(pstcLcdController, (stcLcdDevice.SetYCmd + 0U), (Y >> 8U) & 0xFFU);
    NT35510_WriteRegData(pstcLcdController, (stcLcdDevice.SetYCmd + 1U), (Y >> 0U) & 0xFFU);
}

/***********************************************************************************************************************
  * @brief  Write pixel
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void NT35510_DrawPixel(stc_lcd_controller_t *pstcLcdController, uint16_t X, uint16_t Y, uint16_t Color)
{
    NT35510_SetCursor(pstcLcdController, X, Y);

    NT35510_PrepareWriteRAM(pstcLcdController);

    NT35510_WriteData(pstcLcdController, Color);
}

/***********************************************************************************************************************
  * @brief  Clear screen
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void NT35510_Clear(stc_lcd_controller_t *pstcLcdController, uint16_t Color)
{
    uint32_t i = 0;
    uint32_t TotalPoint = 0;

    TotalPoint = (uint32_t)stcLcdDevice.Width * (uint32_t)stcLcdDevice.Height;

    NT35510_SetCursor(pstcLcdController, 0U, 0U);

    NT35510_PrepareWriteRAM(pstcLcdController);

    for (i = 0UL; i < TotalPoint; i++)
    {
        NT35510_WriteData(pstcLcdController, Color);
    }
}

/***********************************************************************************************************************
  * @brief  NT35510 Init Port
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
static void NT35510_InitPort(void)
{
    stc_gpio_init_t stcGpioInit;

    GPIO_StructInit(&stcGpioInit);
    stcGpioInit.u16PinDrv = PIN_HIGH_DRV;

    /* LCD_CS */
    GPIO_Init(NT35510_CS_PORT, NT35510_CS_PIN, &stcGpioInit);

    /* LCD_RS */
    GPIO_Init(NT35510_RS_PORT, NT35510_RS_PIN, &stcGpioInit);

    /* LCD_WE */
    GPIO_Init(NT35510_WE_PORT, NT35510_WE_PIN, &stcGpioInit);

    /* LCD_OE */
    GPIO_Init(NT35510_OE_PORT, NT35510_OE_PIN, &stcGpioInit);

    /* SMC_DATA[0:15] */
    GPIO_Init(NT35510_DATA00_PORT, NT35510_DATA00_PIN, &stcGpioInit);
    GPIO_Init(NT35510_DATA01_PORT, NT35510_DATA01_PIN, &stcGpioInit);
    GPIO_Init(NT35510_DATA02_PORT, NT35510_DATA02_PIN, &stcGpioInit);
    GPIO_Init(NT35510_DATA03_PORT, NT35510_DATA03_PIN, &stcGpioInit);
    GPIO_Init(NT35510_DATA04_PORT, NT35510_DATA04_PIN, &stcGpioInit);
    GPIO_Init(NT35510_DATA05_PORT, NT35510_DATA05_PIN, &stcGpioInit);
    GPIO_Init(NT35510_DATA06_PORT, NT35510_DATA06_PIN, &stcGpioInit);
    GPIO_Init(NT35510_DATA07_PORT, NT35510_DATA07_PIN, &stcGpioInit);
    GPIO_Init(NT35510_DATA08_PORT, NT35510_DATA08_PIN, &stcGpioInit);
    GPIO_Init(NT35510_DATA09_PORT, NT35510_DATA09_PIN, &stcGpioInit);
    GPIO_Init(NT35510_DATA10_PORT, NT35510_DATA10_PIN, &stcGpioInit);
    GPIO_Init(NT35510_DATA11_PORT, NT35510_DATA11_PIN, &stcGpioInit);
    GPIO_Init(NT35510_DATA12_PORT, NT35510_DATA12_PIN, &stcGpioInit);
    GPIO_Init(NT35510_DATA13_PORT, NT35510_DATA13_PIN, &stcGpioInit);
    GPIO_Init(NT35510_DATA14_PORT, NT35510_DATA14_PIN, &stcGpioInit);
    GPIO_Init(NT35510_DATA15_PORT, NT35510_DATA15_PIN, &stcGpioInit);

    /* LCD_DATA[0:15] */
    GPIO_SetFunc(NT35510_DATA00_PORT, NT35510_DATA00_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_DATA01_PORT, NT35510_DATA01_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_DATA02_PORT, NT35510_DATA02_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_DATA03_PORT, NT35510_DATA03_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_DATA04_PORT, NT35510_DATA04_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_DATA05_PORT, NT35510_DATA05_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_DATA06_PORT, NT35510_DATA06_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_DATA07_PORT, NT35510_DATA07_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_DATA08_PORT, NT35510_DATA08_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_DATA09_PORT, NT35510_DATA09_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_DATA10_PORT, NT35510_DATA10_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_DATA11_PORT, NT35510_DATA11_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_DATA12_PORT, NT35510_DATA12_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_DATA13_PORT, NT35510_DATA13_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_DATA14_PORT, NT35510_DATA14_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_DATA15_PORT, NT35510_DATA15_PIN, GPIO_FUNC_12);

    GPIO_SetFunc(NT35510_CS_PORT, NT35510_CS_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_RS_PORT, NT35510_RS_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_WE_PORT, NT35510_WE_PIN, GPIO_FUNC_12);
    GPIO_SetFunc(NT35510_OE_PORT, NT35510_OE_PIN, GPIO_FUNC_12);
}

/***********************************************************************************************************************
  * @brief  NT35510 Init EXMC
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
static void NT35510_InitEXMC(void)
{
    __IO uint32_t u32To = 0UL;
    int32_t i32Ret = LL_OK;

    stc_exmc_smc_init_t          stcSmcInit;
    stc_exmc_smc_chip_config_t   stcChipConfig;
    stc_exmc_smc_timing_config_t stcTimingConfig;

    en_flag_status_t enChipStatus   = RESET;
    en_flag_status_t enTimingStatus = RESET;

    /* Enable SMC clock */
    FCG_Fcg3PeriphClockCmd(FCG3_PERIPH_SMC, ENABLE);

    /* Enable SMC. */
    EXMC_SMC_Cmd(ENABLE);

    EXMC_SMC_ExitLowPower();

    while (EXMC_SMC_READY != EXMC_SMC_GetStatus())
    {
        if (u32To > SMC_MAX_TIMEOUT)
        {
            i32Ret = LL_ERR;
            break;
        }

        u32To++;
    }

    if (LL_OK == i32Ret)
    {
        /* Configure SMC width && CS &chip & timing. */
        EXMC_SMC_StructInit(&stcSmcInit);
        stcSmcInit.stcChipConfig.u32AddrMatch       = NT35510_ADDR_MATCH;
        stcSmcInit.stcChipConfig.u32AddrMask        = NT35510_ADDR_MASK;
        stcSmcInit.stcChipConfig.u32MemoryWidth     = EXMC_SMC_MEMORY_WIDTH_16BIT;
        stcSmcInit.stcChipConfig.u32BAA             = EXMC_SMC_BAA_PORT_DISABLE;
        stcSmcInit.stcChipConfig.u32ADV             = EXMC_SMC_ADV_PORT_DISABLE;
        stcSmcInit.stcChipConfig.u32BLS             = EXMC_SMC_BLS_SYNC_CS;
        stcSmcInit.stcChipConfig.u32ReadBurstLen    = EXMC_SMC_READ_BURST_4BEAT;
        stcSmcInit.stcChipConfig.u32WriteBurstLen   = EXMC_SMC_WRITE_BURST_4BEAT;
        stcSmcInit.stcChipConfig.u32ReadMode        = EXMC_SMC_READ_SYNC;
        stcSmcInit.stcChipConfig.u32WriteMode       = EXMC_SMC_WRITE_SYNC;
        stcSmcInit.stcTimingConfig.u8RC             = 8U;
        stcSmcInit.stcTimingConfig.u8WC             = 4U;
        stcSmcInit.stcTimingConfig.u8CEOE           = 1U;
        stcSmcInit.stcTimingConfig.u8WP             = 2U;
        stcSmcInit.stcTimingConfig.u8PC             = 4U;
        stcSmcInit.stcTimingConfig.u8TR             = 1U;
        EXMC_SMC_Init(NT35510_CHIP, &stcSmcInit);

        /* Set command: updateregs */
        EXMC_SMC_SetCommand(NT35510_CHIP, EXMC_SMC_CMD_UPDATEREGS, 0UL, 0UL);

        /* Check timing status */
        u32To = 0UL;

        while ((enChipStatus != SET) || (enTimingStatus != SET))
        {
            EXMC_SMC_GetTimingConfig(NT35510_CHIP, &stcTimingConfig);

            if (0 == memcmp(&stcTimingConfig, &stcSmcInit.stcTimingConfig, sizeof(stcTimingConfig)))
            {
                enTimingStatus = SET;
            }

            (void)EXMC_SMC_GetChipConfig(NT35510_CHIP, &stcChipConfig);

            if (0 == memcmp(&stcChipConfig, &stcSmcInit.stcChipConfig, sizeof(stcChipConfig)))
            {
                enChipStatus = SET;
            }

            if (u32To > SMC_MAX_TIMEOUT)
            {
                i32Ret = LL_ERR;
                break;
            }

            u32To++;
        }
    }
}

/***********************************************************************************************************************
  * @brief  NT35510 Configure
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
static void NT35510_Configure(stc_lcd_controller_t *pstcLcdController)
{
    NT35510_WriteRegData(pstcLcdController, 0xF000U, 0x55U);
    NT35510_WriteRegData(pstcLcdController, 0xF001U, 0xAAU);
    NT35510_WriteRegData(pstcLcdController, 0xF002U, 0x52U);
    NT35510_WriteRegData(pstcLcdController, 0xF003U, 0x08U);
    NT35510_WriteRegData(pstcLcdController, 0xF004U, 0x01U);

    /* AVDD Set AVDD 5.2V */
    NT35510_WriteRegData(pstcLcdController, 0xB000U, 0x0DU);
    NT35510_WriteRegData(pstcLcdController, 0xB001U, 0x0DU);
    NT35510_WriteRegData(pstcLcdController, 0xB002U, 0x0DU);

    /* AVDD ratio */
    NT35510_WriteRegData(pstcLcdController, 0xB600U, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xB601U, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xB602U, 0x34U);

    /* AVEE -5.2V */
    NT35510_WriteRegData(pstcLcdController, 0xB100U, 0x0DU);
    NT35510_WriteRegData(pstcLcdController, 0xB101U, 0x0DU);
    NT35510_WriteRegData(pstcLcdController, 0xB102U, 0x0DU);

    /* AVEE ratio */
    NT35510_WriteRegData(pstcLcdController, 0xB700U, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xB701U, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xB702U, 0x34U);

    /* VCL -2.5V */
    NT35510_WriteRegData(pstcLcdController, 0xB200U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xB201U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xB202U, 0x00U);

    /* VCL ratio */
    NT35510_WriteRegData(pstcLcdController, 0xB800U, 0x24U);
    NT35510_WriteRegData(pstcLcdController, 0xB801U, 0x24U);
    NT35510_WriteRegData(pstcLcdController, 0xB802U, 0x24U);

    /* VGH 15V (Free pump) */
    NT35510_WriteRegData(pstcLcdController, 0xBF00U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xB300U, 0x0FU);
    NT35510_WriteRegData(pstcLcdController, 0xB301U, 0x0FU);
    NT35510_WriteRegData(pstcLcdController, 0xB302U, 0x0FU);

    /* VGH ratio */
    NT35510_WriteRegData(pstcLcdController, 0xB900U, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xB901U, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xB902U, 0x34U);

    /* VGL_REG -10V */
    NT35510_WriteRegData(pstcLcdController, 0xB500U, 0x08U);
    NT35510_WriteRegData(pstcLcdController, 0xB501U, 0x08U);
    NT35510_WriteRegData(pstcLcdController, 0xB502U, 0x08U);
    NT35510_WriteRegData(pstcLcdController, 0xC200U, 0x03U);

    /* VGLX ratio */
    NT35510_WriteRegData(pstcLcdController, 0xBA00U, 0x24U);
    NT35510_WriteRegData(pstcLcdController, 0xBA01U, 0x24U);
    NT35510_WriteRegData(pstcLcdController, 0xBA02U, 0x24U);

    /* VGMP/VGSP 4.5V/0V */
    NT35510_WriteRegData(pstcLcdController, 0xBC00U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xBC01U, 0x78U);
    NT35510_WriteRegData(pstcLcdController, 0xBC02U, 0x00U);

    /* VGMN/VGSN -4.5V/0V */
    NT35510_WriteRegData(pstcLcdController, 0xBD00U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xBD01U, 0x78U);
    NT35510_WriteRegData(pstcLcdController, 0xBD02U, 0x00U);

    /* VCOM */
    NT35510_WriteRegData(pstcLcdController, 0xBE00U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xBE01U, 0x64U);

    /* Gamma Setting */
    NT35510_WriteRegData(pstcLcdController, 0xD100U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD101U, 0x33U);
    NT35510_WriteRegData(pstcLcdController, 0xD102U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD103U, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xD104U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD105U, 0x3AU);
    NT35510_WriteRegData(pstcLcdController, 0xD106U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD107U, 0x4AU);
    NT35510_WriteRegData(pstcLcdController, 0xD108U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD109U, 0x5CU);
    NT35510_WriteRegData(pstcLcdController, 0xD10AU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD10BU, 0x81U);
    NT35510_WriteRegData(pstcLcdController, 0xD10CU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD10DU, 0xA6U);
    NT35510_WriteRegData(pstcLcdController, 0xD10EU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD10FU, 0xE5U);
    NT35510_WriteRegData(pstcLcdController, 0xD110U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD111U, 0x13U);
    NT35510_WriteRegData(pstcLcdController, 0xD112U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD113U, 0x54U);
    NT35510_WriteRegData(pstcLcdController, 0xD114U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD115U, 0x82U);
    NT35510_WriteRegData(pstcLcdController, 0xD116U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD117U, 0xCAU);
    NT35510_WriteRegData(pstcLcdController, 0xD118U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD119U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD11AU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD11BU, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD11CU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD11DU, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xD11EU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD11FU, 0x67U);
    NT35510_WriteRegData(pstcLcdController, 0xD120U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD121U, 0x84U);
    NT35510_WriteRegData(pstcLcdController, 0xD122U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD123U, 0xA4U);
    NT35510_WriteRegData(pstcLcdController, 0xD124U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD125U, 0xB7U);
    NT35510_WriteRegData(pstcLcdController, 0xD126U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD127U, 0xCFU);
    NT35510_WriteRegData(pstcLcdController, 0xD128U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD129U, 0xDEU);
    NT35510_WriteRegData(pstcLcdController, 0xD12AU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD12BU, 0xF2U);
    NT35510_WriteRegData(pstcLcdController, 0xD12CU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD12DU, 0xFEU);
    NT35510_WriteRegData(pstcLcdController, 0xD12EU, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD12FU, 0x10U);
    NT35510_WriteRegData(pstcLcdController, 0xD130U, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD131U, 0x33U);
    NT35510_WriteRegData(pstcLcdController, 0xD132U, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD133U, 0x6DU);
    NT35510_WriteRegData(pstcLcdController, 0xD200U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD201U, 0x33U);
    NT35510_WriteRegData(pstcLcdController, 0xD202U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD203U, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xD204U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD205U, 0x3AU);
    NT35510_WriteRegData(pstcLcdController, 0xD206U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD207U, 0x4AU);
    NT35510_WriteRegData(pstcLcdController, 0xD208U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD209U, 0x5CU);
    NT35510_WriteRegData(pstcLcdController, 0xD20AU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD20BU, 0x81U);
    NT35510_WriteRegData(pstcLcdController, 0xD20CU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD20DU, 0xA6U);
    NT35510_WriteRegData(pstcLcdController, 0xD20EU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD20FU, 0xE5U);
    NT35510_WriteRegData(pstcLcdController, 0xD210U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD211U, 0x13U);
    NT35510_WriteRegData(pstcLcdController, 0xD212U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD213U, 0x54U);
    NT35510_WriteRegData(pstcLcdController, 0xD214U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD215U, 0x82U);
    NT35510_WriteRegData(pstcLcdController, 0xD216U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD217U, 0xCAU);
    NT35510_WriteRegData(pstcLcdController, 0xD218U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD219U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD21AU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD21BU, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD21CU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD21DU, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xD21EU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD21FU, 0x67U);
    NT35510_WriteRegData(pstcLcdController, 0xD220U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD221U, 0x84U);
    NT35510_WriteRegData(pstcLcdController, 0xD222U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD223U, 0xA4U);
    NT35510_WriteRegData(pstcLcdController, 0xD224U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD225U, 0xB7U);
    NT35510_WriteRegData(pstcLcdController, 0xD226U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD227U, 0xCFU);
    NT35510_WriteRegData(pstcLcdController, 0xD228U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD229U, 0xDEU);
    NT35510_WriteRegData(pstcLcdController, 0xD22AU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD22BU, 0xF2U);
    NT35510_WriteRegData(pstcLcdController, 0xD22CU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD22DU, 0xFEU);
    NT35510_WriteRegData(pstcLcdController, 0xD22EU, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD22FU, 0x10U);
    NT35510_WriteRegData(pstcLcdController, 0xD230U, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD231U, 0x33U);
    NT35510_WriteRegData(pstcLcdController, 0xD232U, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD233U, 0x6DU);
    NT35510_WriteRegData(pstcLcdController, 0xD300U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD301U, 0x33U);
    NT35510_WriteRegData(pstcLcdController, 0xD302U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD303U, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xD304U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD305U, 0x3AU);
    NT35510_WriteRegData(pstcLcdController, 0xD306U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD307U, 0x4AU);
    NT35510_WriteRegData(pstcLcdController, 0xD308U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD309U, 0x5CU);
    NT35510_WriteRegData(pstcLcdController, 0xD30AU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD30BU, 0x81U);
    NT35510_WriteRegData(pstcLcdController, 0xD30CU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD30DU, 0xA6U);
    NT35510_WriteRegData(pstcLcdController, 0xD30EU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD30FU, 0xE5U);
    NT35510_WriteRegData(pstcLcdController, 0xD310U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD311U, 0x13U);
    NT35510_WriteRegData(pstcLcdController, 0xD312U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD313U, 0x54U);
    NT35510_WriteRegData(pstcLcdController, 0xD314U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD315U, 0x82U);
    NT35510_WriteRegData(pstcLcdController, 0xD316U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD317U, 0xCAU);
    NT35510_WriteRegData(pstcLcdController, 0xD318U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD319U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD31AU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD31BU, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD31CU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD31DU, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xD31EU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD31FU, 0x67U);
    NT35510_WriteRegData(pstcLcdController, 0xD320U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD321U, 0x84U);
    NT35510_WriteRegData(pstcLcdController, 0xD322U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD323U, 0xA4U);
    NT35510_WriteRegData(pstcLcdController, 0xD324U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD325U, 0xB7U);
    NT35510_WriteRegData(pstcLcdController, 0xD326U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD327U, 0xCFU);
    NT35510_WriteRegData(pstcLcdController, 0xD328U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD329U, 0xDEU);
    NT35510_WriteRegData(pstcLcdController, 0xD32AU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD32BU, 0xF2U);
    NT35510_WriteRegData(pstcLcdController, 0xD32CU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD32DU, 0xFEU);
    NT35510_WriteRegData(pstcLcdController, 0xD32EU, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD32FU, 0x10U);
    NT35510_WriteRegData(pstcLcdController, 0xD330U, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD331U, 0x33U);
    NT35510_WriteRegData(pstcLcdController, 0xD332U, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD333U, 0x6DU);
    NT35510_WriteRegData(pstcLcdController, 0xD400U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD401U, 0x33U);
    NT35510_WriteRegData(pstcLcdController, 0xD402U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD403U, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xD404U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD405U, 0x3AU);
    NT35510_WriteRegData(pstcLcdController, 0xD406U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD407U, 0x4AU);
    NT35510_WriteRegData(pstcLcdController, 0xD408U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD409U, 0x5CU);
    NT35510_WriteRegData(pstcLcdController, 0xD40AU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD40BU, 0x81U);
    NT35510_WriteRegData(pstcLcdController, 0xD40CU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD40DU, 0xA6U);
    NT35510_WriteRegData(pstcLcdController, 0xD40EU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD40FU, 0xE5U);
    NT35510_WriteRegData(pstcLcdController, 0xD410U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD411U, 0x13U);
    NT35510_WriteRegData(pstcLcdController, 0xD412U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD413U, 0x54U);
    NT35510_WriteRegData(pstcLcdController, 0xD414U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD415U, 0x82U);
    NT35510_WriteRegData(pstcLcdController, 0xD416U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD417U, 0xCAU);
    NT35510_WriteRegData(pstcLcdController, 0xD418U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD419U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD41AU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD41BU, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD41CU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD41DU, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xD41EU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD41FU, 0x67U);
    NT35510_WriteRegData(pstcLcdController, 0xD420U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD421U, 0x84U);
    NT35510_WriteRegData(pstcLcdController, 0xD422U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD423U, 0xA4U);
    NT35510_WriteRegData(pstcLcdController, 0xD424U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD425U, 0xB7U);
    NT35510_WriteRegData(pstcLcdController, 0xD426U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD427U, 0xCFU);
    NT35510_WriteRegData(pstcLcdController, 0xD428U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD429U, 0xDEU);
    NT35510_WriteRegData(pstcLcdController, 0xD42AU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD42BU, 0xF2U);
    NT35510_WriteRegData(pstcLcdController, 0xD42CU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD42DU, 0xFEU);
    NT35510_WriteRegData(pstcLcdController, 0xD42EU, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD42FU, 0x10U);
    NT35510_WriteRegData(pstcLcdController, 0xD430U, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD431U, 0x33U);
    NT35510_WriteRegData(pstcLcdController, 0xD432U, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD433U, 0x6DU);
    NT35510_WriteRegData(pstcLcdController, 0xD500U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD501U, 0x33U);
    NT35510_WriteRegData(pstcLcdController, 0xD502U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD503U, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xD504U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD505U, 0x3AU);
    NT35510_WriteRegData(pstcLcdController, 0xD506U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD507U, 0x4AU);
    NT35510_WriteRegData(pstcLcdController, 0xD508U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD509U, 0x5CU);
    NT35510_WriteRegData(pstcLcdController, 0xD50AU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD50BU, 0x81U);
    NT35510_WriteRegData(pstcLcdController, 0xD50CU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD50DU, 0xA6U);
    NT35510_WriteRegData(pstcLcdController, 0xD50EU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD50FU, 0xE5U);
    NT35510_WriteRegData(pstcLcdController, 0xD510U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD511U, 0x13U);
    NT35510_WriteRegData(pstcLcdController, 0xD512U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD513U, 0x54U);
    NT35510_WriteRegData(pstcLcdController, 0xD514U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD515U, 0x82U);
    NT35510_WriteRegData(pstcLcdController, 0xD516U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD517U, 0xCAU);
    NT35510_WriteRegData(pstcLcdController, 0xD518U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD519U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD51AU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD51BU, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD51CU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD51DU, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xD51EU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD51FU, 0x67U);
    NT35510_WriteRegData(pstcLcdController, 0xD520U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD521U, 0x84U);
    NT35510_WriteRegData(pstcLcdController, 0xD522U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD523U, 0xA4U);
    NT35510_WriteRegData(pstcLcdController, 0xD524U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD525U, 0xB7U);
    NT35510_WriteRegData(pstcLcdController, 0xD526U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD527U, 0xCFU);
    NT35510_WriteRegData(pstcLcdController, 0xD528U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD529U, 0xDEU);
    NT35510_WriteRegData(pstcLcdController, 0xD52AU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD52BU, 0xF2U);
    NT35510_WriteRegData(pstcLcdController, 0xD52CU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD52DU, 0xFEU);
    NT35510_WriteRegData(pstcLcdController, 0xD52EU, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD52FU, 0x10U);
    NT35510_WriteRegData(pstcLcdController, 0xD530U, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD531U, 0x33U);
    NT35510_WriteRegData(pstcLcdController, 0xD532U, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD533U, 0x6DU);
    NT35510_WriteRegData(pstcLcdController, 0xD600U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD601U, 0x33U);
    NT35510_WriteRegData(pstcLcdController, 0xD602U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD603U, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xD604U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD605U, 0x3AU);
    NT35510_WriteRegData(pstcLcdController, 0xD606U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD607U, 0x4AU);
    NT35510_WriteRegData(pstcLcdController, 0xD608U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD609U, 0x5CU);
    NT35510_WriteRegData(pstcLcdController, 0xD60AU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD60BU, 0x81U);
    NT35510_WriteRegData(pstcLcdController, 0xD60CU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD60DU, 0xA6U);
    NT35510_WriteRegData(pstcLcdController, 0xD60EU, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD60FU, 0xE5U);
    NT35510_WriteRegData(pstcLcdController, 0xD610U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD611U, 0x13U);
    NT35510_WriteRegData(pstcLcdController, 0xD612U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD613U, 0x54U);
    NT35510_WriteRegData(pstcLcdController, 0xD614U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD615U, 0x82U);
    NT35510_WriteRegData(pstcLcdController, 0xD616U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD617U, 0xCAU);
    NT35510_WriteRegData(pstcLcdController, 0xD618U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD619U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xD61AU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD61BU, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xD61CU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD61DU, 0x34U);
    NT35510_WriteRegData(pstcLcdController, 0xD61EU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD61FU, 0x67U);
    NT35510_WriteRegData(pstcLcdController, 0xD620U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD621U, 0x84U);
    NT35510_WriteRegData(pstcLcdController, 0xD622U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD623U, 0xA4U);
    NT35510_WriteRegData(pstcLcdController, 0xD624U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD625U, 0xB7U);
    NT35510_WriteRegData(pstcLcdController, 0xD626U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD627U, 0xCFU);
    NT35510_WriteRegData(pstcLcdController, 0xD628U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD629U, 0xDEU);
    NT35510_WriteRegData(pstcLcdController, 0xD62AU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD62BU, 0xF2U);
    NT35510_WriteRegData(pstcLcdController, 0xD62CU, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xD62DU, 0xFEU);
    NT35510_WriteRegData(pstcLcdController, 0xD62EU, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD62FU, 0x10U);
    NT35510_WriteRegData(pstcLcdController, 0xD630U, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD631U, 0x33U);
    NT35510_WriteRegData(pstcLcdController, 0xD632U, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xD633U, 0x6DU);

    /* LV2 Page 0 enable */
    NT35510_WriteRegData(pstcLcdController, 0xF000U, 0x55U);
    NT35510_WriteRegData(pstcLcdController, 0xF001U, 0xAAU);
    NT35510_WriteRegData(pstcLcdController, 0xF002U, 0x52U);
    NT35510_WriteRegData(pstcLcdController, 0xF003U, 0x08U);
    NT35510_WriteRegData(pstcLcdController, 0xF004U, 0x00U);

    /* Display control */
    NT35510_WriteRegData(pstcLcdController, 0xB100U, 0xCCU);
    NT35510_WriteRegData(pstcLcdController, 0xB101U, 0x00U);

    /* Source hold time */
    NT35510_WriteRegData(pstcLcdController, 0xB600U, 0x05U);

    /* Gate EQ control */
    NT35510_WriteRegData(pstcLcdController, 0xB700U, 0x70U);
    NT35510_WriteRegData(pstcLcdController, 0xB701U, 0x70U);

    /* Source EQ control (Mode 2) */
    NT35510_WriteRegData(pstcLcdController, 0xB800U, 0x01U);
    NT35510_WriteRegData(pstcLcdController, 0xB801U, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xB802U, 0x03U);
    NT35510_WriteRegData(pstcLcdController, 0xB803U, 0x03U);

    /* Inversion mode (2-dot) */
    NT35510_WriteRegData(pstcLcdController, 0xBC00U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xBC01U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0xBC02U, 0x00U);

    /* Timing control 4H w/ 4-delay */
    NT35510_WriteRegData(pstcLcdController, 0xC900U, 0xD0U);
    NT35510_WriteRegData(pstcLcdController, 0xC901U, 0x02U);
    NT35510_WriteRegData(pstcLcdController, 0xC902U, 0x50U);
    NT35510_WriteRegData(pstcLcdController, 0xC903U, 0x50U);
    NT35510_WriteRegData(pstcLcdController, 0xC904U, 0x50U);
    NT35510_WriteRegData(pstcLcdController, 0x3500U, 0x00U);
    NT35510_WriteRegData(pstcLcdController, 0x3A00U, 0x55U); /* 16-bit/pixel */

    NT35510_WriteReg(pstcLcdController, 0x1100U);
    DDL_DelayMS(120UL);
    NT35510_WriteReg(pstcLcdController, 0x2900U);
}

/***********************************************************************************************************************
  * @brief  Read LCD ID
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
static uint16_t NT35510_ReadID(stc_lcd_controller_t *pstcLcdController)
{
    uint16_t WhoAmI = 0;    /* Unsupported LCD */

    NT35510_WriteReg(pstcLcdController, 0xDA00);
    NT35510_ReadData(pstcLcdController);                    /* read 0xDA00: 0x0000 */

    NT35510_WriteReg(pstcLcdController, 0xDB00U);
    WhoAmI  = NT35510_ReadData(pstcLcdController) << 8U;    /* read 0xDB00: 0x0080 */

    NT35510_WriteReg(pstcLcdController, 0xDC00U);
    WhoAmI |= NT35510_ReadData(pstcLcdController) << 0U;    /* read 0xDC00: 0x0000 */

    /* Read ID: ID=008000H (5510H) */
    if (WhoAmI == 0x008000UL)
    {
        WhoAmI = 0x5510U;      /* ID convert to: 0x5510 */
    }

    return (WhoAmI);
}

/***********************************************************************************************************************
  * @brief  Set Scan Direction
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
static void NT35510_SetScanDirectoin(stc_lcd_controller_t *pstcLcdController, uint16_t Directoin)
{
    uint16_t RegData = 0U;

    switch (Directoin)
    {
        case LCD_SCAN_DIR_L2R_U2D:
            RegData |= ((0U << 7) | (0U << 6) | (0U << 5));
            break;

        case LCD_SCAN_DIR_L2R_D2U:
            RegData |= ((1U << 7) | (0U << 6) | (0U << 5));
            break;

        case LCD_SCAN_DIR_R2L_U2D:
            RegData |= ((0U << 7) | (1U << 6) | (0U << 5));
            break;

        case LCD_SCAN_DIR_R2L_D2U:
            RegData |= ((1U << 7) | (1U << 6) | (0U << 5));
            break;

        case LCD_SCAN_DIR_U2D_L2R:
            RegData |= ((0U << 7) | (0U << 6) | (1U << 5));
            break;

        case LCD_SCAN_DIR_U2D_R2L:
            RegData |= ((0U << 7) | (1U << 6) | (1U << 5));
            break;

        case LCD_SCAN_DIR_D2U_L2R:
            RegData |= ((1U << 7) | (0U << 6) | (1U << 5));
            break;

        case LCD_SCAN_DIR_D2U_R2L:
            RegData |= ((1U << 7) | (1U << 6) | (1U << 5));
            break;

        default:
            break;
    }

    /* Set Display Window Scan Directoin */
    NT35510_WriteRegData(pstcLcdController, 0x3600U, RegData);

    /* Set Display Window Width */
    NT35510_WriteRegData(pstcLcdController, stcLcdDevice.SetXCmd + 0U, 0U);
    NT35510_WriteRegData(pstcLcdController, stcLcdDevice.SetXCmd + 1U, 0U);
    NT35510_WriteRegData(pstcLcdController, stcLcdDevice.SetXCmd + 2U, ((stcLcdDevice.Width - 1U)) >> 8U & 0xFFU);
    NT35510_WriteRegData(pstcLcdController, stcLcdDevice.SetXCmd + 3U, ((stcLcdDevice.Width - 1U)) >> 0U & 0xFFU);

    /* Set Display Window  Height */
    NT35510_WriteRegData(pstcLcdController, stcLcdDevice.SetYCmd + 0U, 0U);
    NT35510_WriteRegData(pstcLcdController, stcLcdDevice.SetYCmd + 1U, 0U);
    NT35510_WriteRegData(pstcLcdController, stcLcdDevice.SetYCmd + 2U, ((stcLcdDevice.Height - 1U)) >> 8U & 0xFFU);
    NT35510_WriteRegData(pstcLcdController, stcLcdDevice.SetYCmd + 3U, ((stcLcdDevice.Height - 1U)) >> 0U & 0xFFU);
}

/***********************************************************************************************************************
  * @brief  Set Display Direction
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
static void NT35510_SetDisplayDirection(stc_lcd_controller_t *pstcLcdController, uint16_t Directoin)
{
    if (LCD_DISPLAY_VERTICAL == Directoin)  /* Vertical */
    {
        stcLcdDevice.Directoin = Directoin;
        stcLcdDevice.Width     = 480U;
        stcLcdDevice.Height    = 800U;
        stcLcdDevice.WRamCmd   = 0x2C00U;
        stcLcdDevice.SetXCmd   = 0x2A00U;
        stcLcdDevice.SetYCmd   = 0x2B00U;
    }
    else                                    /* Horizontal */
    {
        stcLcdDevice.Directoin = Directoin;
        stcLcdDevice.Width     = 800U;
        stcLcdDevice.Height    = 480U;
        stcLcdDevice.WRamCmd   = 0x2C00U;
        stcLcdDevice.SetXCmd   = 0x2A00U;
        stcLcdDevice.SetYCmd   = 0x2B00U;
    }

    NT35510_SetScanDirectoin(pstcLcdController, LCD_SCAN_DIR_L2R_U2D);
}

/***********************************************************************************************************************
  * @brief  NT35510 Init
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void NT35510_Init(stc_lcd_controller_t *pstcLcdController)
{
    NT35510_InitPort();

    NT35510_InitEXMC();

    NT35510_WriteRegData(pstcLcdController, 0x0000U, 0x00U);

    printf("\r\n0x%04x", NT35510_ReadID(pstcLcdController));

    NT35510_Configure(pstcLcdController);

    NT35510_SetDisplayDirection(pstcLcdController, LCD_DISPLAY_VERTICAL);

    NT35510_Clear(pstcLcdController, 0);
}

/***********************************************************************************************************************
  * @brief  Get LCD Pixel Width
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
uint16_t NT35510_GetPixelWidth(void)
{
    return (stcLcdDevice.Width);
}

/***********************************************************************************************************************
  * @brief  Get LCD Pixel Height
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
uint16_t NT35510_GetPixelHeight(void)
{
    return (stcLcdDevice.Height);
}

/**
  * @}
  */

/**
  * @}
  */

/**********************************************************************************************************************/

 

2.2.GT911驱动程序设计

/***********************************************************************************************************************
   @file    GT911.c
   @author  king
   @date    06-Mar-2023
   @brief   THIS FILE PROVIDES ALL THE SYSTEM FUNCTIONS.
  *********************************************************************************************************************/

/* Define to prevent recursive inclusion */
#define __GT911_C__

/* Files include */
#include "GT911.h"

/**
  * @addtogroup HC32F4A0_DDL_Examples
  * @{
  */

/**
  * @addtogroup Project_Templates
  * @{
  */

/* Private typedef ****************************************************************************************************/

/* Private define *****************************************************************************************************/

/* Private macro ******************************************************************************************************/

/* Private variables **************************************************************************************************/

/* Private functions **************************************************************************************************/

/***********************************************************************************************************************
  * @brief  GT911 Init I2C
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
static void GT911_InitI2C(void)
{
    stc_gpio_init_t stcGpioInit;

    GPIO_StructInit(&stcGpioInit);
    GPIO_Init(GT911_I2C_SCL_PORT, GT911_I2C_SCL_PIN, &stcGpioInit);
    GPIO_Init(GT911_I2C_SCL_PORT, GT911_I2C_SCL_PIN, &stcGpioInit);

    GPIO_SetFunc(GT911_I2C_SCL_PORT, GT911_I2C_SCL_PIN, GT911_I2C_SCL_FUNC);
    GPIO_SetFunc(GT911_I2C_SDA_PORT, GT911_I2C_SDA_PIN, GT911_I2C_SDA_FUNC);

    FCG_Fcg0PeriphClockCmd(GT911_I2C_FCG, ENABLE);

    BSP_I2C_Init(GT911_I2C_UNIT);
}

/***********************************************************************************************************************
  * @brief  GT911 I2C Read
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
static void GT911_I2C_Read(const uint8_t *SubAddress, uint8_t SubAddressLength, uint8_t *Buffer, uint32_t Length)
{
    BSP_I2C_Read(GT911_I2C_UNIT, GT911_I2C_ADDR, SubAddress, SubAddressLength, Buffer, Length);
}

/***********************************************************************************************************************
  * @brief  GT911 I2C Write
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
static void GT911_I2C_Write(const uint8_t *SubAddress, uint8_t SubAddressLength, const uint8_t *Buffer, uint32_t Length)
{
    BSP_I2C_Write(GT911_I2C_UNIT, GT911_I2C_ADDR, SubAddress, SubAddressLength, Buffer, Length);
}

/***********************************************************************************************************************
  * @brief  GT911 Read
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
static void GT911_REG_Read(uint16_t Address, uint8_t *Buffer, uint32_t Length)
{
    uint8_t SubAddress[2];

    SubAddress[0] = (uint8_t)((Address & 0xFF00U) >> 8);
    SubAddress[1] = (uint8_t)((Address & 0x00FFU) >> 0);

    GT911_I2C_Read(SubAddress, ARRAY_SZ(SubAddress), Buffer, Length);
}

/***********************************************************************************************************************
  * @brief  GT911 Write
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
static void GT911_REG_Write(uint16_t Address, const uint8_t *Buffer, uint32_t Length)
{
    uint8_t SubAddress[2];

    SubAddress[0] = (uint8_t)((Address & 0xFF00U) >> 8);
    SubAddress[1] = (uint8_t)((Address & 0x00FFU) >> 0);

    GT911_I2C_Write(SubAddress, ARRAY_SZ(SubAddress), Buffer, Length);
}

/***********************************************************************************************************************
  * @brief  GT911 Software Reset
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
static void GT911_SoftwareReset(void)
{
    uint8_t Command = 0x02U;

    GT911_REG_Write(GT911_COMMAND, &Command, 1UL);
}

/***********************************************************************************************************************
  * @brief  GT911 Read Product ID
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
static void GT911_ReadProductID(uint8_t *PID, uint32_t Length)
{
    GT911_REG_Read(GT911_PRODUCT_ID, PID, Length);
}

/***********************************************************************************************************************
  * @brief  GT911 Read Touch Status
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
uint8_t GT911_ReadTouchStatus(void)
{
    uint8_t Status = 0U;

    GT911_REG_Read(GT911_TOUCH_STATUS, &Status, 1UL);

    return (Status);
}

/***********************************************************************************************************************
  * @brief  GT911 Clear Touch Status
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void GT911_ClearTouchStatus(void)
{
    uint8_t Status = 0U;

    GT911_REG_Write(GT911_TOUCH_STATUS, &Status, 1UL);
}

/***********************************************************************************************************************
  * @brief  GT911 Get X & Y
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void GT911_GetXY(uint16_t PointX, uint16_t *X, uint16_t *Y)
{
    uint8_t Buffer[4];

    GT911_REG_Read(PointX, Buffer, 4UL);

    (*X) = (uint16_t)Buffer[0] | ((uint16_t)Buffer[1] << 8);
    (*Y) = (uint16_t)Buffer[2] | ((uint16_t)Buffer[3] << 8);
}

/***********************************************************************************************************************
  * @brief  GT911 Init
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void GT911_Init(void)
{
    char PID[4];

    GT911_InitI2C();

    GT911_ReadProductID((uint8_t *)PID, 4UL);

    printf("\r\n%s : %s", __FUNCTION__, PID);

    if (0 == strncmp(PID, "911", 3))
    {
        GT911_SoftwareReset();
    }
    else
    {
        DDL_Printf("Unsupoort Touch Driver IC");
    }
}

/**
  * @}
  */

/**
  * @}
  */

/**********************************************************************************************************************/

 

2.3.LCD程序设计

/***********************************************************************************************************************
   @file    LCD.c
   @author  king
   @date    06-Mar-2023
   @brief   THIS FILE PROVIDES ALL THE SYSTEM FUNCTIONS.
  *********************************************************************************************************************/

/* Define to prevent recursive inclusion */
#define __LCD_C__

/* Files include */
#include "LCD.h"
#include "FONT.h"

/**
  * @addtogroup HC32F4A0_DDL_Examples
  * @{
  */

/**
  * @addtogroup Project_Templates
  * @{
  */

/* Private typedef ****************************************************************************************************/

/* Private define *****************************************************************************************************/

/* Private macro ******************************************************************************************************/
#define LCD_RST_PORT        (TCA9539_IO_PORT0)
#define LCD_RST_PIN         (TCA9539_IO_PIN7)

#define LCD_BKL_PORT        (GPIO_PORT_I)
#define LCD_BKL_PIN         (GPIO_PIN_00)

#define LCD_HEIGHT          NT35510_GetPixelHeight()
#define LCD_WIDTH           NT35510_GetPixelWidth()

/* Private variables **************************************************************************************************/
static stc_lcd_controller_t *stcLcdController = ((stc_lcd_controller_t *)NT35510_BASE);

/* Private functions **************************************************************************************************/

/***********************************************************************************************************************
  * @brief  LCD Init
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void LCD_Init(void)
{
    TCA9539_Init();

    /* Init LCD backlight IO */
    GPIO_OutputCmd(LCD_BKL_PORT, LCD_BKL_PIN, ENABLE);

    /* Init LCD control IO before direction setting */
    TCA9539_WritePin(LCD_RST_PORT, LCD_RST_PIN, TCA9539_PIN_SET);

    /* LCD panel control IO set to output */
    TCA9539_ConfigPin(LCD_RST_PORT, LCD_RST_PIN, TCA9539_DIR_OUT);

    TCA9539_WritePin(LCD_RST_PORT, LCD_RST_PIN, TCA9539_PIN_RESET);
    DDL_DelayMS(50);

    TCA9539_WritePin(LCD_RST_PORT, LCD_RST_PIN, TCA9539_PIN_SET);
    DDL_DelayMS(50);

    NT35510_Init(stcLcdController);

    NT35510_Clear(stcLcdController, LCD_BACKCOLOR);

    /* LCD BLK ON */
    GPIO_SetPins(LCD_BKL_PORT, LCD_BKL_PIN);

    LCD_ShowLOG(100, 100, "EV_F4A0_LQ176_Rev 1.0(HC32F4A0SITB)");
    LCD_ShowLOG(100, 120, __DATE__);
    LCD_ShowLOG(100, 140, __TIME__);
    LCD_ShowLOG(100, 160, "小华开发板");
}

/***********************************************************************************************************************
  * @brief  LCD Draw Point
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void LCD_DrawPoint(uint16_t X, uint16_t Y, uint16_t Color)
{
    NT35510_DrawPixel(stcLcdController, X, Y, Color);
}

/***********************************************************************************************************************
  * @brief  LCD Draw Point
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void LCD_Clear(uint16_t Color)
{
    NT35510_Clear(stcLcdController, Color);
}

/***********************************************************************************************************************
  * @brief  LCD Show English
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void LCD_ShowEN(uint16_t X, uint16_t Y, char ch)
{
    uint8_t  Data  = 0;
    uint16_t Color = 0;

    for (uint8_t i = 0; i < 16; i++)
    {
        Data = ASCII_FONT[ch - 32][i];

        for (uint8_t j = 0; j < 8; j++)
        {
            if ((Data >> j) & 0x01)
            {
                Color = TXT_FORECOLOR;
            }
            else
            {
                Color = TXT_BACKCOLOR;
            }

            LCD_DrawPoint(X + j, Y + i, Color);
        }
    }
}

/***********************************************************************************************************************
  * @brief  LCD Get GBK Font Table
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void LCD_GetGBK(const char *str, uint8_t *Buffer)
{
    uint8_t  GBKH   = str[0];
    uint8_t  GBKL   = str[1];
    uint32_t Offset = 0, i = 0;

    if (GBKL < 0x7F)
    {
        Offset = ((GBKH - 0x81) * 190 + GBKL - 0x40);
    }
    else
    {
        Offset = ((GBKH - 0x81) * 190 + GBKL - 0x41);
    }

    for (i = 0; i < 32; i++)
    {
        Buffer[i] = GBK_FONT[Offset * 32 + i];
    }
}

/***********************************************************************************************************************
  * @brief  LCD Show Chinese
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void LCD_ShowCN(uint16_t StartX, uint16_t StartY, const char *str)
{
    uint8_t Buffer[32];
    uint8_t Array[16][16];
    uint8_t Point[16][16];

    memset(Buffer, 0xFF, sizeof(Buffer));

    LCD_GetGBK(str, Buffer);

    for (uint8_t i = 0; i < 8; i++)
    {
        for (uint8_t j = 0; j < 4; j++)
        {
            uint8_t Data = Buffer[i * 4 + j];

            for (uint8_t k = 0; k < 4; k++)
            {
                if (Data & (0x08 >> (k - 0)))
                {
                    Array[i * 2 + 0][j * 4 + k - 0] = 1;
                }
                else
                {
                    Array[i * 2 + 0][j * 4 + k - 0] = 0;
                }
            }

            for (uint8_t k = 4; k < 8; k++)
            {
                if (Data & (0x80 >> (k - 4)))
                {
                    Array[i * 2 + 1][j * 4 + k - 4] = 1;
                }
                else
                {
                    Array[i * 2 + 1][j * 4 + k - 4] = 0;
                }
            }
        }
    }

    for (uint8_t i = 0; i < 16; i++)
    {
        for (uint8_t j = 0; j < 16; j++)
        {
            Point[i][j] = Array[j][15 - i];
        }
    }

    for (uint8_t i = 0; i < 16; i++)
    {
        for (uint8_t j = 0; j < 16; j++)
        {
            if (Point[15 - i][j])
            {
                LCD_DrawPoint(StartX + i, StartY + j, TXT_FORECOLOR);
            }
            else
            {
                LCD_DrawPoint(StartX + i, StartY + j, TXT_BACKCOLOR);
            }
        }
    }
}

/***********************************************************************************************************************
  * @brief  LCD Show Log
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void LCD_ShowLOG(uint16_t StartX, uint16_t StartY, const char *str)
{
    while (*str != '\0')
    {
        if (*str < 0x7F)
        {
            if (StartX > (LCD_WIDTH - 8))
            {
                StartX  = 0;
                StartY += 16;
            }

            if (StartY > (LCD_HEIGHT - 16))
            {
                StartX = 0;
                StartY = 0;

                LCD_Clear(LCD_BACKCOLOR);
            }

            LCD_ShowEN(StartX, StartY, *str);

            StartX += 0x08;
            str    += 0x01;
        }
        else
        {
            if (StartX > (LCD_WIDTH - 16))
            {
                StartX  = 0;
                StartY += 16;
            }

            if (StartY > (LCD_HEIGHT - 16))
            {
                StartX = 0;
                StartY = 0;

                LCD_Clear(LCD_BACKCOLOR);
            }

            LCD_ShowCN(StartX, StartY, str);

            StartX += 0x10;
            str    += 0x02;
        }
    }
}

/**
  * @}
  */

/**
  * @}
  */

/**********************************************************************************************************************/

 

2.4.TOUCH程序设计

/***********************************************************************************************************************
   @file    TOUCH.c
   @author  king
   @date    06-Mar-2023
   @brief   THIS FILE PROVIDES ALL THE SYSTEM FUNCTIONS.
  *********************************************************************************************************************/

/* Define to prevent recursive inclusion */
#define __TOUCH_C__

/* Files include */
#include "TOUCH.h"

/**
  * @addtogroup HC32F4A0_DDL_Examples
  * @{
  */

/**
  * @addtogroup Project_Templates
  * @{
  */

/* Private typedef ****************************************************************************************************/

/* Private define *****************************************************************************************************/
#define TOUCH_CTRST_PORT        (TCA9539_IO_PORT0)
#define TOUCH_CTRST_PIN         (TCA9539_IO_PIN6)

#define TOUCH_CTINT_PORT        (TCA9539_IO_PORT0)
#define TOUCH_CTINT_PIN         (TCA9539_IO_PIN4)

/* Private macro ******************************************************************************************************/

/* Private variables **************************************************************************************************/
MultiTimer TOUCH_MultiTimer;

/* Private functions **************************************************************************************************/

/***********************************************************************************************************************
  * @brief  Return true is the touchpad is pressed
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
static uint8_t TOUCH_IsPressed(void)
{
    uint8_t Status, Pressed = 0;

    Status = GT911_ReadTouchStatus();

    if ((Status & 0x80U) != 0U)
    {
        GT911_ClearTouchStatus();

        if ((0U < (Status & 0x0FU)) && ((Status & 0x0FU) < 6U))
        {
            Pressed = 1;
        }
    }

    return (Pressed);
}

/***********************************************************************************************************************
  * @brief  TOUCH MultiTimer Callback Function
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void TOUCH_MultiTimerCallback(MultiTimer *timer, void *userData)
{
    uint16_t X = 0, Y = 0;

    if (1 == TOUCH_IsPressed())
    {
        GT911_GetXY(GT911_POINT1, &X, &Y);

        printf("\r\nTouch : (%d, %d)", X, Y);
    }

    MultiTimerStart(&TOUCH_MultiTimer, 10, TOUCH_MultiTimerCallback, "TOUCH");
}

/***********************************************************************************************************************
  * @brief  TOUCH Init
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void TOUCH_Init(void)
{
    TCA9539_Init();

    TCA9539_WritePin(TOUCH_CTRST_PORT, TOUCH_CTRST_PIN, TCA9539_PIN_RESET);
    TCA9539_WritePin(TOUCH_CTINT_PORT, TOUCH_CTINT_PIN, TCA9539_PIN_RESET);

    TCA9539_ConfigPin(TOUCH_CTRST_PORT, TOUCH_CTRST_PIN, TCA9539_DIR_OUT);
    TCA9539_ConfigPin(TOUCH_CTINT_PORT, TOUCH_CTINT_PIN, TCA9539_DIR_OUT);
    DDL_DelayMS(100);

    TCA9539_WritePin(TOUCH_CTINT_PORT, TOUCH_CTINT_PIN, TCA9539_PIN_SET);
    DDL_DelayMS(100);

    TCA9539_WritePin(TOUCH_CTRST_PORT, TOUCH_CTRST_PIN, TCA9539_PIN_SET);
    DDL_DelayMS(100);

    TCA9539_WritePin(TOUCH_CTINT_PORT, TOUCH_CTINT_PIN, TCA9539_PIN_RESET);
    DDL_DelayMS(100);

    TCA9539_ConfigPin(TOUCH_CTRST_PORT, TOUCH_CTRST_PIN, TCA9539_DIR_IN);
    TCA9539_ConfigPin(TOUCH_CTINT_PORT, TOUCH_CTINT_PIN, TCA9539_DIR_IN);

    GT911_Init();

    MultiTimerStart(&TOUCH_MultiTimer, 10, TOUCH_MultiTimerCallback, "TOUCH");
}

/**
  * @}
  */

/**
  * @}
  */

/**********************************************************************************************************************/

 

2.5.ADC驱动程序设计

/***********************************************************************************************************************
   @file    ADC.c
   @author  king
   @date    06-Mar-2023
   @brief   THIS FILE PROVIDES ALL THE SYSTEM FUNCTIONS.
  *********************************************************************************************************************/

/* Define to prevent recursive inclusion */
#define __ADC_C__

/* Files include */
#include "ADC.h"

/**
  * @addtogroup HC32F4A0_DDL_Examples
  * @{
  */

/**
  * @addtogroup Project_Templates
  * @{
  */

/* Private typedef ****************************************************************************************************/

/* Private define *****************************************************************************************************/

/* Private macro ******************************************************************************************************/

/* Private variables **************************************************************************************************/
MultiTimer ADC_MultiTimer;

/* Private functions **************************************************************************************************/

/***********************************************************************************************************************
  * @brief  ADC MultiTimer Callback Function
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void ADC_MultiTimerCallback(MultiTimer *timer, void *userData)
{
    uint16_t Value = 0;

    ADC_Start(CM_ADC1);

    while (RESET == ADC_GetStatus(CM_ADC1, ADC_FLAG_EOCA))
    {
    }

    ADC_ClearStatus(CM_ADC1, ADC_FLAG_EOCA);

    Value = ADC_GetValue(CM_ADC1, ADC_CH3);

#if 0
    static uint16_t StartY = 0;

    char Buffer[50];
    memset(Buffer, 0, sizeof(Buffer));

    sprintf(Buffer, "ADC:%d, %0.2fV", Value, (float)(Value) * 3.3F / 4096.0F);

    LCD_ShowLOG(100, 200, Buffer);
    LCD_DrawPoint(Value / 10, StartY++, LCD_COLOR_GREEN);

    if(StartY >= 800)
    {
        StartY = 0;

        LCD_Clear(LCD_BACKCOLOR);
    }

    MultiTimerStart(&ADC_MultiTimer, 5, ADC_MultiTimerCallback, "ADC");
#else
    printf("\r\nADC:%d, %0.2fV", Value, (float)(Value) * 3.3F / 4096.0F);    

    MultiTimerStart(&ADC_MultiTimer, 250, ADC_MultiTimerCallback, "ADC");
#endif
}

/***********************************************************************************************************************
  * @brief  ADC Init
  * @note
  * @param  none
  * @retval none
  *********************************************************************************************************************/
void ADC_Configure(void)
{
    stc_adc_init_t  stcAdcInit;
    stc_gpio_init_t stcGpioInit;

    /* 1. Enable ADC peripheral clock. */
    FCG_Fcg3PeriphClockCmd(FCG3_PERIPH_ADC1, ENABLE);

    /* 2. Modify the default value depends on the application. Not needed here. */
    ADC_StructInit(&stcAdcInit);

    /* 3. Initializes ADC. */
    ADC_Init(CM_ADC1, &stcAdcInit);

    /* 4. ADC channel configuration. */
    /* 4.1 Set the ADC pin to analog input mode. */
    GPIO_StructInit(&stcGpioInit);
    stcGpioInit.u16PinAttr = PIN_ATTR_ANALOG;
    GPIO_Init(GPIO_PORT_A, GPIO_PIN_03, &stcGpioInit);

    /* 4.2 Enable ADC channels. Call ADC_ChCmd() again to enable more channels if needed. */
    ADC_ChCmd(CM_ADC1, ADC_SEQ_A, ADC_CH3, ENABLE);

    /* 5. Set sampling time if needed. */
    ADC_SetSampleTime(CM_ADC1, ADC_CH3, 0x40U);

    /* 6. Conversion data average calculation function, if needed.
          Call ADC_ConvDataAverageChCmd() again to enable more average channels if needed. */
    ADC_ConvDataAverageConfig(CM_ADC1, ADC_AVG_CNT8);
    ADC_ConvDataAverageChCmd(CM_ADC1, ADC_CH3, ENABLE);

    MultiTimerStart(&ADC_MultiTimer, 250, ADC_MultiTimerCallback, "ADC");
}

/**
  * @}
  */

/**
  * @}
  */

/**********************************************************************************************************************/

 

三、运行效果

3.1.终端

 

3.2.视频

5

 

四、软件工程源代码

Project.zip (3.92 MB, 下载次数: 28)

 

续:

我们需要把一个BIN文件烧录到MCU FLASH中,我们可以使用一些比如J-LINK等专业烧录工具,但MCU FLASH中除了要保存我们GBK_FONT字库外,它还是存储我们用户程序的地方,所以最好的方式是将我们的用户程序在编译生成时,将HEX再转换成BIN文件,然后将用户程序BIN文件和GBK_FONT这个BIN文件进行合并,合并的时候规划好GBK_FONT的起始地址,这样我们在程序调用字体库数据时会用到这个偏移的地址信息;但除了这种实现方式我们,还有其它的实现方式吗?

 

有!!!

 

我们可以把GBK_FONT.BIN文件转换成C数组,然后将这个C数组添加到用户程序中就可以了;BIN转换成C数组的方式有很多,也有专门的转换小工具来实现;我们这边是通过KEIL自带的转换功能实现的哦,主要是用到了FCARM功能,具体操作如下所示:

 

STEP1.将GBK_FONT.BIN文件添加到项目工程中……

 

添加的文件类型为Image File

 

添加后的结构如下图所示:

 

STEP2.这个时候如果直接编译工程,是通过不了的,因为KEIL它不能识别或者说将一个ImageFile类型的文件作为程序源文件进行编译,所以会如下的操作提示:

 

STEP3.我们点击工具栏上的魔术棒按钮,在Utilities项目卡中,Configure Image File Processing(FCARM)配置如下所示:

 

STEP4:配置好,我们再次编译整个工程,这个时候BGK_FONT.BIN文件就会转换为BGK_FONT.H文件了,并添加到你指定GROUP组中……

 

STEP5:这个时候BGK_FONT.H文件中就有了我们需要的字体库C语言数组形式了,我们适当的编译这个文件(我们只需要用这个文件里的数组数据),然后将GBK_FONT.BIN从项目工程中移除,将配置恢复到默认就可以啦……

最新回复

芯片是庆祝节日发的?   详情 回复 发表于 2023-3-10 09:46
点赞 关注(1)
个人签名We are a team and we work as a team !
 
 

回复
举报

6471

帖子

10

TA的资源

版主

沙发
 

最多支持多少TOUCH按键?       

个人签名

在爱好的道路上不断前进,在生活的迷雾中播撒光引

 
 
 

回复

6972

帖子

11

TA的资源

版主

板凳
 

大佬,可以出一期把字库放到flash的教程吗?

点评

放到哪个FLASH?是MCU内部的FLASH,还是外部的QSPI FLASH?如果是MCU内部的FLASH,文末的那个续就是实现方法呀……  详情 回复 发表于 2023-3-9 15:57
 
 
 

回复

206

帖子

0

TA的资源

纯净的硅(初级)

4
 
lugl4313820 发表于 2023-3-9 08:59 大佬,可以出一期把字库放到flash的教程吗?

放到哪个FLASH?是MCU内部的FLASH,还是外部的QSPI FLASH?如果是MCU内部的FLASH,文末的那个续就是实现方法呀……

点评

外部flash吧,内部是不是有点浪费呀。我是想能学习一个中文字库的例子。  详情 回复 发表于 2023-3-9 16:34
个人签名We are a team and we work as a team !
 
 
 

回复

6972

帖子

11

TA的资源

版主

5
 
xld0932 发表于 2023-3-9 15:57 放到哪个FLASH?是MCU内部的FLASH,还是外部的QSPI FLASH?如果是MCU内部的FLASH,文末的那个续就是实现 ...

外部flash吧,内部是不是有点浪费呀。我是想能学习一个中文字库的例子。

点评

后面做到QSPI的时候,我更新一下……  详情 回复 发表于 2023-3-9 19:28
 
 
 

回复

206

帖子

0

TA的资源

纯净的硅(初级)

6
 
lugl4313820 发表于 2023-3-9 16:34 外部flash吧,内部是不是有点浪费呀。我是想能学习一个中文字库的例子。

后面做到QSPI的时候,我更新一下……

个人签名We are a team and we work as a team !
 
 
 

回复

18

帖子

0

TA的资源

一粒金砂(中级)

7
 

芯片是庆祝节日发的?

点评

什么芯片?没发芯片呀……板子是参加测评活动的……  详情 回复 发表于 2023-3-10 12:35
 
 
 

回复

206

帖子

0

TA的资源

纯净的硅(初级)

8
 

什么芯片?没发芯片呀……板子是参加测评活动的……

个人签名We are a team and we work as a team !
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/8 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表