
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.
Prepares the I2C bus data structure, Initializes
GPIO pins to SDA and SCL
Creates a START condition on the I2C data
line by creating a falling edge on SDA, while
holding SCL high
Creates a STOP condition on the I2C data line
by creating a rising edge on SDA, while
holding SCL high
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
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
Returns the current 8-bit register controlling the
port direction
Initializes the LCD for output using values
suggested by the manufacturer
Part of the LCD initialization, this routine writes
values to the internal LCD character RAM, as
suggested by the manufacturer
Loops through an input string array, outputting
each character to the LCD display
Moves cursor to the next line of the LCD
Table 4.3.1-1 – Display Communications Functional Breakdown
Komentáře k této Příručce