Created
October 8, 2014 08:53
-
-
Save michaelb42/fc466de24354e34becf5 to your computer and use it in GitHub Desktop.
ethersex/ethersex m4 macro to map HD44780-LCD connector to PCF8574x I2C-Expander
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git hardware/lcd/config.in hardware/lcd/config.in | |
index a661f67..17359dc 100644 | |
--- hardware/lcd/config.in | |
+++ hardware/lcd/config.in | |
@@ -28,7 +28,7 @@ mainmenu_option next_comment | |
dep_bool "Backlight support" HD44780_BACKLIGHT_SUPPORT $HD44780_SUPPORT | |
elif [ "$HD44780_I2CSUPPORT" = "y" ]; then | |
dep_bool "Readback support" HD44780_READBACK $HD44780_SUPPORT | |
- int "PCF8574 Address" HD44780_PCF8574_ADR 32 | |
+# int "PCF8574 Address" HD44780_PCF8574_ADR 32 | |
define_bool I2C_MASTER_SUPPORT y | |
define_bool I2C_PCF8574X_SUPPORT y | |
fi | |
diff --git hardware/lcd/hd44780_i2c.c hardware/lcd/hd44780_i2c.c | |
index 3b181d5..e4d51f1 100644 | |
--- hardware/lcd/hd44780_i2c.c | |
+++ hardware/lcd/hd44780_i2c.c | |
@@ -53,14 +53,14 @@ | |
#include "hardware/i2c/master/i2c_pcf8574x.h" | |
/* port mapping lcd -> pcf8574x pin */ | |
-#define HD44780_PCF8574x_DB4 (0) | |
-#define HD44780_PCF8574x_DB5 (1) | |
-#define HD44780_PCF8574x_DB6 (2) | |
-#define HD44780_PCF8574x_DB7 (3) | |
-#define HD44780_PCF8574x_RS (4) | |
-#define HD44780_PCF8574x_WR (5) | |
-#define HD44780_PCF8574x_EN (6) | |
-#define HD44780_PCF8574x_BL (7) | |
+//#define HD44780_PCF8574x_DB4 (0) | |
+//#define HD44780_PCF8574x_DB5 (1) | |
+//#define HD44780_PCF8574x_DB6 (2) | |
+//#define HD44780_PCF8574x_DB7 (3) | |
+//#define HD44780_PCF8574x_RS (4) | |
+//#define HD44780_PCF8574x_WR (5) | |
+//#define HD44780_PCF8574x_EN (6) | |
+//#define HD44780_PCF8574x_BL (7) | |
#define HD44780_PCF8574x_DBx_MASK ( _BV(HD44780_PCF8574x_DB4) | \ | |
_BV(HD44780_PCF8574x_DB5) | \ | |
diff --git pinning/hardware/netio_addon.m4 pinning/hardware/netio_addon.m4 | |
index bb22021..d4b7699 100644 | |
--- pinning/hardware/netio_addon.m4 | |
+++ pinning/hardware/netio_addon.m4 | |
@@ -52,3 +52,8 @@ ifdef(`conf_DCF77', `dnl | |
DCF77_USE_INT(1, PD3) | |
pin(DCF1_PON, PA1, OUTPUT) | |
')dnl | |
+ | |
+ifdef(`conf_HD44780',`dnl | |
+ dnl HD44780_PCF8574x_MAPPING(ADR,RS,RW,EN,DB4,DB5,DB6,DB7,BL) | |
+ HD44780_PCF8574x_MAPPING(0x20, 4, 5, 6, 0, 1, 2, 3, 7) | |
+')dnl | |
diff --git pinning/internals/header.m4 pinning/internals/header.m4 | |
index 6406864..7c9063d 100644 | |
--- pinning/internals/header.m4 | |
+++ pinning/internals/header.m4 | |
@@ -354,6 +354,30 @@ define(`SHT_VOLTAGE_COMPENSATION', `dnl | |
#define SHT_VOLTAGE_COMPENSATION_D1 SHT_VOLTAGE_COMPENSATION_D1_$1 | |
') | |
+dnl Map HD44780-LCD connector to PCF8574x I2C-Expander | |
+dnl | |
+dnl HD44780_PCF8574x_MAPPING(ADR,RS,RW,EN,DB4,DB5,DB6,DB7,BL) | |
+dnl ADR - PCF8574x I2C address | |
+dnl RS, RW, EN - LCD control | |
+dnl DB4..DB7 - LCD data (4-Bit mode) | |
+dnl BL - Backlight | |
+dnl | |
+dnl Note: Map PCF8574x PORT-numbers, not Pin-Numbers. | |
+define(`HD44780_PCF8574x_MAPPING', `dnl | |
+ | |
+/* Map HD44780 LCD to PCF8574x connection | |
+ */ | |
+#define HD44780_PCF8574_ADR ($1) | |
+#define HD44780_PCF8574x_RS ($2) | |
+#define HD44780_PCF8574x_WR ($3) | |
+#define HD44780_PCF8574x_EN ($4) | |
+#define HD44780_PCF8574x_DB4 ($5) | |
+#define HD44780_PCF8574x_DB5 ($6) | |
+#define HD44780_PCF8574x_DB6 ($7) | |
+#define HD44780_PCF8574x_DB7 ($8) | |
+#define HD44780_PCF8574x_BL ($9) | |
+') | |
+ | |
divert(1) | |
` | |
#ifndef _PINNING_HEADER |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment