Now, the hardware connection considers a 4-bit interface to the LCD plus the Register Select (RS) and Enable (E) pins, so, six GPIO are used. For this example, digital input/output pins are used as shown on the following figure (purple rectangle):
4. IMPLEMENTATION AND TESTING
After booting Linux, a text editor like nano should be used to generate the program. The three main configurations for GPIOS are the following (using the E pin as example):
Export the GPIO.
echo 148 > /sys/class/gpio/export
Configure the direction of the GPIO (as output).
echo out > /sys/class/gpio/gpio148/direction
Set the GPIO value to Low or High:
echo 0 > /sys/class/gpio/gpio148/value
echo 1 > /sys/class/gpio/gpio148/value
So, based on these configurations and the LCD driver already implemented on the document mentioned on Requirements section, the complete C application for Linux could be generated (find it attached).
The GCC compiler already included on the UDOObuntu image could be used to generate the executable application. The picture below shows the terminal of the UDOO NEO board including the text editor, compilation and execution commands of the application.
The used commands are the following:
$ nano lcd16x2_imx6sx.c
$ sudo gcc lcd16x2_imx6sx.c -o lcd
$ sudo ./lcd
Finally, the following image shows the LCD with the application working on the UDOO NEO board, connecting the LCD using a proto shield:
NOTE:Ensure that M4 core is not running or using the same pins, in order to avoid unexpected behavior on GPIOs.