📄 lcdiof.c
字号:
// ------------------ The Basic I/O functions for LCD --------------------------
/* FileName: lcdiof.c
Version : 0.1
Last Updated: 2007-1-6
Description:
This library contains the necessary functions for input and output data
to the controller IC of LCM.
*/
#ifdef __PORT_CONFIG__
// Port configuration of MCU
void PortConfig(void)
{
#if defined(MCU_6800)
LCD_PS = 1;
LCD_C86 = 1;
#elif defined(MCU_8080)
LCD_PS = 1;
LCD_C86 = 0;
#elif defined(LCD_4SPI)
P3 = 0xFF;
LCD_DataPort = 0xFF;
LCD_PS = 0;
LCD_C86 = 0;
#elif defined(LCD_3SPI)
P3 = 0xFF;
LCD_DataPort = 0xFF;
LCD_PS = 0;
LCD_C86 = 1;
#elif defined(LCD_I2C)
P3 = 0xFF;
LCD_DataPort = 0xFF;
LCD_PS = 1;
LCD_C86 = 1;
#endif
}
#endif
// Reset LCD
void LCD_Reset(void)
{
LCD_RST = 0;
DelayMs(30);
LCD_RST = 1;
DelayMs(500);
}
// Function for sending a byte to LCD
void SendByte(bit DatCmd, uint8 dByte)
{
#ifdef MCU_6800
LCD_DataPort = 0x00; // Set the port as Output
LCD_CS = 0;
LCD_A0 = DatCmd;
LCD_RW = 0;
LCD_DataPort = dByte;
LCD_E = 1;
LCD_E = 0;
LCD_RW = 1;
LCD_CS = 1;
LCD_DataPort = 0xFF;
#elif defined(MCU_8080)
//LCD_DataPort = 0x00; // Set the port as Output
LCD_DataPort = dByte;
LCD_CS = 0;
LCD_A0 = DatCmd;
LCD_RD = 1;
//LCD_DataPort = dByte;
LCD_WR = 0;
LCD_WR = 1;
LCD_A0 = 1;
LCD_CS = 1;
//LCD_DataPort = 0xFF;
#elif defined(LCD_4SPI)
SPI_A0 = DatCmd;
SPI_CS = 0;
spi_sendbyte(dByte);
SPI_CS = 1;
#elif defined(LCD_3SPI)
SPI_CS = 0;
spi_sendbit(DatCmd); // Sendout LCD_A0
spi_sendbyte(dByte);
SPI_CS = 1;
#elif defined(LCD_I2C)
I2C_Start();
I2C_SendByte(LCD_I2C_ADDR);
if (DatCmd == iDat)
{
I2C_SendByte(0x40);
}
else
{
I2C_SendByte(0x00);
}
I2C_SendByte(dByte);
I2C_Stop();
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -