示例#1
0
/*
 * Write data to Data pins. Written data might be 4-bit or 8-bit
 * according to data8Bit variable
 */
void lcdWriteData(uint8_t ui8Data) {
	if (data8Bit) {
		GPIOPinWrite(LCD_GPIO_DATA_BASE, DATA_PINS, ui8Data);
		lcdEnable();
	}
	else {
		GPIOPinWrite(LCD_GPIO_DATA_BASE, DATA_PINS, ui8Data & 0xF0); //send the rest 4-bits
		lcdEnable();
		GPIOPinWrite(LCD_GPIO_DATA_BASE, DATA_PINS, (ui8Data & 0x0F) << 4); //send first 4-bits
		lcdEnable();
	}
}
示例#2
0
文件: lcd.c 项目: iburol/Arduino-C
/*** Function    : lcdReset
**   Parameters  : None
**   Return      : None
**   Description : It will Reset the LCD for 4-bit Mode
**/
void lcdReset(void)
{
	LCD_D7_PORT &= ~LCD_D7_BIT;
	LCD_D6_PORT &= ~LCD_D6_BIT;
	LCD_D5_PORT |= LCD_D5_BIT;
	LCD_D4_PORT |= LCD_D4_BIT;

	lcdEnable();
	__delay_ms__(10);
	lcdEnable();
	__delay_ms__(10);
	lcdEnable();
	__delay_ms__(10);

	LCD_D7_PORT &= ~LCD_D7_BIT;
	LCD_D6_PORT &= ~LCD_D6_BIT;
	LCD_D5_PORT |= LCD_D5_BIT;
	LCD_D4_PORT &= ~LCD_D4_BIT;

	lcdEnable();
	__delay_ms__(10);
}
示例#3
0
文件: lcd.c 项目: iburol/Arduino-C
/*** Function    : lcdwrite4Bits
**   Parameters  : None
**   Return      : unsigned char
**   Description : It will write 4-bit to LCD PORT
**/
void lcdwrite4Bits(unsigned char val)
{
	if(val & 0x08)
		LCD_D7_PORT |=  LCD_D7_BIT;
	else
		LCD_D7_PORT &= ~LCD_D7_BIT;
	if(val & 0x04)
		LCD_D6_PORT |=  LCD_D6_BIT;
	else
		LCD_D6_PORT &= ~LCD_D6_BIT;
	if(val & 0x02)
		LCD_D5_PORT |=  LCD_D5_BIT;
	else
		LCD_D5_PORT &= ~LCD_D5_BIT;
	if(val & 0x01)
		LCD_D4_PORT |=  LCD_D4_BIT;
	else
		LCD_D4_PORT &= ~LCD_D4_BIT;
	lcdEnable();
}
示例#4
0
文件: lcd.c 项目: iburol/Arduino-C
/*** Function    : lcdwrite8Bits
**   Parameters  : None
**   Return      : unsigned char
**   Description : It will write 8-bit to LCD PORT
**/
void lcdwrite8Bits(unsigned char lByte)
{
	if(lByte & 0x80)
		LCD_D7_PORT |=  LCD_D7_BIT;
	else
		LCD_D7_PORT &= ~LCD_D7_BIT;
	if(lByte & 0x40)
		LCD_D6_PORT |=  LCD_D6_BIT;
	else
		LCD_D6_PORT &= ~LCD_D6_BIT;
	if(lByte & 0x20)
		LCD_D5_PORT |=  LCD_D5_BIT;
	else
		LCD_D5_PORT &= ~LCD_D5_BIT;
	if(lByte & 0x10)
		LCD_D4_PORT |=  LCD_D4_BIT;
	else
		LCD_D4_PORT &= ~LCD_D4_BIT;
#if LCD_MODE == 1
	if(val & 0x08)
			LCD_D3_PORT |=  LCD_D3_BIT;
		else
			LCD_D3_PORT &= ~LCD_D3_BIT;
		if(val & 0x04)
			LCD_D2_PORT |=  LCD_D2_BIT;
		else
			LCD_D2_PORT &= ~LCD_D2_BIT;
		if(val & 0x02)
			LCD_D1_PORT |=  LCD_D1_BIT;
		else
			LCD_D1_PORT &= ~LCD_D1_BIT;
		if(val & 0x01)
			LCD_D0_PORT |=  LCD_D0_BIT;
		else
			LCD_D0_PORT &= ~LCD_D0_BIT;
#endif
lcdEnable();
}