diff --git a/firmware/fiatlux.c b/firmware/fiatlux.c index cd6d09b..98d0efb 100644 --- a/firmware/fiatlux.c +++ b/firmware/fiatlux.c @@ -25,4 +25,6 @@ void user_init(void) xTaskCreate(wifi_task, "wifi_task", 512, NULL, 2, NULL); xTaskCreate(&httpd_task, "httpd_task", 512, NULL, 2, NULL); + + xTaskCreate(&lux_task, "lux_task", 512, NULL, 1, NULL); } diff --git a/firmware/lux.cpp b/firmware/lux.cpp index 6fd858b..cd8408f 100644 --- a/firmware/lux.cpp +++ b/firmware/lux.cpp @@ -1,3 +1,32 @@ // // Created by jedi on 25.06.21. // + +#include "lux.h" + +#include +#include +#include + +#include + +const int signal_led_pin = 2; + +const int cs0 = 15; +const int gpio4 = 4; +const int gpio5 = 5; + +extern "C" void signal_led(bool state) { + gpio_write(signal_led_pin, state); +} + +extern "C" void lux_task(void *pvParameters) { + + gpio_enable(signal_led_pin, GPIO_OUTPUT); + gpio_enable(cs0, GPIO_OUTPUT); + gpio_enable(gpio4, GPIO_OUTPUT); + gpio_enable(gpio5, GPIO_OUTPUT); + spi_init(1, SPI_MODE0, SPI_FREQ_DIV_1M, 1, SPI_BIG_ENDIAN, 1); + + vTaskDelete(nullptr); +} \ No newline at end of file diff --git a/firmware/lux.h b/firmware/lux.h index f185111..caf4a88 100644 --- a/firmware/lux.h +++ b/firmware/lux.h @@ -9,6 +9,10 @@ extern "C" { #endif +void lux_task(void *pvParameters); + +void signal_led(bool state); + #ifdef __cplusplus } #endif diff --git a/firmware/web.cpp b/firmware/web.cpp index f324bc8..c5bcaa8 100644 --- a/firmware/web.cpp +++ b/firmware/web.cpp @@ -251,14 +251,13 @@ void websocket_open_cb(struct tcp_pcb *pcb, const char *uri) { } } -extern "C" [[noreturn]] void httpd_task(void *pvParameters) { +extern "C" void httpd_task(void *pvParameters) { - while(!uxSemaphoreGetCount( wifi_available_semaphore )) + while (!uxSemaphoreGetCount(wifi_available_semaphore)) vTaskDelay(500 / portTICK_PERIOD_MS); websocket_register_callbacks((tWsOpenHandler) websocket_open_cb, (tWsHandler) websocket_cb); httpd_init(); - for (;;) - vTaskDelay(500 / portTICK_PERIOD_MS); + vTaskDelete(nullptr); } \ No newline at end of file diff --git a/firmware/wifi.cpp b/firmware/wifi.cpp index aaf3e8d..65b114b 100644 --- a/firmware/wifi.cpp +++ b/firmware/wifi.cpp @@ -116,7 +116,7 @@ SemaphoreHandle_t wifi_available_semaphore = nullptr; } } -extern "C" [[noreturn]] void wifi_task(void *pvParameters) { +extern "C" void wifi_task(void *pvParameters) { (void) pvParameters; /* Default a hostname. */ char *hostname = nullptr; @@ -353,10 +353,8 @@ extern "C" [[noreturn]] void wifi_task(void *pvParameters) { if(wifi_ap_ssid) free(wifi_ap_ssid); if(wifi_ap_password) free(wifi_ap_password); - xSemaphoreGive( wifi_available_semaphore); + xSemaphoreGive(wifi_available_semaphore); - while (1) { - //monitor connection here - vTaskDelay(5000); - } + //monitor loop connection here + vTaskDelete(nullptr); } \ No newline at end of file