Open AhmedHamed00 opened 1 year ago
/*
Author: Ahmed Hamed File Name: LCD.h Description: This is a source for LCD driver */
/FUNCTIONS DEFINITIONS/
/*
Definition: This function is used to initialise the LCD Author: Joe Parameters: N/A / void LCD_Init(void) { SYSCTL_RCGCGPIO_R |=0x03; //passing the clock on the used ports (A,B) /
/*
Definition: This function is used to send a command to LCD Author: Joe Parameters: Command code in Hex @Command: this is the commmand code to be sent */ void LCD_SendCommand(uint8 Command) { GPIO_PORTA_DATA_R= 0; //RS=RW=E=0 uint8 left_Half_Comm; left_Half_Comm= (Command & 0xF0); //RS,RW,E uint8 right_Half_Comm; right_Half_Comm= (Command & 0x0F); //Data pins
GPIO_PORTA_DATA_R= left_Half_Comm; //command parameter divided GPIO_PORTB_DATA_R= right_Half_Comm; //command parameter divided
GPIO_PORTA_DATA_R |=0x80; //Enable on GPIO_PORTA_DATA_R &=0x7F; //Enable off }
/*
Definition: This function is used to display character on LCD
Author: donia
Parameters:
@Data: this is the data("ASCII code") of the character to be displayed on the LCD
/
void LCD_Displaycharacter(uint8 Data)
{
GPIO_WRITE_DATA(LCD_RS_PIN_ID,0X01); / set RS to high(data not address) /
GPIO_WRITE_DATA(LCD_DATA_PORT_ID,Data); / data to be displayed /
GPIO_WRITE_DATA(LCD_E_PIN_ID,0X01); / set enable to high /
delay(1ms);
GPIO_WRITE_DATA(LCD_E_PIN_ID,0X00); / set enable to low */
}
/*
Definition: This function is used to display string ("Array of characters") on LCD Author:donia @Data: this is the data("pointer to a char") of the string to be displayed / void LCD_DisplayString(uint8 Data) { int i; /COUNTER /
while (Data[i]!= 0) /*loop to display each charcter of the string & last character of string is 0 */
{
LCD_Displaycharacter(Data[i]); /*call funcrion disp character to display each character on lcd*/
i++; /* counter for the loop*/
}
}
/*
Definition: This function is used to move the LCD cursor to the required position Author:donia Parameters: @Row: this is the row to write on @Col: this is the column to write on / void LCD_MoveCursor(uint8 Row,uint8 Col) { switch (Row) { case 0: LCD_SendCommand(0x80+col); /cursor place is in same column */ break;
case 1:
LCD_SendCommand(0x80+0x40+col); /*location of cursor is col+number of row in lcd */
break;
}
}
/*
Definition: This function is used to clear the LCD Author: merna mamdouh Parameters: NA / void LCD_ClearScreen(void) { LCD_SendCommand(LCD_CLEAR_COMMAND) / call function LCD_SendCommand to clear lcd */ }
/*
Definition: This function is used to Display intger on the LCD Author: merna mamdouh Parameters: @Data: this is the intger value to be displayed of the LCD / void LCD_DisplayInt(uint16 Data) { unit16 x = itoa(Data); / convert integer to string / LCD_DisplayString(& x); / call function LCD_DisplayString to write integer */
}
modify the LCD driver files and add the definition of the following functions: -LCD_Displaycharacter() -LCD_DisplayString() -LCD_MoveCursor()