ããã«ã¡ã¯ NAS WesternDigital MyBook Liveã®ããŒããšããã«æ¥ç¶ãããLCDã€ã³ãžã±ãŒã¿ãŒãåŒãç¶ã䜿çšããŸãã ãã®ãããåã®ããŒãã§ã¯ãããŒãäžã«I2Cãã¹ã«æ¥ç¶ããå ŽæãèŠã€ããããŒããšã¯ã¹ãã³ããŒãšã€ã³ãžã±ãŒã¿ãŒãæ¥ç¶ããŠããã¹ãŠãæ©èœããããšã確èªããŸããã ä»æ¥ãç§ãã¡ã¯ã€ã³ãžã±ãŒã¿ã«ã·ã¹ãã ã®ã¹ããŒã¿ã¹ã衚瀺ããŸãã
å§ãŸãã¯ããã«ãããŸããïŒ
AppliedMicro APM82181äžã®WD MyBook Liveãããã£ã©ã¯ã¿ãŒLCDãããŒãã«æ¥ç¶æåã®éšåã®å
容ïŒ
1.ã³ã³ãœãŒã«ã®æ¥ç¶
2.ãã£ã¹ã¯ãªãã§ããŠã³ããŒã
3. LEDEã§ã®ã³ã³ãã€ã«
4.ããŒã管çïŒLuCIããã³ã³ã³ãœãŒã«çµç±ïŒ
5. I2Cãã¹ãžã®æ¥ç¶
6. PCF8574ããŒããšã¯ã¹ãã³ããŒã®æ¥ç¶
ä»æ¥ç§éã¯èæ
®ããŸãïŒ
7. i2csetã«ããHD44780ã®åæå
8. I2Cãã¹ã«ããŒã¿ãæžã蟌ãããã®ãã£ã©ã¯ã¿ãŒããã€ã¹
9.ã«ãŒãã«ãžã®HD44780ãã©ã€ããŒã®è¿œå
10.å¿
èŠãªVT100ã³ãã³ãã®åŠçãHD44780ãã©ã€ããŒã«è¿œå ãã
11.ããã€ãã®VT100ã³ãã³ããå«ããã£ã¹ãã¬ã€ãLCD4Linuxã«è¿œå ãã
12. HD44780ãã©ã€ããŒãžã®æåãžã§ãã¬ãŒã¿ãŒããã°ã©ãã³ã°ã³ãã³ãã®è¿œå
13. I2Cãã¹äžã®ããŒã¿äŒéã®æé©å
以åãšåæ§ã«ãè¿œå ãã³ã¡ã³ããæè¿ããŸãã
ãã®ããããã®æç¹ã§ãããŒããšã¯ã¹ãã³ããŒãã·ã¹ãã ã«æ¥ç¶ããããããå¶åŸ¡ã§ããŸãã HD44780ã³ã³ãããŒã©ãŒã®ã¯ããŒã³ã®ã·ã³ãã«LCDã€ã³ãžã±ãŒã¿ãŒããšãã¹ãã³ããŒã«æ¥ç¶ãããŠããŸãã çè«çã«ã¯ãåºåçšã«ãã¹ãŠã®ããŒãããªã³ã«ãããã®ç®çãç¥ãããšã§å¶åŸ¡ã§ããŸãã ããã¯ã©ã€ããç¹æ»
ãããŠã3çªç®ã®ããŒããã€ã³ã¯ããããšã¯ãã§ã«å¯èœã§ããã
7. i2csetã«ããHD44780ã®åæå
HD44780ã³ã³ãããŒã©ãŒãšããŒããšã¯ã¹ãã³ããŒéã®æ¥ç¶ã¯ã次ã®ããã«æ§æãããŠããŸãã
RS-P0
R / W-P1
E-P2
BL-P3
D4-P4
D5-P5
D6-P6
D7-P7
ããã¯ãèŠã€ãã£ããªãã·ã§ã³ã®1ã€ã§ãã ã³ã³ãããŒã©ã¯å€æããã4ãããã¢ãŒãã§åäœãããã€ãã¯éšåçã«éä¿¡ãããŸãã
ãšã¯ã¹ãã³ããŒã®ãã¹ãŠã®ããŒããèªç±ã«äœ¿çšã§ããããããããããšã«ããŒã¿ãçºè¡ããŠããã£ã¹ãã¬ã€ãå¶åŸ¡ã§ããŸãã ããã¯ããŸã䟿å©ã§ã¯ãªããšããããšã«åæããŠããã ãããšæããŸãã
I2Cãã¹çµç±ã§çŽæ¥å¶åŸ¡ããŠã¿ãŸãããã ãã®å¯èœæ§ããã¹ãããç°¡åãªãªãã·ã§ã³ã¯ãI2C-toolsãŠãŒãã£ãªãã£ã¹ã€ãŒãã䜿çšããããšã§ãã LEDEã§ã¯ãUtilitesã»ã¯ã·ã§ã³ã«ãããŸãã ãããã«ã¯ãi2cdetectãi2cdumpãi2cgetãi2csetãå«ãŸããŠããŸãã ç§ãã¡ã¯åŸè
ã«èå³ããããå°ãã¯èšºæã«èå³ããããŸãã
i2cdetectã䜿çšããŠããã¹ã«æ¥ç¶ãããŠããããã€ã¹ãæ€åºãããããã®ã¢ãã¬ã¹ã決å®ã§ããŸãã
ãã®äŸã§ã¯ãã¢ãã¬ã¹0x27ã®ã¿ãããžãŒã§ããroot@lede: i2cdetect 0 WARNING! This program can confuse your I2C bus, cause data loss and worse! I will probe file /dev/i2c-0. I will probe address range 0x03-0x77. Continue? [Y/n] y 0 1 2 3 4 5 6 7 8 9 abcdef 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- 27 -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
i2csetãŠãŒãã£ãªãã£ã¯ãI2Cãã¹äžã®ç¹å®ã®ã¢ãã¬ã¹ãæã€ããã€ã¹ã«ããŒã¿ãåºåããããã«äœ¿çšãããŸãã
LCDã®åæåã·ãŒã±ã³ã¹ããããã°ãç°¡åã«å®è¡ããŠç»é¢ã«æåã衚瀺ã§ããŸãã
è»èŒªãåçºæããªãããã«ãããããããŠã³ããŒãããããšããå§ãããŸãïŒ
PCF8574ãšãã¹ãã³ã㌠ãi2c lcd testilikãã®
I2C hd44780ã¢ãžã¥ãŒã« ã ããã«
çŽæ¥ãªã³ã¯ããããŸãã ã·ã§ã«ã¢ãŒã«ã€ãå
ã«ã¯ãi2csetã³ãã³ããä»ããŠã€ã³ãžã±ãŒã¿ãŒãšé£åããç»é¢ã«æåã亀äºã«è¡šç€ºããã¹ã¯ãªããããããŸãã 䜿çšåã®å¯äžã®ããšã¯ããã¡ã€ã«ã®å
é ã®è¡ãã³ã¡ã³ãã¢ãŠããŸãã¯åé€ããããšã§ãã
insmod i2c-dev insmod i2c-gpio-custom bus0=0,$sda_gpio,$scl_gpio
空ãI / OããŒãã«I2CãœãããŠã§ã¢ããŒããäœæããŸãããæ¢ã«ããŒããŠã§ã¢ããŒãããããŸãã ããã«ã4 * 40ãã£ã¡ã³ã·ã§ã³ã®ã€ã³ãžã±ãŒã¿ãŒçšã«èšèšãããŠããŸãããããã©ãŒãã³ã¹ããã§ãã¯ããi2csetãŠãŒãã£ãªãã£ã®äœ¿çšãç解ããã®ã«åé¡ã¯ãããŸããã
çµæïŒ
ãã®å®è£
ã«é¢ããç°¡åãªèª¬æã ããã·ãŒãžã£write_CMDããã³print_LCDã¯ãããããã€ã³ãžã±ãŒã¿ãŒã«ã³ãã³ããŸãã¯ããŒã¿ã衚瀺ããŸãã ããã¯RSä¿¡å·ã«äŸåããŸãããã®å ŽåããŒããããã«äŸåããŸãã
init_LCDããã·ãŒãžã£ã¯ãããŒã¿ã·ãŒãã«åŸã£ãŠã€ã³ãžã±ãŒã¿ãåæåããããã®ã³ãã³ããé 次çºè¡ããŸããããŒã¿ã·ãŒãã¯ã€ã³ã¿ãŒãããäžã§åºãé
åžãããŠããŸãã ããšãã°ã
ãã¡ã ã 次ã«ãããŸããŸãªæåãç»é¢ã«é 次衚瀺ãããŸãã
8. I2Cãã¹ã«ããŒã¿ãæžã蟌ãããã®ãã£ã©ã¯ã¿ãŒããã€ã¹
ãã¹ãŠã¯åé¡ãããŸãããããŠãŒãã£ãªãã£ã®äœ¿çšãé¿ããæåããã€ã¹ã䜿çšããŠãæå®ãããã¢ãã¬ã¹ã§I2Cãã¹ã«çŽæ¥å
¥ããã€ãã衚瀺ããããšæããŸãã
æ®å¿µãªãããLEDEã«ã¯I2Cãã¹çšã®ãã®ãããªãã©ã€ããŒãèŠã€ãããŸããã§ããã ãã®ãããå®éšçãªç®æšã«ãããæ¢åã®ç®æšã®1ã€ãããçŽãããšã決å®ãããŸããã ããã«äœ¿çšãããå Žåã¯ãããçŽãå¿
èŠã¯ãããŸããããå°ãªããšããã®ããŒã¹ã«åºã¥ããŠæ°ãããã®ãäœæããããšã¯æããã§ãã
I2Cãã¹çšã®EEPROMãã©ã€ããŒã¯ãå®éšã«é©ããŠããããšãå€æããŸããã kmod-eeprom-at24ãã©ã€ããŒã¯LEDEã³ã¢ã«æ¥ç¶ãããŠããŸãããã·ã¹ãã ãæŽæ°ããåŸãããã€ã¹ãè¿œå ããããšããŸããïŒ
root@lede: echo 24c00 0x27 > /sys/bus/i2c/devices/i2c-0/new_device root@lede: echo 24c00 0x27 > [ 33.335472] at24 0-0027: 16 byte 24c00 EEPROM, writable, 1 bytes/write [ 33.342102] i2c i2c-0: new_device: Instantiated device 24c00 at 0x27
æ¥ç¶ã«æåããŸããã ããã€ã¹ã«äœããåºåããå ŽåïŒ
root@lede: echo "1111" > /sys/bus/i2c/devices/i2c-0/0-0027/eeprom
次ã«ããã¹äžã«æ¬¡ã®ãã€ãã·ãŒã±ã³ã¹ã衚瀺ãããŸãã
0x4e-0x00-0x31 0x4e-0x01-0x31 0x4e-0x02-0x31 0x4e-0x03-0x31 0x4e-0x04-0x0a
åããªãã«ã®æåã®ãã€ãã¯ãããã€ã¹ã¢ãã¬ã¹ã«2ïŒ0x27 x 2ïŒãæãããã®ã§ãã 2çªç®ã¯EEPROMã®ã»ã«ã¢ãã¬ã¹ã3çªç®ã¯ããŒã¿ã§ãã ãã©ã€ããŒã¯ãã»ã«ã¢ãã¬ã¹ã®çºè¡ãé€ããLCDã«ããŒã¿ãéä¿¡ããã®ã«éåžžã«é©ããŠããŸãã
ãããåé€ããã«ã¯ããã©ã€ããŒãã¡ã€ã«build_dir / target-powerpc_464fp_musl-1.1.15 / linux-apm821xx_sata / linux-4.4.21 / drivers / misc / eeprom / at24.cãä¿®æ£ããŸãã at24_eeprom_writeããã·ãŒãžã£ïŒ335-337ïŒã®æ°è¡ãã³ã¡ã³ãã¢ãŠãããŸãã
ã³ã³ãã€ã«æŽæ°ãããã€ã¹ã®è¿œå ãåºåã®ç¢ºèª
root@lede: echo 24c00 0x27 > /sys/bus/i2c/devices/i2c-0/new_device [ 2708.782356] at24 0-0027: 16 byte 24c00 EEPROM, writable, 1 bytes/write [ 2708.788891] i2c i2c-0: new_device: Instantiated device 24c00 at 0x27 root@lede: echo "1111" > /sys/bus/i2c/devices/i2c-0/0-0027/eeprom
ãã¹ãŠãæ£ãããã»ã«ã¢ãã¬ã¹ãªãã®åºåãå¿
èŠãªãã®ã®ã¿ïŒ
ãããããi2csetãŠãŒãã£ãªãã£åŒã³åºããåé€ããŠããã¹ãããã°ã©ã ãããçŽãããšãã§ããŸãã åæã«ãçŸåšãããã°ã©ã ã¯ç»é¢ãžãªã¡ããªïŒ2x16æåïŒå°çšã«èšèšãããŠããŸãã build_dirãã£ã¬ã¯ããªã®ãœãŒã¹ãå€æŽãããšãè¿ãå°æ¥ãã¢ã»ã³ããªäžã«å
ã®ããã±ãŒãžãããã¡ã€ã«ã埩å
ããããšäºæ³ãããã¯ãã§ãã æ°žç¶çãªä¿®æ£ãäœæããã«ã¯ããã«ã段éã§ããããé©çšããæ©èœã䜿çšããŸãã
9.ã«ãŒãã«ãžã®HD44780ãã©ã€ããŒã®è¿œå
ãã®LCDæ¥ç¶ãªãã·ã§ã³ã®æäœæ§ã®åé¡ãç 究ããåŸãã€ã³ãžã±ãŒã¿ã«ããã€ãã®æ©èœãå²ãåœãŠãããšãè©Šã¿ãããšã決å®ãããŸããã ããšãã°ããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã®ç¶æ
ã®äžéšã衚瀺ããŸãã
ãã®ãããªããã±ãŒãžã¯æ¢ã«ååšããLEDEã«ãå«ãŸããŠããŸãã ããã¯
LCD4Linuxã§ãã ããã«ãããOSã®ã³ã³ããŒãã³ãã«é¢ããå¿
èŠãªæ
å ±ãååŸããé©åãªå Žæã®ã€ã³ãžã±ãŒã¿ãŒã«é
眮ã§ããŸãã åœç¶ããªã¢ã«ã¿ã€ã æŽæ°ã
ãã ããI2Cãã¹ã®ã€ã³ãžã±ãŒã¿ãŒã§äœ¿çšãããšãããã€ãã®åé¡ãçºçããŸããã
LCD4Linuxããããããã£ã¹ãã¬ã€ãHD44780-I2Cã«æ¥ç¶ãã
ãã¡ã€ã«\ etc \ lcd4linux.conf Display HD44780-I2C { Driver 'HD44780' Model 'generic' Bus 'i2c' Port '/dev/i2c-0' Device '0x27' Bits '4' Size '16x2' asc255bug 0 Icons 1 Wire { RW 'DB1' RS 'DB0' ENABLE 'DB2' GPO 'GND' } }
ãšã©ãŒã®åå ïŒ root@lede: /usr/bin/lcd4linux -v -F LCD4Linux 0.11.0-SVN-1193 starting HD44780: $Rev: 1202 $ HD44780: using model 'generic' HD44780: using I2C bus HD44780: using 1 Controller(s) HD44780: using 4 bit mode udelay: using gettimeofday() delay loop Segmentation fault
åã®ç« ã§äœæãããEEPROMãã©ã€ããŒã«åºã¥ãããã£ã©ã¯ã¿ãŒããã€ã¹ã®äœ¿çšãå«ããããã±ãŒãžããã®ã»ãŒãã¹ãŠã®å¯èœãªãã£ã¹ãã¬ã€ããã¹ããããŸããã ããŸããããŸããã§ããã
ãããããä»ã®æ¹æ³ã§è¡ãããšã«ããŸããã ãã®ç¹å®ã®ã€ã³ãžã±ãŒã¿ãŒã®ãã©ã€ããŒãã·ã¹ãã ã«è¿œå ããŸããã·ã¹ãã ã¯ã·ã³ãã«ãšè¡šç€ºçšã®å¶åŸ¡ã³ãã³ããåãå
¥ãããã®ãã©ã€ããŒã䜿çšããŠLCD4Linuxã«æ°ãããã£ã¹ãã¬ã€ãè¿œå ããŸããããã«ã¯ããã¥ã¢ã«ããããŸãã
ãã®ãããããããI2Cäžã®HD44780ã®æºåãã§ãããã©ã€ããŒãååŸããŸãïŒ
PCF8574 I / Oãšã¯ã¹ãã³ããŒãä»ããŠI2Cãã¹ã«æ¥ç¶ãããHitachi HD44780 LCDã®Linuxãã©ã€ã㌠ã ãã®ãã©ã€ããŒã¯Raspberry Piã§ãã¹ããããVT100端æ«å¶åŸ¡ã³ãã³ããããã€ãç解ããããŸããŸãªã€ã³ãžã±ãŒã¿ãŒãžãªã¡ããªçšã«æ§æãããã«ãŒãœã«ã衚瀺ãæ¶å»ãç¹æ»
ãããããšãã§ããŸãã ãããLEDEã«çµ±åããå°ãæ¹è¯ããããšã¯æ®ã£ãŠããŸãã
ããŠã³ããŒãããããã±ãŒãž/ hd44780 / srcãã©ã«ããŒã«è§£åããŸãã
æš¹æš ls -l -rw-r--r-- 1 root root 18092 Feb 21 2016 LICENSE -rw-r--r-- 1 root root 60 Nov 9 06:17 Makefile -rw-r--r-- 1 root root 1945 Feb 21 2016 README.md -rw-r--r-- 1 root root 10316 Nov 16 04:33 hd44780-dev.c -rw-r--r-- 1 root root 7756 Feb 21 2016 hd44780-i2c.c -rw-r--r-- 1 root root 1122 Nov 16 03:28 hd44780.h -rw-r--r-- 1 root root 235 Feb 21 2016 make.sh
Makefileã«ã¯ããã ããæ®ããŸãïŒ
obj-m := hd44780.o hd44780-y := hd44780-i2c.o hd44780-dev.o
ãããŠãä»ã®LEDEããã±ãŒãžã®ãã¡ã€ã«ãšåæ§ã«ãããã±ãŒãž/ hd44780ã«äžèšã®ãã©ã«ããŒã®ã¿ã®æ°ããMakefileãäœæããŸãã
ããã±ãŒãž/ hd44780 / Makefile include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=hd44780 PKG_RELEASE:=1 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) include $(INCLUDE_DIR)/package.mk define KernelPackage/hd44780 SUBMENU:=Other modules TITLE:=I2C HD44780 driver FILES:=$(PKG_BUILD_DIR)/hd44780.ko AUTOLOAD:=$(call AutoLoad,70,hd44780) KCONFIG:= endef define Package/hd44780/description Big comments.... ... endef MAKE_OPTS:= \ ARCH="$(LINUX_KARCH)" \ CROSS_COMPILE="$(TARGET_CROSS)" \ SUBDIRS="$(PKG_BUILD_DIR)" \ EXTRA_CFLAGS="$(EXTRA_CFLAGS)" define Build/Prepare mkdir -p $(PKG_BUILD_DIR) $(CP) ./src/* $(PKG_BUILD_DIR)/ endef define Build/Compile $(MAKE) -C "$(LINUX_DIR)" \ $(MAKE_OPTS) \ modules endef $(eval $(call KernelPackage,hd44780))
èªåããŒãïŒAUTOLOADïŒ= $ïŒAutoLoadã70ãhd44780ãåŒã³åºãïŒïŒãå«ãè¡ã¯ãåŸã§ãã©ã€ããŒã®ãã¹ãæã«è¿œå ã§ããŸãã ããã§ãLEDEã³ã³ãã£ã®ã¥ã¬ãŒã¿ãŒãåŒã³åºããšã
make menuconfig
ãã©ã€ããŒã¯ã«ãŒãã«ã¢ãžã¥ãŒã«ïŒkmod-hd44780ïŒã«è¡šç€ºãããæ§æã«è¿œå ã§ããŸãã
ã³ã³ãã€ã«ãæŽæ°ãåèµ·ååŸãã¢ãžã¥ãŒã«ã®èªåããŒããæå¹ã«ãªã£ãŠããªãå Žåã¯ãããŒããè©Šè¡ããçµæã確èªããŸãã
root@lede: insmod hd44780 root@lede: lsmod |grep 44780 hd44780 5450 0
ããã€ã¹ãè¿œå ããããšããŠããŸãïŒ
root@lede: echo hd44780 0x27 > /sys/bus/i2c/devices/i2c-0/new_device [ 9463.913178] i2c i2c-0: new_device: Instantiated device hd44780 at 0x27
åæåäžã«ããã©ã€ããŒã§èšå®ãããã€ã³ãžã±ãŒã¿ãŒã«ãäœæãããããã€ã¹ã®ã¢ãã¬ã¹ã衚瀺ãããŸãïŒ "/ dev / lcd0"ãæåŸã«ç¹æ»
ã«ãŒãœã«ããããŸãã
ã€ã³ãžã±ãŒã¿ãŒã«è¡šç€ºãããæåããã®ããã€ã¹ã«éä¿¡ã§ããŸãã
root@lede: echo -n 123 > /dev/lcd0
sysfsïŒ/ sys / class / hd44780 / lcd0ïŒãä»ããŠåäœã¢ãŒããå¶åŸ¡ããããšãã§ããŸãã ãã®ãã¹ã«æ²¿ã£ããã¡ã€ã«åã¯ãbacklightãcursor_displayãgeometryãcursor_blinkã§ãã ãããã䜿çšããŠãç»é¢ã®ãžãªã¡ããªãã«ã¹ã¿ãã€ãºããã«ãŒãœã«ã¢ãŒããšããã¯ã©ã€ããå¶åŸ¡ã§ããŸãã ããšãã°ãç¹æ»
ã«ãŒãœã«ããªãã«ããã«ã¯ã次ã®ã³ãã³ããå
¥åããŸãã
root@lede: echo -n 0 > /sys/class/hd44780/lcd0/cursor_blink
ããã«ã2ã€ã®VT100端æ«ã³ãã³ãããµããŒããããŠããŸããããã«ãããç»é¢ãã¯ãªã¢ãããã«ãŒãœã«ãéå§äœçœ®ã«èšå®ãããŸãã 次ã®ããã«éä¿¡ã§ããŸãã
root@lede: echo -n -e '\x1b'[2J > /dev/lcd0 root@lede: echo -n -e '\x1b'[H > /dev/lcd0
OSãããŒããããšãã«ãå¿
èŠãªã¢ãŒããèšå®ããããšãã§ããŸãã ãããè¡ãã«ã¯ã以äžã®å
容ãå«ãã¿ãŒã²ãã/ linux / apm821xx / base-files / etc / board.d / 03_lcdãã¡ã€ã«ãLEDEã«è¿œå ããŸãã
ããã§ãã·ã¹ãã ãèµ·åãããã³ã«ããŒããæšæ¶ããŸãã
10.å¿
èŠãªVT100ã³ãã³ãã®åŠçãHD44780ãã©ã€ããŒã«è¿œå ãã
ãããã£ãŠããã©ã€ããŒã¯åäœããŸãããLCD4Linuxã§äœ¿çšããã«ã¯ãç»é¢äžã®ä»»æã®äœçœ®ã«æåãé
眮ã§ããå¿
èŠããããŸãã ã¿ãŒããã«ã³ãã³ãã®ãªã¹ãã«åŸã£ãŠãå¿
èŠãªã³ãã³ããéžæããŸãã
Esc [Line; ColumnH-ã«ãŒãœã«ãç»é¢ã®äœçœ®vãhã«ç§»åãã¡ã€ã«ããã±ãŒãž/ hd44780 / src / hd44780-dev.cãèŠã€ããŠãæ°ããã³ãã³ãã®æ€åºãšå®è¡ãè¿œå ããŸãã escã·ãŒã±ã³ã¹ãåŠçããæé ãæ¹è¯ããå¿
èŠããããŸãã
ãªãªãžãã«ïŒ static void hd44780_handle_esc_seq_char(struct hd44780 *lcd, char ch) { int prev_row, prev_col; lcd->esc_seq_buf.buf[lcd->esc_seq_buf.length++] = ch; if (!strcmp(lcd->esc_seq_buf.buf, "[2J")) { prev_row = lcd->pos.row; prev_col = lcd->pos.col; hd44780_clear_display(lcd); hd44780_write_instruction(lcd, HD44780_DDRAM_ADDR | (lcd->geometry->start_addrs[prev_row] + prev_col)); hd44780_leave_esc_seq(lcd); } else if (!strcmp(lcd->esc_seq_buf.buf, "[H")) { hd44780_write_instruction(lcd, HD44780_RETURN_HOME); lcd->pos.row = 0; lcd->pos.col = 0; hd44780_leave_esc_seq(lcd); } else if (lcd->esc_seq_buf.length == ESC_SEQ_BUF_SIZE) { hd44780_flush_esc_seq(lcd); } }
å€æŽãããããŒãžã§ã³ïŒ static void hd44780_handle_esc_seq_char(struct hd44780 *lcd, char ch) { int prev_row, prev_col; struct hd44780_geometry *geo = lcd->geometry; lcd->esc_seq_buf.buf[lcd->esc_seq_buf.length++] = ch; if (!strcmp(lcd->esc_seq_buf.buf, "[2J")) { prev_row = lcd->pos.row; prev_col = lcd->pos.col; hd44780_clear_display(lcd); hd44780_write_instruction(lcd, HD44780_DDRAM_ADDR | (lcd->geometry->start_addrs[prev_row] + prev_col)); hd44780_leave_esc_seq(lcd); } else if (!strcmp(lcd->esc_seq_buf.buf, "[H")) { hd44780_write_instruction(lcd, HD44780_RETURN_HOME); lcd->pos.row = 0; lcd->pos.col = 0; hd44780_leave_esc_seq(lcd); } else if ((lcd->esc_seq_buf.buf[0]=='[') && (lcd->esc_seq_buf.buf[4]=='H') &&
ãŸããescã·ãŒã±ã³ã¹ãèç©ããŠåæããã«ã¯ããããã¡ãŒã®é·ããå€æŽããå¿
èŠããããŸãã ãã¡ã€ã«hd44780.hã§æ¬¡ã®è¡ãèŠã€ããŸãã
#define ESC_SEQ_BUF_SIZE 4
ãããŠãå€ã4ãã6ã«ä¿®æ£ããŸããã³ã³ãã€ã«ããŠç¢ºèªã§ããŸãã LEDEã®1ã€ã®ããã±ãŒãžã®ã¿ãã³ã³ãã€ã«ã§ããŸãã
root@debian:/apm82181-lede-master
ãšã©ãŒããªãå Žåã¯ããããžã§ã¯ãå
šäœãã³ã³ãã€ã«ããæŽæ°ããŠåèµ·åããŸãã ç§ãã¡ã¯ãã§ãã¯ããŸãïŒ
root@lede:/ echo -n -e '\x1b[1;6H' > /dev/lcd0
ã«ãŒãœã«ã2è¡ç®ãš7çªç®ã®äœçœ®ã«ç§»åããŸãïŒæåããçªå·ãä»ããããŸãïŒã 11.ããã€ãã®VT100ã³ãã³ããå«ããã£ã¹ãã¬ã€ãLCD4Linuxã«è¿œå ãã
LCDãã©ã€ããŒã¯ãã®æ©èœãå®è¡ããŸãã ããã§ãLCD4Linuxããã±ãŒãžã§äœ¿çšããŠã·ã¹ãã ã®ã¹ããŒã¿ã¹ã衚瀺ã§ããããã«ãªããŸããã ãã ããã¿ãŒããã«ãããã³ã«ã䜿çšãããã©ã€ããŒã§åäœãããã£ã¹ãã¬ã€ã¯èŠã€ãããŸããã§ããã
ã ããããªãèªèº«ãæžããŠãã ããã
æ°ãããã£ã¹ãã¬ã€ãã©ã€ãã®æžãæ¹ã«ãããšã
ãœãŒã¹ãã¡ã€ã«ã¯ãbuild_dir / target-powerpc_464fp_musl-1.1.15 / lcd4linux-custom / lcd4linux-r1203ãã£ã¬ã¯ããªããŸãã¯dl / lcd4linux-r1203.tar.bz2ããã±ãŒãžããååŸã§ããŸãã
ãã¹ãŠãããã¥ã¢ã«ã®ãšããã§ãã
- drv_Sample.c drvãã¡ã€ã«ãããdrv_vt100.cã®ã³ããŒãäœæããŸã
- GPIOã䜿çšããŠãdrv_vt100.cãç·šéããã°ã©ãã£ãã¯ã¢ãŒãã«é¢é£ãããã¹ãŠãåé€ããŸã
- drv.cã«æ°ãããã©ã€ããŒãè¿œå ããŸã
- Makefile.amã«è¿œå
drivers.m4ã«è¿œå ããŸã if test "$VT100" = "yes"; then TEXT="yes" I2C="yes" DRIVERS="$DRIVERS drv_vt100.o" AC_DEFINE(WITH_VT100,1,[vt100 driver]) fi
- Makefile.amã«è¿œå
次ã«ãdrv_vt100.cãã¡ã€ã«ã«æé ãèšè¿°ããŸãã
drv_vt100_openïŒ static int drv_vt100_open(const char *section) { char *s; int f = -1; s = cfg_get(section, "Port", NULL); if (s == NULL || *s == '\0' || strlen(s) > 80) { error("%s: no '%s.Port' entry from %s", Name, section, cfg_source()); return -1; } strcpy(Port, s); f = open(Port, O_WRONLY); if (f == -1) { error("open(%s) failed: %s", Port, strerror(errno)); return -1; } close (f); return 0; }
drv_vt100_sendïŒ static void drv_vt100_send(const char *data, const unsigned int len) { unsigned int i; int f; f = open(Port, O_WRONLY); write (f, data, len); close (f); }
drv_vt100_clearïŒ static void drv_vt100_clear(void) { char cmd[4]; cmd[0] = 0x1B;
drv_vt100_writeïŒ static void drv_vt100_write(const int row, const int col, const char *data, int len) { char cmd[6]; cmd[0] = 0x1B;
drv_vt100_closeã¯ç©ºã®ãŸãŸã«ããŸãã
LEDEãããžã§ã¯ããšã¯å¥ã®ãã©ã«ããŒã«ãã¡ã€ã«ãç·šéããŠäœæããŸãã 次ã«ããããžã§ã¯ããã³ã³ãã€ã«ãããšãLCD4linuxãã¡ã€ã«ãã¢ãŒã«ã€ãããæŽæ°ããããããbuild_dir / ...ãã©ã«ããŒã§ããããå€æŽããŠãæå³ããããŸããã ããããé©çšããæ©äŒãå©çšããå¿
èŠããããŸãã LCD4Linuxã®ãããã¯ãfeeds / packages / utils / lcd4linux / patchãã©ã«ããŒã«ãããŸãã ç¬èªã®æ°ãããã£ã¹ãã¬ã€ãã©ã€ãVT100ã®è¿œå ã¯ãããã«é
眮ããå¿
èŠããããŸãã
ããããäœæããã«ã¯ã2ã€ã®ãã©ã«ããŒã䞊ã¹ãŠäœæããŸãã äžæ¹ïŒlet 1 /ïŒã«å
ã®ãã¡ã€ã«ãé
眮ããããäžæ¹ïŒlet 2 /ïŒã«åããã¡ã€ã«ãé
眮ããŸãããå€æŽããŸãã 次ã«ãdiffã³ãã³ããå®è¡ããŸãã
diff -Naur ./1 ./2 > 180-vt100.patch
ãã®çµæãããã次ã®å
容ã®180-vt100.patchãã¡ã€ã«ããããŸãã diff -Naur ./vt100/Makefile.am ./vt100-f/Makefile.am --- ./vt100/Makefile.am 2016-11-28 11:01:56.000000000 +0000 +++ ./vt100-f/Makefile.am 2016-11-14 07:33:41.000000000 +0000 @@ -125,6 +125,7 @@ drv_USBHUB.c \ drv_USBLCD.c \ drv_vnc.c \ +drv_vt100.c \ drv_WincorNixdorf.c \ drv_X11.c \ \ diff -Naur ./vt100/drivers.m4 ./vt100-f/drivers.m4 --- ./vt100/drivers.m4 2016-11-14 11:54:41.000000000 +0000 +++ ./vt100-f/drivers.m4 2016-11-14 07:37:00.000000000 +0000 @@ -39,7 +39,7 @@ [ Newhaven, Noritake, NULL, Pertelian, PHAnderson,] [ PICGraphic, picoLCD, picoLCDGraphic, PNG, PPM, RouterBoard,] [ Sample, SamsungSPF, serdisplib, ShuttleVFD, SimpleLCD, st2205, T6963,] - [ TeakLCM, TEW673GRU, Trefon, ULA200, USBHUB, USBLCD, VNC, WincorNixdorf, X11], + [ TeakLCM, TEW673GRU, Trefon, ULA200, USBHUB, USBLCD, VNC, vt100, WincorNixdorf, X11], drivers=$withval, drivers=all ) @@ -114,6 +114,7 @@ USBHUB="yes" USBLCD="yes" VNC="yes" + VT100="yes" WINCORNIXDORF="yes" X11="yes" ;; @@ -279,6 +280,9 @@ VNC) VNC=$val ;; + vt100) + VT100=$val + ;; WincorNixdorf) WINCORNIXDORF=$val ;; @@ -869,6 +873,13 @@ fi fi +if test "$VT100" = "yes"; then + TEXT="yes" + I2C="yes" + DRIVERS="$DRIVERS drv_vt100.o" + AC_DEFINE(WITH_VT100,1,[vt100 driver]) +fi + if test "$WINCORNIXDORF" = "yes"; then TEXT="yes" SERIAL="yes"
ãã¹ãŠã®ãã¡ã€ã«ã«å¯ŸããŠ1ã€ã®ããããäœæãããŸãã feeds / packages / utils / lcd4linux / patchsãã©ã«ããŒã«ãã§ã«ããããããèŠããšãå®è¡ãããŠããdiff -Naur ...ã³ãã³ãã瀺ãè¡ã¯ãããŸããã ããããåãç¶æ
ã«ããããããã©ã«ããŒã«ã³ããŒããŸãã
LEDE Conââfiguratorã«å
¥ããŸãã
LCD4Linuc-customã«ãã£ã¹ãã¬ã€ãã©ã€ããŒã®å€èŠ³ã衚瀺ãããŸãã ããããããžã§ã¯ãã«å«ããèšå®ãä¿åããã³ã³ãã€ã«ãæŽæ°ãåèµ·åããŸãã æ§æãã¡ã€ã«ã«ãã©ã€ããŒãå«ããŸãã
lcd4linux.conf Variables { tick 500 tack 100 minute 60000 } Display VT100 { Driver 'vt100' Size '16x2' Port '/dev/lcd0' } Widget Test { class 'Text' expression '1234567890123456' width 16 } Layout Test { Row01.Col1 'Test' Row02.Col1 'Test' } Display 'VT100' Layout 'Test'
ç§ãã¡ã¯ãã§ãã¯ããŸãïŒ èšå®ã§èšç»ãããŠããããã«ãã€ã³ãžã±ãŒã¿ã«æ°åã衚瀺ãããŸãã
12. HD44780ããã³VT100ãã©ã€ããŒãžã®æåãžã§ãã¬ãŒã¿ãŒããã°ã©ãã³ã°ã³ãã³ãã®è¿œå
HD44780ã³ã³ãããŒã©ãŒã«åºã¥ãã€ã³ãžã±ãŒã¿ãŒã«ã¯ãæ°åãšèšå·ãå«ãæç·ã©ãã³ã¢ã«ãã¡ããããš8ã€ã®èªç±ã«ããã°ã©ã å¯èœãªæåããããŸãïŒãã·ã¢èªã®æåããããŸããããã®å Žåã¯ãããŸããïŒã ããã°ã©ã å¯èœãªãã£ã©ã¯ã¿ãŒã®è¡šç€ºãå€æŽããããšã«ãããç°¡åãªã¢ãã¡ãŒã·ã§ã³ãååŸã§ããŸãã ãã®ãªãã·ã§ã³ã¯LCD4Linuxã®æ§æäŸã«ç€ºãããŠããŸããããã©ã€ããŒã¯ãã®æ©èœããµããŒãããŠããŸãããã䜿çšããããšã¯ã§ããŸããã
ããã«ã€ããŠè€éãªããšã¯äœããããŸãã.1ã€ã®ãã©ã€ããŒã§8ãã€ããåãå
¥ããã³ãã³ãã§æåãžã§ãã¬ãŒã¿ãŒã«éä¿¡ããå¥ã®ãã©ã€ããŒã§éä¿¡ããå¿
èŠããããŸãã
å床修æ£ãã
hd44780-dev.cã®ããã·ãŒãžã£hd44780_handle_esc_seq_char static void hd44780_handle_esc_seq_char(struct hd44780 *lcd, char ch) { int prev_row, prev_col; struct hd44780_geometry *geo = lcd->geometry; if (lcd->is_in_set_char == 0) { lcd->esc_seq_buf.buf[lcd->esc_seq_buf.length++] = ch; if (!strcmp(lcd->esc_seq_buf.buf, "[2J")) { prev_row = lcd->pos.row; prev_col = lcd->pos.col; hd44780_clear_display(lcd); hd44780_write_instruction(lcd, HD44780_DDRAM_ADDR | (lcd->geometry->start_addrs[prev_row] + prev_col)); hd44780_leave_esc_seq(lcd); } else if (!strcmp(lcd->esc_seq_buf.buf, "[H")) { hd44780_write_instruction(lcd, HD44780_RETURN_HOME); lcd->pos.row = 0; lcd->pos.col = 0; hd44780_leave_esc_seq(lcd); } else if ((lcd->esc_seq_buf.buf[0]=='[') && (lcd->esc_seq_buf.buf[4]=='H') &&
8ãã€ãã®æåãžã§ãã¬ãŒã¿ãŒãåãåããCGRAMïŒæåãžã§ãã¬ãŒã¿ãŒïŒã«æžã蟌ãã¢ãŒããè¿œå ããŸãã VT100ã§ESCæåããã°ã©ãã³ã°ã·ãŒã±ã³ã¹ãèŠã€ãããªãã£ããããäœããèãåºãå¿
èŠããããŸããã ãããEscïŒS 8ãã€ããã€ãŸãESCã³ãŒãã次ã«å·Šæ¬åŒ§ãã©ãã³æåSã8ãã€ãã®ãããªãã¯ã¹ïŒãšããŸãããã®å Žåã芪ãã¿ãããã®ãµã€ãº8 * 5ã§ã¯ãåãã€ãã®æäžäœ5ãããã®ã¿ã䜿çšãããŸãã
ããã·ãŒãžã£hd44780_writeã§ãæåãžã§ãã¬ãŒã¿ãŒã®åä¿¡ã¢ãŒãã®ãªã»ãããè¿œå ããŸãïŒè¡lcd-> is_in_set_char = 0ïŒã
hd44780_write void hd44780_write(struct hd44780 *lcd, const char *buf, size_t count) ... case '\e': lcd->is_in_esc_seq = true; lcd->is_in_set_char = 0; break; default: hd44780_write_char(lcd, ch); ...
ãããŠããã®æ§é ãã£ãŒã«ãïŒis_in_set_charïŒãããããŒãã¡ã€ã«hd44780.hã«èšè¿°ããŸãã
struct hd44780 struct hd44780 { struct cdev cdev; struct device *device; struct i2c_client *i2c_client; struct hd44780_geometry *geometry; struct { int row; int col; } pos; char buf[BUF_SIZE]; struct { char buf[ESC_SEQ_BUF_SIZE]; int length; } esc_seq_buf; bool is_in_esc_seq; int is_in_set_char; bool backlight; bool cursor_blink; bool cursor_display; bool dirty; struct mutex lock; struct list_head list; };
次ã«ããã®æ©èœãLCD4Linuxãã£ã¹ãã¬ã€ãã©ã€ããŒã«è¿œå ããŸãã drv_vt100.cãã¡ã€ã«ã®drv_vt100_defcharé¢æ°ïŒ
drv_vt100_defchar static void drv_vt100_defchar(const int ascii, const unsigned char *matrix) { char cmd[12]; int i; cmd[0] = 0x1B;
ã³ã³ãã€ã«ãæŽæ°ãåèµ·åã LCD4linuxæ§æãå床å€æŽããŸãã
lcd4linux.conf Variables { tick 500 tack 100 minute 60000 } Display VT100 { Driver 'vt100' Size '16x2' Port '/dev/lcd0' Icons 1 } Widget RAM { class 'Text' expression meminfo('MemFree')/1024 postfix ' MB RAM' width 11 precision 0 align 'R' update tick } Widget Busy { class 'Text' expression proc_stat::cpu('busy', 500) prefix 'Busy' postfix '%' width 9 precision 1 align 'R' update tick } Widget Uptime { class 'Text' expression uptime('%d days %H:%M:%S') width 20 align 'R' prefix 'Up ' update 1000 } Widget Uptime { class 'Text' expression 'Up '.uptime('%d %H:%M:%S') width 16 align 'L' update 1000 } # Icons Widget Timer { class 'Icon' speed 83 Bitmap { Row1 '.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|' Row2 '.***.|.*+*.|.*++.|.*++.|.*++.|.*++.|.*++.|.*++.|.*++.|.*++.|.*++.|.*++.|.+++.|.+*+.|.+**.|.+**.|.+**.|.+**.|.+**.|.+**.|.+**.|.+**.|.+**.|.+**.|' Row3 '*****|**+**|**++*|**+++|**++.|**++.|**+++|**+++|**+++|**+++|**+++|+++++|+++++|++*++|++**+|++***|++**.|++**.|++***|++***|++***|++***|++***|*****|' Row4 '*****|**+**|**+**|**+**|**+++|**+++|**+++|**+++|**+++|**+++|+++++|+++++|+++++|++*++|++*++|++*++|++***|++***|++***|++***|++***|++***|*****|*****|' Row5 '*****|*****|*****|*****|*****|***++|***++|**+++|*++++|+++++|+++++|+++++|+++++|+++++|+++++|+++++|+++++|+++**|+++**|++***|+****|*****|*****|*****|' Row6 '.***.|.***.|.***.|.***.|.***.|.***.|.**+.|.*++.|.+++.|.+++.|.+++.|.+++.|.+++.|.+++.|.+++.|.+++.|.+++.|.+++.|.++*.|.+**.|.***.|.***.|.***.|.***.|' Row7 '.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|' Row8 '.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|' } } Layout L16x2 { Row1 { Col1 'Uptime' col16 'Timer' } Row2 { Col1 'Busy' Col11 'RAM' } } Display 'VT100' Layout 'L16x2'
ç§ãã¡ã¯ãã§ãã¯ããŸãïŒ
root@lede: /usr/bin/lcd4linux -v -F LCD4Linux 0.11.0-SVN-1193 starting vt100: $Rev: 001 $ vt100: reserving 1 of 8 user-defined characters for icons initializing layout 'L16x2' Creating new timer group (1000 ms) widget 'Uptime': Class 'text', Parent '<root>', Layer 1, Row 0, Col 0 (to 0,16) Creating new timer group (83 ms) widget 'Timer': Class 'icon', Parent '<root>', Layer 1, Row 0, Col 15 (to 1,16) Creating new timer group (500 ms) widget 'Busy': Class 'text', Parent '<root>', Layer 1, Row 1, Col 0 (to 1,9) widget 'RAM': Class 'text', Parent '<root>', Layer 1, Row 1, Col 10 (to 1,21)
ç»é¢ã«ã¯ãæåŸã®ããŒãããã®ããŒãã®åäœæéãã·ã¹ãã ã®ããŒãã空ãã¡ã¢ãªãå
å¡«ããã³ã¯ãªãŒãã³ã°ãã£ã¹ã¯ã®åœ¢ã®ã¢ãã¡ãŒã·ã§ã³ã·ã³ãã«ã衚瀺ãããŸããããã180-vt100.patchã«LCD4Linuxæ§æä¿®æ£ãè¿œå ãããšãããŒãæã«åãçš®é¡ã®ã€ã³ãžã±ãŒã¿ãŒã衚瀺ãããŸãã180-vt100.patch --- a/lcd4linux.conf.sample 2016-11-15 09:47:46.000000000 +0000 +++ af/lcd4linux.conf.sample 2016-11-18 03:18:22.000000000 +0000 @@ -567,7 +567,14 @@ HttpPort '5800' } - +Display VT100 { + Driver 'vt100' + Size '16x2' + Port '/dev/lcd0' + Icons 1 +} + + Display FutabaVFD { Driver 'FutabaVFD' Port '/dev/parport0' @@ -674,7 +681,7 @@ Widget RAM { class 'Text' - expression meminfo('MemTotal')/1024 + expression meminfo('MemFree')/1024 postfix ' MB RAM' width 11 precision 0 @@ -828,6 +835,14 @@ update 1000 } +Widget Uptime { + class 'Text' + expression 'Up '.uptime('%d %H:%M:%S') + width 16 + align 'L' + update 1000 +} + Widget mpris_TrackPosition_bar { class 'Bar' expression mpris_dbus::method_PositionGet('org.kde.amarok') @@ -1015,7 +1030,7 @@ Widget Timer { class 'Icon' - speed 50 + speed 83 Bitmap { Row1 '.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|.....|' Row2 '.***.|.*+*.|.*++.|.*++.|.*++.|.*++.|.*++.|.*++.|.*++.|.*++.|.*++.|.*++.|.+++.|.+*+.|.+**.|.+**.|.+**.|.+**.|.+**.|.+**.|.+**.|.+**.|.+**.|.+**.|' @@ -1225,6 +1240,17 @@ } } +Layout L16x2-2 { + Row1 { + Col1 'Uptime' + col16 'Timer' + } + Row2 { + Col1 'Busy' + Col11 'RAM' + } +} + Layout L20x2 { Row1 { Col1 'CPUinfo' @@ -1323,7 +1349,7 @@ -Display 'ACool' +#Display 'ACool' #Display 'SerDispLib' #Display 'LCD-Linux' #Display 'LCD2041' @@ -1354,7 +1380,7 @@ #Display 'IRLCD' #Display 'USBLCD' #Display 'BWCT' -#Display 'Image' +Display 'Image' #Display 'TeakLCD' #Display 'Trefon' #Display 'LCD2USB' @@ -1363,15 +1389,17 @@ #Display 'ctinclud' #Display 'picoLCD' #Display 'VNC' +Display 'VT100' #Display 'FutabaVFD' #Display 'GLCD2USB' -#Layout 'Default' -Layout 'TestLayer' +Layout 'Default' +#Layout 'TestLayer' #Layout 'TestImage' #Layout 'L8x2' #Layout 'L16x1' #Layout 'L16x2' +Layout 'L16x2-2' #Layout 'L20x2' #Layout 'L40x2' #Layout 'Test'
13. I2Cãã¹äžã®ããŒã¿äŒéã®æé©å
ããã§ãã¹ãŠãèšç»ã©ããã«åäœããã®ã§ãããŒã¿è»¢éé床ã«ã€ããŠå°ã説æããŸãã2ã€ã®ç¹ã«æ³šç®ããããšæããŸãããŸããI2Cãã¹äžã®ããŒã¿ã¯ãéåžžã«å°ããªãããã¯ãã€ãŸã1ãã€ãã§éä¿¡ãããŸããåãããã¯ã«ã¯ãã¹ã¬ãŒãããã€ã¹ã®ã¢ãã¬ã¹ãè¿œå ãããŸãããŠãããã®å€§ããããã€ã¹ã®ã¢ãã¬ã¹ã転éãããšããã¹ã®äœ¿çšçãå¢å ããéä¿¡æéãççž®ããããšæ³å®ããã®ã¯è«ççã§ããããã¯ãäŒéãåå¥ã®ãã€ãã§ã©ã®ããã«èŠãããã§ã1ç§ããšã«ã¢ãã¬ã¹ãã€ãïŒ0x4EïŒã§ããããšãããããŸãã éšåçãªæé©åãå®è¡ããŸãããããè¡ãã«ã¯ã1ãã€ãã®ããŒã¿ãã€ã³ãžã±ãŒã¿ãŒã«éä¿¡ãããæ¹æ³ãèŠããŠãããŠãã ãããLCDã¯4ãããã¢ãŒãã§åäœããŸããäžåºŠã«ååã®ãã€ããååŸããŸãããããã®ããŒããã€ãã¯ããæå¹ãä¿¡å·ãçºè¡ããŠç¢ºèªããå¿
èŠããããŸãããã®çµæã1ãã€ããããã»ããµãŒããI2Cãã¹ã®ã€ã³ãžã±ãŒã¿ãŒã«è»¢éããã«ã¯ã6ãã€ãããããŸãã- ãæå¹ãä¿¡å·ã®ãªãäžäœããŒããã€ã
- ãæå¹ãä¿¡å·ã䜿çšããäžäœããŒããã€ã
- ãæå¹ãä¿¡å·ã®ãªãäžäœããŒããã€ã
- ãæå¹ãä¿¡å·ã®ãªãäžäœããŒããã€ã
- ä¿¡å·ãæå¹ãã®äžäœããŒããã€ã
- ãæå¹ãä¿¡å·ã®ãªãäžäœããŒããã€ã
ãŸããããããã«ã¢ãã¬ã¹ãä»éãããããå®éã«ã¯12ãã€ãã§ããã¹é床ã¯100 KHzã§1.2ããªç§ã§ããåã6ãã€ããéä¿¡ããããšãææ¡ããŸããã1ã€ã®ãããã¯ã§ã1ã€ã®ã¢ãã¬ã¹ãã€ããã€ãŸã 12ã§ã¯ãªã7ãã€ããHD44780ãã©ã€ããŒããããŒã¿ã転éããããã®å
ã®æé ãhd44780_write_dataãhd44780_write_nibbleãpcf8574_raw_writeïŒhd44780-dev.cããïŒ static void pcf8574_raw_write(struct hd44780 *lcd, u8 data) { i2c_smbus_write_byte(lcd->i2c_client, data); } static void hd44780_write_nibble(struct hd44780 *lcd, dest_reg reg, u8 data) { data = (data << 4) & 0xF0; if (reg == DR) data |= RS; data = data | (RW & 0x00); if (lcd->backlight) data |= BL; pcf8574_raw_write(lcd, data); pcf8574_raw_write(lcd, data | E); pcf8574_raw_write(lcd, data); } static void hd44780_write_data(struct hd44780 *lcd, u8 data) { u8 h = (data >> 4) & 0x0F; u8 l = data & 0x0F; hd44780_write_nibble(lcd, DR, h); hd44780_write_nibble(lcd, DR, l); udelay(37 + 4); }
ãã©ã€ãHD44780ããã®æé ããã±ããããŒã¿è»¢éçšã«ä¿®æ£ãhd44780-dev.cã®hd44780_write_data static void hd44780_write_data(struct hd44780 *lcd, u8 data) { u8 h = (data >> 4) & 0x0F; u8 l = data & 0x0F; u8 buf[5]; h = (h << 4) & 0xF0; l = (l << 4) & 0xF0; h |= RS; l |= RS; h = h | (RW & 0x00); l = l | (RW & 0x00); if (lcd->backlight){ h |= BL; l |= BL; } buf[0] = h | E; buf[1] = h; buf[2] = l; buf[3] = l | E; buf[4] = l; i2c_smbus_write_i2c_block_data(lcd->i2c_client, h, 5, (const u8 *)(&buf[0])); udelay(37 + 4); }
ããã¯ããã€ã0x1Fã®è»¢éãã©ã®ããã«èŠãããã§ã ãŸãã0.67ããªç§ããããŸãã次ã«ãããã©ã«ãã®ãã¹é床ã¯100 KHzã§ãããããã¯æ倧å€ã§ã¯ãããŸããããã¡ãããLCDã®ããŒããšã¯ã¹ãã³ããŒã«ã¯ãã®ãããªé床ãæšå¥šãããŸãããããåæã«ãå€ãã®éçºè
ã¯400 KHzã§ã®ã¹ã ãŒãºãªæäœã«ã€ããŠè©±ããŠããŸãããã¡ãããå¿
èŠã«å¿ããŠéæšæºã¢ãŒãã䜿çšããããšã¯æ£åœåãããé害ããªãããšã培åºçã«ãã¹ãããŸããããããè¡ãæ¹æ³ãšäœãèµ·ãããããèšããŸãããæ¿æš©ã®å
å«ã«é¢ããæ
å ±ã¯ã€ã³ã¿ãŒãããã§èŠã€ããããšãã§ããªãã£ãã®ã§ãLEDEã®ãœãŒã¹ã³ãŒããä¿®æ£ããªããã°ãªããŸããã§ããããã®çµæãé«éã¢ãŒããæå¹ã«ããããã®2ã€ã®ãªãã·ã§ã³ããããŸãã400 kHzã1ã€ç®ã¯ããã©ã¡ãŒã¿ãã«ãŒãã«ã¢ãžã¥ãŒã«ã«æž¡ãããšã§ããã¢ãžã¥ãŒã«ã¯i2c-ibm_iicã§ãããã©ã¡ãŒã¿ãŒã¯iic_force_fastã§ãããã®ãããèµ·åæã«i2c-ibm_iic.iic_force_fast = 1ãã«ãŒãã«ãã©ã¡ãŒã¿ãŒã«è¿œå ããå¿
èŠããããŸããããã¯ã次ã®ããã«U-bootããŒããŒã§å®è¡ã§ããŸãã setenv addmisc 'setenv bootargs ${bootargs} i2c-ibm_iic.iic_force_fast=1'
ã·ã¹ãã ãããŒããããšã次ã®ããšãã§ããŸãã root@lede: dmesg | grep i2c [ 0.000000] Kernel command line: root=/dev_nfs rw nfsroot=192.168.1.10:/nfs/debian_ppc/rootfs ip=dhcp console=ttyS0,115200 i2c-ibm_iic.iic_force_fast=1 [ 4.770923] i2c /dev entries driver [ 4.774742] ibm-iic 4ef600700.i2c: using fast (400 kHz) mode [ 10.456041] i2c i2c-0: new_device: Instantiated device hd44780 at 0x27
2çªç®ã¯ãããã€ã¹ããªãŒã§ãã¹ã®åäœã¢ãŒããæå®ããããšã§ãïŒapollo3g.dtsiãé«éã¢ãŒããã©ã¡ãŒã¿ãŒïŒïŒ IIC0: i2c@ef600700 { compatible = "ibm,iic"; reg = <0xef600700 0x00000014>; interrupt-parent = <&UIC0>; interrupts = <0x2 0x4>; fast-mode; #address-cells = <1>; #size-cells = <0>; };
ã³ã³ãã€ã«åŸãTFTPãµãŒããŒã®ããã€ã¹ããªãŒãæŽæ°ããããšãå¿ããªãã§ãã ããããããŠçµæïŒ root@lede: dmesg | grep i2c [ 4.774585] i2c /dev entries driver [ 4.778396] ibm-iic 4ef600700.i2c: using fast (400 kHz) mode [ 10.464396] i2c i2c-0: new_device: Instantiated device hd44780 at 0x27 root@lede: ls -al /proc/device-tree/plb/opb/i2c@ef600700 -r--r--r-- 1 root root 4 Nov 18 04:13
ãŸãããã€ã転éã¬ãŒãã¯0.19ããªç§ã§ããããã¯ããªãªãžãã«ãããã»ãŒ1æ¡åªããŠããŸããçµè«ãšããŠãå®äºããäœæ¥ã®çµæãšããŠãLinuxïŒLEDEïŒãé©çšå¯èœãªãããžã§ã¯ãã®ãªãŒãã³ãœãŒã¹ã§ææžåãããŠããªãããã»ããµã§ããŒãã䜿çšããæ©äŒãåŸããšèšããŸããã¡ã€ã³ã€ãŒãµãããã€ã³ã¿ãŒãã§ã€ã¹ãSATAäžã®ã¹ãã¬ãŒãžãI2Cçµç±ã®ç®¡çãããã³ããã€ãã®ããŒãã¯ãéçºè
ã«ååãªæ©äŒãæäŸããŸãããããŠæåŸã«ãäžèšã®ãã¹ãŠãè€è£œããããã«ããã£ã¬ã¯ããªæ§é ã«åŸã£ãŠLEDEããã®ãã¡ã€ã«ïŒãã¹ãŠãèŠããŠããããã«ïŒãå©çšå¯èœã§ãã