This commit is contained in:
parent
f4d1b53760
commit
006d281ad6
5 changed files with 42 additions and 10 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,32 @@
|
|||
//
|
||||
// Created by jedi on 25.06.21.
|
||||
//
|
||||
|
||||
#include "lux.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
|
||||
#include <esp/spi.h>
|
||||
|
||||
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);
|
||||
}
|
|
@ -9,6 +9,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
void lux_task(void *pvParameters);
|
||||
|
||||
void signal_led(bool state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
Loading…
Reference in a new issue