summaryrefslogtreecommitdiffstats
path: root/polycom_xmit/gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'polycom_xmit/gpio.c')
-rw-r--r--polycom_xmit/gpio.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/polycom_xmit/gpio.c b/polycom_xmit/gpio.c
index 8a595ac..04dad5d 100644
--- a/polycom_xmit/gpio.c
+++ b/polycom_xmit/gpio.c
@@ -26,14 +26,22 @@ static struct gpio
#define N_GPIOS (sizeof(gpios)/sizeof(gpios[0]))
+static uint32_t mask;
+
static os_timer_t gpio_timer;
static os_timer_t gpio_intr_timer;
+uint32_t ICACHE_FLASH_ATTR
+gpio_read (void)
+{
+ return gpio_input_get () & mask;
+}
+
void ICACHE_FLASH_ATTR
gpio_dispatch (void)
{
- uint32_t v = gpio_input_get ();
+ uint32_t v = gpio_read ();
msg_send (v);
}
@@ -97,19 +105,19 @@ gpio_page (struct espconn *conn)
"}\n"
"table, th, td {\n"
"border: 1px solid black;\n" "}\n" "</style>");
-
+ ptr += os_sprintf (ptr, "<meta http-equiv='refresh' content='5'>");
ptr += os_sprintf (ptr, "</head><body>");
- v = gpio_input_get ();
+ v = gpio_read ();
ptr += os_sprintf (ptr, "<h2>GPIO: 0x%04x</h2><br/>", v);
ptr += os_sprintf (ptr, "<table>");
- for (i = 0; i < 16; ++i)
+ for (i = 0; i < N_GPIOS; ++i)
{
- j = 1 << i;
ptr +=
os_sprintf (ptr,
"<tr><td>%d</td><td>0x%04x</td><td>%s</td></tr>",
- i, j, (j & v) ? "High" : "Low");
+ gpios[i].id, gpios[i].bit,
+ (gpios[i].bit & v) ? "High" : "Low");
}
@@ -149,6 +157,7 @@ gpio_init (void)
gpio_pin_intr_state_set (GPIO_ID_PIN (gpios[i].id),
GPIO_PIN_INTR_ANYEDGE);
+ mask |= gpios[i].bit;
}
ETS_GPIO_INTR_ENABLE ();