image

這次我們來玩玩  4行的 2004a I2C char lcd 模組. 這個模組是之前買來接 arduino的,屬於I2C 介面,slave address是0x3F.電壓2.5v-6v.

 

[硬體接法]

將2004A的 SDA、SCL、VCC_3.3V、GND拉到 evk上的 exp cn VEXT_3v3, I2C3_SDA、I2C3_SCL、GND.

image

image

 

[軟體driver]

請到以下網站下載 hd44780-i2c linux drvier

https://github.com/gorskima/hd44780-i2c

 

網站說明得很詳細,記得詳細閱讀

解壓縮可以看到以下檔案

image

 

[開發]

修改三個檔案

1.
\vendor\nxp-opensource\kernel_imx\arch\arm64\configs\android_defconfig

--加上--

CONFIG_HD44780_I2C=y
CONFIG_AUXDISPLAY=y

----

2.
\vendor\nxp-opensource\kernel_imx\drivers\auxdisplay\Makefile

--加上--

obj-$(CONFIG_HD44780_I2C)        += hd44780-i2c.o hd44780-dev.o

---

3.
\vendor\nxp-opensource\kernel_imx\drivers\auxdisplay\Kconfig

--加上--

config HD44780_I2C
    tristate "HD44780 I2C Character LCD support"
    depends on GPIOLIB || COMPILE_TEST
    select CHARLCD
    ---help---
      Enable support for Character LCDs using a HD44780 I2C controller.
      The LCD is accessible through the /dev/lcdx char device (10, 156).
      This code can either be compiled as a module, or linked into the
      kernel and started at boot.
      If you don't understand what all this is about, say N.

----

將上面解壓縮的三個檔案複製到

\vendor\nxp-opensource\kernel_imx\drivers\auxdisplay\hd44780-i2c.c
\vendor\nxp-opensource\kernel_imx\drivers\auxdisplay\hd44780-dev.c
\vendor\nxp-opensource\kernel_imx\drivers\auxdisplay\hd44780.h


[build]
make -j8 bootimage
make -j8 dtboimage

[check point]
產出
\out\target\product\evk_8mm\obj\KERNEL_OBJ\drivers\auxdisplay\hd44780-dev.o
\out\target\product\evk_8mm\obj\KERNEL_OBJ\drivers\auxdisplay\hd44780-i2c.o

 

[燒錄]

.adb reboot bootloader
.fastboot flash dtbo_a dtbo-imx8mm-epson.img
.fastboot flash boot_a boot.img
.fastboot reboot

 

[verify]
adb root
adb shell
echo hd44780 0x3f > /sys/class/i2c-adapter/i2c-2/new_device
echo Hello, world! > /dev/lcd0

就可以在 2004a char lcd上秀出內容了
image

image

經過以上流程,就可以在char lcd上秀出文字.

arrow
arrow
    創作者介紹
    創作者 CuteParrot 的頭像
    CuteParrot

    馴龍窩

    CuteParrot 發表在 痞客邦 留言(0) 人氣()