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.c65
1 files changed, 57 insertions, 8 deletions
diff --git a/polycom_xmit/gpio.c b/polycom_xmit/gpio.c
index 04dad5d..8e8c66a 100644
--- a/polycom_xmit/gpio.c
+++ b/polycom_xmit/gpio.c
@@ -8,20 +8,21 @@ static struct gpio
uint32_t pin;
uint32_t func;
uint32_t bit;
+ int pull;
} gpios[] =
{
{
- 0, PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0, BIT0},
+ 0, PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0, BIT0, 1},
{
- 2, PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2, BIT2},
+ 2, PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2, BIT2, 1},
{
- 12, PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12, BIT12},
+ 12, PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12, BIT12, 0},
{
- 13, PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13, BIT13},
+ 13, PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13, BIT13, 1},
{
- 14, PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14, BIT14},
+ 14, PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14, BIT14, 1},
{
- 15, PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15, BIT15}
+ 15, PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15, BIT15, 0}
};
#define N_GPIOS (sizeof(gpios)/sizeof(gpios[0]))
@@ -42,7 +43,10 @@ void ICACHE_FLASH_ATTR
gpio_dispatch (void)
{
uint32_t v = gpio_read ();
- msg_send (v);
+ int red, green;
+ red = ! !(v & BIT12);
+ green = ! !(v & BIT14);
+ msg_send (red,green,v);
}
@@ -128,6 +132,48 @@ gpio_page (struct espconn *conn)
+void ICACHE_FLASH_ATTR
+gpio_colour_page (struct espconn *conn)
+{
+ char *page = os_zalloc (1024);
+ char *ptr = page;
+ int i;
+ uint32_t j, v;
+ int red, green;
+
+ if (!page)
+ {
+ webserver_send_reply (conn, 400, "text/html",
+ "<html><head></head><body>Out of memory</body></html>",
+ 0);
+ return;
+
+ }
+
+ ptr += os_sprintf (ptr, "<html><head>");
+ ptr += os_sprintf (ptr, "<meta http-equiv='refresh' content='5'>");
+ ptr += os_sprintf (ptr, "</head>");
+
+ v = gpio_read ();
+
+ red = ! !(v & BIT12);
+ green = ! !(v & BIT14);
+
+ if ((!red) && (!green))
+ ptr += os_sprintf (ptr, "<body bgcolor='#000000'>");
+ else if ((!red) && (green))
+ ptr += os_sprintf (ptr, "<body bgcolor='#00ff00'>");
+ else if ((red) && (!green))
+ ptr += os_sprintf (ptr, "<body bgcolor='#ff0000'>");
+ else if ((red) && (green))
+ ptr += os_sprintf (ptr, "<body bgcolor='#ffff00'>");
+ ptr += os_sprintf (ptr, "</body></html>");
+ webserver_send_reply (conn, 200, "text/html", page, ptr - page);
+ os_free (page);
+}
+
+
+
@@ -143,7 +189,10 @@ gpio_init (void)
for (i = 0; i < N_GPIOS; ++i)
{
PIN_FUNC_SELECT (gpios[i].pin, gpios[i].func);
- PIN_PULLUP_EN (gpios[i].pin);
+ if (gpios[i].pull)
+ PIN_PULLUP_EN (gpios[i].pin);
+ else
+ PIN_PULLUP_DIS (gpios[i].pin);
/* disable drivers */
gpio_output_set (0, 0, 0, gpios[i].bit);