正点原子stm32F103RCT6mini板子驱动NT35310的寄存器代码
时间: 2023-10-02 08:07:58 浏览: 93
正点原子 stm32f103 寄存器版本示例程序
以下是正点原子STM32F103RCT6mini板子驱动NT35310的寄存器代码,供您参考:
```c
#include "NT35310.h"
void NT35310_Init(void)
{
/* 内部时钟PLL设置 */
NT35310_WriteCommand(0xE0); //Positive voltage Gamma control
NT35310_WriteData(0x00);
NT35310_WriteData(0x03);
NT35310_WriteData(0x09);
NT35310_WriteCommand(0xE1); //Negative voltage Gamma control
NT35310_WriteData(0x20);
NT35310_WriteData(0x20);
NT35310_WriteData(0x20);
NT35310_WriteCommand(0xE2); //Power control
NT35310_WriteData(0x0D);
NT35310_WriteData(0x0D);
NT35310_WriteData(0x0D);
NT35310_WriteData(0x0D);
NT35310_WriteData(0x0D);
NT35310_WriteData(0x0D);
NT35310_WriteData(0x0D);
NT35310_WriteData(0x0D);
NT35310_WriteData(0x0F);
NT35310_WriteCommand(0xE3); //Driver timing control A
NT35310_WriteData(0x10);
NT35310_WriteData(0x0B);
NT35310_WriteData(0x00);
NT35310_WriteData(0x00);
NT35310_WriteData(0x00);
NT35310_WriteData(0x01);
NT35310_WriteData(0x00);
NT35310_WriteData(0x44);
NT35310_WriteCommand(0xE4); //Driver timing control B
NT35310_WriteData(0x03);
NT35310_WriteData(0x18);
NT35310_WriteData(0x18);
NT35310_WriteData(0x04);
NT35310_WriteData(0x04);
NT35310_WriteData(0x08);
NT35310_WriteData(0x00);
NT35310_WriteCommand(0xE5); //Power-on sequence control
NT35310_WriteData(0x11);
NT35310_WriteData(0x06);
NT35310_WriteData(0x12);
NT35310_WriteData(0x12);
NT35310_WriteData(0x13);
NT35310_WriteData(0x14);
NT35310_WriteData(0x15);
NT35310_WriteData(0x10);
NT35310_WriteData(0x00);
NT35310_WriteData(0x00);
NT35310_WriteData(0x00);
NT35310_WriteCommand(0xE6); //Internal timing control
NT35310_WriteData(0x01);
NT35310_WriteData(0xFF);
NT35310_WriteData(0xFF);
NT35310_WriteData(0x00);
NT35310_WriteCommand(0xE7); //???Gamma control
NT35310_WriteData(0x40);
NT35310_WriteData(0x8A);
NT35310_WriteData(0x00);
NT35310_WriteData(0x00);
NT35310_WriteData(0x14);
NT35310_WriteCommand(0xF0); //Set pixel data format
NT35310_WriteData(0x03);
NT35310_WriteCommand(0x3A); //Set pixel format
NT35310_WriteData(0x55);
NT35310_WriteCommand(0x36); //Set address mode
NT35310_WriteData(0xC0);
NT35310_WriteCommand(0x11); //Exit sleep
HAL_Delay(120);
NT35310_WriteCommand(0x29); //Display on
}
void NT35310_WriteCommand(uint8_t command)
{
NT35310_DC_RESET; //DC引脚低电平,表示写入的是命令
HAL_SPI_Transmit(&hspi1, &command, 1, 100);
}
void NT35310_WriteData(uint8_t data)
{
NT35310_DC_SET; //DC引脚高电平,表示写入的是数据
HAL_SPI_Transmit(&hspi1, &data, 1, 100);
}
```
其中,`NT35310_Init()`函数用于初始化NT35310驱动器,配置各种控制寄存器,使得液晶屏能够正常工作。`NT35310_WriteCommand()`函数用于向寄存器写入命令,`NT35310_WriteData()`函数用于向寄存器写入数据。在这些函数中,通过SPI接口与STM32F103RCT6mini板子进行通信,实现对NT35310驱动器的控制。
阅读全文