/********************************************** 函数名:Lcd全屏擦除函数 功能:将Lcd整屏擦为指定颜色 入口参数:color 指定Lcd全屏颜色 RGB(5-6-5) 返回值:无 ***********************************************/ void LCD_Clear(unsigned int Color) { unsigned long index = 0; LCD_WR_REG(0x0020,0x0000);//GRAM水平起始位置 LCD_WR_REG(0x0021,00000); LCD_WR_REG(0x0050,0x00);//水平 GRAM起始位置 LCD_WR_REG(0x0051,239);//水平GRAM终止位置 LCD_WR_REG(0x0052,0x00);//垂直GRAM起始位置 LCD_WR_REG(0x0053,319);//垂直GRAM终止位置 LCD_WR_REG16(0x0022); LCD_RD_H(); LCD_RS_H(); LCD_CS_L(); for(index = 0; index < 76800; index++) { // LCD_WR_DATA16(Color); LCD_WR_L(); DATA_LCD_PORT=Color>>8; LCD_WR_H(); LCD_WR_L(); DATA_LCD_PORT=Color&0XFF; LCD_WR_H(); } LCD_CS_H(); }
void LCD_WRITE_REG(unsigned int index) { int value_index; // uint -> int LCD_RS_L(); LCD_CS_L(); value_index=index; value_index =value_index>>8; SPI0_communication((unsigned char)(value_index)); //00000000 000000000 value_index=index; value_index &=0x00ff; SPI0_communication((unsigned char)(index)); LCD_CS_H(); LCD_RS_H(); }
/****************************************************************************** * Function Name : LCD_WRITE_COMMAND * Description : send command to LCD * Input : index, data * Output : None * Return : None ******************************************************************************/ void LCD_WRITE_COMMAND(unsigned int index,unsigned int data) { //select command register LCD_RS_L(); LCD_CS_L(); SPI0_communication((unsigned char)(index>>8)); //00000000 000000000 SPI0_communication((unsigned char)(index)); LCD_CS_H(); //send data LCD_RS_H(); LCD_CS_L(); SPI0_communication((unsigned char)(data>>8)); //00000000 000000000 SPI0_communication((unsigned char)(data)); LCD_CS_H(); }
void LCD_WR_DATA16(unsigned int data)//写积存器数据 { LCD_RD_H(); LCD_RS_H(); LCD_CS_L(); LCD_WR_L(); DATA_LCD_PORT=data>>8; delay_us(1); LCD_WR_H(); LCD_WR_L(); delay_us(1); DATA_LCD_PORT=data&0XFF; delay_us(1); LCD_WR_H(); LCD_CS_H(); }