标题:
ST7796初始化代码
[打印本页]
作者:
OD_ping
时间:
2019-3-20 03:16
标题:
ST7796初始化代码
最近在做LCD controller, 贴一个ST7796初始化代码供大家参考。
单片机源程序如下:
/*
* 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;
}
/*-----------------------------------------------------------*/
复制代码
作者:
jnhcxu
时间:
2019-10-18 09:47
谢谢老板,压缩包里的内容比帖子上多了什么吗?
作者:
1516581329
时间:
2019-10-30 16:37
楼主有发一个ST7796.h,谢谢
作者:
oakcode
时间:
2019-11-14 13:29
没有参考价值
作者:
shu_007
时间:
2020-12-24 21:08
这是LCD初始化,我不相信!!!
作者:
rayin
时间:
2021-3-12 16:00
液晶显示屏的驱动IC的初始化代码要说明是和那家的LCD什么尺寸搭配才有意义。比如和深超2.4 ,翰彩的什么尺寸的搭配。不然无显或是显示效果不好,或者不正常,就发出来的代码没有什么意义。
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1