Specifications
107
4.3.1 Display Functions
In order to communicate over the I2C bus with the display, an accurate “bit-
banged” I2C interface was created using a set of functions to encapsulate certain
functionality of the bus, including operations to drive pins high and low, convert
strings to binary output, transmit, receive acknowledgement, and configure the
LCD to default functionality. Table 4.3.1-1 describes the purpose of each function
in the display software.
Function
Description
void I2C_Init()
Prepares the I2C bus data structure, Initializes
GPIO pins to SDA and SCL
void I2C_Start()
Creates a START condition on the I2C data
line by creating a falling edge on SDA, while
holding SCL high
void I2C_Stop()
Creates a STOP condition on the I2C data line
by creating a rising edge on SDA, while
holding SCL high
void I2C_WriteByte(byte)
Writes a single byte to the I2C bus by masking
each bit to determine the value (1 or 0),
creating the correct high/low transition on SDA,
then driving the clock line high and low to clock
the data in
void I2C_GetAck()
Sets the SDA line to input and drives the SCL
line high. Checks if the device pulls the SDA
line low to acknowledge receipt of a packet.
void SetPinValue(Port, Pin, bool)
Sets an individual pin to either high or low
bool GetPinValue(Port, Pin)
Gets the value of an individual pin
void SetPortValue(Port, byte)
Sets lines of a port to either output or input,
depending on the input 8-bit value
char GetPortValue(Port)
Returns the current 8-bit register controlling the
port direction
void Init_LCD()
Initializes the LCD for output using values
suggested by the manufacturer
void cgram()
Part of the LCD initialization, this routine writes
values to the internal LCD character RAM, as
suggested by the manufacturer
void show(char *text)
Loops through an input string array, outputting
each character to the LCD display
void nextline()
Moves cursor to the next line of the LCD
void clearscreen()
Clears the LCD screen
Table 4.3.1-1 – Display Communications Functional Breakdown










