From 7059fd523d6514d04e232f1d0acbc983856bd2e6 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 21 Jul 2015 19:10:32 +0100 Subject: first shipped version --- polycom_xmit/gpio.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 8 deletions(-) (limited to 'polycom_xmit/gpio.c') 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", + "Out of memory", + 0); + return; + + } + + ptr += os_sprintf (ptr, ""); + ptr += os_sprintf (ptr, ""); + ptr += os_sprintf (ptr, ""); + + v = gpio_read (); + + red = ! !(v & BIT12); + green = ! !(v & BIT14); + + if ((!red) && (!green)) + ptr += os_sprintf (ptr, ""); + else if ((!red) && (green)) + ptr += os_sprintf (ptr, ""); + else if ((red) && (!green)) + ptr += os_sprintf (ptr, ""); + else if ((red) && (green)) + ptr += os_sprintf (ptr, ""); + ptr += os_sprintf (ptr, ""); + 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); -- cgit v1.2.3