void LcdInit(void) { //输出引脚初始化 Init_LCDGpio(); SpiInit(); //SPI初始化 LCD_SCLK_LOW(); LCD_SCLK_HIGH(); LCD_SDIN_LOW(); LCD_SDIN_HIGH(); LCD_DC_LOW(); LCD_DC_HIGH(); LCD_SCE_LOW(); LCD_SCE_HIGH(); LcdReset(); /*液晶复位*/ //LcdFunctionSet(ACTIVE, H_ADDR, EXT_INS); /*扩展指令集*/ LcdBiasSystem(0x03); /*推荐混合率 1:48*/ LcdSetVop(0x32); /*V(6.06) = 3.06 + 0.06*Vop*/ LcdTempCtrl(0x00); /*温度系数 0~3*/ LcdFunctionSet(ACTIVE, H_ADDR, BAS_INS); /*基本指令集*/ LcdDispalyControl((u8)NORMAL_MODE); /*普通模式显示*/ // LcdWriteDC(LCDCMD , 0x21 ); /*扩展指令*/ LcdWriteDC(LCDCMD , 0xc8 ); /*设置偏压*/ LcdWriteDC(LCDCMD , 0x20 ); /*标准指令*/ LcdWriteDC(LCDCMD , 0x0c );/*标准显示模式*/ LcdClsScr(); }
// 发送数据或指令 // DC : 数据或指令 // info : 发送的信息 void LcdWriteDC(u8 DC, uint8_t info) { LcdEnable(TRUE); if( DC == DATA) LCD_DC_HIGH(); else LCD_DC_LOW(); Delaynus(5); SpiSendByte(info); LcdEnable(FALSE); }
/** * @brief Writes command to select the LCD register. * @param LCDReg: Address of the selected register. * @retval None */ void LCD_IO_WriteReg(uint8_t LCDReg) { /* Reset LCD control line CS */ LCD_CS_LOW(); /* Set LCD data/command line DC to Low */ LCD_DC_LOW(); /* Send Command */ SPIx_Write(LCDReg); /* Deselect : Chip Select high */ LCD_CS_HIGH(); }
void LCDSend(unsigned char data, unsigned char cd) { LCD_CS_LOW(); if (cd == SEND_CHR) { LCD_DC_HIGH(); } else { LCD_DC_LOW(); } // send data over SPI SEND_BYTE_SPI(); LCD_CS_HIGH(); }
/** * @brief Writes command to select the LCD register. * @param LCDReg: Address of the selected register. * @retval None */ void LCD_IO_WriteReg(uint16_t LCDReg) { /* Reset LCD control line CS */ LCD_CS_LOW(); /* Set LCD data/command line DC to Low */ LCD_DC_LOW(); //LCD_RW_LOW(); /* Send Command */ //SPIx_Write(LCDReg); LCD_PORT_Value(LCDReg >> 8); Toggle_LCD_RW(); //LCD_RW_HIGH(); //LCD_RW_LOW(); /* Send Command */ //SPIx_Write(LCDReg); LCD_PORT_Value(LCDReg); Toggle_LCD_RW(); //LCD_RW_HIGH(); /* Deselect : Chip Select high */ LCD_CS_HIGH(); }