標(biāo)題:
ST7796初始化代碼
[打印本頁(yè)]
作者:
OD_ping
時(shí)間:
2019-3-20 03:16
標(biāo)題:
ST7796初始化代碼
最近在做LCD controller, 貼一個(gè)ST7796初始化代碼供大家參考。
單片機(jī)源程序如下:
/*
* ST7796.c
*
* Created on: Nov 29, 2018
* Author: 20150287
*/
#include "ST7796.h"
#include "fsl_debug_console.h"
status_t writeTable(st7796_cmd_t *cmdTable, uint32_t numCmds)
{
while(numCmds--)
{
writeCommand(cmdTable++);
}
return kStatus_Success;
}
/*-----------------------------------------------------------*/
status_t writeData(uint8_t data, uint8_t type, uint32_t delay)
{
uint8_t tx[BUFFER_SIZE] = {type, data};
/* after tx wait delay ms */
APP_SPI_Write(tx, delay);
return kStatus_Success;
}
/*-----------------------------------------------------------*/
status_t writeCommand(st7796_cmd_t *cmd)
{
uint8_t numArgs = cmd->numArgs;
uint8_t *args = cmd->args;
writeData(cmd->value, ST7796_DC_CMD, 0U);
while(numArgs--)
{
writeData(*args++, ST7796_DC_DATA, (numArgs > 0) ? 0U : cmd->delay);
}
return kStatus_Success;
}
/*-----------------------------------------------------------*/
void APP_ST7796_Init(void)
{
/* cmds follows the format:
*
* command
* post command delay
* number of arguments/parameters
* array of arguments
*
* */
st7796_cmd_t cmds[] = {
{
ST7796_SWRESET,
150U,
0U,
{},
},
{
ST7796_SLPOUT,
150U,
0U,
{},
},
{
ST7796_IFPXFMT,
12U,
1U,
{(ST7796_IFPXFMT_RGB_16 | ST7796_IFPXFMT_CTRL_16)},
},
{
ST7796_IFMODE,
12U,
1U,
{0x00},
},
{
ST7796_DFC,
12U,
1U,
{0xA2},
},
{
ST7796_NORON,
12U,
0U,
{},
},
{
ST7796_INVON,
12U,
0U,
{},
},
{
ST7796_INVOFF,
12U,
0U,
{},
},
{
ST7796_IDMOFF,
12U,
0U,
{},
},
{
ST7796_WRCTRLD,
12U,
1U,
{0x00 | ST7796_WRCTRLD_BCTRL_ON | ST7796_WRCTRLD_DD_ON | ST7796_WRCTRLD_BL_ON},
},
{
ST7796_DISPON,
500U,
0U,
{},
},
{
ST7796_WRDISBV,
12U,
1U,
{0x7F},
},
};
PRINTF("ST7796: Starting setup.\r\n");
writeTable(cmds, 12U);
PRINTF("ST7796: Setup complete.\r\n");
return;
}
/*-----------------------------------------------------------*/
復(fù)制代碼
作者:
jnhcxu
時(shí)間:
2019-10-18 09:47
謝謝老板,壓縮包里的內(nèi)容比帖子上多了什么嗎?
作者:
1516581329
時(shí)間:
2019-10-30 16:37
樓主有發(fā)一個(gè)ST7796.h,謝謝
作者:
oakcode
時(shí)間:
2019-11-14 13:29
沒(méi)有參考價(jià)值
作者:
shu_007
時(shí)間:
2020-12-24 21:08
這是LCD初始化,我不相信。!
作者:
rayin
時(shí)間:
2021-3-12 16:00
液晶顯示屏的驅(qū)動(dòng)IC的初始化代碼要說(shuō)明是和那家的LCD什么尺寸搭配才有意義。比如和深超2.4 ,翰彩的什么尺寸的搭配。不然無(wú)顯或是顯示效果不好,或者不正常,就發(fā)出來(lái)的代碼沒(méi)有什么意義。
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1