rene0 / dcf77pi

Yet another DCF77 decoder. This one is intended for the Raspberry Pi platform but might work on other devices using GPIO pins too.
BSD 2-Clause "Simplified" License
18 stars 6 forks source link

Can't use GPIOs > 256 #1

Closed mhaas closed 8 years ago

mhaas commented 8 years ago

Hi,

my sun7i based board has GPIO higher than 256. I am trying to use pin 266, but dcf77pi is trying to open pin 10.

mhaas commented 8 years ago

This patch should fix it:

diff --git a/input.c b/input.c
index e76e2c3..0dd1f11 100644
--- a/input.c
+++ b/input.c
@@ -110,7 +110,7 @@ set_mode_live(void)
        int res;

        /* fill hardware structure and initialize hardware */
-       hw.pin = (uint8_t)strtol(get_config_value("pin"), NULL, 10);
+       hw.pin = (uint32_t)strtol(get_config_value("pin"), NULL, 10);
        hw.active_high = (bool)strtol(get_config_value("activehigh"), NULL, 10);
        hw.freq = (uint32_t)strtol(get_config_value("freq"), NULL, 10);
        if (hw.freq < 10 || hw.freq > 155000 || (hw.freq & 1) == 1) {
diff --git a/input.h b/input.h
index 203acab..64d8c19 100644
--- a/input.h
+++ b/input.h
@@ -65,7 +65,7 @@ struct hardware {
        /* GPIO device number (FreeBSD only) */
        uint8_t iodev;
        /* pin number to read from */
-       uint8_t pin;
+       uint32_t pin;
        /** pin value is high (1) or low (0) for active signal */
        bool active_high;
 };
rene0 commented 8 years ago

You really want support for more than 65535 pins? Otherwise uint16_t should be fine.